--- /dev/null
+# -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
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.
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.