I want to use GNU gprof that comes with GCC to profile my C program. However, it returns __dyld section not supported error when I compile with the -pg flag and try to run the program:
$ gcc -pg main.c
$ ./a.out
dyld: __dyld section not supported in /Users/evgenii/Downloads/c_profile/./a.out
This error has been reported here. Is there a way to use the GNU profiler on macOS Mojave? I'm aware that there are alternative tools for profiling, but I want to use gprof.
Related
Using clang or clang++ the command of
clang -S -emit-llvm ./source.c
will create a llvm ir document. However debugging information is missing. So when you test and compile things you lose debugging information.
How does one can make clang emit human readable llvm ir document with debug information ?
The standard option to add debug info is -g. So, running clang -g -S -emit-llvm source.c will emit necessary information
I have a program written on Linux in GNU C. The program compiles with GCC. I have an install shell script,
gcc -o program program.c -Wall -pedantic -std=gnu11 -lm -fopenmp
which works greatly.
The problem is with Mac. For some reason, Mac sees gcc and instead uses clang even though GCC is installed and install.sh explicitly says gcc. clang doesn't work with omp.h The problem is that clang can't use omp.h and solutions offered http://releases.llvm.org/3.7.0/tools/clang/docs/ReleaseNotes.html#openmp-support don't work, and omp.h may not work in mac at all Enable OpenMP support in clang in Mac OS X (sierra)
I never use macs, and because of this nonsense I never plan to. However, some people using my program want to use Mac, so I have to deal with this.
I've tried various shell script modifications, but none of them work, mac insists on using clang and won't use gcc
I need to do one of two things which I don't know how to do:
1) force Mac to use gcc (which it refuses to do now)
2) get clang to use omp.h in mac (which from other answers on Stack Overflow, looks impossible)
Your second option (get clang to use omp.h) is not impossible (any more). From my answer here:
Try using Homebrew's llvm:
brew install llvm
You then have all the llvm binaries in /usr/local/opt/llvm/bin. To compile the OpenMP Hello World program, for example, type
/usr/local/opt/llvm/bin/clang -fopenmp -L/usr/local/opt/llvm/lib omp_hello.c -o hello
You might also have to set the CPPFLAGS with -I/usr/local/opt/llvm/include.
I am experimenting with cross compiling for ARM-Linux under Windows using Eclipse-Mars. My set-up is as follows:
Win10 x64
Eclipse Mars.2 Release (4.5.2)
GNU Toolchain for RaspberryPi (SysGCC)
Target platform: RaspberryPi2 running Raspian
Source project in 'C (not C++) using Linux Threads (pthreads)
I have knocked up a small 'C project using 'pthreads' which compiles under Eclipse and runs successfully on the Pi.
My problem is that Eclipse shows a number of errors in its Problems TAB to do with Linux's threads:
Type 'pthread_cond_t' could not be resolved
Type 'pthread_mutex_t' could not be resolved
Type 'pthread_t' could not be resolved
I have Eclipse as:
Cross GCC Compiler settings to use g++ with -std=c++11 -O0 -g3 -Wall -c -fmessage-length=0.
Cross G++ Compiler settings to use g++ with -std=c++11 -O0 -g3 -Wall -c -fmessage-length=0.
In other words both are the same.
If I rename my source files from foo.c to foo.cpp and recompile, then the Eclipse errors disappear!!!
This implies that Eclipse's C++ settings are correct, but its 'C settings are not.
Can anybody suggest anything for me to try?
g++ ist a C++ compiler, so you might try to use other settings for the Cross GCC Compiler, eg. gcc.
Also make sure you are linking the pthread library.
I got a gcc compilation error:
gcc-4.9: error: unrecognized command line option '-rdynamic'
and I tested compilation with -rdynamic in some environments. While I used the same version of gcc (4.9.2), in some environments gcc worked well, but others (e.g. Homebrew gcc 4.9.2_1, cygwin 64bit) not. What makes the difference?
-rdynamic passes the flag -export-dynamic to ELF linker, on targets that support it.
Executable formats in OS X and Windows are not ELF, thus the option -rdynamic is not supported building for these operating systems.
I have gcc 4.1.2 installed. I installed a new separate gcc (version 4.4.6) too using yum on CentOS. Now my question is, do these two gcc versions use the same glibc version or glibc is different for both of them? How can I find out? Secondly, is it better to have a newer version of glibc in terms of performance?
Both GCC versions will use the glibc version you have installed on your system. GCC packages don't (usually) ship a separate C library.
Write a simple program which makes a call to a glibc function. Then compile it with both versions of gcc and then do ldd a.out on each compilation. You'll get the list of libraries used.
If your source file is test.c then:
$ gcc test.c -o out1 # with gcc 4.1.2
$ gcc test.c -o out2 # with gcc 4.4.6
$ ldd out1
$ ldd out2
This will show the libc versions used by each gcc.
Performance may or may not be better depending on the update done for glibc functions.