Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 667020 - sys-devel/gcc-config deletes libunwind.so from sys-libs/libunwind when /lib and /usr/lib are merged
Summary: sys-devel/gcc-config deletes libunwind.so from sys-libs/libunwind when /lib a...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All All
: Normal normal (vote)
Assignee: Gentoo Toolchain Maintainers
URL:
Whiteboard:
Keywords: PATCH
Depends on: 699900
Blocks: usrmerge, usrmerge-fixes
  Show dependency tree
 
Reported: 2018-09-25 06:28 UTC by Dennis Schridde
Modified: 2019-12-08 22:38 UTC (History)
3 users (show)

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


Attachments
build.log.xz (build.log.xz,42.92 KB, application/x-xz)
2018-09-25 06:28 UTC, Dennis Schridde
Details
gcc-config-2.0-handle-usrmerge.patch (gcc-config-2.0-handle-usrmerge.patch,1.29 KB, patch)
2018-12-02 18:08 UTC, Dennis Schridde
Details | Diff
gcc-config-2.0-handle-usrmerge.patch (gcc-config-2.0-handle-usrmerge.patch,1.31 KB, patch)
2018-12-02 18:11 UTC, Dennis Schridde
Details | Diff
Patch for gcc-config.git (gcc-config.patch,2.74 KB, patch)
2019-08-31 08:46 UTC, Arfrever Frehtes Taifersar Arahesis
Details | Diff
Patch for gentoo.git (sys-libs/libunwind) (libunwind.patch,4.92 KB, patch)
2019-08-31 08:47 UTC, Arfrever Frehtes Taifersar Arahesis
Details | Diff
Patch implementing short term solution (gcc-config.patch,2.26 KB, patch)
2019-09-04 19:40 UTC, Arfrever Frehtes Taifersar Arahesis
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dennis Schridde 2018-09-25 06:28:27 UTC
My /usr/lib/libunwind.so disappears regularly:
1. packages fail to compile
2. I notice the file is gone
3. I rebuild sys-libs/libunwind
4. packages compile again

I somehow suspect this is related to me having USE=-split-usr, but I cannot confirm that.  I further suspect that portage or some package portage builds (ebuild or eclass) somehow is responsible for "cleaning up" /usr/lib, but I also cannot confirm that.

No other libraries but /usr/lib/libunwind.so appear to be affected.

This manifests for many packages.  In the case of mesa, it tries to link against the static archive instead.  Other packages often already fail in the configure phase or refuse to link -lunwind at all.


Portage 2.3.50 (python 2.7.13-final-42, default/linux/amd64/17.1/desktop/plasma/systemd, gcc-8.2.0, glibc-2.27-r6, 4.18.9-gentoo x86_64)
=================================================================
                         System Settings
=================================================================
System uname: Linux-4.18.9-gentoo-x86_64-AMD_Ryzen_5_2400G_with_Radeon_Vega_Graphics-with-gentoo-2.6
KiB Mem:    15258704 total,   2768684 free
KiB Swap:          0 total,         0 free
Timestamp of repository gentoo: Tue, 25 Sep 2018 05:15:01 +0000
Head commit of repository gentoo: 68b81dd9bc9dee70f036ed2f9598a73d8a6be704
Head commit of repository flatpak-overlay: 1d9243e2689d727ceb87bf7c58cce68547fe0da4

Timestamp of repository gnome: Sun, 23 Sep 2018 15:03:52 +0000
Head commit of repository gnome: 5a337fe7cf37494b44e3407d249def99ce0be328

Timestamp of repository steam-overlay: Sat, 22 Sep 2018 08:03:49 +0000
Head commit of repository steam-overlay: 45a9ad9cd82cde3fcf181bfdf69bfbb249b64d95

Head commit of repository local: ae7f28842c857f668262e8b223213099b7158cff

sh bash 4.4_p23
ld GNU ld (Gentoo 2.31.1 p3) 2.31.1
ccache version 3.4.3 [disabled]
app-shells/bash:          4.4_p23::gentoo
dev-java/java-config:     2.2.0-r4::gentoo
dev-lang/perl:            5.26.2::gentoo
dev-lang/python:          2.7.15::gentoo, 3.6.6::gentoo, 3.7.0::gentoo
dev-util/ccache:          3.4.3::gentoo
dev-util/cmake:           3.12.2::gentoo
dev-util/pkgconfig:       0.29.2::gentoo
sys-apps/baselayout:      2.6-r1::gentoo
sys-apps/sandbox:         2.13::gentoo
sys-devel/autoconf:       2.13::gentoo, 2.69-r4::gentoo
sys-devel/automake:       1.11.6-r3::gentoo, 1.13.4-r2::gentoo, 1.15.1-r2::gentoo, 1.16.1-r1::gentoo
sys-devel/binutils:       2.31.1-r1::gentoo
sys-devel/gcc:            8.2.0-r3::gentoo
sys-devel/gcc-config:     2.0::gentoo
sys-devel/libtool:        2.4.6-r5::gentoo
sys-devel/make:           4.2.1-r4::gentoo
sys-kernel/linux-headers: 4.17::gentoo (virtual/os-headers)
sys-libs/glibc:           2.27-r6::gentoo
Repositories:

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

flatpak-overlay
    location: /var/db/repos/flatpak-overlay
    sync-type: git
    sync-uri: https://github.com/fosero/flatpak-overlay.git
    masters: gentoo

gnome
    location: /var/db/repos/gnome
    sync-type: git
    sync-uri: https://github.com/gentoo-mirror/gnome.git
    masters: gentoo

steam-overlay
    location: /var/db/repos/steam-overlay
    sync-type: git
    sync-uri: https://github.com/gentoo-mirror/steam-overlay.git
    masters: gentoo

local
    location: /var/cache/portage/local
    sync-type: git
    sync-uri: https://github.com/devurandom/gentoo-overlay.git
    masters: gentoo gnome
    priority: 1000

ACCEPT_KEYWORDS="amd64 ~amd64"
ACCEPT_LICENSE="* -@EULA"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-pipe -O2 -march=znver1"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /etc/grs/systems.conf /usr/lib64/libreoffice/program/sofficerc /usr/share/config /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/php/apache2-php7.2/ext-active/ /etc/php/cgi-php7.2/ext-active/ /etc/php/cli-php7.2/ext-active/ /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c"
CXXFLAGS="-pipe -O2 -march=znver1"
DISTDIR="/var/cache/portage/distfiles"
EMERGE_DEFAULT_OPTS="--keep-going --nospinner --verbose-conflicts"
ENV_UNSET="DBUS_SESSION_BUS_ADDRESS DISPLAY 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-logs buildsyspkg cgroup compressdebug config-protect-if-modified distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync multilib-strict network-sandbox news parallel-fetch parallel-install preserve-libs protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="http://ftp.spline.inf.fu-berlin.de/mirrors/gentoo/ http://ftp-stud.hs-esslingen.de/pub/Mirrors/gentoo/ http://distfiles.gentoo.org"
LANG="en_GB.UTF-8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,--hash-style=gnu"
MAKEOPTS="-j6 -l4"
PKGDIR="/var/cache/portage/packages"
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="/tmp"
USE="X a52 aac aacplus aacs acl acpi activities aio alsa amd64 appindicator appstream archive audit avahi ayatana bash-completion bdplus berkdb bluetooth bluray branding bs2b btrfs bzip2 cairo caps cdda cddb cdio cdr celt chromaprint cjk clang cli colord colorio conntrack crypt cups cxx d3d9 dbus declarative device-mapper dirac djvu dri drm dts dvb dvd dvdr editorconfig egl elf emboss encode epub exif fam fax fbcon ffmpeg fftw firefox firewalld fish-completion fits flac fontconfig fontforge fortran fribidi gbm gdbm geoclue geolocation gif git glamor gles gmp google googledrive gpg gps graphicsmagick gstreamer gtk gtk3 harfbuzz hdf5 http2 ibus iconv icu idn imlib inotify introspection ipv6 jemalloc jpeg jpeg2k json kde kipi kms kwallet ladspa latex lcms ldap libatomic libidn2 libinput libnotify libproxy libsecret libsoxr libtirpc libvirt lm_sensors lv2 lvm lz4 lzma lzo mad markdown mbim mercurial metis mjpeg mng mobi modemmanager modplug modules mp3 mp4 mpeg mplayer mpris mtp multilib mysql ncurses netlink networkmanager nls nptl office ogg openal opencl opencv openexr opengl openh264 openmax openmp opus pam pango pcap pch pcre pcre2 pdf pgo phonon pixman plasma png policykit postscript ppds prison pulseaudio python qml qt5 raw readline redfish samba sasl scanner schroedinger sctp sdl sdl2 seccomp semantic-desktop share snappy sparse speech speex spell ssl startup-notification steamruntime stemmer svg systemd tbb tcpd teamd telepathy tga theora threads tiff timezone truetype tslib udev udisks unicode unwind upnp upnp-av upower usb utempter v4l v4l2 vaapi vkd3d vorbis vpx vulkan wasm wavpack wayland webchannel webengine webp widgets wmf wps x264 x265 xattr xcb xcomposite xinerama xkb xml xmp xrandr xscreensaver xv xvid xwayland xz yaml zeroconf zeromq zlib zstd" ABI_X86="64" ALSA_CARDS="hda-intel" 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 plan sheets stage words" CAMERAS="ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="aes avx avx2 f16c fma3 mmx mmxext pclmul popcnt sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3" ELIBC="glibc" ENLIGHTENMENT_MODULES="*" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" GRUB_PLATFORMS="efi-64" INPUT_DEVICES="joystick libinput" KERNEL="linux" L10N="de de-DE en en-GB ar fa tr ja ko zh zh-CN zh-TW" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LIRC_DEVICES="devinput" LLVM_TARGETS="AMDGPU BPF" LUA_TARGET="lua5-2" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-6 php7-0" POSTGRES_TARGETS="postgres9_5 postgres10" PYTHON_SINGLE_TARGET="python3_6" PYTHON_TARGETS="python2_7 python3_6 pypy pypy3" QEMU_SOFTMMU_TARGETS="riscv32 riscv64 x86_64" QEMU_USER_TARGETS="riscv32 riscv64" RUBY_TARGETS="ruby23" STEAMGAMES="dirt_rally dont_starve portal source_engine te120 trine2 witcher2" USERLAND="GNU" VIDEO_CARDS="amdgpu virgl" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq 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

=================================================================
                        Package Settings
=================================================================

sys-libs/libunwind-1.2.1-r2::gentoo was built with the following:
USE="libatomic lzma static-libs -debug -debug-frame -doc" ABI_X86="32 (64) (-x32)"


media-libs/mesa-18.2.0-r1::gentoo was built with the following:
USE="d3d9 dri3 egl gallium gbm gles2 llvm lm_sensors opencl osmesa unwind vaapi vulkan wayland -classic -debug -gles1 -pax_kernel -pic (-selinux) -test -valgrind -vdpau -xa -xvmc" ABI_X86="32 (64) (-x32)" VIDEO_CARDS="radeonsi virgl (-freedreno) -i915 -i965 (-imx) -intel -nouveau -r100 -r200 -r300 -r600 -radeon (-vc4) (-vivante) -vmware"
CFLAGS="-pipe -O2 -march=znver1 -g"
CXXFLAGS="-pipe -O2 -march=znver1 -g"


sys-apps/baselayout-2.6-r1::gentoo was built with the following:
USE="-build -split-usr" ABI_X86="(64)"


sys-apps/coreutils-8.30::gentoo was built with the following:
USE="acl caps gmp nls xattr -hostname -kill -multicall (-selinux) -split-usr -static -test -vanilla" ABI_X86="(64)"


sys-apps/systemd-239-r1::gentoo was built with the following:
USE="acl audit elfutils gcrypt gnuefi idn kmod libidn2 lz4 lzma pam pcre (policykit) resolvconf seccomp ssl sysv-utils xkb -apparmor -build -cryptsetup -curl -http -importd -nat -qrcode (-selinux) -split-usr -test -vanilla" ABI_X86="32 (64) (-x32)"
CFLAGS="-pipe -O2 -march=znver1 -g"
CXXFLAGS="-pipe -O2 -march=znver1 -g"
Comment 1 Dennis Schridde 2018-09-25 06:28:54 UTC
Created attachment 547854 [details]
build.log.xz
Comment 2 Dennis Schridde 2018-09-25 06:31:10 UTC
Another candidate to blame might be the default/linux/amd64/17.1 profile, which changed library paths.  Just the same as for the other suspicions though: I cannot confirm that, either.
Comment 3 Alexander Tsoy 2018-09-25 17:34:28 UTC
> I somehow suspect this is related to me having USE=-split-usr
If your /{lib,lib64} are symlinks to /usr/{lib,lib64} and you don't have separate /usr partition, then this might be a gcc-config bug:

    # If /usr isn't a sep mount, then don't bother with linking stuff.
    if ln "${ROOT}/${LDPATH}/libgcc.a" "${ROOT}"/lib/.gcc.config.$$ 2>/dev/null ; then
        rm -f "${ROOT}"/lib/.gcc.config.$$
        if [[ -n $(find "${ROOT}"/lib*/lib{gcc_s,unwind}.so* 2>/dev/null) ]] ; then
            # If we previously had stuff in /, make sure ldconfig gets re-run.
            rm -f "${ROOT}"/lib*/lib{gcc_s,unwind}.so*
            return 1
        fi
        return 0
    fi
Comment 4 Dennis Schridde 2018-09-25 20:34:30 UTC
(In reply to Alexander Tsoy from comment #3)
> > I somehow suspect this is related to me having USE=-split-usr
> If your /{lib,lib64} are symlinks to /usr/{lib,lib64} and you don't have
> separate /usr partition, then this might be a gcc-config bug:

/usr is on the same partition as /, but in a different subvolume:

/dev/bcache0 on / type btrfs (rw,nodev,noatime,compress=zstd,ssd,space_cache,subvolid=257,subvol=/@gentoo)
/dev/bcache0 on /usr type btrfs (rw,nodev,noatime,compress=zstd,ssd,space_cache,subvolid=1659,subvol=/@gentoo-usr)
Comment 5 Alexander Tsoy 2018-09-25 20:41:34 UTC
(In reply to Dennis Schridde from comment #4)
> /usr is on the same partition as /, but in a different subvolume:
So.. is it possible to create hardlink on a different subvolume? Relevant line from the code snippet in my previous comment:

> if ln "${ROOT}/${LDPATH}/libgcc.a" "${ROOT}"/lib/.gcc.config.$$ 2>/dev/null ...
Comment 6 Alexander Tsoy 2018-09-25 20:58:22 UTC
(In reply to Alexander Tsoy from comment #5)
> So.. is it possible to create hardlink on a different subvolume?
Nevermind. Looks like hard links across subvolumes are not allowed.
Comment 7 Dennis Schridde 2018-12-02 18:08:42 UTC
Created attachment 556956 [details, diff]
gcc-config-2.0-handle-usrmerge.patch

(In reply to Alexander Tsoy from comment #3)
> > I somehow suspect this is related to me having USE=-split-usr
> If your /{lib,lib64} are symlinks to /usr/{lib,lib64} and you don't have
> separate /usr partition, then this might be a gcc-config bug:
> 
>     # If /usr isn't a sep mount, then don't bother with linking stuff.
>     if ln "${ROOT}/${LDPATH}/libgcc.a" "${ROOT}"/lib/.gcc.config.$$
> 2>/dev/null ; then
>         rm -f "${ROOT}"/lib/.gcc.config.$$
>         if [[ -n $(find "${ROOT}"/lib*/lib{gcc_s,unwind}.so* 2>/dev/null) ]]
> ; then
>             # If we previously had stuff in /, make sure ldconfig gets
> re-run.
>             rm -f "${ROOT}"/lib*/lib{gcc_s,unwind}.so*
>             return 1
>         fi
>         return 0
>     fi

We are on the right track:

# gcc-config -l
 [1] riscv64-unknown-elf-7.2.0 *

 [2] x86_64-pc-linux-gnu-8.2.0 *

# ll /usr/lib64/libunwind.so*
lrwxrwxrwx 1 root root    18 Dec  2 17:24 /usr/lib64/libunwind.so -> libunwind.so.8.0.1
lrwxrwxrwx 1 root root    18 Dec  2 17:24 /usr/lib64/libunwind.so.8 -> libunwind.so.8.0.1
-rwxr-xr-x 1 root root 59520 Dec  2 17:24 /usr/lib64/libunwind.so.8.0.1

# gcc-config -f 1
 * Switching cross-compiler to riscv64-unknown-elf-7.2.0 ...
>>> Regenerating /etc/ld.so.cache...                                                                                                                                                                                                                                                                                                                                  [ ok ]

# ll /usr/lib64/libunwind.so*
lrwxrwxrwx 1 root root    18 Dec  2 17:24 /usr/lib64/libunwind.so -> libunwind.so.8.0.1
lrwxrwxrwx 1 root root    18 Dec  2 17:24 /usr/lib64/libunwind.so.8 -> libunwind.so.8.0.1
-rwxr-xr-x 1 root root 59520 Dec  2 17:24 /usr/lib64/libunwind.so.8.0.1

# gcc-config -f 2
 * Switching native-compiler to x86_64-pc-linux-gnu-8.2.0 ...
>>> Regenerating /etc/ld.so.cache...                                                                                                                                                                                                                                                                                                                                  [ ok ]

 * If you intend to use the gcc from the new profile in an already
 * running shell, please remember to do:

 *   . /etc/profile

# ll /usr/lib64/libunwind.so*
ls: cannot access '/usr/lib64/libunwind.so*': No such file or directory


I enabled tracing in gcc-config (`set -x`) and found this in the logs:

+ handle_split_usr
+ local LDPATH  
++ grep -h '^LDPATH=' /etc/env.d/gcc/x86_64-pc-linux-gnu-8.2.0
++ tail -1
+ eval 'LDPATH="/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0:/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/32"'
++ LDPATH=/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0:/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/32
+ LDPATH=/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0
+ ln ///usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/libgcc.a //lib/.gcc.config.20775
+ rm -f //lib/.gcc.config.20775
++ find '//lib*/libgcc_s.so*' '//lib*/libgcc_s*dylib' //lib64/libunwind.so //lib64/libunwind.so.8 //lib64/libunwind.so.8.0.1 //lib/libunwind.so //lib/libunwind.so.8 //lib/libunwind.so.8.0.1 '//lib*/libunwind*dylib'
+ [[ -n //lib64/libunwind.so
//lib64/libunwind.so.8
//lib64/libunwind.so.8.0.1
//lib/libunwind.so
//lib/libunwind.so.8
//lib/libunwind.so.8.0.1 ]]
+ rm -f '//lib*/libgcc_s.so*' '//lib*/libgcc_s*dylib' //lib64/libunwind.so //lib64/libunwind.so.8 //lib64/libunwind.so.8.0.1 //lib/libunwind.so //lib/libunwind.so.8 //lib/libunwind.so.8.0.1 '//lib*/libunwind*dylib'
+ return 1


(In reply to Alexander Tsoy from comment #6)
> (In reply to Alexander Tsoy from comment #5)
> > So.. is it possible to create hardlink on a different subvolume?
> Nevermind. Looks like hard links across subvolumes are not allowed.

While this may be correct, it does not apply here. In my case /usr/lib/ and /lib/ are on the same subvolume (even though /usr/lib and /lib are not!).


Attached patch is my attempt to fix this and works for me.
Comment 8 Dennis Schridde 2018-12-02 18:11:44 UTC
Created attachment 556958 [details, diff]
gcc-config-2.0-handle-usrmerge.patch

Improved commit message and comments
Comment 9 Alexander Tsoy 2019-07-20 15:37:44 UTC
Please fix summary of the bug. This should also block bug #690294
Comment 10 Matthias Maier gentoo-dev 2019-07-20 17:07:55 UTC
Confirming. This bug had been a constant companion for the last 2(?) years.
Comment 11 Dennis Schridde 2019-07-21 11:03:10 UTC
(In reply to Alexander Tsoy from comment #9)
> Please fix summary of the bug. This should also block bug #690294

What is wrong with the summary?
Comment 12 Alexander Tsoy 2019-07-21 16:01:38 UTC
(In reply to Dennis Schridde from comment #11)
> What is wrong with the summary?
This is a bug in sys-devel/gcc-config, so it should be in summary. I tried to find this bug recently and that took me some time. :) Also baselayout and profile are unrelated to this bug imo.
Comment 13 Alexander Tsoy 2019-07-21 17:30:33 UTC
@toolchain, gcc-config tries to copy libunwind.so* from gcc's LDPATH. This was introduced in [1] (before sys-libs/libunwind was added to the tree). Is this still needed for some arches and/or gcc versions? Maybe the code that handles libunwind.so should be completely removed from gcc-config?

[1] https://gitweb.gentoo.org/proj/gcc-config.git/commit/?id=b3ff223fe02bfb4e04c730564f3c3f33565e07b7
Comment 14 Sergei Trofimovich (RETIRED) gentoo-dev 2019-07-21 19:22:40 UTC
(In reply to Alexander Tsoy from comment #13)
> @toolchain, gcc-config tries to copy libunwind.so* from gcc's LDPATH. This
> was introduced in [1] (before sys-libs/libunwind was added to the tree). Is
> this still needed for some arches and/or gcc versions? Maybe the code that
> handles libunwind.so should be completely removed from gcc-config?
> 
> [1]
> https://gitweb.gentoo.org/proj/gcc-config.git/commit/
> ?id=b3ff223fe02bfb4e04c730564f3c3f33565e07b7

I think it's still needed for arches with complex exception unwinder like ia64. There libunwind gets linked into many binaries by default. AFAIU libgcc_s is in the same boat and it's more widespread.
Comment 15 Arfrever Frehtes Taifersar Arahesis 2019-08-30 08:37:38 UTC
The patch from comment #8 looks generally good.
[ ] should be [[ ]].
Both checks (for Prefix and the new proposed one) could be moved to the beginning of handle_split_usr() function.


(In reply to Sergei Trofimovich from comment #14)
> I think it's still needed for arches with complex exception unwinder like
> ia64. There libunwind gets linked into many binaries by default. AFAIU
> libgcc_s is in the same boat and it's more widespread.

While the code for libgcc_s.so might need to remain in gcc-config, the simpler solution for libunwind.so is to change sys-libs/libunwind to install all shared libraries to /lib instead of /usr/lib.
Comment 16 Arfrever Frehtes Taifersar Arahesis 2019-08-31 08:15:04 UTC
(In reply to Arfrever Frehtes Taifersar Arahesis from comment #15)
> The patch from comment #8 looks generally good.

Actually not.
Comparing /lib and /usr/lib is a bad idea.
Even when /lib and /usr/lib are the same directory, /usr/lib/gcc could be on a separate filesystem, in which case gcc-config should still create /lib/libgcc_s.so.*.
Comment 17 Arfrever Frehtes Taifersar Arahesis 2019-08-31 08:46:31 UTC
Created attachment 588574 [details, diff]
Patch for gcc-config.git
Comment 18 Arfrever Frehtes Taifersar Arahesis 2019-08-31 08:47:32 UTC
Created attachment 588576 [details, diff]
Patch for gentoo.git (sys-libs/libunwind)
Comment 19 Arfrever Frehtes Taifersar Arahesis 2019-09-01 05:29:24 UTC
Comment on attachment 588576 [details, diff]
Patch for gentoo.git (sys-libs/libunwind)

Patch obsolete in favor of new patches for bug #693250 and bug #693252.
Comment 20 Sergei Trofimovich (RETIRED) gentoo-dev 2019-09-02 07:28:46 UTC
stop handling of libunwind (at least on ia64) in gcc-config might be good enough solution but we have too many moving parts at the same time:
1. gcc-config should stop fiddlind with /lib/libunwind.so*
2. while sys-libs/libunwind moves into /lib
3. while gcc starts linking to /lib's libunwind

Updating in wrong order will render system unusable for user.

While the problem to solve here is somewhat straightforward: stop overriding /usr/lib/libunwind.so when /lib and /usr/lib are the same thing (or always).

I think we should fix one thing at a time to be able to roll back safely if problems arise.

Thus I suggest fixing gcc-config first and see if we can tweak the rest as a cleanup (if possible). To recap: what gcc-config does here is it preserves a copy of libgcc_s and it's dependencies somewhere in /lib for the case when /usr/lib is not available yet. It copies those to /lib assuming ldconfig finds it there.

I suggest:
change gcc-config's location for libgcc_s copy to be a standalone directory, say
    LDPATH=/lib/libgcc_s-backup
and dump files there. That should allows us to release gcc-config separately and check if it works.
Comment 21 Arfrever Frehtes Taifersar Arahesis 2019-09-02 20:06:47 UTC
(In reply to Sergei Trofimovich from comment #20)

Currently gcc-config (only on IA64) creates /lib/libunwind.so.7 (which can be also /usr/lib/libunwind.so.7 when /lib and /usr/lib are merged), but does not create /lib/libunwind.so

Notice .so.* instead of .so* in this line:
https://gitweb.gentoo.org/proj/gcc-config.git/tree/gcc-config?id=9b907ef80bc421df23515afc4c306e4d96c67649#n320

>=sys-libs/libunwind-1.0.1 installs:
 /usr/lib/libunwind.so (which can be also /lib/libunwind.so)
 /usr/lib/libunwind.so.8 (which can be also /lib/libunwind.so.8)
 /usr/lib/libunwind.so.8.0.1 (or 8.0.0 in older version) (which can be also /lib/libunwind.so.8.0.1)

gcc-config firstly deletes all libunwind.so* which matches libraries coming from both sys-devel/gcc and sys-libs/libunwind:
https://gitweb.gentoo.org/proj/gcc-config.git/tree/gcc-config?id=9b907ef80bc421df23515afc4c306e4d96c67649#n303

Until final solution is hopefully accepted, the simpler workaround is to change gcc-config to delete only libunwind.so.7* WITHOUT libunwind.so and libunwind.so.8.
Comment 22 Larry the Git Cow gentoo-dev 2019-09-04 19:00:12 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/gcc-config.git/commit/?id=17c4c852f979668387b1b965d48470cb730df5b6

commit 17c4c852f979668387b1b965d48470cb730df5b6
Author:     Sergei Trofimovich <slyfox@gentoo.org>
AuthorDate: 2019-09-04 18:59:31 +0000
Commit:     Sergei Trofimovich <slyfox@gentoo.org>
CommitDate: 2019-09-04 18:59:31 +0000

    gcc-config: clarify why libunwind.so* is needed at all
    
    Bug: https://bugs.gentoo.org/667020
    Bug: https://bugs.gentoo.org/693252
    Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>

 gcc-config | 5 +++++
 1 file changed, 5 insertions(+)

https://gitweb.gentoo.org/proj/gcc-config.git/commit/?id=f4139631463fe56aebf3c04a44f8691ccd044c01

commit f4139631463fe56aebf3c04a44f8691ccd044c01
Author:     Sergei Trofimovich <slyfox@gentoo.org>
AuthorDate: 2019-09-04 18:53:38 +0000
Commit:     Sergei Trofimovich <slyfox@gentoo.org>
CommitDate: 2019-09-04 18:53:38 +0000

    gcc-config: don't perform a cleanup for prefix systems
    
    Patch by [Arfrever]. No changes in actual handling of
    /lib*/ file on non-prefix systems yet.
    
    Bug: https://bugs.gentoo.org/667020
    Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>

 gcc-config | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
Comment 23 Arfrever Frehtes Taifersar Arahesis 2019-09-04 19:40:44 UTC
Created attachment 589056 [details, diff]
Patch implementing short term solution
Comment 24 Larry the Git Cow gentoo-dev 2019-09-05 06:28:40 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/gcc-config.git/commit/?id=ff954c6b20686d490d1382f90d2a4d64754bb18e

commit ff954c6b20686d490d1382f90d2a4d64754bb18e
Author:     Arfrever Frehtes Taifersar Arahesis <Arfrever@Apache.Org>
AuthorDate: 2019-09-04 19:29:58 +0000
Commit:     Sergei Trofimovich <slyfox@gentoo.org>
CommitDate: 2019-09-05 06:28:11 +0000

    gcc-config: During initial clean-up, delete only libunwind.so.7*, but not other files matching libunwind.so*.
    
    libunwind.so belongs to sys-libs/libunwind.
    libunwind.so.7* is copied by gcc-config (only on ia64) from active version of sys-devel/gcc.
    libunwind.so.8* belong to sys-libs/libunwind since 1.0.1 version released on 2011-09-11.
    
    [slyfox@: sumplified 'return' statement]
    Bug: https://bugs.gentoo.org/667020
    Signed-off-by: Arfrever Frehtes Taifersar Arahesis <Arfrever@Apache.Org>

 gcc-config | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)
Comment 25 Sergei Trofimovich (RETIRED) gentoo-dev 2019-09-07 21:39:18 UTC
(In reply to Sergei Trofimovich from comment #20)
> stop handling of libunwind (at least on ia64) in gcc-config might be good
> enough solution but we have too many moving parts at the same time:
> 1. gcc-config should stop fiddlind with /lib/libunwind.so*
> 2. while sys-libs/libunwind moves into /lib
> 3. while gcc starts linking to /lib's libunwind
> 
> Updating in wrong order will render system unusable for user.
> 
> While the problem to solve here is somewhat straightforward: stop overriding
> /usr/lib/libunwind.so when /lib and /usr/lib are the same thing (or always).
> 
> I think we should fix one thing at a time to be able to roll back safely if
> problems arise.
> 
> Thus I suggest fixing gcc-config first and see if we can tweak the rest as a
> cleanup (if possible). To recap: what gcc-config does here is it preserves a
> copy of libgcc_s and it's dependencies somewhere in /lib for the case when
> /usr/lib is not available yet. It copies those to /lib assuming ldconfig
> finds it there.
> 
> I suggest:
> change gcc-config's location for libgcc_s copy to be a standalone directory,
> say
>     LDPATH=/lib/libgcc_s-backup
> and dump files there. That should allows us to release gcc-config separately
> and check if it works.

Implemented LDPATH backup as:

    https://gitweb.gentoo.org/proj/gcc-config.git/commit/?id=44570a44be60a8fc33bd05089047c1f2980b3047

Will add a bit of verbosity around copying backup libraries and will cut a gcc-config-2.1. For now gcc-config-9999 should be in a good shape to test the changes.
Comment 26 Larry the Git Cow gentoo-dev 2019-09-07 22:47:07 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/gcc-config.git/commit/?id=04d7a13d933a0fb7266df332ddaa2a2d1141d7be

commit 04d7a13d933a0fb7266df332ddaa2a2d1141d7be
Author:     Sergei Trofimovich <slyfox@gentoo.org>
AuthorDate: 2019-09-07 22:44:34 +0000
Commit:     Sergei Trofimovich <slyfox@gentoo.org>
CommitDate: 2019-09-07 22:44:34 +0000

    Revert "gcc-config: store gcc backup into /lib/gcc-backup, not /lib"
    
    This reverts commit 44570a44be60a8fc33bd05089047c1f2980b3047.
    
    Unfortunately ld.so does has static set of fallback paths
    when it fails to lookup shared library from ld.so.cache:
    those are /lib64 and /usr/lib64 on amd64.
    
    Let's revert the change and jkeep relying on /lib64 for now.
    
    Bug: https://bugs.gentoo.org/667020
    Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>

 Makefile          | 22 +++-------------------
 envd-gcc-backup   |  3 ---
 gcc-backup/README | 41 -----------------------------------------
 gcc-config        | 18 +-----------------
 4 files changed, 4 insertions(+), 80 deletions(-)
Comment 27 Larry the Git Cow gentoo-dev 2019-09-08 09:15:15 UTC
The bug has been referenced in the following commit(s):

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

commit cc51dde0d07754dd5ce1155424d730274372739f
Author:     Sergei Trofimovich <slyfox@gentoo.org>
AuthorDate: 2019-09-08 09:13:26 +0000
Commit:     Sergei Trofimovich <slyfox@gentoo.org>
CommitDate: 2019-09-08 09:15:09 +0000

    sys-devel/gcc-config: bump up to 2.1
    
    - Don't cleanup /lib/libunwind.so (bug #667020)
    - Drop GCC_PATH reconstruction (bug #174422)
    - Use findmnt for mountpoint check when available (bug #693588)
    - drop /etc/env.d/gcc/.NATIVE symlink
    - drop /etc/env.d/gcc/config migration code
    - drop empty /etc/env.d/05gcc-${CTARGET} files
    - add einfo logging around library backup
    
    Bug: https://bugs.gentoo.org/667020
    Bug: https://bugs.gentoo.org/174422
    Bug: https://bugs.gentoo.org/693588
    Package-Manager: Portage-2.3.75, Repoman-2.3.17
    Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>

 sys-devel/gcc-config/Manifest               |  1 +
 sys-devel/gcc-config/gcc-config-2.1.ebuild  | 54 +++++++++++++++++++++++++++++
 sys-devel/gcc-config/gcc-config-9999.ebuild |  4 +--
 3 files changed, 57 insertions(+), 2 deletions(-)
Comment 28 Sergei Trofimovich (RETIRED) gentoo-dev 2019-12-08 22:38:21 UTC
libunwind.so destruction should be sorted out. Longer-term work to move libunwind to /lib is in related tickets.