rui314 / mold

Mold: A Modern Linker 🦠
MIT License
14.34k stars 470 forks source link

Build fails on master (9c651d513a1d22875c1967dc2c3f7aaa0161281c) #136

Closed thesamesam closed 2 years ago

thesamesam commented 2 years ago

9c651d513a1d22875c1967dc2c3f7aaa0161281c fails to build for me.

Seems to fail to build for me as below (full log: build.log):

x86_64-pc-linux-gnu-g++ -DMOLD_VERSION=\"0.9.6\" -DLIBDIR="\"/usr/local/lib\"" -DGIT_HASH=\"9c651d513a1d22875c1967dc2c3f7aaa0161281c\" -O2 -pipe -march=native -fdiagnostics-color=always -frecord-gcc-switches -ggdb3 -pthread -fPIE -fno-unwind-tables -fno-asynchronous-unwind-tables -std=c++20 -fno-exceptions -Wl,-O1 -Wl,--as-needed -Wl,--defsym=__gentoo_check_ldflags__=0 out/compress.o out/demangle.o out/filepath.o out/hyperloglog.o out/main.o out/perf.o out/tar.o out/elf/arch-arm64.o out/elf/arch-i386.o out/elf/arch-x86-64.o out/elf/cmdline.o out/elf/gc-sections.o out/elf/icf.o out/elf/input-sections.o out/elf/linker-script.o out/elf/main.o out/elf/mapfile.o out/elf/object-file.o out/elf/output-chunks.o out/elf/output-file.o out/elf/passes.o out/elf/relocatable.o out/elf/subprocess.o out/macho/arch-arm64.o out/macho/arch-x86-64.o out/macho/cmdline.o out/macho/dead-strip.o out/macho/dumper.o out/macho/input-sections.o out/macho/main.o out/macho/mapfile.o out/macho/object-file.o out/macho/output-chunks.o out/macho/output-file.o out/macho/tapi.o out/macho/yaml.o -o mold -pthread -lz -lxxhash -ldl -lm -lmimalloc -ltbb -lcrypto
/usr/lib/gcc/x86_64-pc-linux-gnu/11.2.1/../../../../x86_64-pc-linux-gnu/bin/ld: out/macho/arch-arm64.o: in function `mold::SyncOut<mold::macho::Context<mold::macho::ARM64> >& mold::SyncOut<mold::macho::Context<mold::macho::ARM64> >::operator<< <mold::macho::ObjectFile<mold::macho::ARM64>&>(mold::macho::ObjectFile<mold::macho::ARM64>&)':
/var/tmp/portage/sys-devel/mold-9999/work/mold-9999/macho/../mold.h:68: undefined reference to `std::ostream& mold::macho::operator<< <mold::macho::ARM64>(std::ostream&, mold::macho::InputFile<mold::macho::ARM64> const&)'
/usr/lib/gcc/x86_64-pc-linux-gnu/11.2.1/../../../../x86_64-pc-linux-gnu/bin/ld: /var/tmp/portage/sys-devel/mold-9999/work/mold-9999/macho/../mold.h:68: undefined reference to `std::ostream& mold::macho::operator<< <mold::macho::ARM64>(std::ostream&, mold::macho::InputFile<mold::macho::ARM64> const&)'
/usr/lib/gcc/x86_64-pc-linux-gnu/11.2.1/../../../../x86_64-pc-linux-gnu/bin/ld: out/macho/arch-arm64.o: in function `std::ostream& mold::macho::operator<< <mold::macho::ARM64>(std::ostream&, mold::macho::InputSection<mold::macho::ARM64> const&)':
/var/tmp/portage/sys-devel/mold-9999/work/mold-9999/macho/mold.h:856: undefined reference to `std::ostream& mold::macho::operator<< <mold::macho::ARM64>(std::ostream&, mold::macho::InputFile<mold::macho::ARM64> const&)'
/usr/lib/gcc/x86_64-pc-linux-gnu/11.2.1/../../../../x86_64-pc-linux-gnu/bin/ld: out/macho/arch-x86-64.o: in function `std::ostream& mold::macho::operator<< <mold::macho::X86_64>(std::ostream&, mold::macho::InputSection<mold::macho::X86_64> const&)':
/var/tmp/portage/sys-devel/mold-9999/work/mold-9999/macho/mold.h:856: undefined reference to `std::ostream& mold::macho::operator<< <mold::macho::X86_64>(std::ostream&, mold::macho::InputFile<mold::macho::X86_64> const&)'
/usr/lib/gcc/x86_64-pc-linux-gnu/11.2.1/../../../../x86_64-pc-linux-gnu/bin/ld: out/macho/arch-x86-64.o: in function `mold::SyncOut<mold::macho::Context<mold::macho::X86_64> >& mold::SyncOut<mold::macho::Context<mold::macho::X86_64> >::operator<< <mold::macho::ObjectFile<mold::macho::X86_64>&>(mold::macho::ObjectFile<mold::macho::X86_64>&)':
/var/tmp/portage/sys-devel/mold-9999/work/mold-9999/macho/../mold.h:68: undefined reference to `std::ostream& mold::macho::operator<< <mold::macho::X86_64>(std::ostream&, mold::macho::InputFile<mold::macho::X86_64> const&)'
/usr/lib/gcc/x86_64-pc-linux-gnu/11.2.1/../../../../x86_64-pc-linux-gnu/bin/ld: /var/tmp/portage/sys-devel/mold-9999/work/mold-9999/macho/../mold.h:68: undefined reference to `std::ostream& mold::macho::operator<< <mold::macho::X86_64>(std::ostream&, mold::macho::InputFile<mold::macho::X86_64> const&)'
/usr/lib/gcc/x86_64-pc-linux-gnu/11.2.1/../../../../x86_64-pc-linux-gnu/bin/ld: /var/tmp/portage/sys-devel/mold-9999/work/mold-9999/macho/../mold.h:68: undefined reference to `std::ostream& mold::macho::operator<< <mold::macho::X86_64>(std::ostream&, mold::macho::InputFile<mold::macho::X86_64> const&)'
/usr/lib/gcc/x86_64-pc-linux-gnu/11.2.1/../../../../x86_64-pc-linux-gnu/bin/ld: /var/tmp/portage/sys-devel/mold-9999/work/mold-9999/macho/../mold.h:68: undefined reference to `std::ostream& mold::macho::operator<< <mold::macho::X86_64>(std::ostream&, mold::macho::InputFile<mold::macho::X86_64> const&)'
/usr/lib/gcc/x86_64-pc-linux-gnu/11.2.1/../../../../x86_64-pc-linux-gnu/bin/ld: out/macho/arch-x86-64.o:/var/tmp/portage/sys-devel/mold-9999/work/mold-9999/macho/../mold.h:68: more undefined references to `std::ostream& mold::macho::operator<< <mold::macho::X86_64>(std::ostream&, mold::macho::InputFile<mold::macho::X86_64> const&)' follow
/usr/lib/gcc/x86_64-pc-linux-gnu/11.2.1/../../../../x86_64-pc-linux-gnu/bin/ld: out/macho/main.o: in function `mold::SyncOut<mold::macho::Context<mold::macho::ARM64> >& mold::SyncOut<mold::macho::Context<mold::macho::ARM64> >::operator<< <mold::macho::ObjectFile<mold::macho::ARM64>&>(mold::macho::ObjectFile<mold::macho::ARM64>&)':
/var/tmp/portage/sys-devel/mold-9999/work/mold-9999/macho/../mold.h:68: undefined reference to `std::ostream& mold::macho::operator<< <mold::macho::ARM64>(std::ostream&, mold::macho::InputFile<mold::macho::ARM64> const&)'
/usr/lib/gcc/x86_64-pc-linux-gnu/11.2.1/../../../../x86_64-pc-linux-gnu/bin/ld: out/macho/main.o: in function `mold::SyncOut<mold::macho::Context<mold::macho::ARM64> >& mold::SyncOut<mold::macho::Context<mold::macho::ARM64> >::operator<< <mold::macho::DylibFile<mold::macho::ARM64>&>(mold::macho::DylibFile<mold::macho::ARM64>&)':
/var/tmp/portage/sys-devel/mold-9999/work/mold-9999/macho/../mold.h:68: undefined reference to `std::ostream& mold::macho::operator<< <mold::macho::ARM64>(std::ostream&, mold::macho::InputFile<mold::macho::ARM64> const&)'
/usr/lib/gcc/x86_64-pc-linux-gnu/11.2.1/../../../../x86_64-pc-linux-gnu/bin/ld: out/macho/mapfile.o: in function `void mold::macho::print_map<mold::macho::ARM64>(mold::macho::Context<mold::macho::ARM64>&)':
/var/tmp/portage/sys-devel/mold-9999/work/mold-9999/macho/mapfile.cc:31: undefined reference to `std::ostream& mold::macho::operator<< <mold::macho::ARM64>(std::ostream&, mold::macho::InputFile<mold::macho::ARM64> const&)'
/usr/lib/gcc/x86_64-pc-linux-gnu/11.2.1/../../../../x86_64-pc-linux-gnu/bin/ld: out/macho/mapfile.o: in function `void mold::macho::print_map<mold::macho::X86_64>(mold::macho::Context<mold::macho::X86_64>&)':
/var/tmp/portage/sys-devel/mold-9999/work/mold-9999/macho/mapfile.cc:31: undefined reference to `std::ostream& mold::macho::operator<< <mold::macho::X86_64>(std::ostream&, mold::macho::InputFile<mold::macho::X86_64> const&)'
collect2: error: ld returned 1 exit status
make: *** [Makefile:95: mold] Error 1

Let me know if I can provide more information / try something for you.

System information:

Portage 3.0.30 (python 3.10.1-final-0, default/linux/amd64/17.1/desktop/plasma/systemd, gcc-11.2.1, glibc-2.34-r4, 5.10.84-gentoo-dist-hardened x86_64)
=================================================================
System uname: Linux-5.10.84-gentoo-dist-hardened-x86_64-AMD_Ryzen_9_3950X_16-Core_Processor-with-glibc2.34
KiB Mem:    16361304 total,   9707520 free
KiB Swap:   16777212 total,  16255408 free
Timestamp of repository gentoo: Wed, 15 Dec 2021 00:51:38 +0000
Head commit of repository gentoo: aa55a7825e8eb8f3fe974b5929c9cfe319669d6f

Timestamp of repository kde: Tue, 14 Dec 2021 03:56:15 +0000
Head commit of repository kde: 4377fd65aed0e0b4f68c4df682c5f485cbc75684

Timestamp of repository qt: Tue, 14 Dec 2021 03:55:53 +0000
Head commit of repository qt: aec842097a2aae4d94ebc76ec8cb0d9650470f2e

Timestamp of repository sam_c: Tue, 14 Dec 2021 03:56:23 +0000
Head commit of repository sam_c: 0778fdec29c82212d3762c4a629a5734b85a7556

Timestamp of repository steam-overlay: Tue, 14 Dec 2021 03:55:55 +0000
Head commit of repository steam-overlay: ebb9b0cfdbce6c266accccc951b3a49ebf814371

sh dash 0.5.11.5
ld GNU ld (Gentoo 2.37_p1 p1) 2.37
ccache version 4.5.1 [disabled]
app-misc/pax-utils:        1.3.3::gentoo
app-shells/bash:           5.1_p12::gentoo
dev-java/java-config:      2.3.1::gentoo
dev-lang/perl:             5.34.0-r5::gentoo
dev-lang/python:           3.8.12_p1::gentoo, 3.9.9::gentoo, 3.10.1::gentoo
dev-lang/rust-bin:         1.57.0::gentoo
dev-util/ccache:           4.5.1::gentoo
dev-util/cmake:            3.22.1::gentoo
dev-util/meson:            0.60.2-r1::gentoo
sys-apps/baselayout:       2.8::gentoo
sys-apps/sandbox:          2.29::gentoo
sys-apps/systemd:          249.6-r1::gentoo
sys-devel/autoconf:        2.13-r1::gentoo, 2.71-r1::gentoo
sys-devel/automake:        1.16.5::gentoo
sys-devel/binutils:        2.37_p1-r1::gentoo
sys-devel/binutils-config: 5.4::gentoo
sys-devel/clang:           12.0.1::gentoo, 13.0.0::gentoo
sys-devel/gcc:             9.4.0::gentoo, 10.3.1_p20211126::gentoo, 11.2.1_p20211127::gentoo
sys-devel/gcc-config:      2.5-r1::gentoo
sys-devel/libtool:         2.4.6-r6::gentoo
sys-devel/lld:             13.0.0::gentoo
sys-devel/llvm:            12.0.1::gentoo, 13.0.0::gentoo
sys-devel/make:            4.3::gentoo
sys-kernel/linux-headers:  5.15-r1::gentoo (virtual/os-headers)
sys-libs/glibc:            2.34-r4::gentoo
Repositories:

gentoo
    location: /var/db/repos/gentoo
    sync-type: git
    sync-uri: https://github.com/gentoo-mirror/gentoo.git
    priority: -1000
    sync-git-clone-extra-opts: -b stable -c gc.reflogExpire=0 -c gc.reflogExpireUnreachable=0 -c gc.rerereresolved=0 -c gc.rerereunresolved=0 -c gc.pruneExpire=now
    sync-git-verify-commit-signature: yes

crossdev
    location: /var/db/repos/crossdev
    masters: gentoo

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

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

sam_c
    location: /var/db/repos/sam_c
    sync-type: git
    sync-uri: https://github.com/gentoo-mirror/sam_c.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

ACCEPT_KEYWORDS="amd64 ~amd64"
ACCEPT_LICENSE="@FREE"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-O2 -pipe -march=native -fdiagnostics-color=always -frecord-gcc-switches"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /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-php8.1/ext-active/ /etc/php/cgi-php8.1/ext-active/ /etc/php/cli-php8.1/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="-O2 -pipe -march=native -fdiagnostics-color=always -frecord-gcc-switches"
DISTDIR="/var/cache/distfiles"
EMERGE_DEFAULT_OPTS="--keep-going --with-bdeps=y --complete-graph --deep --changed-deps-report=y --usepkg-exclude sys-fs/zfs --usepkg-exclude sys-fs/zfs-kmod --usepkg=n --implicit-system-deps=n"
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 -march=native -fdiagnostics-color=always -frecord-gcc-switches"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs buildpkg-live cgroup config-protect-if-modified distlocks ebuild-locks fixlafiles ipc-sandbox mount-sandbox multilib-strict network-sandbox news parallel-fetch parallel-install 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 -march=native -fdiagnostics-color=always -frecord-gcc-switches"
GENTOO_MIRRORS="http://mirror.bytemark.co.uk/gentoo/ http://www.mirrorservice.org/sites/distfiles.gentoo.org/ http://mirrors.soeasyto.com/distfiles.gentoo.org/ http://mirrors.gethosted.online/gentoo"
L10N="en en-GB"
LANG="en_GB.UTF-8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,--defsym=__gentoo_check_ldflags__=0"
LINGUAS="en en_GB"
MAKEOPTS="-j24"
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="PIC X a52 aac acl acpi activities aes alsa amd64 avx avx2 bash-completion bluetooth branding bzip2 cairo caps cdda cdr cli crypt dbus declarative dist-kernel dri dts dvd dvdr emacs emboss encode exif f16c filecaps firewalld flac fma3 fortran gdbm gif gmp gpm graphite gtk gui hardened hunspell iconv icu ipv6 jit jpeg kde kdesu kipi kwallet lcms libglvnd libnotify libtirpc llvm-libunwind mad mmx mmxext mng mp3 mp4 mpeg multilib ncurses nls nptl ogg opengl openmp pam pango pclmul pcre pdf pgo pie plasma png policykit popcnt ppds pulseaudio qml qt5 rdrand readline sdl seccomp semantic-desktop sha spell split-usr sse sse2 sse3 sse4_1 sse4_2 sse4a ssl ssse3 startup-notification svg system-av1 system-binutils system-boost system-bootstrap system-cairo system-clang system-digest system-ffmpeg system-harfbuzz system-heimdal system-icu system-jpeg system-leveldb system-libevent system-libs system-libvpx system-libyaml system-lz4 system-mitkrb5 system-sqlite system-ssl system-tbb system-uulib system-webp system-zlib systemd threads tiff truetype udev udisks unicode upower usb verify-sig vorbis vulkan wayland widgets x264 xattr xcb xml xv xvid zfs zlib zsh-completion" ABI_X86="32 64" ADA_TARGET="gnat_2020" 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="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 mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="libinput" KERNEL="linux" L10N="en en-GB" 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 python3_10 python3_8" RUBY_TARGETS="ruby26 ruby27" USERLAND="GNU" VIDEO_CARDS="amdgpu radeonsi radeon" 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:  ADDR2LINE, AR, ARFLAGS, AS, ASFLAGS, CC, CCLD, CONFIG_SHELL, CPP, CPPFLAGS, CTARGET, CXX, CXXFILT, ELFEDIT, F77FLAGS, FC, GCOV, GPROF, INSTALL_MASK, LC_ALL, LD, LEX, LFLAGS, LIBTOOL, MAKE, MAKEFLAGS, NM, OBJCOPY, OBJDUMP, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, RANLIB, READELF, RUSTFLAGS, SIZE, STRINGS, STRIP, YACC, YFLAGS
thesamesam commented 2 years ago

Note that CC=clang, CXX=clang++ seems to build successfully (LLVM and Clang 13.0.0).

Failing GCC:

$ gcc --version
gcc (Gentoo Hardened 11.2.1_p20211127 p0) 11.2.1 20211127
Copyright (C) 2021 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.

If you're having issues reproducing the failure with GCC, I can try give e.g. a Dockerfile to reproduce it with Gentoo.

rui314 commented 2 years ago

Thanks. I can reproduce the issue, and I believe I forgot to instantiate a template. I'll submit a fix.

thesamesam commented 2 years ago

Confirmed that fixes the issue for me, thank you!