[cfe-dev] Where are the library flags filtered??

peng li peterlee at cs.utah.edu
Sun Jul 18 00:34:37 PDT 2010

Hi There

I want to implement a functionality that clang can pass an extra option 
to the linker ld automatically and implicitly.

Currently, I found that the main entry for clang is located in 
path/to/llvm/tools/clang/tools/driver/driver.cpp. In the main function 
of this source file, I printed out all arguments to see what concrete 
options are passed into clang. It is strange that I found all flags 
related to the library are filtered out no matter those flags are added 
explicitly or implicitly, for instance, if I wrote a simple command: 
"clang -o add add.c -lm -lxxx", then all options but the -lm and -lxxx 
can be passed successfully into clang since they were printed successfully.

Since I know clang just uses ld as its default linker, maybe the flags 
related to library have been processed before passed to clang, I am just 
wondering where this stage happens. Thanks a lot for your explanation...

Best regards


More information about the cfe-dev mailing list