If the host triple and the target triple are different but the host is LoongArch, in some cases --with-arch=native can be useful. For example, if we are bootstrapping a loongarch64-linux-musl toolchain on a Glibc-based system and we don't intend to use the toolchain on other machines, we can use
../gcc/configure --{build,host}=loongarch64-linux-gnu \ --target=loongarch64-linux-musl --with-arch=native Relax the check in config.gcc to allow such configurations. gcc/ChangeLog: * config.gcc [target=loongarch*-*-*, with_arch=native]: Allow building cross compiler if the host CPU is LoongArch. --- Tested on x86_64-linux-gnu (building a cross compiler targeting LoongArch --with-arch=native still rejected) and loongarch64-linux-gnu (building a cross compiler targeting loongarch64-linux-musl allowed). Ok for trunk? gcc/config.gcc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gcc/config.gcc b/gcc/config.gcc index 1446eb2b3ca..146bca22a38 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -4939,10 +4939,13 @@ case "${target}" in case ${with_arch} in "" | loongarch64 | la464) ;; # OK, append here. native) - if test x${host} != x${target}; then + case ${host} in + loongarch*) ;; # OK + *) echo "--with-arch=native is illegal for cross-compiler." 1>&2 exit 1 - fi + ;; + esac ;; "") echo "Please set a default value for \${with_arch}" \ -- 2.41.0