Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 812251 - dev-libs/libbsd-0.11.3 does not respect SYSROOT
Summary: dev-libs/libbsd-0.11.3 does not respect SYSROOT
Status: RESOLVED WONTFIX
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: AMD64 Linux
: Normal normal
Assignee: Freedesktop bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-09-09 09:46 UTC by hoelbezier
Modified: 2021-09-10 08:24 UTC (History)
1 user (show)

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


Attachments
`emerge --root=/opt/libbsd-test --sysroot=/opt/libbsd-test dev-libs/libbsd` build.log (build.log,8.86 KB, text/x-log)
2021-09-09 09:46 UTC, hoelbezier
Details

Note You need to log in before you can comment on or make changes to this bug.
Description hoelbezier 2021-09-09 09:46:53 UTC
Created attachment 738514 [details]
`emerge --root=/opt/libbsd-test --sysroot=/opt/libbsd-test dev-libs/libbsd` build.log

Emerging dev-libs/libbsd using --root=/libbsd-test --sysroot=/libbsd-test fails during the configure phase. Turns out libbsd looks for libmd in /usr/lib64 and not in /libbsd-test/usr/lib64.

===== emerge --info =====

Portage 3.0.20 (python 3.9.6-final-0, default/linux/amd64/17.1/no-multilib/hardened, gcc-10.3.0, glibc-2.33-r1, 5.10.62-1-lts x86_64)
=================================================================
                         System Settings
=================================================================
System uname: Linux-5.10.62-1-lts-x86_64-Intel-R-_Core-TM-_i5-8400_CPU_@_2.80GHz-with-glibc2.33
KiB Mem:     8021928 total,   2727004 free
KiB Swap:          0 total,         0 free
Timestamp of repository gentoo: Wed, 08 Sep 2021 12:00:01 +0000
Head commit of repository gentoo: 12018527a21366c2b33923a81f1e108634ac8c5e
sh bash 5.1_p8
ld GNU ld (Gentoo 2.36.1 p5) 2.36.1
app-shells/bash:          5.1_p8::gentoo
dev-lang/perl:            5.34.0::gentoo
dev-lang/python:          3.9.6_p2::gentoo
sys-apps/baselayout:      2.7::gentoo
sys-apps/openrc:          0.43.5::gentoo
sys-apps/sandbox:         2.24::gentoo
sys-devel/autoconf:       2.69-r5::gentoo
sys-devel/automake:       1.16.3-r1::gentoo
sys-devel/binutils:       2.36.1-r2::gentoo
sys-devel/gcc:            10.3.0-r2::gentoo
sys-devel/gcc-config:     2.4::gentoo
sys-devel/libtool:        2.4.6-r6::gentoo
sys-devel/make:           4.3::gentoo
sys-kernel/linux-headers: 5.10::gentoo (virtual/os-headers)
sys-libs/glibc:           2.33-r1::gentoo
Repositories:

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

ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="@FREE"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-O2 -pipe"
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/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-O2 -pipe"
DISTDIR="/var/cache/distfiles"
EMERGE_DEFAULT_OPTS=" --usepkg --binpkg-respect-use=y"
ENV_UNSET="CARGO_HOME DBUS_SESSION_BUS_ADDRESS DISPLAY 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"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs binpkg-multi-instance buildpkg config-protect-if-modified distlocks ebuild-locks 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"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
MAKEOPTS="-j6"
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 amd64 bzip2 crypt hardened iconv ipv6 libglvnd libtirpc ncurses nls nptl openmp pcre pie readline seccomp split-usr ssl ssp unicode xattr xtpax zlib" ABI_X86="64" ADA_TARGET="gnat_2018" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" 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-3 php7-4" POSTGRES_TARGETS="postgres12 postgres13" PYTHON_SINGLE_TARGET="python3_9" PYTHON_TARGETS="python3_9" RUBY_TARGETS="ruby26" 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:  CC, CPPFLAGS, CTARGET, CXX, INSTALL_MASK, LC_ALL, LINGUAS, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, RUSTFLAGS
Comment 1 hoelbezier 2021-09-09 14:37:04 UTC
Setting CFLAGS="${CFLAGS} --sysroot=/libbsd-test" fixes the issue. It would seem autoconf-generated configure scripts are broken in regard to the --with-sysroot option (on which ebuilds rely).
Comment 2 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2021-09-10 01:30:21 UTC
I'm assuming this (https://savannah.gnu.org/support/?110537) is your bug upstream to autoconf? If so, remember to cross-link -- it's really useful.

Thanks for the report(s)!
Comment 3 hoelbezier 2021-09-10 07:13:18 UTC
It’s not, someone else did it. I planned to report upstream this morning. Keeping in mind that I should cross-link issues. :)
Comment 4 James Le Cuirot gentoo-dev 2021-09-10 08:24:05 UTC
autoconf's --with-sysroot only does so much. I think it's mainly used by libtool when relinking. Of course, not everything uses autotools either, and I'm not aware of even CMake or Meson having an equivalent.

I think it was implied that a long time that Gentoo only supported cross-compiling into the /usr/${CHOST} environment set up by crossdev. I recall seeing many reports by users failing to set up environments elsewhere, getting little official help, and trying to fudge in nasty workarounds like -L/libbsd-test/usr/lib64. That didn't get them far.

I think I discovered --sysroot for myself, but I found that inserting it into CFLAGS wasn't that reliable. By far the most reliable method is to set CC="${CHOST}-gcc --sysroot=/libbsd-test" and the same for CXX. This probably works so well because we support multilib by injecting -m32 into CC and CXX.

I have long wondered whether Portage should do this for you, especially since EAPI 7, but I haven't quite convinced myself yet.

In your case, you're not actually cross-compiling. My personal stance is that we shouldn't go out of our way to support the native SYSROOT!=/ case because it's not really feasible. If the build tries to execute something because it's not cross-compiling then it will almost certainly fail due to using libraries from / rather than SYSROOT or ROOT. The best chance of making this work is to force it to think you are cross-compiling, either by building an alternative toolchain like x86_64-cross-linux-gnu, or by forcing the build systems somehow. But what's the point when you may as well chroot instead?