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

Unable to cross-compile riscv64 Hello world program in c under wsl2 #19107

Closed
wrongnull opened this issue Feb 27, 2024 · 6 comments · Fixed by #20909
Closed

Unable to cross-compile riscv64 Hello world program in c under wsl2 #19107

wrongnull opened this issue Feb 27, 2024 · 6 comments · Fixed by #20909
Labels
arch-riscv 32-bit and 64-bit RISC-V bug Observed behavior contradicts documented or intended behavior
Milestone

Comments

@wrongnull
Copy link
Contributor

wrongnull commented Feb 27, 2024

Zig Version

0.12.0-dev.7512+085bde688

Steps to Reproduce and Observed Behavior

wrongnull@DESKTOP-22AKPRT:~$ uname -a
Linux DESKTOP-22AKPRT 5.15.133.1-microsoft-standard-WSL2 #1 SMP Thu Oct 5 21:02:42 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
wrongnull@DESKTOP-22AKPRT:~$ cat test.c
#include <stdio.h>


int main() {
  printf("Hello wrold\n");
}
wrongnull@DESKTOP-22AKPRT:~$ zig cc test.c -target riscv64-linux-gnu
projects/zig/build/stage3/lib/zig/libc/glibc/sysdeps/riscv/start-2.33.S:48:2: error: unknown directive
 .cfi_label .Ldummy
 ^
In file included from test.c:1:
In file included from projects/zig/build/stage3/lib/zig/libc/include/generic-glibc/stdio.h:27:
In file included from projects/zig/build/stage3/lib/zig/libc/include/generic-glibc/bits/libc-header-start.h:33:
In file included from projects/zig/build/stage3/lib/zig/libc/include/generic-glibc/features.h:539:
projects/zig/build/stage3/lib/zig/libc/include/riscv64-linux-gnu/gnu/stubs.h:17:11: fatal error: 'gnu/stubs-lp64d.h' file not found
   17 | # include <gnu/stubs-lp64d.h>
      |           ^~~~~~~~~~~~~~~~~~~

Expected Behavior

Compiles successfully

@wrongnull wrongnull added the bug Observed behavior contradicts documented or intended behavior label Feb 27, 2024
@slonik-az
Copy link

0.12.0-dev.7512+085bde688

WoW: -dev.7512 ? The current nightly build is 0.12.0-dev.3033+031f23117. Where are the extra 4000 commits coming from? What branch are you compiling?

@kassane
Copy link
Contributor

kassane commented Feb 27, 2024

possible fix:

Please, try same test on riscv64-linux-musl, for now.

@RossComputerGuy
Copy link
Contributor

@kassane Yes, that PR does in fact fix this. I've used my PR to produce RISC-V glibc linked binaries. However, I have run into some other unrelated issues with RISC-V due to LLVM.

@nektro
Copy link
Contributor

nektro commented Feb 27, 2024

085bde6 is the most recent as of yesterday @slonik-az, am also surprised at the jump tho

@wrongnull
Copy link
Contributor Author

I rebuilt the compiler just now and current zig version is 0.12.0-dev.7529+bd0dbb0a1
However, the original issue is still stands but fix mentioned above works fine. Thank you @RossComputerGuy
In addition, compiling without glibc works for me.
I think I'll leave this issue open until it's fixed in master.

@RossComputerGuy
Copy link
Contributor

You're welcome, but btw this issue will likely close as this is a duplicate of #3340.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arch-riscv 32-bit and 64-bit RISC-V bug Observed behavior contradicts documented or intended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants