From d685db6eb665885be85f0e5f6464d93a2de27fec Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Sun, 2 May 2021 01:33:12 +0200 Subject: [PATCH] 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. --- Toolchain/Patches/gcc.patch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Toolchain/Patches/gcc.patch b/Toolchain/Patches/gcc.patch index 6d4f2840ed2..39f5eefd91c 100644 --- a/Toolchain/Patches/gcc.patch +++ b/Toolchain/Patches/gcc.patch @@ -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"