-
Notifications
You must be signed in to change notification settings - Fork 14
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
Comments
@nickdesaulniers Thanks. The upstream Linux needs to be patched to be built by clang. The changes mainly include:
I will discuss with GCC/Linux LoongArch port's maintainers @ChenghuaXu @chenhuacai to confirm whehter the changes could be upstreamed. |
Right, clang will perform semantic analysis before optimizations; this can result in source code compiler portability issues. See: |
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 |
Any progress here? |
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:
|
Some progress update:
|
|
Done with https://reviews.llvm.org/D153120. |
With these LLVM bits patched and this tree, a build without Remaining:
|
v2 of the enablement patches is sent. For minimal Linux-side modifications two more LLVM patches are needed:
|
v3: https://lore.kernel.org/20230625095644.3156349-1-kernel@xen0n.name/ I can confirm that
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 |
Hi, Nathan,
On Tue, Jun 27, 2023 at 5:41 AM Nathan Chancellor ***@***.***> wrote:
v3: ***@***.***/
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 <https://reviews.llvm.org/D138135>, although I did need the
following diff to avoid erroring out in the vDSO (#1859
<#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 76d7fff
<https://git.kernel.org/linus/76d7fff22be3e4185ee5f9da2eecbd8188e76b2c>
("MIPS: VDSO: Use CLANG_FLAGS instead of filtering out '--target='") to
arch/loongarch from arch/mips. Additionally, a variant of 08f6554
<https://git.kernel.org/masahiroy/linux-kbuild/c/08f6554ff90ef189e6b8f0303e57005bddfdd6a7>
("mips: Include KBUILD_CPPFLAGS in CHECKFLAGS invocation") will be needed
for arch/loongarch to avoid the same error after feb843a
<https://git.kernel.org/masahiroy/linux-kbuild/c/feb843a469fb0ab00d2d23cfb9bcc379791011bb>
("kbuild: add $(CLANG_FLAGS) to KBUILD_CPPFLAGS") is merged into mainline.
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>?
Thanks.
Huacai
… —
Reply to this email directly, view it on GitHub
<#1787 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AFCGEMSXMG2UJWVGMDG7VYLXNH6X5ANCNFSM6AAAAAATZRXQTI>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
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 |
Sure thing, I will never complain about having to do less work :) I’ll review whatever is sent my way. |
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>
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>
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>
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>
After
|
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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:
Am I missing anything? |
If it's difficult to implement And we are already building the kernel image as a PIE so I guess it might be not so difficult... |
For the record, I started a discussion on how to best implement the |
Seems that's a pretty complete picture! 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. |
I meant to do that [file an issue on tuxmake's gitlab] today, but gitlab was having an outtage this morning... |
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. |
Regarding the review process of the |
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...
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. |
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>
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>
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>
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>
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>
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>
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>
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>
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>
https://discourse.llvm.org/t/rfc-promoting-the-loongarch-backend-from-experimental-to-official/67506 claims:
So it would be interesting to try this and see how well supported this combo is, and whether anything is missing.
The text was updated successfully, but these errors were encountered: