if the options are flagged with a: -Wl as Your example, they are used in the context of the
compiler driver. So You must add them to the compiler options (and not as expected
to the linker options.)
"gcc" is a compiler.
"ld" is a linker, in the GCC world.
-Wl says the gcc compiler to pass the following option to the linker. The thing is you can call the linker through the compiler indirectly.
So when you invoke "gcc main.o" this will compile & link (internally calls ld also) will give the final executable.
If you call gcc with option -C it will just compile wont link. So if you want to pass a flag to linker ld through compiler you should use -Wl
gcc main.o -Wl,lgcc
In this lgcc will be passed on to linker saying that linker to use the library "gcc" (here gcc is library libgcc.a not the compiler "gcc.exe"
@xpress_embedo if you explain the whole process or all the compiler/linker options you use, then I can help you.