Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is clang's equivalent to -rdynamic gcc flag?

Tags:

c++

macos

clang

I can't find any similar option that would include all the function names into the final release binary. Or does clang do it by default?

like image 385
Violet Giraffe Avatar asked Jan 22 '14 09:01

Violet Giraffe


People also ask

What is difference between G ++ and GCC?

DIFFERENCE BETWEEN g++ & gcc g++ is used to compile C++ program. gcc is used to compile C program.

Is GCC the same as Clang?

Clang is much faster and uses far less memory than GCC. Clang aims to provide extremely clear and concise diagnostics (error and warning messages), and includes support for expressive diagnostics. GCC's warnings are sometimes acceptable, but are often confusing and it does not support expressive diagnostics.

Will Clang replace GCC?

Clang is designed to provide a frontend compiler that can replace GCC. Apple Inc. (including NeXT later) has been using GCC as the official compiler.


2 Answers

The correct answer to this question is -Wl,-export_dynamic and not -Wl,--export-dynamic.

-Wl,--export-dynamic is only correct if you are using the GNU linker on ELF platforms.

This question is about OS X.

Source: http://www.opensource.apple.com/source/ld64/ld64-236.3/src/ld/Options.cpp

...
else if ( strcmp(arg, "-export_dynamic") == 0 ) {
    fExportDynamic = true;
}
...
like image 144
Thomas Avatar answered Oct 11 '22 18:10

Thomas


At least clang 3.3 seems to support -rdynamic though neither clang --help nor the manpage documents it. (If you are on OSX, -rdynamic isn't needed)

gcc -rdynamic says "-rdynamic Pass the flag --export-dynamic to the ELF linker, on targets that support it."

So clang should also be able to do the same with -Wl,--export-dynamic.

like image 23
nos Avatar answered Oct 11 '22 17:10

nos