https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116393
Bug ID: 116393 Summary: -fpie discards -fpic Product: gcc Version: 11.4.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: stsp at users dot sourceforge.net Target Milestone: --- Created attachment 58940 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58940&action=edit test case Attached is a small test-case. Just run make: ``` cc -fpic -fpie -c -o weak.o weak.c cc -shared -o liba.so weak.o /usr/bin/ld: weak.o: warning: relocation against `sym' in read-only section `.text' /usr/bin/ld: weak.o: relocation R_X86_64_PC32 against symbol `sym' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: final link failed: bad value collect2: error: ld returned 1 exit status make: *** [makefile:6: liba.so] Error 1 ``` It asks for -fpic, which is already there. Surprisingly, removing -fpie makes it to build.