Toolchain: Enable building all code with -fPIC

Ordinarily this would force the compiler to not inline certain
symbols and call them via the PLT instead. To counteract this
I've also added -fno-semantic-interposition which disables
ELF symbol interposition. Our dynamic loader doesn't support
this anyway and we might even consider not implementing this
at all.

Even though this is a toolchain change this doesn't require
rebuilding the toolchain unless you're planning to build
for the x86_64 arch.
This commit is contained in:
Gunnar Beutner 2021-05-02 01:33:12 +02:00 committed by Andreas Kling
parent a050b43290
commit d685db6eb6

View file

@ -129,7 +129,7 @@ diff -Naur gcc-11.1.0-RC-20210420/gcc/config/serenity.h gcc-11.1.0-RC-20210420.s
+#define LINK_SPEC "%{shared:-shared} %{static:-static} %{!static: %{rdynamic:-export-dynamic} %{!fbuilding-libgcc:-lgcc_s -dynamic-linker /usr/lib/Loader.so}}"
+
+#undef CC1_SPEC
+#define CC1_SPEC "-fno-exceptions -ftls-model=initial-exec"
+#define CC1_SPEC "-fno-exceptions -ftls-model=initial-exec %{!fno-pic:%{!fno-PIC:%{!fpic:%{!fPIC: -fPIC}}}} -fno-semantic-interposition"
+
+#undef CC1PLUS_SPEC
+#define CC1PLUS_SPEC "-fno-exceptions -ftls-model=initial-exec"