How to use the output clang++ -fsave-optimization-record command? - clang++

I compiled with the clang++ -fsave-optimization-record command.
Now I have a file.opt.yaml file but I don't know what to do with this file...
Is there a tool to visualize something or to display its content ?
I wonder the same thing for clang++ -fdiagnostics-show-hotness.
Thx!

Related

don't understand the difference between "gcc -c file.c" and "gcc -o file.c" command

Command :
`gcc -c -Wall hello.c`
Here is the error : while calling ./hello.o
bash: ./hello.o: cannot execute binary file: Exec format error
need help please ..
.o is an object file, not an executable. It's an intermediate step. The -c option just says to make that step. You'll still have to link that object file into an executable.
These are the options you are asking for
-c
Compile or assemble the source files, but do not link. The linking stage simply is not done. The ultimate output is in the form of an object file for each source file.
By default, the object file name for a source file is made by replacing the suffix ‘.c’, ‘.i’, ‘.s’, etc., with ‘.o’.
Unrecognized input files, not requiring compilation or assembly, are ignored.
-o file
Place output in file file. This applies to whatever sort of output is being produced, whether it be an executable file, an object file, an assembler file or preprocessed C code.
If -o is not specified, the default is to put an executable file in a.out, the object file for source.suffix in source.o, its assembler file in source.s, a precompiled header file in source.suffix.gch, and all preprocessed C source on standard output.
Using the first option you will have an object file, not an executable so you cannot execute it

When changing the comment of a .c file, scons still re-compile it?

It's said that scons uses MD5 signature as default decider to dertermine whether a source file needs re-compilation. E.g. I've got SConstruct as below:
Library('o.c')
And my o.c is:
$ cat o.c
/*commented*/
#include<stdio.h>
int f(){
printf("hello\n");
return 2;
}
Run scons and remove the comment line, run scons again. I expect that scons should not compile it again, but actually it's:
gcc -o o.o -c o.c
scons: done building targets.
If I change SConstruct file to add one line:
Decider('MD5').
Still same result.
My question is: how to make sure that for scons, when changing source file comments, they don't get re-built?
Thanks!
As you correctly stated, SCons uses the MD5 hashsum of a source file to decide whether it has changed or not (content-based), and a rebuild of the target seems to be required (since one of its dependencies changed).
By adding or changing a comment, the MD5 sum of the file changes...so the trigger fires.
If you don't like this behaviour, you can write and use your own Decider function which will omit comment changes to your likings. Please check section 6.1.4 "Writing Your Own Custom Decider Function" in the UserGuide to see how this can be done.

clang complete add path to includes

I have simple question today. I'm using this vim config - https://github.com/gergap/vim
The problem is with clang completion. It works but when I want to add more includes to get better completion then nothing is happening - it won't detect new headers.
Get #include <sys/types.h> for example. This is what I've added to .clang_complete file placed in directory where my main.c is placed:
-I/usr/include/x86_64-linux-gnu/sys/
which I found by invoking
find /usr/include/ -name types.h
What can be wrong? Could you show me some working .clang_complete files with includes to unix headers? Maybe I'll find problem in that way.
This is the output from gcc with -v flag:
/usr/lib/gcc/x86_64-linux-gnu/4.8/include
/usr/local/include
/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed
/usr/include/x86_64-linux-gnu
/usr/include
To investigate, run your gcc (or clang) with the -v option. This will display the search path used while compiling. On my system (FreeBSD) a simple compile without -I options prints
#include "..." search starts here:
#include <...> search starts here:
/usr/include/clang/3.4.1
/usr/include
End of search list.
That should give you an idea what directories to add to .clang_complete. Important: order matters!

Linux: no such file or directory

I am new in Linux, can anyone tell me which directory the computer search for "ansinist.h"? Below is the syntax:
USER#USER-PC /cygdrive/f/Dataset_extract/500ppi-Legacy/SRC/BIN/TXT2NIST
$ make -f makefile.mak
gcc -ansi -O2 -I/include -L/lib -c txt2nist.c
txt2nist.c:15:22: fatal error: ansinist.h: No such file or directory
#include <ansinist.h>
^
compilation terminated.
makefile.mak:53: recipe for target 'txt2nist.o' failed
make: *** [txt2nist.o] Error 1
This answer could help you. In general case, be sure that you have installed the libraries that you're going to use in your project.
To find the file ansinist.h
sudo find / -name ansinist.h
And please paste your output here but you should be sure you installed all the required libraries first..
1)if your header file is in current directory then use #include "ansinist.h"
because this syntax search directly into current directory.
2)if your header file is in /usr/include/ then #include< ansinist.h>
because this syntax first search into /usr/include/ then current directory.
3)also you can use #include < /path/ansinist.h>
where path=path where is header file.
4)if above things will not work then please give value of #echo $PATH for next i can help you.

Windres syntax error

I am working in MinGW environment (downloaded with their installer on 12/12/2011). I am attempting to compile a resource (.rc) file using Windres. The specific command I use is
Windres -O coff About1.rc -o About1.res
Windres generates at least 100 lines of warning messages reading: "warning: null characters ignored". Following this Windres emits: "Abouty1.rc:1:syntax error".
As a matter of fact, there are no null characters in the About1.rc file. In addtition, the first line of the file is an include statement: #include "dlgresource.h". I played around and eliminated this statement and it turns out that it doesn't matter what I put there, I get the same flurry of messages and the syntax error notification.
To make things more confusing, this same .rc file compiles without any problem using MSFT's rc.exe. The resulting .res file links smoothly with the program .obj file and runs perfectly.
I have no idea what is going on. Any ideas?
Thanks,
Mark Allyn
Your .rc file is probably encoded as UTF-16.
That's what's required in general by Microsoft's [rc.exe], in order to be able to deal with international characters, but GNU [windres.exe] can only deal with ANSI encoding.
One workaround is to convert the file to ANSI on the spot (possibly losing e.g. Russian or Greek characters):
> chcp 1252
Active code page: 1252
> type my.rc | windres --output-format=COFF -o my.res
> _
You probably used VS or a similar tool to generate the file. There are some parts of the character encodings that you cannot see resulting in null characters and etc.
Generate a new .res file with the same content, don't copy/paste the content, type it in yourself.
Try:
windres About1.rc -o About1.o
and then just use the resulting .o file instead of the originally intended .res file.
I've had the same troubles than you today. I know it has passed a lot of time from your question, but I'm writting this on the hope that it can be useful for someone.
First, I obtained an object file .o compiled using Cygwin, writting:
windres -o resource.o resource.rc
By doing that, you dont need to use the .res file, but the .o one, and you can then link this object with all the others, when you compile yout program, using GNU resources:
g++ Header_files CPP_files flags ... -o program.exe recource.o -lm
For instance.

Resources