Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 851732 - dev-lang/zig failed to test in riscv
Summary: dev-lang/zig failed to test in riscv
Status: CONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: riscv Linux
: Normal normal
Assignee: Eric Joldasov
URL:
Whiteboard:
Keywords: PullRequest
Depends on:
Blocks: 796596
  Show dependency tree
 
Reported: 2022-06-13 15:39 UTC by ArchFeh(Yu Gu)
Modified: 2025-03-08 12:35 UTC (History)
5 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
build log (build.log,166.99 KB, text/x-log)
2022-06-13 15:43 UTC, ArchFeh(Yu Gu)
Details
environment (environment,98.18 KB, text/plain)
2022-06-13 15:44 UTC, ArchFeh(Yu Gu)
Details
build log without use test (build.log,165.14 KB, text/x-log)
2022-06-13 16:04 UTC, ArchFeh(Yu Gu)
Details
zig-0.10.0 build log (build.log,242.30 KB, text/x-log)
2022-12-03 00:03 UTC, ArchFeh(Yu Gu)
Details
zig-0.10.0 environment (environment,102.17 KB, text/plain)
2022-12-03 00:03 UTC, ArchFeh(Yu Gu)
Details
patch in case github is unavailable (13498.patch,11.15 KB, patch)
2022-12-04 08:41 UTC, Eric Joldasov
Details | Diff
build log with patch (build.log,527.33 KB, text/x-log)
2022-12-05 02:43 UTC, ArchFeh(Yu Gu)
Details
0.14.0 build log (build.log,38.44 KB, text/x-log)
2025-03-07 00:58 UTC, Jakov Smolić
Details
0.14.0 build log (build.log,44.76 KB, text/x-log)
2025-03-08 12:35 UTC, Jakov Smolić
Details

Note You need to log in before you can comment on or make changes to this bug.
Description ArchFeh(Yu Gu) 2022-06-13 15:39:08 UTC
dev-lang/zig-0.9.1 segmentation fault in test phase in riscv.
Comment 1 ArchFeh(Yu Gu) 2022-06-13 15:43:49 UTC
Created attachment 784643 [details]
build log
Comment 2 ArchFeh(Yu Gu) 2022-06-13 15:44:07 UTC
Created attachment 784646 [details]
environment
Comment 3 ArchFeh(Yu Gu) 2022-06-13 16:04:30 UTC
Created attachment 784649 [details]
build log without use test
Comment 4 Eric Joldasov 2022-07-16 16:24:47 UTC
Upstream bug https://github.com/ziglang/zig/issues/11918 , upstream fix https://github.com/ziglang/zig/pull/11951
Comment 5 Larry the Git Cow gentoo-dev 2022-08-22 08:18:06 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=d005e3b069726d01579b86d32f6fe32c26573aa3

commit d005e3b069726d01579b86d32f6fe32c26573aa3
Author:     Eric Joldasov <bratishkaerik@getgoogleoff.me>
AuthorDate: 2022-07-26 21:25:12 +0000
Commit:     Jakov Smolić <jsmolic@gentoo.org>
CommitDate: 2022-08-22 08:16:08 +0000

    dev-lang/zig: block dev-lang/zig-bin, add risv stage0 patch for 0.9.1
    
    Bug: https://bugs.gentoo.org/851732
    Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
    Signed-off-by: Jakov Smolić <jsmolic@gentoo.org>

 dev-lang/zig/files/zig-0.9.1-fix-riscv.patch | 47 ++++++++++++++++++++++++++++
 dev-lang/zig/zig-0.9.1.ebuild                | 26 +++++++--------
 2 files changed, 59 insertions(+), 14 deletions(-)
Comment 6 Eric Joldasov 2022-12-01 14:21:53 UTC
Can you please retry with 0.10.0 release? Thank you
Comment 7 ArchFeh(Yu Gu) 2022-12-02 04:48:57 UTC
(In reply to Eric Joldasov from comment #6)
> Can you please retry with 0.10.0 release? Thank you

Yes I am testing it!
Comment 8 ArchFeh(Yu Gu) 2022-12-03 00:03:32 UTC
Created attachment 839197 [details]
zig-0.10.0 build log

zig-0.10.0 compile failed. zig-bin-0.10.0 installed successfully but has runtime error "[1]    107570 segmentation fault (core dumped)  zig"
Comment 9 ArchFeh(Yu Gu) 2022-12-03 00:03:57 UTC
Created attachment 839199 [details]
zig-0.10.0 environment
Comment 10 Eric Joldasov 2022-12-04 08:31:00 UTC
Looks like it tries to use bundled source of libc++, even without `-Duse-zig-libcxx` (so equal to false). I'll try to make patch and send it to upstream.
Comment 11 Eric Joldasov 2022-12-04 08:40:53 UTC
Found out that pull request for this already exist!
https://github.com/ziglang/zig/pull/13498

> This change also adds logic to look-up the system libc++ includes on Linux and BSD-likes.
> This was needed to fix a bug on Linux where we were using Zig-provided libc++ includes even when linking against the system-provided lib.

Would you like to try it? Thank you!
https://patch-diff.githubusercontent.com/raw/ziglang/zig/pull/13498.patch
Comment 12 Eric Joldasov 2022-12-04 08:41:48 UTC
Created attachment 839579 [details, diff]
patch in case github is unavailable
Comment 13 ArchFeh(Yu Gu) 2022-12-04 08:51:13 UTC
(In reply to Eric Joldasov from comment #11)
> Found out that pull request for this already exist!
> https://github.com/ziglang/zig/pull/13498
> 
> > This change also adds logic to look-up the system libc++ includes on Linux and BSD-likes.
> > This was needed to fix a bug on Linux where we were using Zig-provided libc++ includes even when linking against the system-provided lib.
> 
> Would you like to try it? Thank you!
> https://patch-diff.githubusercontent.com/raw/ziglang/zig/pull/13498.patch

yep gonna try it later today!
Comment 14 ArchFeh(Yu Gu) 2022-12-05 02:43:47 UTC
Created attachment 840177 [details]
build log with patch

compile passed, but test failed. run '$ zig' show 
"/usr/bin/zig: error while loading shared libraries: cpp.so.15: cannot open shared object file: No such file or directory"
Comment 15 Eric Joldasov 2022-12-18 12:15:06 UTC
Fixing can take a long time, so I'll just wait until my VisionFive 2 arrives :)
Comment 16 Eric Joldasov 2023-01-09 14:27:58 UTC
*** Bug 890234 has been marked as a duplicate of this bug. ***
Comment 17 Eric Joldasov 2024-12-21 14:57:10 UTC
Can you test with `dev-lang/zig-0.13.0-r2` please? Thanks!
Comment 18 Jakov Smolić archtester gentoo-dev 2024-12-29 17:40:58 UTC
(In reply to Eric Joldasov from comment #17)
> Can you test with `dev-lang/zig-0.13.0-r2` please? Thanks!

Initially there's an error reported in https://github.com/ziglang/zig/issues/21740 and with the fix from https://github.com/ziglang/zig/pull/21474 applied I'm now hitting a new one, apparently the build system is misdetecting or trying to build for the wrong ABI, so need to investigate why that happens here

```
info: truncate /var/tmp/portage/dev-lang/zig-0.13.0-r2/work/zig-0.13.0_build/stage3/lib/zig/compiler_rt/negvsi2_test.zig
install
└─ install zig
   └─ zig build-exe zig ReleaseFast native-native 1 errors
error: sub-compilation of libunwind failed
    /usr/include/gnu/stubs.h:14:11: note: 'gnu/stubs-lp64.h' file not found
# include <gnu/stubs-lp64.h>
          ^~~~~~~~~~~~~~~~~~~
```
Comment 19 Eric Joldasov 2025-03-05 19:08:22 UTC
> apparently the build system is misdetecting or trying to build for the wrong
> ABI, so need to investigate why that happens here

Can you please re-check with 0.14.0? Upstream states a lot of fixes went in this release cycle for risc-v targets.

Preferably with full log, so that we can see (if it fails) whether it's a bug in zig or in eclass target/cpu translation or something else.
Comment 20 Jakov Smolić archtester gentoo-dev 2025-03-07 00:58:22 UTC
Created attachment 920317 [details]
0.14.0 build log
Comment 21 Jakov Smolić archtester gentoo-dev 2025-03-07 00:58:41 UTC
(In reply to Eric Joldasov from comment #19)
> > apparently the build system is misdetecting or trying to build for the wrong
> > ABI, so need to investigate why that happens here
> 
> Can you please re-check with 0.14.0? Upstream states a lot of fixes went in
> this release cycle for risc-v targets.
> 
> Preferably with full log, so that we can see (if it fails) whether it's a
> bug in zig or in eclass target/cpu translation or something else.

It's same error as 0.13.0-r2
Comment 22 Eric Joldasov 2025-03-07 05:19:59 UTC
(In reply to Jakov Smolić from comment #21)
> It's same error as 0.13.0-r2

Thanks, can you also send "emerge --info" and "ls /usr/include/gnu/" please? Right now it seems like misdetection in eclass cpu translation
Comment 23 Jakov Smolić archtester gentoo-dev 2025-03-07 11:43:22 UTC
riscv-testing ~ # ls -l /usr/include/gnu/
total 20
-rw-r--r-- 1 root root 1451 Jan 25 01:17 lib-names-lp64d.h
-rw-r--r-- 1 root root  657 Jan 25 01:16 lib-names.h
-rw-r--r-- 1 root root 1264 Jan 25 01:16 libc-version.h
-rw-r--r-- 1 root root  715 Jan 25 01:17 stubs-lp64d.h
-rw-r--r-- 1 root root  569 Jan 25 01:16 stubs.h

# emerge --info
Portage 3.0.67 (python 3.12.9-final-0, default/linux/riscv/23.0/rv64/lp64d/systemd, gcc-14, glibc-2.40-r8, 6.1.31 riscv64)
=================================================================
System uname: Linux-6.1.31-riscv64-with-glibc2.40
KiB Mem:   131976904 total, 126699104 free
KiB Swap:          0 total,         0 free
sh bash 5.2_p37
ld GNU ld (Gentoo 2.44 p1) 2.44.0
app-misc/pax-utils:        1.3.8::gentoo
app-shells/bash:           5.2_p37::gentoo
dev-build/autoconf:        2.72-r1::gentoo
dev-build/automake:        1.17-r1::gentoo
dev-build/cmake:           3.31.6::gentoo
dev-build/libtool:         2.5.4::gentoo
dev-build/make:            4.4.1-r100::gentoo
dev-build/meson:           1.7.0::gentoo
dev-lang/perl:             5.40.0-r1::gentoo
dev-lang/python:           3.12.9::gentoo, 3.13.2::gentoo
dev-lang/rust-bin:         1.85.0-r1::gentoo
llvm-core/clang:           19.1.7::gentoo, 20.1.0-r1::gentoo
llvm-core/lld:             19.1.7::gentoo
llvm-core/llvm:            19.1.7::gentoo, 20.1.0::gentoo
sys-apps/baselayout:       2.17::gentoo
sys-apps/sandbox:          2.43::gentoo
sys-apps/systemd:          257.2::gentoo
sys-devel/binutils:        2.44::gentoo
sys-devel/binutils-config: 5.5.2::gentoo
sys-devel/gcc:             14.2.1_p20241221::gentoo
sys-devel/gcc-config:      2.12.1::gentoo
sys-kernel/linux-headers:  6.13::gentoo (virtual/os-headers)
sys-libs/glibc:            2.40-r8::gentoo
Repositories:

gentoo
    location: /var/db/repos/gentoo
    sync-type: rsync
    sync-uri: rsync://rsync.gentoo.org/gentoo-portage
    priority: -1000
    volatile: True
    sync-rsync-verify-jobs: 1
    sync-rsync-verify-max-age: 3
    sync-rsync-verify-metamanifest: yes
    sync-rsync-extra-opts:

Binary Repositories:

gentoobinhost
    priority: 1
    sync-uri: https://distfiles.gentoo.org/releases/riscv/binpackages/23.0/rv64_lp64d

ACCEPT_KEYWORDS="riscv ~riscv"
ACCEPT_LICENSE="@FREE"
CBUILD="riscv64-unknown-linux-gnu"
CFLAGS="-O2 -pipe"
CHOST="riscv64-unknown-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c"
CXXFLAGS="-O2 -pipe"
DISTDIR="/var/cache/distfiles"
EMERGE_DEFAULT_OPTS="--jobs=5"
ENV_UNSET="CARGO_HOME DBUS_SESSION_BUS_ADDRESS DISPLAY GDK_PIXBUF_MODULE_FILE GOBIN GOPATH PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR XDG_STATE_HOME"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs binpkg-multi-instance buildpkg-live config-protect-if-modified distlocks ebuild-locks fixlafiles merge-sync merge-wait multilib-strict news parallel-fetch pkgdir-index-trusted preserve-libs protect-owned qa-unresolved-soname-deps sandbox strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="http://distfiles.gentoo.org"
LANG="C.UTF8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
LEX="flex"
MAKEOPTS="-j32 -l32"
PKGDIR="/var/cache/binpkgs"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"
PORTAGE_TMPDIR="/var/tmp"
USE="acl bzip2 crypt gdbm iconv ipv6 ncurses nls openmp pam pcre readline riscv seccomp ssl systemd test-rust udev unicode xattr zlib" ADA_TARGET="gcc_14" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_anon authn_dbm authn_file authz_dbm authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir env expires ext_filter file_cache filter headers include info log_config logio mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="karbon sheets words" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock greis isync itrax navcom oceanserver oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 tsip tripmate tnt ublox" GUILE_SINGLE_TARGET="3-0" GUILE_TARGETS="3-0" INPUT_DEVICES="libinput" KERNEL="linux" LCD_DEVICES="bayrad cfontz glk hd44780 lb216 lcdm001 mtxorb text" LUA_SINGLE_TARGET="lua5-1" LUA_TARGETS="lua5-1" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php8-2" POSTGRES_TARGETS="postgres16" PYTHON_SINGLE_TARGET="python3_12" PYTHON_TARGETS="python3_12" RUBY_TARGETS="ruby32" VIDEO_CARDS="fbdev" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipp2p iface geoip fuzzy condition tarpit sysrq proto logmark ipmark dhcpmac delude chaos account"
Unset:  ADDR2LINE, AR, ARFLAGS, AS, ASFLAGS, CC, CCLD, CONFIG_SHELL, CPP, CPPFLAGS, CTARGET, CXX, CXXFILT, ELFEDIT, EXTRA_ECONF, F77FLAGS, FC, GCOV, GPROF, INSTALL_MASK, LC_ALL, LD, LFLAGS, LIBTOOL, LINGUAS, MAKE, MAKEFLAGS, NM, OBJCOPY, OBJDUMP, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, PYTHONPATH, RANLIB, READELF, RUSTFLAGS, SHELL, SIZE, STRINGS, STRIP, YACC, YFLAGS
Comment 24 Eric Joldasov 2025-03-07 14:58:06 UTC
I see, does setting ZIG_CPU="generic_rv64+i+m+a+f+d+zicsr+zifencei+c+d" in make.conf helps?
Comment 25 Jakov Smolić archtester gentoo-dev 2025-03-08 12:31:04 UTC
(In reply to Eric Joldasov from comment #24)
> I see, does setting ZIG_CPU="generic_rv64+i+m+a+f+d+zicsr+zifencei+c+d" in
> make.conf helps?

Yeah, that does the trick, it does install fine, did some quick runtime tests, it's able to compile and run code with no issues. There was an error in the test phase but the build didn't error out so that should be fixed as well, I'll upload the build log in a second
Comment 26 Jakov Smolić archtester gentoo-dev 2025-03-08 12:35:22 UTC
Created attachment 920355 [details]
0.14.0 build log