Difference between -shared and -Wl,-shared of the GCC options
There is a difference between passing -shared
to gcc or -shared
to ld (via -Wl
). Passing -shared
to GCC may enable or disable other flags at link time. In particular, different crt*
files might be involved.
To get more information, grep for -shared
in GCC's gcc/config/
directory and subdirectories.
Edit: To give a specific example: on i386 FreeBSD, gcc -shared
will link in object file crtendS.o
, while without -shared
, it will link in crtend.o
instead. Thus, -shared
and -Wl,-shared
are not equivalent.
I don't think there is any difference. -shared
is not a supported option of gcc
and it is passed to linker whether you specify it with -Wl
or not. -Wl
option of gcc is used to specify that a comma separated list of options is to be passed to linker for further processing.