public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc] LoongArch: Use medium cmodel build libc_nonshared.a.
@ 2022-12-07 2:43 Yinyu Cai
0 siblings, 0 replies; only message in thread
From: Yinyu Cai @ 2022-12-07 2:43 UTC (permalink / raw)
To: glibc-cvs
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=9f482b73f41a9a1bbfb173aad0733d1c824c788a
commit 9f482b73f41a9a1bbfb173aad0733d1c824c788a
Author: Chenghua Xu <xuchenghua@loongson.cn>
Date: Wed Sep 7 10:33:00 2022 +0800
LoongArch: Use medium cmodel build libc_nonshared.a.
This patch is used to fix address out-of-bounds error when building
Chrome.
Diff:
---
sysdeps/loongarch/Makefile | 6 ++++++
sysdeps/loongarch/configure | 22 ++++++++++++++++++++++
sysdeps/loongarch/configure.ac | 10 ++++++++++
3 files changed, 38 insertions(+)
diff --git a/sysdeps/loongarch/Makefile b/sysdeps/loongarch/Makefile
index 746d4c2c8f..1778fd1c88 100644
--- a/sysdeps/loongarch/Makefile
+++ b/sysdeps/loongarch/Makefile
@@ -5,3 +5,9 @@ endif
# LoongArch's assembler also needs to know about PIC as it changes the
# definition of some assembler macros.
ASFLAGS-.os += $(pic-ccflag)
+
+# All the objects in lib*_nonshared.a need to be compiled with medium code
+# model or large applications may fail to link.
+ifeq (yes,$(have-cmodel-medium))
+CFLAGS-.oS += -mcmodel=medium
+endif
diff --git a/sysdeps/loongarch/configure b/sysdeps/loongarch/configure
index 3046915ce2..a08ba67c9a 100644
--- a/sysdeps/loongarch/configure
+++ b/sysdeps/loongarch/configure
@@ -72,3 +72,25 @@ if test "$libc_cv_static_pie_on_loongarch" = yes; then
$as_echo "#define SUPPORT_STATIC_PIE 1" >>confdefs.h
fi
+
+ # Check if gcc supports option -mcmodel=medium.
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC supports option -mcmodel=medium" >&5
+$as_echo_n "checking whether $CC supports option -mcmodel=medium... " >&6; }
+if ${libc_cv_loongarch_cmodel_medium+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if { ac_try='${CC-cc} -c $CFLAGS -mcmodel=medium /dev/null 1>&5'
+ { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; }; then
+ libc_cv_loongarch_cmodel_medium=yes
+ else
+ libc_cv_loongarch_cmodel_medium=no
+ fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_loongarch_cmodel_medium" >&5
+$as_echo "$libc_cv_loongarch_cmodel_medium" >&6; }
+config_vars="$config_vars
+have-cmodel-medium = $libc_cv_loongarch_cmodel_medium"
diff --git a/sysdeps/loongarch/configure.ac b/sysdeps/loongarch/configure.ac
index 06dd408ad9..9df387f086 100644
--- a/sysdeps/loongarch/configure.ac
+++ b/sysdeps/loongarch/configure.ac
@@ -51,3 +51,13 @@ EOF
if test "$libc_cv_static_pie_on_loongarch" = yes; then
AC_DEFINE(SUPPORT_STATIC_PIE)
fi
+
+ # Check if gcc supports option -mcmodel=medium.
+AC_CACHE_CHECK(whether $CC supports option -mcmodel=medium,
+ libc_cv_loongarch_cmodel_medium, [
+ if AC_TRY_COMMAND(${CC-cc} -c $CFLAGS -mcmodel=medium /dev/null 1>&AS_MESSAGE_LOG_FD); then
+ libc_cv_loongarch_cmodel_medium=yes
+ else
+ libc_cv_loongarch_cmodel_medium=no
+ fi])
+LIBC_CONFIG_VAR([have-cmodel-medium], [$libc_cv_loongarch_cmodel_medium])
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-12-07 2:43 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-07 2:43 [glibc] LoongArch: Use medium cmodel build libc_nonshared.a Yinyu Cai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).