Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 956021 - dev-lang/rust-1.85.1 make default linker more specific
Summary: dev-lang/rust-1.85.1 make default linker more specific
Status: UNCONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Gentoo Rust Project
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-05-16 10:12 UTC by Esteve Varela Colominas
Modified: 2025-05-16 10:45 UTC (History)
3 users (show)

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 Esteve Varela Colominas 2025-05-16 10:12:02 UTC
In a recent commit[1], the default linker for rust got reduced from "$(tc-getCC)" to the generic "$CHOST-cc". Since I build rust with CC=$CHOST-clang and USE=lto, any rust program needs to be linked with clang in order to compile. Previously, this worked fine, since the default linker was set appropriately. Now, it only works inside portage as I've set RUSTFLAGS="-Clinker=$CHOST-clang", but whenever I build anything outside of portage, it complains about not being able to interpret the object files.

I think it would be appropriate to use "$CHOST-clang" when tc-is-clang, "$CHOST-gcc" when tc-is-gcc, and only fall back to "$CHOST-cc" when neither is true.

[1]: https://gitweb.gentoo.org/repo/gentoo.git/commit/dev-lang/rust?id=f65ef3fddd9ef9cc3d2d172f6da9a39231b1e2d1

$ emerge --info dev-lang/rust
Portage 3.0.67 (python 3.13.3-final-0, default/linux/amd64/23.0/split-usr/desktop, gcc-14, glibc-2.40-r8, 6.12.25 x86_64)
=================================================================
                         System Settings
=================================================================
System uname: Linux-6.12.25-x86_64-AMD_Ryzen_5_PRO_2500U_w-_Radeon_Vega_Mobile_Gfx-with-glibc2.40
KiB Mem:    23466944 total,    847912 free
KiB Swap:    8388604 total,   6832436 free
Timestamp of repository gentoo: Sun, 04 May 2025 22:00:00 +0000
Head commit of repository gentoo: 7fa6e25b14c5a7c63336b5194c2b57640cc7c24d
Timestamp of repository guru: Sun, 04 May 2025 14:39:22 +0000
Head commit of repository guru: ea6df2f0cbf1716d6ba2b23f6f72ca2d9309bcf3

Timestamp of repository pf4public: Sun, 04 May 2025 14:39:22 +0000
Head commit of repository pf4public: b37e105eefe4ab8d643e04d788268a738f2b5261

Timestamp of repository without-systemd: Wed, 23 Apr 2025 15:38:40 +0000
Head commit of repository without-systemd: bb792e99c5a08ed704b09045583393bad14f0d74

sh dash 0.5.12-r1
ld GNU ld (Gentoo 2.44 p1) 2.44.0
ccache version 4.10.2 [disabled]
app-misc/pax-utils:        1.3.8::gentoo
app-shells/bash:           5.2_p37::gentoo
dev-build/autoconf:        2.13-r8::gentoo, 2.72-r1::gentoo
dev-build/automake:        1.17-r1::gentoo
dev-build/cmake:           3.31.5::gentoo
dev-build/libtool:         2.5.4::gentoo
dev-build/make:            4.4.1-r100::gentoo
dev-build/meson:           1.7.0::gentoo
dev-java/java-config:      2.3.4::gentoo
dev-lang/perl:             5.40.2::gentoo
dev-lang/python:           3.12.10::gentoo, 3.13.3::gentoo
dev-lang/rust:             1.85.1::gentoo
dev-util/ccache:           4.10.2-r1::gentoo
llvm-core/clang:           19.1.7::gentoo
llvm-core/lld:             19.1.7::gentoo
llvm-core/llvm:            19.1.7::gentoo
sys-apps/baselayout:       2.17::gentoo
sys-apps/openrc:           0.62.2::gentoo
sys-apps/sandbox:          2.39::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.12::gentoo (virtual/os-headers)
sys-libs/glibc:            2.40-r8::gentoo
Repositories:

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

localrepo
    location: /usr/local/portage
    masters: gentoo
    priority: -1000
    volatile: True

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

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

without-systemd
    location: /var/db/repos/without-systemd
    sync-type: git
    sync-uri: https://github.com/gentoo-mirror/without-systemd.git
    masters: gentoo
    volatile: False

Installed sets: @group-extdeps, @group-fonts, @group-i3-desktop, @group-sway-desktop, @group-system
ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="@FREE"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-O2 -pipe -O3 -w -march=znver1 -flto -fuse-linker-plugin -flto=4 --param=lto-max-streaming-parallelism=4 -fgraphite-identity -floop-nest-optimize -fdevirtualize-at-ltrans -fipa-pta -fno-semantic-interposition"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/config /usr/share/gnupg/qualified.txt /var/bind"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-O2 -pipe -O3 -w -march=znver1 -flto -fuse-linker-plugin -flto=4 --param=lto-max-streaming-parallelism=4 -fgraphite-identity -floop-nest-optimize -fdevirtualize-at-ltrans -fipa-pta -fno-semantic-interposition"
DISTDIR="/usr/portage/distfiles"
EMERGE_DEFAULT_OPTS="--ask --nospinner --quiet-unmerge-warn --keep-going --usepkg --with-bdeps=y --binpkg-respect-use=n --binpkg-changed-deps=n"
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 -O3 -w -march=znver1 -flto -fuse-linker-plugin -flto=4 --param=lto-max-streaming-parallelism=4 -fgraphite-identity -floop-nest-optimize -fdevirtualize-at-ltrans -fipa-pta -fno-semantic-interposition"
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 merge-wait multilib-strict network-sandbox news parallel-fetch pid-sandbox pkgdir-index-trusted preserve-libs protect-owned qa-unresolved-soname-deps sandbox strict unknown-features-warnunmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2 -pipe -O3 -w -march=znver1 -flto -fuse-linker-plugin -flto=4 --param=lto-max-streaming-parallelism=4 -fgraphite-identity -floop-nest-optimize -fdevirtualize-at-ltrans -fipa-pta -fno-semantic-interposition"
GENTOO_MIRRORS="http://distfiles.gentoo.org"
INSTALL_MASK="/etc/apparmor.d /etc/systemd /lib/systemd /usr/lib/systemd"
LANG="ca_ES.utf8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,-z,pack-relative-relocs"
LEX="flex"
MAKEFLAGS="-j8"
MAKEOPTS="-j4 -l5"
PKGDIR="/usr/portage/packages"
PORTAGE_BZIP2_COMMAND="lbzip2"
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"
RUSTFLAGS="-Copt-level=3 -Ctarget-cpu=znver1 -Clinker-plugin-lto -Clinker=clang -Clink-arg=-fuse-ld=lld"
SHELL="/bin/zsh"
USE="X acl acpi alsa amd64 bzip2 cairo crypt cups dbus dist-kernel dri elogind encode exif flac fontconfig gdbm gif gtk gui iconv icu ipv6 jpeg lcms libnotify libtirpc lto modules-compress mp4 multilib ncurses nls ogg opengl openmp pam pango pcre pdf pgo png policykit ppds qml readline seccomp sound split-usr ssl startup-notification svg test-rust truetype udev udisks unicode upower usb v4l vaapi vim-syntax vorbis vulkan wxwidgets x264 xattr xcb xft xml xv zlib zsh-completion" ABI_X86="64" 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 deflatedir 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 rrdtoolswap syslog" CPU_FLAGS_X86="aes avx avx2 f16c fma3 mmx mmxext pclmul popcnt rdrand sha sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3" 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 synaptics" KERNEL="linux" L10N="ca es-ES es en-GB en-US en"LCD_DEVICES="bayrad cfontz glk hd44780 lb216 lcdm001 mtxorb text" LUA_SINGLE_TARGET="lua5-4"LUA_TARGETS="lua5-4" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php8-2" POSTGRES_TARGETS="postgres17" PYTHON_SINGLE_TARGET="python3_13" PYTHON_TARGETS="python3_13" RUBY_TARGETS="ruby32" VIDEO_CARDS="amdgpu" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipp2piface 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, LC_ALL, LD, LFLAGS, LIBTOOL, LINGUAS, MAKE, NM, OBJCOPY, OBJDUMP, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, PYTHONPATH, RANLIB, READELF, SIZE, STRINGS, STRIP, YACC, YFLAGS

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

dev-lang/rust-1.85.1::gentoo was built with the following:
USE="lto system-llvm (-big-endian) -clippy -debug -dist -doc (-llvm-libunwind) -rust-analyzer -rust-src -rustfmt -test -verify-sig -wasm" ABI_X86="(64) -32 (-x32)" CPU_FLAGS_X86="sse2" LLVM_SLOT="(19)" LLVM_TARGETS="(X86) -AArch64 -AMDGPU -ARC -ARM -AVR -BPF -CSKY -DirectX -Hexagon -Lanai -LoongArch -M68k -MSP430 -Mips -NVPTX -PowerPC -RISCV -SPIRV -Sparc -SystemZ -VE -WebAssembly -XCore -Xtensa"
CFLAGS="-O2 -pipe -O3 -w -march=znver1"
CXXFLAGS="-O2 -pipe -O3 -w -march=znver1"
LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,-z,pack-relative-relocs -fuse-ld=lld"
Comment 1 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2025-05-16 10:13:31 UTC
See the extensive discussion in bug 951740 too. Baking in information from the time dev-lang/rust was built is not ideal.
Comment 2 Esteve Varela Colominas 2025-05-16 10:45:22 UTC
I read the thread and yeah, I understand why it was changed. Unfortunately, the rlib format is something that gets baked into the compiler at build-time, so it only makes sense to make sure a compatible linker is used by default.

This is at least only necessary when USE=lto, and I wonder if it affects USE=-system-llvm. Alternatively, a USE=clang, like in firefox, could be considered?