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

test building LoongArch #1787

Closed
nickdesaulniers opened this issue Jan 12, 2023 · 25 comments
Closed

test building LoongArch #1787

nickdesaulniers opened this issue Jan 12, 2023 · 25 comments
Labels
[ARCH] loongarch This bug impacts ARCH=loongarch good first issue Good for newcomers

Comments

@nickdesaulniers
Copy link
Member

https://discourse.llvm.org/t/rfc-promoting-the-loongarch-backend-from-experimental-to-official/67506 claims:

LLVM/Clang-16 is able to build many large programs for LoongArch, e.g.
Gcc, Binutils, Linux, ...

So it would be interesting to try this and see how well supported this combo is, and whether anything is missing.

@nickdesaulniers nickdesaulniers added good first issue Good for newcomers [ARCH] loongarch This bug impacts ARCH=loongarch labels Jan 12, 2023
@SixWeining
Copy link

@nickdesaulniers Thanks. The upstream Linux needs to be patched to be built by clang. The changes mainly include:

  • Add '$' prefix to register names in inline asm. See discussion: https://reviews.llvm.org/D136436. These files need to be patched:
    arch/loongarch/include/asm/cmpxchg.h
    arch/loongarch/include/asm/futex.h
    arch/loongarch/include/asm/vdso/gettimeofday.h
  • Fix some builtin invocation in arch/loongarch/include/asm/loongarch.h to avoid clang error: error: argument to '__builtin_xxx' must be a constant integer. GCC doesn't report such error in -O1 or above when callee is inlined while Clang does. But this is not arch specific.

I will discuss with GCC/Linux LoongArch port's maintainers @ChenghuaXu @chenhuacai to confirm whehter the changes could be upstreamed.

@nickdesaulniers
Copy link
Member Author

GCC doesn't report such error in -O1 or above when callee is inlined while Clang does. But this is not arch specific.

Right, clang will perform semantic analysis before optimizations; this can result in source code compiler portability issues. See:
commit 158807d ("x86/uaccess: Make __get_user_size() Clang compliant on 32-bit")
as an example.

@xen0n
Copy link
Member

xen0n commented Jan 14, 2023

Thanks very much for the attention. This is going to be valuable for future LoongArch users (particularly some enterprise or distro-building use cases but there are more), and I'll work with the arch/loongarch maintainers to ensure any necessary changes end up in the mainline. (I'm a reviewer for arch/loongarch code and helped the port's initial upstreaming.)

@nickdesaulniers
Copy link
Member Author

Any progress here?

@xen0n
Copy link
Member

xen0n commented Apr 21, 2023

I suppose the earlier verification with Linux was done with an earlier in-house version, that didn't make use of as many new features as the current HEAD does. The LoongArch community co-developed Linux and Binutils/GCC so there are a few new toolchain features that got added for Linux's needs, but similar support in LLVM has lagged behind a bit.

Current missing pieces in LLVM/Clang:

Aside from the missing Clang features, some kernel changes are also necessary:

  • -G0 is used to disable emission of small-data sections, but currently not wired up for LoongArch in Clang (leading to unused argument error on -G 0; not including the argument in case of Clang is enough)
  • -msoft-float takes precedence over -mabi=lp64s (leading to unused argument error on -mabi=lp64s; omitting -mabi in case of Clang is enough)
  • -mexplicit-relocs is not needed (Clang behaves as expected from the very beginning)
  • all asm("xx") need to become asm("$xx") due to not having D136436 (as explained by @SixWeining earlier)
  • CSR, IOCSR and CPUCFG helpers need slight tweaks (done, will be part of the Clang enablement patches; also covered earlier)

@xen0n
Copy link
Member

xen0n commented May 16, 2023

Some progress update:

@heiher
Copy link
Member

heiher commented Jun 8, 2023

  • Need to prevent optimization from eliminating CSR/IOCSR builtin ops without any data-dependency.

@xry111
Copy link

xry111 commented Jun 17, 2023

  • Need to prevent optimization from eliminating CSR/IOCSR builtin ops without any data-dependency.

Done with https://reviews.llvm.org/D153120.

@xen0n
Copy link
Member

xen0n commented Jun 23, 2023

  • llvm-objcopy needs adaptation: https://reviews.llvm.org/D153609
  • The lld port (currently under review) needs to ignore e_flags of files that doesn't contain code, similar to what BFD does, to be able to link vmlinuz.efi.elf

With these LLVM bits patched and this tree, a build without CONFIG_RELOCATABLE and CONFIG_MODULE now works!

Remaining:

  • __attribute__((model("extreme"))) support in Clang for CONFIG_MODULE
  • Investigate LLD's behavior difference in pre-populating the GOT to unbreak CONFIG_RELOCATABLE

@xen0n
Copy link
Member

xen0n commented Jun 24, 2023

v2 of the enablement patches is sent. For minimal Linux-side modifications two more LLVM patches are needed:

@nathanchance
Copy link
Member

v3: https://lore.kernel.org/20230625095644.3156349-1-kernel@xen0n.name/

I can confirm that ARCH=loongarch LLVM=1 defconfig + CONFIG_MODULES=n + CONFIG_RELOCATABLE=n builds with that series on top of next-20230626 using llvm/llvm-project@7827bee + D138135, although I did need the following diff to avoid erroring out in the vDSO (#1859):

clang: error: unsupported option '-mabi=' for target 'x86_64-pc-linux-gnu'
make[4]: *** [.../scripts/Makefile.build:370: arch/loongarch/vdso/vdso.lds] Error 1
diff --git a/arch/loongarch/vdso/Makefile b/arch/loongarch/vdso/Makefile
index ee4abcf5642e..19f6ea4b3fb4 100644
--- a/arch/loongarch/vdso/Makefile
+++ b/arch/loongarch/vdso/Makefile
@@ -16,11 +16,8 @@ ccflags-vdso := \
        $(filter -E%,$(KBUILD_CFLAGS)) \
        $(filter -march=%,$(KBUILD_CFLAGS)) \
        $(filter -m%-float,$(KBUILD_CFLAGS)) \
-       -D__VDSO__
-
-ifeq ($(cc-name),clang)
-ccflags-vdso += $(filter --target=%,$(KBUILD_CFLAGS))
-endif
+       -D__VDSO__ \
+       $(CLANG_FLAGS)

 cflags-vdso := $(ccflags-vdso) \
        -isystem $(shell $(CC) -print-file-name=include) \

which is basically applying 76d7fff22be3 ("MIPS: VDSO: Use CLANG_FLAGS instead of filtering out '--target='") to arch/loongarch from arch/mips. Additionally, a variant of 08f6554ff90e ("mips: Include KBUILD_CPPFLAGS in CHECKFLAGS invocation") will be needed for arch/loongarch to avoid the same error after feb843a469fb ("kbuild: add $(CLANG_FLAGS) to KBUILD_CPPFLAGS") is merged into mainline.

@chenhuacai
Copy link

chenhuacai commented Jun 27, 2023 via email

@nathanchance
Copy link
Member

Can the modification of 08f6554

https://git.kernel.org/masahiroy/linux-kbuild/c/08f6554ff90ef189e6b8f0303e57005bddfdd6a7

be

added before feb843a

https://git.kernel.org/masahiroy/linux-kbuild/c/feb843a469fb0ab00d2d23cfb9bcc379791011bb?

Yes, it should be fine. I can send a small series with those two changes on top of loongarch-next, since I see v3 has been applied. I can do it tomorrow.

@xen0n
Copy link
Member

xen0n commented Jun 27, 2023

Can the modification of 08f6554
https://git.kernel.org/masahiroy/linux-kbuild/c/08f6554ff90ef189e6b8f0303e57005bddfdd6a7
be
added before feb843a
https://git.kernel.org/masahiroy/linux-kbuild/c/feb843a469fb0ab00d2d23cfb9bcc379791011bb?

Yes, it should be fine. I can send a small series with those two changes on top of loongarch-next, since I see v3 has been applied. I can do it tomorrow.

Thanks! But I guess it would probably be more convenient for Huacai if we (Huacai and/or I) craft the series instead, because he seems to have to go through in-house integrations before updating loongarch-next, so how about we do it right away in UTC+8 working time so you could wake up to see everything integrated?

@nathanchance
Copy link
Member

Thanks! But I guess it would probably be more convenient for Huacai if we (Huacai and/or I) craft the series instead, because he seems to have to go through in-house integrations before updating loongarch-next, so how about we do it right away in UTC+8 working time so you could wake up to see everything integrated?

Sure thing, I will never complain about having to do less work :) I’ll review whatever is sent my way.

intel-lab-lkp pushed a commit to intel-lab-lkp/linux that referenced this issue Jun 27, 2023
This is a port of commit 76d7fff ("MIPS: VDSO: Use CLANG_FLAGS
instead of filtering out '--target='") to arch/loongarch, for fixing
cross-compilation with Clang.

Reported-by: Nathan Chancellor <nathan@kernel.org>
Link: ClangBuiltLinux#1787 (comment)
Signed-off-by: WANG Xuerui <git@xen0n.name>
intel-lab-lkp pushed a commit to intel-lab-lkp/linux that referenced this issue Jun 27, 2023
This is a port of commit 08f6554 ("mips: Include KBUILD_CPPFLAGS
in CHECKFLAGS invocation") to arch/loongarch, for fixing
cross-compilation of Linux/LoongArch with Clang, where previously the
`--target` flag would no longer be present for the CHECKFLAGS cc
invocation leading to build failure.

Reported-by: Nathan Chancellor <nathan@kernel.org>
Link: ClangBuiltLinux#1787 (comment)
Signed-off-by: WANG Xuerui <git@xen0n.name>
heiher pushed a commit to heiher/linux that referenced this issue Jun 27, 2023
This is a port of commit 76d7fff ("MIPS: VDSO: Use CLANG_FLAGS
instead of filtering out '--target='") to arch/loongarch, for fixing
cross-compilation with Clang.

Reported-by: Nathan Chancellor <nathan@kernel.org>
Link: ClangBuiltLinux#1787 (comment)
Signed-off-by: WANG Xuerui <git@xen0n.name>
heiher pushed a commit to heiher/linux that referenced this issue Jun 27, 2023
This is a port of commit 08f6554 ("mips: Include KBUILD_CPPFLAGS
in CHECKFLAGS invocation") to arch/loongarch, for fixing
cross-compilation of Linux/LoongArch with Clang, where previously the
`--target` flag would no longer be present for the CHECKFLAGS cc
invocation leading to build failure.

Reported-by: Nathan Chancellor <nathan@kernel.org>
Link: ClangBuiltLinux#1787 (comment)
Signed-off-by: WANG Xuerui <git@xen0n.name>
@heiher
Copy link
Member

heiher commented Jun 27, 2023

After jump-label is added to LoongArch, two more LLVM patches are needed:

chenhuacai pushed a commit to chenhuacai/linux that referenced this issue Jun 27, 2023
This is a port of commit 76d7fff ("MIPS: VDSO: Use CLANG_FLAGS
instead of filtering out '--target='") to arch/loongarch, for fixing
cross-compilation with Clang.

Reported-by: Nathan Chancellor <nathan@kernel.org>
Link: ClangBuiltLinux/linux#1787 (comment)
Signed-off-by: WANG Xuerui <git@xen0n.name>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
chenhuacai pushed a commit to chenhuacai/linux that referenced this issue Jun 27, 2023
This is a port of commit 08f6554 ("mips: Include KBUILD_CPPFLAGS in
CHECKFLAGS invocation") to arch/loongarch, for fixing cross-compilation
of Linux/LoongArch with Clang, where previously the `--target` flag
would no longer be present for the CHECKFLAGS cc invocation leading to
build failure.

Reported-by: Nathan Chancellor <nathan@kernel.org>
Link: ClangBuiltLinux/linux#1787 (comment)
Signed-off-by: WANG Xuerui <git@xen0n.name>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
chenhuacai pushed a commit to chenhuacai/linux that referenced this issue Jun 27, 2023
This is a port of commit 76d7fff ("MIPS: VDSO: Use CLANG_FLAGS
instead of filtering out '--target='") to arch/loongarch, for fixing
cross-compilation with Clang.

Reported-by: Nathan Chancellor <nathan@kernel.org>
Link: ClangBuiltLinux/linux#1787 (comment)
Signed-off-by: WANG Xuerui <git@xen0n.name>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
chenhuacai pushed a commit to chenhuacai/linux that referenced this issue Jun 27, 2023
This is a port of commit 08f6554 ("mips: Include KBUILD_CPPFLAGS in
CHECKFLAGS invocation") to arch/loongarch, for fixing cross-compilation
of Linux/LoongArch with Clang, where previously the `--target` flag
would no longer be present for the CHECKFLAGS cc invocation leading to
build failure.

Reported-by: Nathan Chancellor <nathan@kernel.org>
Link: ClangBuiltLinux/linux#1787 (comment)
Signed-off-by: WANG Xuerui <git@xen0n.name>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
chenhuacai pushed a commit to chenhuacai/linux that referenced this issue Jun 28, 2023
This is a port of commit 76d7fff ("MIPS: VDSO: Use CLANG_FLAGS
instead of filtering out '--target='") to arch/loongarch, for fixing
cross-compilation with Clang.

Reported-by: Nathan Chancellor <nathan@kernel.org>
Link: ClangBuiltLinux/linux#1787 (comment)
Signed-off-by: WANG Xuerui <git@xen0n.name>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
chenhuacai pushed a commit to chenhuacai/linux that referenced this issue Jun 28, 2023
This is a port of commit 08f6554 ("mips: Include KBUILD_CPPFLAGS in
CHECKFLAGS invocation") to arch/loongarch, for fixing cross-compilation
of Linux/LoongArch with Clang, where previously the `--target` flag
would no longer be present for the CHECKFLAGS cc invocation leading to
build failure.

Reported-by: Nathan Chancellor <nathan@kernel.org>
Link: ClangBuiltLinux/linux#1787 (comment)
Signed-off-by: WANG Xuerui <git@xen0n.name>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
akiyks pushed a commit to akiyks/linux that referenced this issue Jun 28, 2023
This is a port of commit 76d7fff ("MIPS: VDSO: Use CLANG_FLAGS
instead of filtering out '--target='") to arch/loongarch, for fixing
cross-compilation with Clang.

Reported-by: Nathan Chancellor <nathan@kernel.org>
Link: ClangBuiltLinux#1787 (comment)
Signed-off-by: WANG Xuerui <git@xen0n.name>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
akiyks pushed a commit to akiyks/linux that referenced this issue Jun 28, 2023
This is a port of commit 08f6554 ("mips: Include KBUILD_CPPFLAGS in
CHECKFLAGS invocation") to arch/loongarch, for fixing cross-compilation
of Linux/LoongArch with Clang, where previously the `--target` flag
would no longer be present for the CHECKFLAGS cc invocation leading to
build failure.

Reported-by: Nathan Chancellor <nathan@kernel.org>
Link: ClangBuiltLinux#1787 (comment)
Signed-off-by: WANG Xuerui <git@xen0n.name>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
akiyks pushed a commit to akiyks/linux that referenced this issue Jun 29, 2023
This is a port of commit 76d7fff ("MIPS: VDSO: Use CLANG_FLAGS
instead of filtering out '--target='") to arch/loongarch, for fixing
cross-compilation with Clang.

Reported-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Link: ClangBuiltLinux#1787 (comment)
Signed-off-by: WANG Xuerui <git@xen0n.name>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
akiyks pushed a commit to akiyks/linux that referenced this issue Jun 29, 2023
This is a port of commit 08f6554 ("mips: Include KBUILD_CPPFLAGS in
CHECKFLAGS invocation") to arch/loongarch, for fixing cross-compilation
of Linux/LoongArch with Clang, where previously the `--target` flag
would no longer be present for the CHECKFLAGS cc invocation leading to
build failure.

Reported-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Link: ClangBuiltLinux#1787 (comment)
Signed-off-by: WANG Xuerui <git@xen0n.name>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
akiyks pushed a commit to akiyks/linux that referenced this issue Jun 30, 2023
This is a port of commit 76d7fff ("MIPS: VDSO: Use CLANG_FLAGS
instead of filtering out '--target='") to arch/loongarch, for fixing
cross-compilation with Clang.

Reported-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Link: ClangBuiltLinux#1787 (comment)
Signed-off-by: WANG Xuerui <git@xen0n.name>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
akiyks pushed a commit to akiyks/linux that referenced this issue Jun 30, 2023
This is a port of commit 08f6554 ("mips: Include KBUILD_CPPFLAGS in
CHECKFLAGS invocation") to arch/loongarch, for fixing cross-compilation
of Linux/LoongArch with Clang, where previously the `--target` flag
would no longer be present for the CHECKFLAGS cc invocation leading to
build failure.

Reported-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Link: ClangBuiltLinux#1787 (comment)
Signed-off-by: WANG Xuerui <git@xen0n.name>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
@nathanchance
Copy link
Member

The initial LoongArch clang build support has been merged into mainline: https://git.kernel.org/linus/112e7e21519422b6f2bb0fa8061f5685e9757170

Should we mark this as resolved and open more specific tracking issues for:

  • Getting this turned on in continuous integration (need tuxmake to support LoongArch first, I can look into this in next week)
  • Implementing __attribute__((model("extreme"))) for CONFIG_MODULES=y
  • Getting ld.lld support merged
  • Investigating what breaks CONFIG_RELOCATABLE=y with ld.lld

Am I missing anything?

@xry111
Copy link

xry111 commented Jul 5, 2023

If it's difficult to implement model attribute, should we consider loading the main kernel image into XKVRANGE instead of XKPRANGE? If we can load the main kernel image into XKVRANGE we can make the main kernel image and the modules altogether in a 2GB range, thus the "normal" code model will be sufficient.

And we are already building the kernel image as a PIE so I guess it might be not so difficult...

@xen0n
Copy link
Member

xen0n commented Jul 6, 2023

For the record, I started a discussion on how to best implement the model attribute over at the LLVM forums. Hairier than I originally expected but still kinda feasible, but of course any simplification of the picture would be appreciated.

@xen0n
Copy link
Member

xen0n commented Jul 6, 2023

The initial LoongArch clang build support has been merged into mainline: https://git.kernel.org/linus/112e7e21519422b6f2bb0fa8061f5685e9757170

Should we mark this as resolved and open more specific tracking issues for:

  • Getting this turned on in continuous integration (need tuxmake to support LoongArch first, I can look into this in next week)
  • Implementing __attribute__((model("extreme"))) for CONFIG_MODULES=y
  • Getting ld.lld support merged
  • Investigating what breaks CONFIG_RELOCATABLE=y with ld.lld

Am I missing anything?

Seems that's a pretty complete picture! I'd be fine with closing this issue and tracking the follow-up work separately.

@nickdesaulniers
Copy link
Member Author

I'd be fine with closing this issue and tracking the follow-up work separately.

As a member of @ClangBuiltLinux, please feel empowered to do so. Make sure to use the loongarch label on relevant github issues, and consider linking to each individual issue. I prefer distinct issues filed to track each work item, if it makes sense to do so.

@nickdesaulniers
Copy link
Member Author

nickdesaulniers commented Jul 7, 2023

need tuxmake to support LoongArch first, I can look into this in next week

I meant to do that [file an issue on tuxmake's gitlab] today, but gitlab was having an outtage this morning...

@xen0n
Copy link
Member

xen0n commented Jul 10, 2023

Hmm I just discovered I don't have issue triage permissions. Not in a hurry though, I created the follow-up issues anyway and I'll fix the labels / close this issue whenever the permissions are sorted out.

@xen0n
Copy link
Member

xen0n commented Jul 10, 2023

Regarding the review process of the ld.lld port: review activity has resumed, and all review comments are again addressed, so I still expect it to get merged before the LLVM 17 branch. I'll coordinate anyway should anything happen.

@nathanchance
Copy link
Member

Hmm I just discovered I don't have issue triage permissions.

And I don't see how to give them to you :/ in the Organization settings, I see "Triage" as one of the pre-defined roles in the "Repository roles" section but I do not see it in the "Base permissions" drop down under the "Member privileges" section...

I'll fix the labels / close this issue whenever the permissions are sorted out.

Looks like Nick already added labels. I opened ClangBuiltLinux/continuous-integration2#599 for adding LoongArch to our continuous integration. I will close this up since all action items should have their own issue now.

shikongzhineng pushed a commit to shikongzhineng/linux that referenced this issue Jul 12, 2023
This is a port of commit 76d7fff ("MIPS: VDSO: Use CLANG_FLAGS
instead of filtering out '--target='") to arch/loongarch, for fixing
cross-compilation with Clang.

Reported-by: Nathan Chancellor <nathan@kernel.org>
Link: ClangBuiltLinux#1787 (comment)
Signed-off-by: WANG Xuerui <git@xen0n.name>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
shikongzhineng pushed a commit to shikongzhineng/linux that referenced this issue Jul 12, 2023
This is a port of commit 08f6554 ("mips: Include KBUILD_CPPFLAGS in
CHECKFLAGS invocation") to arch/loongarch, for fixing cross-compilation
of Linux/LoongArch with Clang, where previously the `--target` flag
would no longer be present for the CHECKFLAGS cc invocation leading to
build failure.

Reported-by: Nathan Chancellor <nathan@kernel.org>
Link: ClangBuiltLinux#1787 (comment)
Signed-off-by: WANG Xuerui <git@xen0n.name>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Whissi pushed a commit to Whissi/linux-stable that referenced this issue Jul 19, 2023
commit 5ddc7a3 upstream.

This is a port of commit 08f6554 ("mips: Include KBUILD_CPPFLAGS in
CHECKFLAGS invocation") to arch/loongarch, for fixing cross-compilation
of Linux/LoongArch with Clang, where previously the `--target` flag
would no longer be present for the CHECKFLAGS cc invocation leading to
build failure.

Reported-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Link: ClangBuiltLinux/linux#1787 (comment)
Signed-off-by: WANG Xuerui <git@xen0n.name>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
intel-lab-lkp pushed a commit to intel-lab-lkp/linux that referenced this issue Aug 1, 2023
On my test machine, the clang version is 16.0.4, when build kernel
with clang:

  make CC=clang loongson3_defconfig
  make CC=clang

there exist many errors such as:

  clang-16: error: argument unused during compilation: '-mabi=lp64s'
  error: unknown register name 'a0' in asm
  error: unknown register name 't0' in asm

the above issues have been fixed in the upstream llvm project recently,
it works well when update clang version to 17.0.0:

  make CC=clang loongson3_defconfig
  make CC=clang menuconfig (set CONFIG_MODULES=n and CONFIG_RELOCATABLE=n)
  make CC=clang

thus 17.0.0 is the minimal clang version to build kernel on LoongArch,
it is better to error out if clang version is less than 17.0.0, then
we can do the right thing to update clang version and avoid wasting
time to analysis kernel errors.

By the way, the clang 17.0.0 still have some issues to build kernel on
LoongArch, you need to unset CONFIG_MODULES and CONFIG_RELOCATABLE to
avoid build errors. Additionally, if you want a workable kernel, some
modules should be set as y instead of m if CONFIG_MODULES=n.

Link: ClangBuiltLinux#1787
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
wanghao75 pushed a commit to openeuler-mirror/kernel that referenced this issue Aug 25, 2023
mainline inclusion
from mainline-v6.5-rc1
commit b89673a
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I7MWTU
CVE: NA

--------------------------------

This is a port of commit 76d7fff ("MIPS: VDSO: Use CLANG_FLAGS
instead of filtering out '--target='") to arch/loongarch, for fixing
cross-compilation with Clang.

Signed-off-by: Yongzhen Zhang <zhangyongzhen@kylinos.cn>
Reported-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Link: ClangBuiltLinux/linux#1787 (comment)
Signed-off-by: WANG Xuerui <git@xen0n.name>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
wanghao75 pushed a commit to openeuler-mirror/kernel that referenced this issue Aug 25, 2023
mainline inclusion
from mainline-v6.5-rc1
commit 5ddc7a3
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I7MWTU
CVE: NA

--------------------------------

This is a port of commit 08f6554 ("mips: Include KBUILD_CPPFLAGS in
CHECKFLAGS invocation") to arch/loongarch, for fixing cross-compilation
of Linux/LoongArch with Clang, where previously the `--target` flag
would no longer be present for the CHECKFLAGS cc invocation leading to
build failure.

Signed-off-by: Yongzhen Zhang <zhangyongzhen@kylinos.cn>
Reported-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Link: ClangBuiltLinux/linux#1787 (comment)
Signed-off-by: WANG Xuerui <git@xen0n.name>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
shikongzhineng pushed a commit to shikongzhineng/linux that referenced this issue Dec 25, 2023
This is a port of commit 76d7fff ("MIPS: VDSO: Use CLANG_FLAGS
instead of filtering out '--target='") to arch/loongarch, for fixing
cross-compilation with Clang.

Reported-by: Nathan Chancellor <nathan@kernel.org>
Link: ClangBuiltLinux#1787 (comment)
Signed-off-by: WANG Xuerui <git@xen0n.name>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
shikongzhineng pushed a commit to shikongzhineng/linux that referenced this issue Dec 25, 2023
This is a port of commit 76d7fff ("MIPS: VDSO: Use CLANG_FLAGS
instead of filtering out '--target='") to arch/loongarch, for fixing
cross-compilation with Clang.

Reported-by: Nathan Chancellor <nathan@kernel.org>
Link: ClangBuiltLinux#1787 (comment)
Signed-off-by: WANG Xuerui <git@xen0n.name>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
shikongzhineng pushed a commit to shikongzhineng/linux that referenced this issue Dec 25, 2023
This is a port of commit 76d7fff ("MIPS: VDSO: Use CLANG_FLAGS
instead of filtering out '--target='") to arch/loongarch, for fixing
cross-compilation with Clang.

Reported-by: Nathan Chancellor <nathan@kernel.org>
Link: ClangBuiltLinux#1787 (comment)
Signed-off-by: WANG Xuerui <git@xen0n.name>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[ARCH] loongarch This bug impacts ARCH=loongarch good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

7 participants