Toolchain: Use -ftls-model=initial-exec by default

Our TLS implementation relies on the TLS model being "initial-exec".
We previously enforced this by adding the '-ftls-model=initial-exec'
flag in the root CmakeLists file, but that did not affect ports - So
now we put that flag in the gcc spec files.

Closes #5366
This commit is contained in:
Itamar 2021-02-19 15:54:40 +02:00 committed by Andreas Kling
parent 4f80bb6ce3
commit 7df61e2c9b
Notes: sideshowbarker 2024-07-18 22:09:06 +09:00
3 changed files with 12 additions and 6 deletions

View file

@ -73,9 +73,9 @@ set(CMAKE_CXX_EXTENSIONS OFF)
if (${CMAKE_HOST_SYSTEM_NAME} MATCHES SerenityOS)
# FIXME: Something makes this go crazy and flag unused variables that aren't flagged as such when building with the toolchain.
# Disable -Werror for now.
add_compile_options(-Wno-unknown-warning-option -Wall -Wextra -Wmissing-declarations -Wformat=2 -fdiagnostics-color=always -ftls-model=initial-exec)
add_compile_options(-Wno-unknown-warning-option -Wall -Wextra -Wmissing-declarations -Wformat=2 -fdiagnostics-color=always)
else()
add_compile_options(-Wno-unknown-warning-option -Wall -Wextra -Werror -Wmissing-declarations -Wformat=2 -fdiagnostics-color=always -ftls-model=initial-exec)
add_compile_options(-Wno-unknown-warning-option -Wall -Wextra -Werror -Wmissing-declarations -Wformat=2 -fdiagnostics-color=always)
endif()
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")

View file

@ -102,7 +102,7 @@ diff -ruN a/gcc/config/arm/serenity-elf.h b/gcc/config/arm/serenity-elf.h
diff -ruN a/gcc/config/serenity.h b/gcc/config/serenity.h
--- a/gcc/config/serenity.h 1970-01-01 02:00:00.000000000 +0200
+++ b/gcc/config/serenity.h 2020-12-12 10:43:35.280270540 +0200
@@ -0,0 +1,31 @@
@@ -0,0 +1,37 @@
+/* Useful if you wish to make target-specific GCC changes. */
+#undef TARGET_SERENITY
+#define TARGET_SERENITY 1
@ -115,7 +115,7 @@ diff -ruN a/gcc/config/serenity.h b/gcc/config/serenity.h
+/* Files that are linked before user code.
+ The %s tells GCC to look for these files in the library directory. */
+#undef STARTFILE_SPEC
+#define STARTFILE_SPEC "%{!shared:crt0.o%s} crti.o%s %{shared|pie:crtbeginS.o%s; :crtbegin.o%s}"
+#define STARTFILE_SPEC "%{static:crt0.o%s} crti.o%s %{!static: %{!fbuilding-libgcc:crt0_shared.o%s}} %{shared|pie:crtbeginS.o%s; :crtbegin.o%s}"
+
+/* Files that are linked after user code. */
+#undef ENDFILE_SPEC
@ -124,6 +124,12 @@ diff -ruN a/gcc/config/serenity.h b/gcc/config/serenity.h
+#undef LINK_SPEC
+#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"
+
+#undef CC1PLUS_SPEC
+#define CC1PLUS_SPEC "-fno-exceptions -ftls-model=initial-exec"
+
+/* Additional predefined macros. */
+#undef TARGET_OS_CPP_BUILTINS
+#define TARGET_OS_CPP_BUILTINS() \

View file

@ -125,10 +125,10 @@ diff -ruN a/gcc/config/serenity.h b/gcc/config/serenity.h
+#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"
+#define CC1_SPEC "-fno-exceptions -ftls-model=initial-exec"
+
+#undef CC1PLUS_SPEC
+#define CC1PLUS_SPEC "-fno-exceptions"
+#define CC1PLUS_SPEC "-fno-exceptions -ftls-model=initial-exec"
+
+/* Additional predefined macros. */
+#undef TARGET_OS_CPP_BUILTINS