Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 905898 - llvm-strip ELF files generated by dev-scheme/guile: In procedure bytevector-u8-ref: Argument 2 out of range: ...
Summary: llvm-strip ELF files generated by dev-scheme/guile: In procedure bytevector-u...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Scheme Project
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-05-07 19:56 UTC by Sergei Trofimovich
Modified: 2023-05-16 20:53 UTC (History)
0 users

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sergei Trofimovich 2023-05-07 19:56:31 UTC
Initially observed as a guix build failure against dev-scheme/guile-zlib.

Reproducible: Always

Steps to Reproduce:
The following minimal example from guix should be enough to reproduce the failure using ::gentoo only packages:

1. Use clang-based profile, like default/linux/amd64/17.1/systemd/clang/merged-usr
2. Install dev-scheme/guile-3.0.9 and dev-scheme/guile-zlib
3. Create a test file:

;;; $ cat utils.scm
(define-module (bug utils)
  #:use-module (ice-9 match)
  #:autoload   (zlib) (make-zlib-input-port)
  #:export (decompressed-port))

(define (decompressed-port compression input)
  "Return an input port where INPUT is decompressed according to COMPRESSION,
a symbol such as 'xz."
  (match compression
    ('gzip         (values (make-zlib-input-port input #:format 'gzip)
                           '()))
    (_             (error "unsupported compression scheme" compression))))

4. Trigger the bug:

$ guile --fresh-auto-compile utils.scm
;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
;;;       or pass the --no-auto-compile argument to disable.
;;; compiling utils.scm
;;; WARNING: compilation of utils.scm failed:
;;; In procedure bytevector-u8-ref: Argument 2 out of range: 185581
Actual Results:  
;;; WARNING: compilation of utils.scm failed:
;;; In procedure bytevector-u8-ref: Argument 2 out of range: 185581

Expected Results:  
Compilation should succeed.

For this case it's enough to rebuild dev-scheme/guile-zlib to avoid .go file corruption:

$ FEATURES="nostrip -splitdebug" emerge -1 --quiet dev-scheme/guile-zlib
$ guile --fresh-auto-compile utils.scm
;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
;;;       or pass the --no-auto-compile argument to disable.
;;; compiling /root/guix/z/utils.scm
;;; compiled /root/.cache/guile/ccache/3.0-LE-8-4.6/root/guix/z/utils.scm.go

Note: compilation succeeded
Comment 1 Sergei Trofimovich 2023-05-07 19:57:41 UTC
$ emerge --info
Portage 3.0.47 (python 3.11.3-final-0, default/linux/amd64/17.1/systemd/clang/merged-usr, gcc-12, glibc-2.37-r2, 6.3.1 x86_64)
=================================================================
System uname: Linux-6.3.1-x86_64-AMD_Ryzen_9_5950X_16-Core_Processor-with-glibc2.37
KiB Mem:   131857692 total,  66839176 free
KiB Swap:  197786108 total, 197786108 free
Head commit of repository gentoo: ae8246c2645c785a1040650b3ff67d503cc23376

Head commit of repository nix-guix: 64edf8fe00c3fb3bcfc53aeb9287a4d3fb7cc882

Head commit of repository slyfox: 88e3aa67d93db149312e1387ef5e57a5b0cf05a1

sh bash 5.2_p15-r2
ld GNU ld (Gentoo 2.40 p4) 2.40.0
app-misc/pax-utils:        1.3.7::gentoo
app-shells/bash:           5.2_p15-r2::gentoo
dev-java/java-config:      2.3.1::gentoo
dev-lang/perl:             5.36.1-r1::gentoo
dev-lang/python:           3.10.11::gentoo, 3.11.3::gentoo
dev-lang/rust:             1.69.0-r1::gentoo
dev-util/cmake:            3.26.3::gentoo
dev-util/meson:            1.1.0::gentoo
sys-apps/baselayout:       2.13-r1::gentoo
sys-apps/sandbox:          2.30-r1::gentoo
sys-apps/systemd:          253.4::gentoo
sys-devel/autoconf:        2.71-r6::gentoo
sys-devel/automake:        1.16.5-r1::gentoo
sys-devel/binutils:        2.40-r4::gentoo
sys-devel/binutils-config: 5.5::gentoo
sys-devel/clang:           15.0.7-r1::gentoo, 16.0.3::gentoo
sys-devel/gcc:             12.2.1_p20230304::gentoo, 13.1.0-r1::gentoo
sys-devel/gcc-config:      2.10::gentoo
sys-devel/libtool:         2.4.7-r1::gentoo
sys-devel/lld:             15.0.7::gentoo, 16.0.3::gentoo
sys-devel/llvm:            15.0.7::gentoo, 16.0.3::gentoo
sys-devel/make:            4.4.1::gentoo
sys-kernel/linux-headers:  6.3::gentoo (virtual/os-headers)
sys-libs/glibc:            2.37-r2::gentoo
Repositories:

gentoo
    location: /var/db/repos/gentoo
    sync-type: git
    sync-uri: https://github.com/gentoo/gentoo.git
    priority: -1000
    volatile: False

nix-guix
    location: /var/db/repos/nix-guix
    sync-type: git
    sync-uri: https://github.com/trofi/nix-guix-gentoo.git
    masters: gentoo
    volatile: False

slyfox
    location: /var/db/repos/slyfox
    sync-type: git
    sync-uri: https://github.com/trofi/slyfox-gentoo.git
    masters: gentoo
    volatile: False

ACCEPT_KEYWORDS="amd64 ~amd64"
ACCEPT_LICENSE="@FREE"
ADDR2LINE="llvm-addr2line"
AR="llvm-ar"
AS="clang -c"
CBUILD="x86_64-pc-linux-gnu"
CC="clang"
CFLAGS="-O2 -pipe -fdiagnostics-show-option -frecord-gcc-switches"
CHOST="x86_64-pc-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/sandbox.d"
CPP="clang-cpp"
CXX="clang++"
CXXFLAGS="-O2 -pipe"
DISTDIR="/bound/distfiles"
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 fail-clean fixlafiles ipc-sandbox merge-sync multilib-strict network-sandbox news parallel-fetch pid-sandbox preserve-libs protect-owned qa-unresolved-soname-deps sandbox sfperms 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"
LD="ld.lld"
LDFLAGS="-Wl,-O1 -Wl,--as-needed -fuse-ld=lld -rtlib=compiler-rt -unwindlib=libunwind -Wl,--as-needed  -Wl,--hash-style=gnu"
LEX="flex"
MAKEOPTS="-j17 -l17"
NM="llvm-nm"
OBJCOPY="llvm-objcopy"
OBJDUMP="llvm-objdump"
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="/dev/shm"
RANLIB="llvm-ranlib"
READELF="llvm-readelf"
SHELL="/bin/bash"
STRINGS="llvm-strings"
STRIP="llvm-strip"
USE="acl amd64 bzip2 clang cli crypt dri fortran gdbm iconv ipv6 libglvnd libtirpc llvm-libunwind multilib ncurses nls nptl openmp pam pcre readline seccomp ssl systemd test-rust udev unicode xattr zlib" ABI_X86="64" ADA_TARGET="gnat_2021" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache 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" CPU_FLAGS_X86="mmx mmxext sse sse2" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock greis isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="libinput" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LUA_SINGLE_TARGET="lua5-1" LUA_TARGETS="lua5-1" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php7-4 php8-0" POSTGRES_TARGETS="postgres12 postgres13" PYTHON_SINGLE_TARGET="python3_11" PYTHON_TARGETS="python3_11" RUBY_TARGETS="ruby30" USERLAND="GNU" VIDEO_CARDS="amdgpu fbdev intel nouveau radeon radeonsi vesa dummy v4l" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq proto steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  ARFLAGS, ASFLAGS, CCLD, CONFIG_SHELL, CPPFLAGS, CTARGET, CXXFILT, ELFEDIT, EMERGE_DEFAULT_OPTS, EXTRA_ECONF, F77FLAGS, FC, GCOV, GPROF, INSTALL_MASK, LC_ALL, LFLAGS, LIBTOOL, LINGUAS, MAKE, MAKEFLAGS, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, RUSTFLAGS, SIZE, YACC, YFLAGS
Comment 2 Sergei Trofimovich 2023-05-07 20:42:45 UTC
As a workaround the below seems to be enough to unbreak the example:

# add to dev-scheme/guile-zlib
src_install() {
       default

       # Workaround llvm-strip problem of mangling guile ELF debug
       # sections: https://bugs.gentoo.org/905898
       dostrip -x "/usr/$(get_libdir)/guile"
}

For real `guix` package I had to add the workaround to at least 3 packages: dev-scheme/guile-zlib, dev-scheme/guile-zstd, dev-scheme/guile-lzlib. Otherwise the build fails.
Comment 3 Larry the Git Cow gentoo-dev 2023-05-16 11:50:46 UTC
The bug has been referenced in the following commit(s):

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

commit 3a1364a6a38575dea322388e778a20d2d008f7db
Author:     Maciej Barć <xgqt@gentoo.org>
AuthorDate: 2023-05-16 11:46:01 +0000
Commit:     Maciej Barć <xgqt@gentoo.org>
CommitDate: 2023-05-16 11:50:43 +0000

    dev-scheme/guile-lzlib: do not strip guile bytecode
    
    Bug: https://bugs.gentoo.org/905898
    Signed-off-by: Maciej Barć <xgqt@gentoo.org>

 ...guile-lzlib-0.0.2.ebuild => guile-lzlib-0.0.2-r1.ebuild} | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

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

commit 30fe460e5275811feac4ac68c024c1e4ba1cae54
Author:     Maciej Barć <xgqt@gentoo.org>
AuthorDate: 2023-05-16 11:43:57 +0000
Commit:     Maciej Barć <xgqt@gentoo.org>
CommitDate: 2023-05-16 11:50:43 +0000

    dev-scheme/guile-zlib: do not strip guile bytecode
    
    Bug: https://bugs.gentoo.org/905898
    Signed-off-by: Maciej Barć <xgqt@gentoo.org>

 .../{guile-zlib-0.1.0.ebuild => guile-zlib-0.1.0-r1.ebuild}    | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

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

commit 4171bfcb004899aa0e96aad951f19a13f1d325c3
Author:     Maciej Barć <xgqt@gentoo.org>
AuthorDate: 2023-05-16 11:42:05 +0000
Commit:     Maciej Barć <xgqt@gentoo.org>
CommitDate: 2023-05-16 11:50:43 +0000

    dev-scheme/guile-zstd: do not strip guile bytecode
    
    Bug: https://bugs.gentoo.org/905898
    Signed-off-by: Maciej Barć <xgqt@gentoo.org>

 .../{guile-zstd-0.1.1.ebuild => guile-zstd-0.1.1-r1.ebuild} | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

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

commit 7e3b8ea2dbbeffdb67ab6b029d2d7349e059d4e4
Author:     Maciej Barć <xgqt@gentoo.org>
AuthorDate: 2023-05-16 11:34:53 +0000
Commit:     Maciej Barć <xgqt@gentoo.org>
CommitDate: 2023-05-16 11:50:43 +0000

    dev-scheme: use dostrip instead of RESTRICT
    
    Bug: https://bugs.gentoo.org/905898
    Signed-off-by: Maciej Barć <xgqt@gentoo.org>

 dev-scheme/akku/akku-1.1.0.ebuild                         | 13 +++++++++++--
 dev-scheme/bytestructures/bytestructures-1.0.10.ebuild    | 12 +++++++++---
 dev-scheme/bytestructures/bytestructures-2.0.1.ebuild     | 11 +++++++++--
 dev-scheme/fibers/fibers-1.2.0.ebuild                     |  7 +++++--
 dev-scheme/guile-config/guile-config-0.5.1.ebuild         | 11 +++++++++--
 .../guile-dbd-postgresql-2.1.8.ebuild                     |  7 +++++--
 .../guile-dbd-sqlite3/guile-dbd-sqlite3-2.1.8.ebuild      |  7 +++++--
 dev-scheme/guile-dbi/guile-dbi-2.1.8.ebuild               |  7 +++++--
 dev-scheme/guile-gcrypt/guile-gcrypt-0.3.0.ebuild         | 12 +++++++++---
 dev-scheme/guile-gcrypt/guile-gcrypt-0.4.0.ebuild         | 12 +++++++++---
 dev-scheme/guile-gi/guile-gi-0.3.1-r2.ebuild              |  8 ++++++--
 dev-scheme/guile-gi/guile-gi-0.3.2-r2.ebuild              |  7 +++++--
 dev-scheme/guile-gi/guile-gi-9999.ebuild                  |  7 +++++--
 dev-scheme/guile-git/guile-git-0.5.2.ebuild               | 12 ++++++++++--
 dev-scheme/guile-gnutls/guile-gnutls-3.7.11-r1.ebuild     |  5 ++++-
 dev-scheme/guile-hall/guile-hall-0.4.1.ebuild             | 11 +++++++++--
 dev-scheme/guile-json/guile-json-4.7.3.ebuild             | 11 +++++++++--
 dev-scheme/guile-lib/guile-lib-0.2.7.ebuild               | 11 +++++++++--
 dev-scheme/guile-libyaml/guile-libyaml-20211124.ebuild    |  5 ++++-
 dev-scheme/guile-ncurses/guile-ncurses-3.0-r3.ebuild      |  7 +++++--
 dev-scheme/guile-ncurses/guile-ncurses-3.1.ebuild         |  5 ++++-
 dev-scheme/guile-nyacc/guile-nyacc-1.06.7.ebuild          |  7 +++++--
 dev-scheme/guile-reader/guile-reader-0.6.3-r2.ebuild      |  7 +++++--
 dev-scheme/guile-sqlite3/guile-sqlite3-0.1.3.ebuild       | 15 +++++++++++----
 dev-scheme/guile-ssh/guile-ssh-0.16.0-r1.ebuild           |  5 ++++-
 dev-scheme/guile-ssh/guile-ssh-0.16.2.ebuild              |  5 ++++-
 dev-scheme/guile-ssh/guile-ssh-0.16.3.ebuild              |  5 ++++-
 dev-scheme/skribilo/skribilo-0.10.0.ebuild                |  6 +++++-
 dev-scheme/skribilo/skribilo-0.9.5.ebuild                 |  8 ++++++--
 29 files changed, 190 insertions(+), 56 deletions(-)
Comment 4 Sergei Trofimovich 2023-05-16 12:32:20 UTC
I also suggest applying strip workaround to dev-scheme/guile as well: without it guix builds fine, but fails at runtime. With the workaround it seems to work as expected.

--- guile-3.0.9.ebuild  2023-02-08 23:28:23.373959421 +0000
+++ guile-3.0.9-r1.ebuild       2023-05-08 08:10:05.349714530 +0100
@@ -78,4 +82,8 @@
        keepdir /usr/share/guile/site

        find "${ED}" -name '*.la' -delete || die
+
+       # Workaround llvm-strip problem of mangling guile ELF debug
+       # sections: https://bugs.gentoo.org/905898
+       dostrip -x "/usr/$(get_libdir)/guile"
 }
Comment 5 Maciej Barć gentoo-dev 2023-05-16 14:57:45 UTC
Sergei, 3.0.9 already restricts stripping...?
Comment 6 Sergei Trofimovich 2023-05-16 20:50:02 UTC
I re-tested on a fresh system and indeed dev-scheme/guile does not need any extra fixes. Individual packages were enough. Thank you!
Comment 7 Maciej Barć gentoo-dev 2023-05-16 20:53:29 UTC
Thanks a lot for reporting this Sergei, `dev-scheme/guile` should use the new `dostrip -x` approach in new versions. It would just be surprising if it had been broken...