]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
LoongArch: add new configure option --with-strict-align-lib
authorYang Yujie <yangyujie@loongson.cn>
Mon, 28 Aug 2023 02:20:12 +0000 (10:20 +0800)
committerLulu Cheng <chenglulu@loongson.cn>
Tue, 5 Sep 2023 03:48:05 +0000 (11:48 +0800)
LoongArch processors may not support memory accesses without natural
alignments.  Building libraries with -mstrict-align may help with
toolchain binary compatiblity and performance on these implementations
(e.g. Loongson 2K1000LA).

No significant performance degredation is observed on current mainstream
LoongArch processors when the option is enabled.

gcc/ChangeLog:

* config.gcc: use -mstrict-align for building libraries
if --with-strict-align-lib is given.
* doc/install.texi: likewise.

gcc/config.gcc
gcc/doc/install.texi

index 543b0ba076ba08c0fc2eea1ceb999ab74f38f101..89af167e5d947688950e35b11052fd2be09628fb 100644 (file)
@@ -4892,7 +4892,7 @@ case "${target}" in
                ;;
 
        loongarch*-*)
-               supported_defaults="abi arch tune fpu simd multilib-default"
+               supported_defaults="abi arch tune fpu simd multilib-default strict-align-lib"
 
                # Local variables
                unset \
@@ -5089,6 +5089,17 @@ case "${target}" in
                        ;;
                esac
 
+               # Build libraries with -mstrict-align if --with-strict-align-lib is given.
+               case ${with_strict_align_lib} in
+               yes) strict_align_opt="/mstrict-align" ;;
+               ""|no)  ;;
+               *)
+                       echo "Unknown option: --with-strict-align-lib=${with_strict_align_lib}" 1>&2
+                       exit 1
+                       ;;
+               esac
+
+
                # Handle --with-multilib-default
                if echo "${with_multilib_default}" \
                | grep -E -e '[[:space:]]' -e '//' -e '/$' -e '^/' > /dev/null 2>&1; then
@@ -5250,6 +5261,9 @@ case "${target}" in
                                        ;;
                        esac
 
+                       # Use mstrict-align for building libraries if --with-strict-align-lib is given.
+                       loongarch_multilib_list_make="${loongarch_multilib_list_make}${strict_align_opt}"
+
                        # Check for repeated configuration of the same multilib variant.
                        if echo "${elem_abi_base}/${elem_abi_ext}" \
                         | grep -E "^(${all_abis%|})$" >/dev/null 2>&1; then
index bbc58cb60caf109b5e5bb817e3c657fa193191cb..31f2234640f8782adc49dca93260b0836ef03f03 100644 (file)
@@ -1416,6 +1416,10 @@ Multiple @var{option}s may appear consecutively while @var{arch} may only
 appear in the beginning or be omitted (which means @option{-march=abi-default}
 is applied when building the libraries).
 
+@item --with-strict-align-lib
+On LoongArch targets, build all enabled multilibs with @option{-mstrict-align}
+(Not enabled by default).
+
 @item --with-multilib-generator=@var{config}
 Specify what multilibs to build.  @var{config} is a semicolon separated list of
 values, possibly consisting of a single value.  Currently only implemented