Skip to content

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

Closed

Description

@wrongnull

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

Activity

  1. added
    bug
    on Feb 27, 2024
  2. slonik-az commented on Feb 27, 2024

    @slonik-az

    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?

  3. kassane commented on Feb 27, 2024

    @kassane
    Contributor

    possible fix:

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

  4. RossComputerGuy commented on Feb 27, 2024

    @RossComputerGuy
    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.

  5. nektro commented on Feb 27, 2024

    @nektro
    Contributor

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

  6. wrongnull commented on Feb 27, 2024

    @wrongnull
    ContributorAuthor

    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.

  7. RossComputerGuy commented on Feb 27, 2024

    @RossComputerGuy
    Contributor

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

  8. added this to the 0.14.0 milestone on Aug 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    arch-riscv64bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions