What is clang's equivalent to -rdynamic gcc fl

2019-04-28 03:40发布

问题:

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?

回答1:

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.



回答2:

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;
}
...


回答3:

My Google-fu is telling me you can replace that by

-Wl,--export-dynamic

Which is what GCC usually passes to the linker when it is passed -rdynamic. I would first try it without anything, and see if the flag was necessary.



标签: c++ macos clang