-
-
Notifications
You must be signed in to change notification settings - Fork 91
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
loongarch64-linux-musl #164
Comments
musl upstream does not support this target yet https://wiki.musl-libc.org/supported-platforms |
There is some patch in the mailing list and I guess the support is coming soon. https://inbox.vuxu.org/musl/2a8d55b0-add3-4d90-1119-4e5c28b6626e@loongson.cn/ Anyway, maybe trying to make #166 work first is a good idea. |
musl support is coming: https://www.openwall.com/lists/musl/2024/01/25/12 |
https://musl.libc.org/releases.html musl 1.2.5 adds loongarch64 support. |
current status is:
In other words, unable to build compiler_rt from source due to LLVM bug in lowering to fp16. |
I'm trying to handle the code model issue for loongarch64 target. If the code model is not set properly, it will have R_LARCH_B26 overflow problem now. |
I managed to bootstrap a loongarch64-linux-musl zig with some patch like this on zig: diff --git a/lib/libc/glibc/sysdeps/loongarch/start.S b/lib/libc/glibc/sysdeps/loongarch/start.S
index de7f9645cf..976dd92178 100644
--- a/lib/libc/glibc/sysdeps/loongarch/start.S
+++ b/lib/libc/glibc/sysdeps/loongarch/start.S
@@ -56,7 +56,7 @@ ENTRY (ENTRY_POINT)
/* Terminate call stack by noting ra is undefined. Use a dummy
.cfi_label to force starting the FDE. */
- .cfi_label .Ldummy
+ /* .cfi_label .Ldummy */
cfi_undefined (1)
or a5, a0, zero /* rtld_fini */
diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig
index 233cf7e3eb..80e37c1ad3 100644
--- a/src/codegen/llvm.zig
+++ b/src/codegen/llvm.zig
@@ -11799,6 +11799,7 @@ fn backendSupportsF16(target: std.Target) bool {
.mips64,
.mips64el,
.s390x,
+ .loongarch64,
=> false,
.aarch64,
.aarch64_be,
However, when trying to use this zig to build a simple hello world C file #include <stdio.h>
int main() {
printf("Hello, World!\n");
return 0;
} with
I got the following error. But this doesn't happen on x86_64 zig. #0 0x000000000a435b18 in ZigLLVMTargetMachineEmitToFile (targ_machine_ref=0x7fffe7ec9f90,
module_ref=0x7fffe6ffff90, error_message=0x7fffeef32050,
options=<error reading variable: Cannot access memory at address 0x0>)
at /Users/yxd/playspace/zig/src/zig_llvm.cpp:218
#1 0x0000000009860f30 in codegen.llvm.Object.emit (self=<optimized out>, options=...)
at /Users/yxd/playspace/zig/src/codegen/llvm.zig:1317
#2 0x000000000985f210 in Compilation.emitLlvmObject (comp=0x7ffff7fe6c10, arena=...,
default_emit=..., bin_emit_loc=..., llvm_object=0x7fffedf0c1d0) at Compilation.zig:2756
#3 0x0000000009938304 in link.File.emitLlvmObject (arena=..., llvm_object=0x0,
prog_node=...) at link.zig:1032
#4 link.Elf.flushModule (self=0x7fffedf28e70, arena=..., tid=main, prog_node=...)
at /Users/yxd/playspace/zig/src/link/Elf.zig:992
#5 0x000000000985ccc8 in link.File.flushModule (base=0x7fffedf292d0, tid=main)
at link.zig:635
#6 link.File.linkAsArchive (base=0x7fffedf292d0, tid=main) at link.zig:762
#7 link.File.flush (base=<optimized out>, arena=..., tid=main, prog_node=...)
at link.zig:619
#8 0x000000000985b4cc in Compilation.flush (comp=0x7ffff7fe6c10, arena=..., tid=main,
prog_node=...) at Compilation.zig:2446
#9 0x000000000980acd8 in Compilation.update (comp=0x7ffff7fe6c10, main_progress_node=...)
at Compilation.zig:2396
#10 0x0000000009ffc598 in Compilation.updateSubCompilation (parent_comp=0x7fffeff43770,
sub_comp=0x7ffff7fe6c10, misc_task=compiler_rt) at Compilation.zig:6274
#11 0x000000000a009054 in Compilation.buildOutputFromZig (comp=0x7fffeff43770,
output_mode=<optimized out>, out=0x7fffeff43cf8, misc_task_tag=compiler_rt,
prog_node=...) at Compilation.zig:6413
#12 0x0000000009fceb84 in Compilation.buildRt (comp=0x7fffeff43770, misc_task=compiler_rt,
output_mode=Exe, out=0x0,
prog_node=<error reading variable: Cannot access memory at address 0x0>)
at Compilation.zig:4612
#13 0x0000000009fcea54 in Thread.WaitGroup.spawnManager__anon_193170.Manager.run (
wg_inner=0x7ffffffe66d8, args_inner=...)
at /Users/yxd/playspace/zig-bootstrap/out/host/lib/zig/std/Thread/WaitGroup.zig:62
#14 Thread.callFn__anon_390026 (args=...)
at /Users/yxd/playspace/zig-bootstrap/out/host/lib/zig/std/Thread.zig:409
#15 Thread.PosixThreadImpl.spawn__anon_319169.Instance.entryFn (raw_arg=0x7ffff7fbb800)
at /Users/yxd/playspace/zig-bootstrap/out/host/lib/zig/std/Thread.zig:678
#16 0x000000000a4d3050 in start (p=0x7fffeef378f0)
at /Users/yxd/playspace/zig-bootstrap/out/host/lib/zig/libc/musl/src/thread/pthread_create.c:207
#17 0x00000000095775b4 in __clone ()
at /Users/yxd/playspace/zig-bootstrap/out/host/lib/zig/libc/musl/src/thread/loongarch64/clone.s:27 Looking into this. |
Same as #166 (comment) |
With LLVM 19.1.0rc4 I get this:
|
Managed to bootstrap loongarch64-linux-musl with this patch. However, I'm not familiar with llvm so I'm not sure whether this fix is reasonable. |
…ongarch (#107791) For zig with LLVM 19.1.0rc4, we are seeing the following error when bootstrapping a `loongarch64-linux-musl` target. ziglang/zig-bootstrap#164 (comment) It seems that this issue is caused by `PromoteFloatResult` is not handling FREEZE OP on loongarch. Here is the reproduction of the error: https://godbolt.org/z/PPfvWjjG5 ~~This patch adds the FREEZE OP handling with `PromoteFloatRes_UnaryOp` and adds a test case.~~ This patch changes loongarch's way of floating point promotion to soft promotion to avoid this problem. See: loongarch's handling of `half`: - #93894 - #94456 Also see: other float promotion FREEZE handling - 0019c2f
…ongarch (llvm#107791) For zig with LLVM 19.1.0rc4, we are seeing the following error when bootstrapping a `loongarch64-linux-musl` target. ziglang/zig-bootstrap#164 (comment) It seems that this issue is caused by `PromoteFloatResult` is not handling FREEZE OP on loongarch. Here is the reproduction of the error: https://godbolt.org/z/PPfvWjjG5 ~~This patch adds the FREEZE OP handling with `PromoteFloatRes_UnaryOp` and adds a test case.~~ This patch changes loongarch's way of floating point promotion to soft promotion to avoid this problem. See: loongarch's handling of `half`: - llvm#93894 - llvm#94456 Also see: other float promotion FREEZE handling - llvm@0019c2f (cherry picked from commit 13280d9)
With 1ad232c ✅ We are now able to bootstrap a loongarch64-linux-musl zig. But now it has the following error when running
|
Since we've successfully bootstrapped a Zig compiler for this target, I think any bugs encountered from this point should be filed on ziglang/zig as individual issues. |
…ongarch (llvm#107791) For zig with LLVM 19.1.0rc4, we are seeing the following error when bootstrapping a `loongarch64-linux-musl` target. ziglang/zig-bootstrap#164 (comment) It seems that this issue is caused by `PromoteFloatResult` is not handling FREEZE OP on loongarch. Here is the reproduction of the error: https://godbolt.org/z/PPfvWjjG5 ~~This patch adds the FREEZE OP handling with `PromoteFloatRes_UnaryOp` and adds a test case.~~ This patch changes loongarch's way of floating point promotion to soft promotion to avoid this problem. See: loongarch's handling of `half`: - llvm#93894 - llvm#94456 Also see: other float promotion FREEZE handling - llvm@0019c2f (cherry picked from commit 13280d9)
system:
OS: loongarchlinux
GCC:
The text was updated successfully, but these errors were encountered: