-
-
Notifications
You must be signed in to change notification settings - Fork 92
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-gnu #166
Comments
loongarch64 support was added in glibc 2.36 |
Those error indicate missing loongarch-specific logic in the zig standard library. |
system: OS: loongarchlinux Kernel:
GCC:
binutils: 2.41-3 glibc:
With this patch, the error log is as follows:
|
system: OS: loongarchlinux Kernel:
clang
glibc
The GCC toolchain provided by the system is not working, tried with llvm and clang. The command to build bootstrap
With the same patch above, it seems that it is possible to compile zig2 successfully but failed in stage 3.
|
it seems that zig itself requires However, loongarch64 does not have Maybe we should add a translation layer for |
is there a specific reason for this or is it because its simply not implemented yet in the kernel since loongarch64 is such a relatively new architecture? |
Check the syscalls here. It seems that it is not implemented in Linux kernel intentionally. And golang has an emulation implementation of |
With current patch, I think I have implemented most of the loongarch64 things needed for zig std lib. The current build command I use:
The current error output:
The backtrace of error above:
The overflow happens on stack element 18 where I guess things like |
This has been fixed. And now the error is zig2 failed to build libunwind.
|
Disabled the macro The next problem is that ld.lld having error doing relocation when linking zig binary. |
Managed to replace |
With the patch now it is possible to build a stage3 zig binary with command
With this stage3 zig binary, there is still some problem:
|
Now have the same issue as |
@yxd-ym so only the LLVM 19 upgrade remains now? |
For successfully bootstraping a loongarch64 zig binary, YES. However, for a workable loongarch64 zig binary, I'm still looking into this problem. It seems that the CPP declaration of this function: ZIG_EXTERN_C bool ZigLLVMTargetMachineEmitToFile(
LLVMTargetMachineRef targ_machine_ref,
LLVMModuleRef module_ref,
char **error_message,
struct ZigLLVMEmitOptions options
); zig binding function: extern fn ZigLLVMTargetMachineEmitToFile(
T: *TargetMachine,
M: *Module,
ErrorMessage: *[*:0]const u8,
options: EmitOptions,
) bool; So I guess this is a struct function parameter passing by value ABI problem? Currently I have no idea how to solve this problem yet. |
I'll try to take a look at this soon. |
It's most likely just down to missing |
With ziglang/zig#21251 we are able to bootstrap a loongarch64 zig to compile hello world c program and zig program. |
Unfortunately I wasn't able to bootstrap zig on my loongarch64 machine (used yxd-ym/zig-boostrap bootstrap-loongarch-2 branch) [user@la64-nb tmp]$ uname -s -r -v -m -o
Linux 6.9.0-loongarch-alt0.4.0.g5aec712dc5f3.0.port #1 SMP PREEMPT_DYNAMIC Mon May 13 10:08:11 UTC 2024 loongarch64 GNU/Linux Bootstrap fails on zig build (after llvm is built). Here is fragment of log: I would like to try mold, but currently no idea how to do it. Any other ideas how to fix it/what problem might be? |
You don't need to run the bootstrap build script on a loongarch64 machine. I recommend using a amd64 or arm64 machine with relatively new gcc/clang (or even zig 0.13) to run the bootstrap script.
This problem should already be fixed in ziglang/zig#21153. So maybe you should try my llvm19-fix-f16 branch that is base on llvm19 branch (which includes the fix) here. |
For some reason on loongarch64 llvm19-fix-f16 gave similar error Now attempting to build on x86_64 machine |
The problem is because we are not customizing the code model of zig2 to be medium in bootstrap script. Also, what is the version of your host's clang? |
[user@la64-nb zig]$ clang++ --version
ALT Linux Team clang version 18.1.8
Target: loongarch64-unknown-linux-gnu
Thread model: posix
Installed dir: /usr/bin So 18.1.8, with no patches |
Good job, it works on LoongArchLinux:
|
Close by #188 |
It seems that the result is the same as #164
I'm working on this patch to try to make it work.
system:
OS: loongarchlinux
GCC:
The text was updated successfully, but these errors were encountered: