Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

`-Wl,` prefix to compiler flag

Tags:

c++

gcc

I'm new to a codebase and I'm looking through a Makefile. I see several compiler flags specified with a -Wl, prefix (i.e. -Wl,--no-undefined specified). I have not encountered this syntax before and it is difficult to Google search.

What is the prefix doing? It looks like it has to do with warnings, but I don't know and I'm hesitant to mess with it.

like image 318
Zak Avatar asked Nov 20 '17 16:11

Zak


2 Answers

It has nothing to do with warnings.

From GCC manual:

-Wl,option

Pass option as an option to the linker. If option contains commas, it is split into multiple options at the commas. You can use this syntax to pass an argument to the option. For example, ‘-Wl,-Map,output.map’ passes ‘-Map output.map’ to the linker. When using the GNU linker, you can also get the same effect with ‘-Wl,-Map=output.map’.

like image 124
HolyBlackCat Avatar answered Oct 07 '22 17:10

HolyBlackCat


man gcc:

-Wl,option

Pass option as an option to the linker. If option contains commas, it is split into multiple options at the commas. You can use this syntax to pass an argument to the option. For example, -Wl,-Map,output.map passes -Map output.map to the linker. When using the GNU linker, you can also get the same effect with -Wl,-Map=output.map.

Also important tip for google, add quotes for search that include special character. The following search led me to an answer: "-wl" flag

like image 43
OriBS Avatar answered Oct 07 '22 16:10

OriBS