Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Rust fails to compile with LTO
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
strategictraveler
n00b
n00b


Joined: 19 Oct 2024
Posts: 3

PostPosted: Sat Oct 19, 2024 2:38 pm    Post subject: Rust fails to compile with LTO Reply with quote

I Followed the wiki to setup Rust but I kept getting linking errors saying ld didn't recognize output, so I visited the Rust docs. It mentions that LLD has to be used when using -C linker-plugin-lto. So I switched to Clang+LLD, but now I get different errors.

When running
Code:
emerge -avuDNt dev-lang/rust

I get this.

Relevant files in /etc/portage:

    /etc/portage/env/O3.conf
    Code:
    COMMON_FLAGS="${COMMON_FLAGS} -O3"
    CFLAGS="${COMMON_FLAGS}"
    CXXFLAGS="${COMMON_FLAGS}"
    FCFLAGS="${COMMON_FLAGS}"
    FFLAGS="${COMMON_FLAGS}"

    /etc/portage/env/compiler-clang-lto.conf
    Code:
    RUSTFLAGS="-C target-cpu=native -C opt-level=3 -C link-arg=-fuse-ld=lld -C linker-plugin-lto"
    LDFLAGS="${LDFLAGS} -fuse-ld=lld"

    CC="clang"
    CXX="clang++"
    CPP="clang-cpp"
    AR="llvm-ar"
    NM="llvm-nm"
    RANLIB="llvm-ranlib"

    /etc/portage/package.env
    Code:
    sys-devel/gcc O3.conf
    sys-devel/llvm O3.conf
    sys-devel/clang O3.conf
    dev-lang/rust O3.conf compiler-clang-lto.conf



emerge --info:
Code:
Portage 3.0.65 (python 3.12.6-final-0, default/linux/amd64/23.0/hardened/systemd, gcc-13, glibc-2.39-r6, 6.11.2-1.qubes.fc37.x86_64 x86_64)
=================================================================
                         System Settings
=================================================================
System uname: Linux-6.11.2-1.qubes.fc37.x86_64-x86_64-Intel-R-_Core-TM-_i7-4610M_CPU_@_3.00GHz-with-glibc2.39
KiB Mem:     2771056 total,    124640 free
KiB Swap:    1048572 total,    999164 free
Timestamp of repository gentoo: Fri, 18 Oct 2024 10:48:30 +0000
Head commit of repository gentoo: 53922cbd7f64efee5c3bdeeaaab18a69f5dec1bb

Head commit of repository qubes: 548943d662b8ee97f64de7f0c60da92444b131d6

sh bash 5.2_p37
ld GNU ld (Gentoo 2.42 p6) 2.42.0
app-misc/pax-utils:        1.3.7::gentoo
app-shells/bash:           5.2_p37::gentoo
dev-build/autoconf:        2.71-r7::gentoo
dev-build/automake:        1.16.5-r2::gentoo
dev-build/cmake:           3.30.2::gentoo
dev-build/libtool:         2.4.7-r4::gentoo
dev-build/make:            4.4.1-r1::gentoo
dev-build/meson:           1.5.1::gentoo
dev-lang/perl:             5.40.0::gentoo
dev-lang/python:           3.12.6_p4::gentoo
dev-lang/rust-bin:         1.81.0::gentoo
sys-apps/baselayout:       2.15::gentoo
sys-apps/sandbox:          2.39::gentoo
sys-apps/systemd:          255.11::gentoo
sys-devel/binutils:        2.42-r2::gentoo
sys-devel/binutils-config: 5.5.2::gentoo
sys-devel/clang:           18.1.8::gentoo
sys-devel/gcc:             13.3.1_p20240614::gentoo
sys-devel/gcc-config:      2.11::gentoo
sys-devel/lld:             18.1.8::gentoo
sys-devel/llvm:            18.1.8-r1::gentoo
sys-kernel/linux-headers:  6.1::gentoo (virtual/os-headers)
sys-libs/glibc:            2.39-r6::gentoo
Repositories:

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

qubes
    location: /var/db/repos/qubes
    sync-openpgp-key-refresh: no
    sync-type: git
    sync-uri: https://github.com/fepitre/qubes-gentoo.git
    masters: gentoo
    volatile: False
    sync-git-verify-commit-signature: true
    sync-git-clone-extra-opts: --branch release4.2

Binary Repositories:

gentoobinhost
    priority: 1
    sync-uri: https://distfiles.gentoo.org/releases/amd64/binpackages/23.0/x86-64

ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="@FREE"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=native -O2 -pipe -flto -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing"
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"
CXXFLAGS="-march=native -O2 -pipe -flto -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing"
DISTDIR="/var/cache/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="-march=native -O2 -pipe -flto -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs binpkg-multi-instance buildpkg-live 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 sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-march=native -O2 -pipe -flto -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing"
GENTOO_MIRRORS="http://distfiles.gentoo.org"
LANG="C.UTF8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,-z,pack-relative-relocs"
LEX="flex"
MAKEOPTS="-j4 -l5"
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"
SHELL="/bin/bash"
USE="acl amd64 bzip2 cet crypt gdbm hardened iconv ipv6 libtirpc lto man multilib ncurses nocd openmp pam pcre pgo pic pie readline seccomp ssl ssp systemd test-rust udev unicode xattr xtpax zlib" ABI_X86="64" ADA_TARGET="gcc_12" 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" CPU_FLAGS_X86="mmx mmxext sse sse2 aes avx avx2 f16c fma3 pclmul popcnt rdrand sse3 sse4_1 sse4_2 ssse3" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock greis isync itrax mtk3301 ntrip 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="dummy lavapipe swrast zink" 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, EMERGE_DEFAULT_OPTS, 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, SIZE, STRINGS, STRIP, YACC, YFLAGS


emerge -pqv:
Code:
[ebuild  N    ] dev-lang/rust-1.81.0  USE="lto rust-analyzer rust-src rustfmt (-big-endian) -clippy -debug -dist -doc (-llvm-libunwind) (-miri) (-nightly) (-parallel-compiler) -profiler (-system-bootstrap) (-system-llvm) -test -verify-sig -wasm" ABI_X86="(64) -32 (-x32)" CPU_FLAGS_X86="sse2" 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"
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 9824
Location: almost Mile High in the USA

PostPosted: Sun Oct 20, 2024 1:01 am    Post subject: Reply with quote

You probably ran out of RAM. You'll need to add swap and probably also reduce your -j jobs. On 64-bit this should finish, but slowly... Or just use rust-bin.

32-bit, it could fail and we don't have a solution yet.
_________________
Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum