0

I write C/C++ with GCC/Clang, but know little about compiler options that starts with "-f".

For example, to turn on Address Sanitizer, I pass "-fno-omit-frame-pointer -fsanitize=address" to the compiler. This should both affect compile and link stages.

Another example, to turn on OpenMP, I pass "-fopenmp" to the compiler, which gives support of compile and link to shared openmp library.

If I use static openmp library, I should pass "-fopenmp" to the compiler, and pass "-fopenmp -static" to the linker. And this StackOverFlow answer says it means "-lgomp -lrt".

My question: is there any method to expand the "-f" started compile/options, thus I can know what exactly libraries this "-f" flag links to?

ChrisZZ
  • 1,521
  • 2
  • 17
  • 24

2 Answers2

2

Let's check the docs of clang at https://clang.llvm.org/docs/ClangCommandLineReference.html --verbose or -v looks very promising. A quick check at compiler-explorer.com gives promising results.

GCC has a similar page with all options: https://gcc.gnu.org/onlinedocs/gcc/Option-Summary.html Here we have -v as well, though as it prints stuff to stderr, I can't verify the output at compiler-explorer.

JVApen
  • 11,008
  • 5
  • 31
  • 67
0

I don't think so - this is not normalized - the two examples that you cite are sizable extensions to gcc that do things their own way.

But you can check the final executable with ldd - you will see the linked-in libraries.

mmomtchev
  • 2,497
  • 1
  • 8
  • 23