Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 951712 - dev-build/meson: wrongly detects linker as bfd with llvm-core/clang and -fuse-ld=lld in *FLAGS
Summary: dev-build/meson: wrongly detects linker as bfd with llvm-core/clang and -fuse...
Status: UNCONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: AMD64 Linux
: Normal normal
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-03-21 13:34 UTC by Joungmin Lee
Modified: 2025-03-22 13:56 UTC (History)
4 users (show)

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


Attachments
meson-log.txt (meson-log.txt,214.17 KB, text/plain)
2025-03-21 14:39 UTC, zyxhere
Details
build.log (build.log,50.09 KB, text/x-log)
2025-03-21 14:42 UTC, Joungmin Lee
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Joungmin Lee 2025-03-21 13:34:04 UTC
Emerging pipewire-1.4.1 failed with thin-LTO enabled in /etc/portage/make.conf.

I observed that ninja tried to use ld.bfd even though I added '-fuse-ld=lld' into LDFLAGS. It was built without a problem when gcc toolchain was used.

Note that the bug might not be confined to pipewire: similar errors have been observed some other packages using meson/ninja such as zstd.



Reproducible: Always

Steps to Reproduce:
1. Add ~amd64 flag to pipewire
2. Run `emerge -avuDN @world`
Actual Results:  
...

>>> Configuring source in /var/tmp/portage/media-video/pipewire-1.4.1/work/pipewire-1.4.1 ...
 * abi_x86_64.amd64: running multilib-minimal_abi_src_configure
meson setup -Db_lto=true -Db_lto_mode=thin --libdir lib64 --localstatedir /var/lib --prefix /usr --sysconfdir /etc --wrap-mode nodownload --build.pkg-config-path /usr/share/pkgconfig --pkg-config-path /usr/share/pkgconfig --native-file /var/tmp/portage/media-video/pipewire-1.4.1/temp/meson.x86_64-pc-linux-gnu.amd64.ini -Db_pch=false -Dwerror=false -Dbuildtype=plain -Ddocdir=/usr/share/doc/pipewire-1.4.1 -Ddbus=enabled -Davahi=disabled -Ddocs=disabled -Dman=disabled -Dexamples=enabled -Dtests=disabled -Dinstalled_tests=disabled -Dlibffado=disabled -Dgstreamer=disabled -Dgstreamer-device-provider=disabled -Dgsettings=disabled -Dsystemd=disabled -Dlogind=enabled -Dlogind-provider=libelogind -Dsystemd-system-service=disabled -Dsystemd-system-unit-dir=/lib/systemd/system -Dsystemd-user-unit-dir=/usr/lib/systemd/user -Dsystemd-user-service=disabled -Dpipewire-alsa=enabled -Dselinux=disabled -Dspa-plugins=enabled -Dalsa=enabled -Dcompress-offload=disabled -Daudiomixer=enabled -Daudioconvert=enabled -Dbluez5=enabled -Dbluez5-backend-hsp-native=enabled -Dbluez5-backend-hfp-native=enabled -Dbluez5-backend-native-mm=disabled -Dbluez5-backend-ofono=enabled -Dbluez5-backend-hsphfpd=enabled -Dbluez5-codec-aac=enabled -Dbluez5-codec-aptx=enabled -Dbluez5-codec-ldac=enabled -Dbluez5-codec-g722=enabled -Dopus=enabled -Dbluez5-codec-opus=enabled -Dlibusb=enabled -Decho-cancel-webrtc=disabled -Dcontrol=enabled -Daudiotestsrc=enabled -Dffmpeg=disabled -Dpw-cat-ffmpeg=disabled -Dflatpak=disabled -Dpipewire-jack=enabled -Djack=disabled -Djack-devel=true -Dlibjack-path=/usr/lib64 -Dsupport=enabled -Devl=disabled -Dtest=disabled -Dbluez5-codec-lc3plus=disabled -Dbluez5-codec-lc3=disabled -Debur128=disabled -Dlv2=disabled -Dv4l2=enabled -Dlibcamera=disabled -Droc=disabled -Dreadline=enabled -Draop=enabled -Dvideoconvert=enabled -Dvideotestsrc=enabled -Dvolume=enabled -Dvulkan=disabled -Dpw-cat=disabled -Dudev=enabled -Dudevrulesdir=/usr/lib/udev/rules.d -Dsdl2=disabled -Dlibmysofa=disabled -Dsndfile=disabled -Dsession-managers=[] -Dpam-defaults-install=true -Dx11=enabled -Dx11-xfixes=enabled -Dlibcanberra=enabled -Dsnap=disabled -Dgsettings-pulse-schema=disabled /var/tmp/portage/media-video/pipewire-1.4.1/work/pipewire-1.4.1 /var/tmp/portage/media-video/pipewire-1.4.1/work/pipewire-1.4.1-abi_x86_64.amd64
The Meson build system
Version: 1.7.0
Source dir: /var/tmp/portage/media-video/pipewire-1.4.1/work/pipewire-1.4.1
Build dir: /var/tmp/portage/media-video/pipewire-1.4.1/work/pipewire-1.4.1-abi_x86_64.amd64
Build type: native build
Project name: pipewire
Project version: 1.4.1
C compiler for the host machine: clang (clang 19.1.7 "clang version 19.1.7")
C linker for the host machine: clang ld.lld 19.1.7

...

Found ninja-1.12.1 at /usr/bin/ninja

ERROR: LLVM's ThinLTO only works with gold, lld, lld-link, ld64 or mold, not ld.bfd

A full log can be found at /var/tmp/portage/media-video/pipewire-1.4.1/work/pipewire-1.4.1-abi_x86_64.amd64/meson-logs/meson-log.txt



Portage 3.0.67 (python 3.12.9-final-0, default/linux/amd64/23.0/desktop/plasma, gcc-14, glibc-2.41-r1, 6.13.6-gentoo x86_64)
=================================================================
System uname: Linux-6.13.6-gentoo-x86_64-AMD_Ryzen_7_9700X_8-Core_Processor-with-glibc2.41
KiB Mem:    48375788 total,  39988024 free
KiB Swap:   32767996 total,  32767996 free
Timestamp of repository gentoo: Fri, 21 Mar 2025 11:45:00 +0000
Head commit of repository gentoo: 09e62af1564b77db9951ac837376abd89ccd4436
Timestamp of repository guru: Thu, 20 Mar 2025 11:33:31 +0000
Head commit of repository guru: bba937232305c649e1daef0bd83d17259d6ce297

sh bash 5.2_p37
ld GNU ld (Gentoo 2.44 p1) 2.44.0
app-misc/pax-utils:        1.3.8::gentoo
app-shells/bash:           5.2_p37::gentoo
dev-build/autoconf:        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.0-r1::gentoo
dev-lang/python:           3.12.9::gentoo, 3.13.2::gentoo
dev-lang/rust:             1.85.1::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.56::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.13::gentoo (virtual/os-headers)
sys-libs/glibc:            2.41-r1::gentoo
Repositories:

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

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

local
    location: /var/db/repos/local
    masters: gentoo
    volatile: False

Binary Repositories:

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

ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="*"
AR="llvm-ar"
CBUILD="x86_64-pc-linux-gnu"
CC="clang"
CFLAGS="-march=x86-64-v4 -mtune=znver4 -O2 -pipe -flto=thin"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /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/revdep-rebuild /etc/sandbox.d"
CPP="clang-cpp"
CXX="clang++"
CXXFLAGS="-march=x86-64-v4 -mtune=znver4 -O2 -pipe -flto=thin"
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=x86-64-v4 -mtune=znver4 -O2 -pipe"
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 strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-march=x86-64-v4 -mtune=znver4 -O2 -pipe"
GENTOO_MIRRORS="rsync://ftp.iij.ad.jp/pub/linux/gentoo/     http://ftp.iij.ad.jp/pub/linux/gentoo/     ftp://ftp.iij.ad.jp/pub/linux/gentoo/     https://ftp.jaist.ac.jp/pub/Linux/Gentoo/     http://ftp.jaist.ac.jp/pub/Linux/Gentoo/     ftp://ftp.jaist.ac.jp/pub/Linux/Gentoo/     rsync://ftp.jaist.ac.jp/pub/Linux/Gentoo/     https://ftp.lanet.kr/pub/gentoo/"
LANG="en_US.UTF-8"
LDFLAGS="-fuse-ld=lld -Wl,-O2 -Wl,--sort-common -Wl,--as-needed -Wl,-z,pack-relative-relocs"
LEX="flex"
MAKEOPTS="-j8"
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="/var/tmp"
RANLIB="llvm-ranlib"
RUSTFLAGS=" -C target-cpu=native"
SHELL="/bin/bash"
STRIP="llvm-strip"
USE="X a52 aac acl acpi activities alsa amd64 bluetooth branding bzip2 cairo cdda cdr cet crypt cups dbus declarative dri dts dvd dvdr elogind encode eselect-ldso exif flac gdbm gif gpm gtk gui iconv icu ipv6 jpeg kde kf6compat kwallet lcms libnotify libtirpc mad mng mp3 mp4 mpeg multilib ncurses networkmanager nls ogg opengl openmp pam pango pcre pdf pipewire plasma png policykit ppds pulseaudio qml qt5 qt6 readline screencast sdl seccomp semantic-desktop sound spell ssl startup-notification svg test-rust tiff truetype udev udisks unicode upower usb vaapi vorbis vulkan wayland widgets wxwidgets x264 xattr xcb xft xml xv xvid zlib" 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 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 avx512_bf16 avx512_bitalg avx512_vbmi2 avx512_vnni avx512_vp2intersect avx512_vpopcntdq avx512bw avx512cd avx512dq avx512f avx512ifma avx512vbmi avx512vl f16c fma3 pclmul popcnt rdrand sha sse3 sse4_1 sse4_2 sse4a ssse3 vpclmulqdq" 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" 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="amdgpu fbdev intel nouveau radeon radeonsi vesa dummy" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipp2p iface geoip fuzzy condition tarpit sysrq proto logmark ipmark dhcpmac delude chaos account"
Unset:  ADDR2LINE, ARFLAGS, AS, ASFLAGS, CCLD, CONFIG_SHELL, CPPFLAGS, CTARGET, CXXFILT, ELFEDIT, EMERGE_DEFAULT_OPTS, EXTRA_ECONF, F77FLAGS, FC, GCOV, GPROF, INSTALL_MASK, LC_ALL, LD, LFLAGS, LIBTOOL, LINGUAS, MAKE, MAKEFLAGS, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, PYTHONPATH, READELF, SIZE, STRINGS, YACC, YFLAGS
Comment 1 zyxhere 2025-03-21 14:06:10 UTC
Does adding LD="ld.lld" to make.conf help?
Comment 2 Joungmin Lee 2025-03-21 14:24:55 UTC
(In reply to zyxhere from comment #1)
> Does adding LD="ld.lld" to make.conf help?

Unfortunately, declaring LD="ld.lld" did not solve the issue, either.
Comment 3 zyxhere 2025-03-21 14:30:58 UTC
Always attach the build.log
Comment 4 zyxhere 2025-03-21 14:38:41 UTC
Hmm I can reproduce with package.env
Comment 5 zyxhere 2025-03-21 14:39:20 UTC
Created attachment 921489 [details]
meson-log.txt
Comment 6 Joungmin Lee 2025-03-21 14:42:07 UTC
Created attachment 921490 [details]
build.log

Oops, I forgot to attach the full build.log
Comment 7 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2025-03-21 16:49:47 UTC
(In reply to zyxhere from comment #4)
> Hmm I can reproduce with package.env

What did you set in there, in full, so I can repro?
Comment 8 zyxhere 2025-03-21 18:31:09 UTC
(In reply to Sam James from comment #7)
> (In reply to zyxhere from comment #4)
> > Hmm I can reproduce with package.env
> 
> What did you set in there, in full, so I can repro?

COLOURS="-fdiagnostics-color=always -fcolor-diagnostics"
HARDEN="-ftrivial-auto-var-init=zero"
COMMON_FLAGS="-march=native -O2 -pipe -flto=thin ${HARDEN} ${COLOURS}" 
#${POLLY}"
CFLAGS="${COMMON_FLAGS}"
CXXFLAGS="${COMMON_FLAGS}"
FCFLAGS="${COMMON_FLAGS}"
FFLAGS="${COMMON_FLAGS}"
LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,-z,pack-relative-relocs
		-flto=thin -fuse-ld=lld -Wl,--color-diagnostics"
GOAMD64="v3"
CGO_CFLAGS="${COMMON_FLAGS}"
CGO_CXXFLAGS="${COMMON_FLAGS}"
CGO_FFLAGS="${COMMON_FLAGS}"
CGO_LDFLAGS="${LDFLAGS}"
RUSTFLAGS="${RUSTFLAGS}"
CC="clang"
CXX="clang++"
CPP="clang-cpp"
AR="llvm-ar"
AS="llvm-as"
NM="llvm-nm"
RANLIB="llvm-ranlib"
LD="ld.lld"
READELF="llvm-readelf"
OBJDUMP="llvm-objdump"
OBJCOPY="llvm-objcopy"
STRIP="llvm-strip"
#LLVM=1
Comment 9 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2025-03-21 18:43:02 UTC
(In reply to zyxhere from comment #8)
> (In reply to Sam James from comment #7)
> > (In reply to zyxhere from comment #4)
> > > Hmm I can reproduce with package.env
> > 
> > What did you set in there, in full, so I can repro?
> 
> COLOURS="-fdiagnostics-color=always -fcolor-diagnostics"
> HARDEN="-ftrivial-auto-var-init=zero"
> COMMON_FLAGS="-march=native -O2 -pipe -flto=thin ${HARDEN} ${COLOURS}" 

What happens if you put -fuse-ld=lld in here too?
Comment 10 zyxhere 2025-03-21 18:46:09 UTC
(In reply to Sam James from comment #9)
> (In reply to zyxhere from comment #8)
> > (In reply to Sam James from comment #7)
> > > (In reply to zyxhere from comment #4)
> > > > Hmm I can reproduce with package.env
> > > 
> > > What did you set in there, in full, so I can repro?
> > 
> > COLOURS="-fdiagnostics-color=always -fcolor-diagnostics"
> > HARDEN="-ftrivial-auto-var-init=zero"
> > COMMON_FLAGS="-march=native -O2 -pipe -flto=thin ${HARDEN} ${COLOURS}" 
> 
> What happens if you put -fuse-ld=lld in here too?

You mean in C*FLAGS?
Tried and it still fails with the same error
Comment 11 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2025-03-21 18:49:53 UTC
Meson is detecting the linker with:
```
Detecting linker via: `clang -Wl,--version` -> 0
stdout:
GNU ld (Gentoo 2.44 p1) 2.44.0
Copyright (C) 2025 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.
-----------
Sanity testing C compiler: clang
Is cross compiler: False.
Sanity check compiler command line: clang sanitycheckc.c -o sanitycheckc.exe -D_FILE_OFFSET_BITS=64
Sanity check compile stdout:

-----
Sanity check compile stderr:

-----
Running test binary command:  /var/tmp/portage/media-video/pipewire-1.4.1/work/pipewire-1.4.1-abi_x86_64.amd64/meson-private/sanitycheckc.exe
C compiler for the build machine: clang (clang 18.1.8 "clang version 18.1.8")
C linker for the build machine: clang ld.bfd 2.44
```

It needs to honour CFLAGS and LDFLAGS when doing this.
Comment 12 Eli Schwartz gentoo-dev 2025-03-21 20:01:07 UTC
(In reply to zyxhere from comment #8)
> (In reply to Sam James from comment #7)
> > (In reply to zyxhere from comment #4)
> > > Hmm I can reproduce with package.env
> > 
> > What did you set in there, in full, so I can repro?
> 
> COLOURS="-fdiagnostics-color=always -fcolor-diagnostics"
> HARDEN="-ftrivial-auto-var-init=zero"
> COMMON_FLAGS="-march=native -O2 -pipe -flto=thin ${HARDEN} ${COLOURS}" 
> #${POLLY}"
> CFLAGS="${COMMON_FLAGS}"
> CXXFLAGS="${COMMON_FLAGS}"
> FCFLAGS="${COMMON_FLAGS}"
> FFLAGS="${COMMON_FLAGS}"
> LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,-z,pack-relative-relocs
> 		-flto=thin -fuse-ld=lld -Wl,--color-diagnostics"
> GOAMD64="v3"
> CGO_CFLAGS="${COMMON_FLAGS}"
> CGO_CXXFLAGS="${COMMON_FLAGS}"
> CGO_FFLAGS="${COMMON_FLAGS}"
> CGO_LDFLAGS="${LDFLAGS}"
> RUSTFLAGS="${RUSTFLAGS}"
> CC="clang"
> CXX="clang++"
> CPP="clang-cpp"
> AR="llvm-ar"
> AS="llvm-as"
> NM="llvm-nm"
> RANLIB="llvm-ranlib"
> LD="ld.lld"
> READELF="llvm-readelf"
> OBJDUMP="llvm-objdump"
> OBJCOPY="llvm-objcopy"
> STRIP="llvm-strip"
> #LLVM=1



Added all these lines to ./env, prepended with "export".

$ (. ./env; ../../../meson.py setup builddir3)
C compiler for the host machine: clang (clang 19.1.7 "clang version 19.1.7")
C linker for the host machine: clang ld.lld 19.1.7

$ cat builddir3/meson-logs/meson-log.txt

Detecting compiler via: `clang --version` -> 0
stdout:
clang version 19.1.7
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/llvm/19/bin
Configuration file: /etc/clang/x86_64-pc-linux-gnu-clang.cfg
-----------
Running command: -x c -E -dM -
-----
-----------
Detecting linker via: `clang -Wl,--version -Wl,-O1 -Wl,--as-needed -Wl,-z,pack-relative-relocs -flto=thin -fuse-ld=lld -Wl,--color-diagnostics` -> 0
stdout:
LLD 19.1.7 (compatible with GNU linkers)
-----------
-----------
Detecting LLD linker via: `clang -Wl,-v -Wl,-O1 -Wl,--as-needed -Wl,-z,pack-relative-relocs -flto=thin -fuse-ld=lld -Wl,--color-diagnostics` -> 1
stdout:
LLD 19.1.7 (compatible with GNU linkers)
-----------
stderr:
ld.lld: error: undefined symbol: main
>>> referenced by /usr/lib/gcc/x86_64-pc-linux-gnu/14/../../../../lib64/Scrt1.o:(_start)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
-----------
Sanity testing C compiler: clang
Is cross compiler: False.
Sanity check compiler command line: clang sanitycheckc.c -o sanitycheckc.exe -march=native -O2 -pipe -flto=thin -ftrivial-auto-var-init=zero -fdiagnostics-color=always -fcolor-diagnostics -D_FILE_OFFSET_BITS=64 -Wl,-O1 -Wl,--as-needed -Wl,-z,pack-relative-relocs -fuse-ld=lld -Wl,--color-diagnostics


Seems to work for me?


$ ../../../meson.py setup builddir

C compiler for the host machine: ccache cc (gcc 14.2.1 "cc (Gentoo 14.2.1_p20241221 p7) 14.2.1 20241221")
C linker for the host machine: cc ld.bfd 2.43


$ LDFLAGS="-fuse-ld=lld" ../../../meson.py setup builddir2

C compiler for the host machine: ccache cc (gcc 14.2.1 "cc (Gentoo 14.2.1_p20241221 p7) 14.2.1 20241221")
C linker for the host machine: cc ld.lld 19.1.7


$ cat builddir2/meson-logs/meson-log.txt

Detecting compiler via: `cc --version` -> 0
stdout:
cc (Gentoo 14.2.1_p20241221 p7) 14.2.1 20241221
Copyright (C) 2024 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-----------
Running command: -cpp -x c -E -dM -
-----
-----------
Detecting linker via: `cc -Wl,--version -fuse-ld=lld` -> 0
stdout:
LLD 19.1.7 (compatible with GNU linkers)
-----------
stderr:
collect2 version 14.2.1 20241221
/usr/lib/llvm/19/bin/ld.lld -plugin /usr/libexec/gcc/x86_64-pc-linux-gnu/14/liblto_plugin.so -plugin-opt=/usr/libexec/gcc/x86_64-pc-linux-gnu/14/lto-wrapper -plugin-opt=-fresolution=/tmp/ccgf2jkP.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -pie -z now /usr/lib/gcc/x86_64-pc-linux-gnu/14/../../../../lib64/Scrt1.o /usr/lib/gcc/x86_64-pc-linux-gnu/14/../../../../lib64/crti.o /usr/lib/gcc/x86_64-pc-linux-gnu/14/crtbeginS.o -L/usr/lib/gcc/x86_64-pc-linux-gnu/14 -L/usr/lib/gcc/x86_64-pc-linux-gnu/14/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/x86_64-pc-linux-gnu/14/../../../../x86_64-pc-linux-gnu/lib -L/usr/lib/gcc/x86_64-pc-linux-gnu/14/../../.. --version -lgcc --push-state --as-needed -lgcc_s --pop-state -lc -lgcc --push-state --as-needed -lgcc_s --pop-state /usr/lib/gcc/x86_64-pc-linux-gnu/14/crtendS.o /usr/lib/gcc/x86_64-pc-linux-gnu/14/../../../../lib64/crtn.o
-----------
-----------
Detecting LLD linker via: `cc -Wl,-v -fuse-ld=lld` -> 1
stdout:
LLD 19.1.7 (compatible with GNU linkers)
-----------
stderr:
collect2 version 14.2.1 20241221
/usr/lib/llvm/19/bin/ld.lld -plugin /usr/libexec/gcc/x86_64-pc-linux-gnu/14/liblto_plugin.so -plugin-opt=/usr/libexec/gcc/x86_64-pc-linux-gnu/14/lto-wrapper -plugin-opt=-fresolution=/tmp/cckrMfrK.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -pie -z now /usr/lib/gcc/x86_64-pc-linux-gnu/14/../../../../lib64/Scrt1.o /usr/lib/gcc/x86_64-pc-linux-gnu/14/../../../../lib64/crti.o /usr/lib/gcc/x86_64-pc-linux-gnu/14/crtbeginS.o -L/usr/lib/gcc/x86_64-pc-linux-gnu/14 -L/usr/lib/gcc/x86_64-pc-linux-gnu/14/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/x86_64-pc-linux-gnu/14/../../../../x86_64-pc-linux-gnu/lib -L/usr/lib/gcc/x86_64-pc-linux-gnu/14/../../.. -v -lgcc --push-state --as-needed -lgcc_s --pop-state -lc -lgcc --push-state --as-needed -lgcc_s --pop-state /usr/lib/gcc/x86_64-pc-linux-gnu/14/crtendS.o /usr/lib/gcc/x86_64-pc-linux-gnu/14/../../../../lib64/crtn.o
ld.lld: error: undefined symbol: main
>>> referenced by /usr/lib/gcc/x86_64-pc-linux-gnu/14/../../../../lib64/Scrt1.o:(_start)
collect2: error: ld returned 1 exit status
-----------
Sanity testing C compiler: ccache cc
Comment 13 Joungmin Lee 2025-03-22 13:56:26 UTC
I tried emerge with environmental variables prepended with 'export', but encountered the same error message.


/etc/portage/make.conf
---
# These settings were set by the catalyst build script that automatically
# built this stage.
# Please consult /usr/share/portage/config/make.conf.example for a more
# detailed example.
export CC=clang
export CPP=clang-cpp
export CXX=clang++
export AR=llvm-ar
export NM=llvm-nm
export RANLIB=llvm-ranlib
export STRIP=llvm-strip
export OBJDUMP=llvm-objdump
export OBJCOPY=llvm-objcopy
export READELF=llvm-readelf
export LD=ld.lld


export COMMON_FLAGS="-march=x86-64-v4 -mtune=znver4 -O2 -pipe"
export CFLAGS="${COMMON_FLAGS} -flto=thin"
export CXXFLAGS="${COMMON_FLAGS} -flto=thin"
export FCFLAGS="${COMMON_FLAGS}"
export FFLAGS="${COMMON_FLAGS}"
export RUSTFLAGS="${RUSTFLAGS} -C target-cpu=native"

export LDFLAGS="-flto=thin -fuse-ld=lld -Wl,-O2 -Wl,--sort-common -Wl,--as-needed -Wl,-z,pack-relative-relocs"

# NOTE: This stage was built with the bindist USE flag enabled

# This sets the language of build output to English.
# Please keep this setting intact when reporting bugs.
LC_MESSAGES=C.utf8

MAKEOPTS="-j8"
ACCEPT_LICENSE="*"

GENTOO_MIRRORS="rsync://ftp.iij.ad.jp/pub/linux/gentoo/ \
    http://ftp.iij.ad.jp/pub/linux/gentoo/ \
    ftp://ftp.iij.ad.jp/pub/linux/gentoo/ \
    https://ftp.jaist.ac.jp/pub/Linux/Gentoo/ \
    http://ftp.jaist.ac.jp/pub/Linux/Gentoo/ \
    ftp://ftp.jaist.ac.jp/pub/Linux/Gentoo/ \
    rsync://ftp.jaist.ac.jp/pub/Linux/Gentoo/ \
    https://ftp.lanet.kr/pub/gentoo/"

USE="${USE} vaapi eselect-ldso"