8

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.

Zak
  • 12,213
  • 21
  • 59
  • 105
  • Googling "gcc wl" would have pointed you to the right documentation as the first result. – Mat Nov 20 '17 at 16:23
  • 8
    On the bright side, now it will be indexed in one more place to help the next person who didn't choose the exact right words for the search. – Zak Nov 20 '17 at 16:30

2 Answers2

17

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’.

HolyBlackCat
  • 78,603
  • 9
  • 131
  • 207
3

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

OriBS
  • 722
  • 5
  • 9