]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
LoongArch: Add support for libgcc on LA32
authormengqinggang <mengqinggang@loongson.cn>
Thu, 11 Dec 2025 06:13:55 +0000 (14:13 +0800)
committerLulu Cheng <chenglulu@loongson.cn>
Fri, 12 Dec 2025 07:56:47 +0000 (15:56 +0800)
LA32 does not support extreme code mode, change to medium code model on LA32.

libgcc/ChangeLog:

* configure: Regenerate.
* configure.ac:
* config/loongarch/t-crtstuff-la32: New file.
* config/loongarch/t-crtstuff: Rename to t-crtstuff-la64.

Reviewed-by: Xi Ruoyao <xry111@xry111.site>
Reviewed-by: Lulu Cheng <chenglulu@loongson.cn>
libgcc/config/loongarch/t-crtstuff-la32 [new file with mode: 0644]
libgcc/config/loongarch/t-crtstuff-la64 [moved from libgcc/config/loongarch/t-crtstuff with 100% similarity]
libgcc/configure
libgcc/configure.ac

diff --git a/libgcc/config/loongarch/t-crtstuff-la32 b/libgcc/config/loongarch/t-crtstuff-la32
new file mode 100644 (file)
index 0000000..d2bc8e5
--- /dev/null
@@ -0,0 +1,11 @@
+# -fasynchronous-unwind-tables is on by default for LoongArch.
+# We turn it off for crt*.o because it would make __EH_FRAME_BEGIN__ point
+# to .eh_frame data from crtbeginT.o instead of the user-defined object
+# during static linking.
+CRTSTUFF_T_CFLAGS += -fno-omit-frame-pointer -fno-asynchronous-unwind-tables
+
+# As shown in the test case PR118844, when using lld for linking,
+# it fails due to B26 in crtbeginS.o causing the link to exceed the range.
+# Therefore, the issue was resolved by adding the compilation option
+# "-mcmodel=extreme" when compiling crtbeginS.o.
+CRTSTUFF_T_CFLAGS_S += -mcmodel=medium
index fe7a21c296c3b7cd945c9822b34e47554500171e..8cdc021f9c1819b4a91d0ad978627966e346dda8 100755 (executable)
@@ -5397,6 +5397,18 @@ case ${host} in
 esac
 
 
+case ${host} in
+loongarch32*-*-*)
+  tmake_file="${tmake_file} loongarch/t-crtstuff-la32"
+  ;;
+esac
+
+case ${host} in
+loongarch64*-*-*)
+  tmake_file="${tmake_file} loongarch/t-crtstuff-la64"
+  ;;
+esac
+
 # Check if xtensa target is configured for windowed ABI and thus needs to use
 # custom unwind code.
 # This is after config.host so we can augment tmake_file.
index 59452436bd8ab379c69fc096ee1fb83898d20cbd..1ae782c480c8bf0fe1da38755bf19d21518438ca 100644 (file)
@@ -530,6 +530,18 @@ case ${host} in
 esac
 AC_SUBST(solaris_ld_v2_maps)
 
+case ${host} in
+loongarch32*-*-*)
+  tmake_file="${tmake_file} loongarch/t-crtstuff-la32"
+  ;;
+esac
+
+case ${host} in
+loongarch64*-*-*)
+  tmake_file="${tmake_file} loongarch/t-crtstuff-la64"
+  ;;
+esac
+
 # Check if xtensa target is configured for windowed ABI and thus needs to use
 # custom unwind code.
 # This is after config.host so we can augment tmake_file.