mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-24 05:25:13 +00:00
Toolchain: Link libgcc_s on an as-needed basis
If we pass `-lgcc_s` explicitly to the linker, it will be added as a dependency even if no functions are used from it. This behavior is not consistent with other systems. GCC can already handle passing the correct flags, so let's rely on that instead. As an added benefit, we now get support for the `-static-libgcc` flag; and `-static-pie` will no longer mistakenly link us against the dynamic version of libgcc. No toolchain rebuild is required.
This commit is contained in:
parent
e0e8fd6384
commit
738e52da56
Notes:
sideshowbarker
2024-07-17 22:42:30 +09:00
Author: https://github.com/BertalanD Commit: https://github.com/SerenityOS/serenity/commit/738e52da562 Pull-request: https://github.com/SerenityOS/serenity/pull/11273 Reviewed-by: https://github.com/IdanHo ✅
1 changed files with 10 additions and 6 deletions
|
@ -46,10 +46,10 @@ index a75b44ee4..6fab7c3ca 100644
|
||||||
+
|
+
|
||||||
; This comment is to ensure we retain the blank line above.
|
; This comment is to ensure we retain the blank line above.
|
||||||
diff --git a/gcc/config.gcc b/gcc/config.gcc
|
diff --git a/gcc/config.gcc b/gcc/config.gcc
|
||||||
index 357b0bed0..18d099584 100644
|
index 357b0bed0..151d93312 100644
|
||||||
--- a/gcc/config.gcc
|
--- a/gcc/config.gcc
|
||||||
+++ b/gcc/config.gcc
|
+++ b/gcc/config.gcc
|
||||||
@@ -686,6 +686,12 @@ x86_cpus="generic intel"
|
@@ -686,6 +686,13 @@ x86_cpus="generic intel"
|
||||||
|
|
||||||
# Common parts for widely ported systems.
|
# Common parts for widely ported systems.
|
||||||
case ${target} in
|
case ${target} in
|
||||||
|
@ -58,11 +58,12 @@ index 357b0bed0..18d099584 100644
|
||||||
+ gnu_ld=yes
|
+ gnu_ld=yes
|
||||||
+ default_use_cxa_atexit=yes
|
+ default_use_cxa_atexit=yes
|
||||||
+ extra_options="${extra_options} serenity.opt"
|
+ extra_options="${extra_options} serenity.opt"
|
||||||
|
+ tmake_file="t-slibgcc"
|
||||||
+ ;;
|
+ ;;
|
||||||
*-*-darwin*)
|
*-*-darwin*)
|
||||||
tmake_file="t-darwin "
|
tmake_file="t-darwin "
|
||||||
tm_file="${tm_file} darwin.h"
|
tm_file="${tm_file} darwin.h"
|
||||||
@@ -1084,6 +1090,18 @@ case ${target} in
|
@@ -1084,6 +1091,18 @@ case ${target} in
|
||||||
esac
|
esac
|
||||||
|
|
||||||
case ${target} in
|
case ${target} in
|
||||||
|
@ -169,10 +170,10 @@ index 14a01fe71..3f8e44288 100644
|
||||||
/* This allows for a pagesize of 16384, which we have on Darwin20, but should
|
/* This allows for a pagesize of 16384, which we have on Darwin20, but should
|
||||||
diff --git a/gcc/config/serenity.h b/gcc/config/serenity.h
|
diff --git a/gcc/config/serenity.h b/gcc/config/serenity.h
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 000000000..d57aacca9
|
index 000000000..dc2f5361e
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/gcc/config/serenity.h
|
+++ b/gcc/config/serenity.h
|
||||||
@@ -0,0 +1,44 @@
|
@@ -0,0 +1,47 @@
|
||||||
+/* Useful if you wish to make target-specific GCC changes. */
|
+/* Useful if you wish to make target-specific GCC changes. */
|
||||||
+#undef TARGET_SERENITY
|
+#undef TARGET_SERENITY
|
||||||
+#define TARGET_SERENITY 1
|
+#define TARGET_SERENITY 1
|
||||||
|
@ -196,7 +197,7 @@ index 000000000..d57aacca9
|
||||||
+#define ENDFILE_SPEC "%{shared|static-pie|!no-pie:crtendS.o%s; :crtend.o%s} crtn.o%s"
|
+#define ENDFILE_SPEC "%{shared|static-pie|!no-pie:crtendS.o%s; :crtend.o%s} crtn.o%s"
|
||||||
+
|
+
|
||||||
+#undef LINK_SPEC
|
+#undef LINK_SPEC
|
||||||
+#define LINK_SPEC "%{shared:-shared} %{static:-static} %{!static: %{rdynamic:-export-dynamic} %{!fbuilding-libgcc:%{!nostdlib:%{!nodefaultlibs:-lgcc_s}} -dynamic-linker /usr/lib/Loader.so}}"
|
+#define LINK_SPEC "%{shared:-shared} %{static:-static} %{!static: %{rdynamic:-export-dynamic} -dynamic-linker /usr/lib/Loader.so}"
|
||||||
+
|
+
|
||||||
+#undef CC1_SPEC
|
+#undef CC1_SPEC
|
||||||
+#define CC1_SPEC "-ftls-model=initial-exec %{!fno-pic:%{!fno-PIC:%{!fpic:%{!fPIC: -fPIC}}}} -fno-semantic-interposition"
|
+#define CC1_SPEC "-ftls-model=initial-exec %{!fno-pic:%{!fno-PIC:%{!fpic:%{!fPIC: -fPIC}}}} -fno-semantic-interposition"
|
||||||
|
@ -207,6 +208,9 @@ index 000000000..d57aacca9
|
||||||
+#undef CPP_SPEC
|
+#undef CPP_SPEC
|
||||||
+#define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
|
+#define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
|
||||||
+
|
+
|
||||||
|
+/* Use --as-needed -lgcc_s for eh support. */
|
||||||
|
+#define USE_LD_AS_NEEDED 1
|
||||||
|
+
|
||||||
+/* Additional predefined macros. */
|
+/* Additional predefined macros. */
|
||||||
+#undef TARGET_OS_CPP_BUILTINS
|
+#undef TARGET_OS_CPP_BUILTINS
|
||||||
+#define TARGET_OS_CPP_BUILTINS() \
|
+#define TARGET_OS_CPP_BUILTINS() \
|
||||||
|
|
Loading…
Add table
Reference in a new issue