Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ABI 'o32' is not supported on CPU 'mips64r2' #884

Open
tpimh opened this issue Feb 14, 2020 · 7 comments
Open

ABI 'o32' is not supported on CPU 'mips64r2' #884

tpimh opened this issue Feb 14, 2020 · 7 comments
Labels
[ARCH] mips This bug impacts ARCH=mips [BUG] llvm A bug that should be fixed in upstream LLVM [FIXED][LLVM] 17 This bug was fixed in LLVM 17.0 low priority This bug is not critical and not a priority Reported upstream This bug was filed on LLVM’s issue tracker, Phabricator, or the kernel mailing list.

Comments

@tpimh
Copy link

tpimh commented Feb 14, 2020

Both CONFIG_MIPS32_O32=y and CONFIG_CPU_MIPSR2=y can not be enabled at the same time.

As this comment suggests this should be fixed: https://github.com/ClangBuiltLinux/llvm-project/blob/cccf1ef0c89432339363fc0121e3d97f5a04ac69/clang/test/Driver/mips-abi.c#L12

@tpimh tpimh added [BUG] llvm A bug that should be fixed in upstream LLVM low priority This bug is not critical and not a priority [ARCH] mips This bug impacts ARCH=mips labels Feb 14, 2020
@tpimh
Copy link
Author

tpimh commented Apr 23, 2020

From clang source code quoted in #885 (comment):

  // FIXME: It's valid to use O32 on a 64-bit CPU but the backend can't handle
  //        this yet. It's better to fail here than on the backend assertion.
  if (processorSupportsGPR64() && ABI == "o32") {
    Diags.Report(diag::err_target_unsupported_abi) << ABI << CPU;
    return false;
  }
  // FIXME: It's valid to use O32 on a mips64/mips64el triple but the backend
  //        can't handle this yet. It's better to fail here than on the
  //        backend assertion.
  if (getTriple().isMIPS64() && ABI == "o32") {
    Diags.Report(diag::err_target_unsupported_abi_for_triple)
        << ABI << getTriple().str();
    return false;
  }

@nathanchance
Copy link
Member

nathanchance commented Mar 4, 2021

Upstream LLVM issue: https://llvm.org/pr38063

Patch disabling CONFIG_MIPS32_O32 for Clang: https://lore.kernel.org/r/1614838778-3696-1-git-send-email-yangtiezhu@loongson.cn/

@nickdesaulniers nickdesaulniers added the Reported upstream This bug was filed on LLVM’s issue tracker, Phabricator, or the kernel mailing list. label Mar 4, 2021
@nathanchance
Copy link
Member

Upstream thread with some addition info from Arnd: https://lore.kernel.org/CADVatmNtFYyqk0KwYzB1x6hOPkQ=0gV8mPN1BWp6QWrCs5GaxA@mail.gmail.com/

@nickdesaulniers
Copy link
Member

@ardbiesheuvel came up with:

diff --git a/arch/mips/Makefile b/arch/mips/Makefile
index bb236de13133..d7b7451d055f 100644
--- a/arch/mips/Makefile
+++ b/arch/mips/Makefile
@@ -409,7 +409,7 @@ ifdef CONFIG_MIPS32_N32
 endif
 ifdef CONFIG_MIPS32_O32
        @$(kecho) '  Checking missing-syscalls for O32'
-       $(Q)$(MAKE) $(build)=. missing-syscalls missing_syscalls_flags="-mabi=32"
+       $(Q)$(MAKE) $(build)=. missing-syscalls missing_syscalls_flags="--target=mips-linux"
 endif
 
 install:
diff --git a/arch/mips/vdso/Makefile b/arch/mips/vdso/Makefile
index f72658b3a53f..2fb69d606547 100644
--- a/arch/mips/vdso/Makefile
+++ b/arch/mips/vdso/Makefile
@@ -141,8 +141,8 @@ ifdef CONFIG_MIPS32_O32
 
 obj-vdso-o32 := $(obj-vdso-y:%.o=$(obj)/%-o32.o)
 
-$(obj-vdso-o32): KBUILD_CFLAGS := $(cflags-vdso) -mabi=32
-$(obj-vdso-o32): KBUILD_AFLAGS := $(aflags-vdso) -mabi=32
+$(obj-vdso-o32): KBUILD_CFLAGS := $(cflags-vdso) --target=mips-linux -march=mips32r6
+$(obj-vdso-o32): KBUILD_AFLAGS := $(aflags-vdso) --target=mips-linux -march=mips32r6
 
 $(obj)/%-o32.o: $(src)/%.S FORCE
        $(call if_changed_dep,vdsoas_o_S)
@@ -151,7 +151,7 @@ $(obj)/%-o32.o: $(src)/%.c FORCE
        $(call cmd,force_checksrc)
        $(call if_changed_rule,cc_o_c)
 
-$(obj)/vdso-o32.lds: KBUILD_CPPFLAGS := $(ccflags-vdso) -mabi=32
+$(obj)/vdso-o32.lds: KBUILD_CPPFLAGS := $(ccflags-vdso) --target=mips-linux -march=mips32r6
 $(obj)/vdso-o32.lds: $(src)/vdso.lds.S FORCE
        $(call if_changed_dep,cpp_lds_S)

Seems to build. With some touch ups to avoid passing that flag to GCC will probably be upstreamable.

@nickdesaulniers
Copy link
Member

@FlyGoat
Copy link
Member

FlyGoat commented Apr 7, 2023

Clang patch: https://reviews.llvm.org/D146269

@nickdesaulniers nickdesaulniers added the [PATCH] Submitted A patch has been submitted for review label Apr 7, 2023
@nathanchance
Copy link
Member

This is fixed in LLVM 17 with llvm/llvm-project@7983f8a. Perhaps now that this is fixed in the toolchain, the kernel will accept a workaround disabling the configuration for older toolchain versions? Otherwise, we could just leave it broken.

@nathanchance nathanchance added [FIXED][LLVM] 17 This bug was fixed in LLVM 17.0 and removed [PATCH] Submitted A patch has been submitted for review labels Sep 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[ARCH] mips This bug impacts ARCH=mips [BUG] llvm A bug that should be fixed in upstream LLVM [FIXED][LLVM] 17 This bug was fixed in LLVM 17.0 low priority This bug is not critical and not a priority Reported upstream This bug was filed on LLVM’s issue tracker, Phabricator, or the kernel mailing list.
Projects
None yet
Development

No branches or pull requests

4 participants