https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109217
--- Comment #4 from Stas Sergeev <stsp at users dot sourceforge.net> --- (In reply to Richard Biener from comment #3) > -static-pie is now marked as the negative of -shared, so it works with that > (the later cancelling out the earlier). It isn't handled that way for > -static vs. -shared, not sure if we can use Negative() with multiple options. So could you please suggest the exact command line that works? I tried: $ LC_ALL=C cc -Wall -o libmain.so main.c -shared -static-pie /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/12/../../../x86_64-linux-gnu/rcrt1.o: in function `_start': (.text+0x1b): undefined reference to `main' collect2: error: ld returned 1 exit status So obviously -static-pie just indeed, as you say, cancels -shared. Is there any -static-solib or alike, to produce the solib at the end?