Created attachment 716700 [details] Build log of clang I was in the process of upgrading the whole llvm toolchain from 11 to 12 `clang-12.0.0-r1` failed to build. emerge already upgraded package llvm, lld and their dependency to 12 using command `sudo emerge -av clang:12 llvm:12 lld:0` when the build failed with: ``` FAILED: bin/clang-tblgen : && /usr/lib/llvm/11/bin/clang++ -march=skylake -mtune=intel -O2 -flto=thin -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -fdiagnostics-color -ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual -pedantic -Wno-long-long -Wno-nested-anon-types -flto=thin -fuse-ld=lld -Wl,--plugin-opt=O3,-O3,--gc-sections,--icf=safe -Wl,--color-diagnostics -Wl,-O3 -Wl,--gc-sections utils/TableGen/CMakeFiles/clang-tblgen.dir/ASTTableGen.cpp.o utils/TableGen/CMakeFiles/clang-tblgen.dir/ClangASTNodesEmitter.cpp.o utils/TableGen/CMakeFiles/clang-tblgen.dir/ClangASTPropertiesEmitter.cpp.o utils/TableGen/CMakeFiles/clang-tblgen.dir/ClangAttrEmitter.cpp.o utils/TableGen/CMakeFiles/clang-tblgen.dir/ClangCommentCommandInfoEmitter.cpp.o utils/TableGen/CMakeFiles/clang-tblgen.dir/ClangCommentHTMLNamedCharacterReferenceEmitter.cpp.o utils/TableGen/CMakeFiles/clang-tblgen.dir/ClangCommentHTMLTagsEmitter.cpp.o utils/TableGen/CMakeFiles/clang-tblgen.dir/ClangDataCollectorsEmitter.cpp.o utils/TableGen/CMakeFiles/clang-tblgen.dir/ClangDiagnosticsEmitter.cpp.o utils/TableGen/CMakeFiles/clang-tblgen.dir/ClangOpcodesEmitter.cpp.o utils/TableGen/CMakeFiles/clang-tblgen.dir/ClangOpenCLBuiltinEmitter.cpp.o utils/TableGen/CMakeFiles/clang-tblgen.dir/ClangOptionDocEmitter.cpp.o utils/TableGen/CMakeFiles/clang-tblgen.dir/ClangSACheckersEmitter.cpp.o utils/TableGen/CMakeFiles/clang-tblgen.dir/ClangSyntaxEmitter.cpp.o utils/TableGen/CMakeFiles/clang-tblgen.dir/ClangTypeNodesEmitter.cpp.o utils/TableGen/CMakeFiles/clang-tblgen.dir/MveEmitter.cpp.o utils/TableGen/CMakeFiles/clang-tblgen.dir/NeonEmitter.cpp.o utils/TableGen/CMakeFiles/clang-tblgen.dir/SveEmitter.cpp.o utils/TableGen/CMakeFiles/clang-tblgen.dir/TableGen.cpp.o -o bin/clang-tblgen -L/usr/lib/llvm/12/lib64 -Wl,-rpath,"\$ORIGIN/../lib64" /usr/lib/llvm/12/lib64/libLLVMSupport.a /usr/lib/llvm/12/lib64/libLLVMTableGen.a -lpthread /usr/lib/llvm/12/lib64/libLLVMSupport.a -lrt -ldl -lpthread -lm /usr/lib64/libz.so -ltinfo /usr/lib/llvm/12/lib64/libLLVMDemangle.a && : Wrong types for attribute: inalloca nest noalias nocapture noundef nonnull readnone readonly signext zeroext byref(void) byval(void) preallocated(void) sret(void) align 1 dereferenceable(1) dereferenceable_or_null(1) void (%"class.llvm::Optional"*, %"struct.(anonymous namespace)::RealFileSystem::WorkingDirectory"*)* @_ZN4llvm8OptionalIN12_GLOBAL__N_114RealFileSystem16WorkingDirectoryEEaSEOS3_ in function _ZN4llvm8OptionalIN12_GLOBAL__N_114RealFileSystem16WorkingDirectoryEEaSEOS3_ LLVM ERROR: Broken function found, compilation aborted! PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace. Stack dump: 0. Running pass 'Function Pass Manager' on module '/usr/lib/llvm/12/lib64/libLLVMSupport.a(VirtualFileSystem.cpp.o at 4681956)'. 1. Running pass 'Module Verifier' on function '@_ZN4llvm8OptionalIN12_GLOBAL__N_114RealFileSystem16WorkingDirectoryEEaSEOS3_' Wrong types for attribute: inalloca nest noalias nocapture noundef nonnull readnone readonly signext zeroext byref(void) byval(void) preallocated(void) sret(void) align 1 dereferenceable(1) dereferenceable_or_null(1) tail call fastcc align 8 void @_ZL25getPragmaAttributeSupportRN4llvm12RecordKeeperE(%"class.llvm::RecordKeeper"* nonnull align 8 dereferenceable(249) %0) in function _ZN5clang33EmitClangAttrSubjectMatchRuleListERN4llvm12RecordKeeperERNS0_11raw_ostreamE LLVM ERROR: Broken function found, compilation aborted! clang-11: error: unable to execute command: Aborted (core dumped) clang-11: error: linker command failed due to signal (use -v to see invocation) ninja: build stopped: subcommand failed. ``` Output of `emerge --info '=sys-devel/clang-12.0.0-r1::gentoo'`: ``` Portage 3.0.18 (python 3.9.5-final-0, default/linux/amd64/17.1/systemd, gcc-11.1.0, glibc-2.33, 5.12.8-gentoo x86_64) ================================================================= System Settings ================================================================= System uname: Linux-5.12.8-gentoo-x86_64-Intel-R-_Core-TM-_i7-8750H_CPU_@_2.20GHz-with-glibc2.33 KiB Mem: 16276412 total, 8849576 free KiB Swap: 13107192 total, 12784652 free Timestamp of repository gentoo: Thu, 17 Jun 2021 00:15:01 +0000 Head commit of repository gentoo: 6ebf0796efd8578098ab4afe14a677be3c3c990b sh bash 5.1_p8 ld GNU ld (Gentoo 2.35.2 p1) 2.35.2 ccache version 4.3 [enabled] app-shells/bash: 5.1_p8::gentoo dev-java/java-config: 2.3.1::gentoo dev-lang/perl: 5.32.1::gentoo dev-lang/python: 3.8.9_p2::gentoo, 3.9.5_p2::gentoo dev-lang/rust: 1.52.1::gentoo dev-util/ccache: 4.3::gentoo dev-util/cmake: 3.18.5::gentoo sys-apps/baselayout: 2.7::gentoo sys-apps/sandbox: 2.24::gentoo sys-devel/autoconf: 2.13-r1::gentoo, 2.69-r5::gentoo sys-devel/automake: 1.16.3-r1::gentoo sys-devel/binutils: 2.35.2::gentoo sys-devel/gcc: 9.3.0-r2::gentoo, 11.1.0-r1::gentoo sys-devel/gcc-config: 2.4::gentoo sys-devel/libtool: 2.4.6-r6::gentoo sys-devel/make: 4.3::gentoo sys-kernel/linux-headers: 5.10::gentoo (virtual/os-headers) sys-libs/glibc: 2.33::gentoo Repositories: gentoo location: /var/db/repos/gentoo sync-type: rsync sync-uri: rsync://rsync.au.gentoo.org/gentoo-portage priority: -1000 sync-rsync-verify-metamanifest: yes sync-rsync-verify-jobs: 1 sync-rsync-verify-max-age: 24 sync-rsync-extra-opts: eclipse location: /var/lib/layman/eclipse sync-type: laymansync sync-uri: https://github.com/gentoo/eclipse-overlay.git masters: gentoo priority: 50 guru location: /var/lib/layman/guru sync-type: laymansync sync-uri: https://anongit.gentoo.org/git/repo/proj/guru.git masters: gentoo priority: 50 mv location: /var/lib/layman/mv sync-type: laymansync sync-uri: https://anongit.gentoo.org/git/user/mv.git masters: gentoo priority: 50 science location: /var/lib/layman/science sync-type: laymansync sync-uri: https://anongit.gentoo.org/git/proj/sci.git masters: gentoo priority: 50 ACCEPT_KEYWORDS="amd64" ACCEPT_LICENSE="@FREE" CBUILD="x86_64-pc-linux-gnu" CC="clang" CFLAGS="-march=skylake -mtune=intel -O2 -flto=thin" 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/revdep-rebuild /etc/sandbox.d /etc/terminfo" CXX="clang++" CXXFLAGS="-march=skylake -mtune=intel -O2 -flto=thin" DISTDIR="/var/cache/distfiles" 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="-Ofast -march=native -flto" FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs ccache config-protect-if-modified distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync multilib-strict network-sandbox news parallel-fetch 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="-Ofast -march=native -flto" GENTOO_MIRRORS="https://mirror.aarnet.edu.au/pub/gentoo/ http://mirror.aarnet.edu.au/pub/gentoo/ rsync://mirror.aarnet.edu.au/pub/gentoo/ ftp://ftp.swin.edu.au/gentoo http://ftp.swin.edu.au/gentoo" LANG="C.UTF8" LDFLAGS="-flto=thin -fuse-ld=lld -Wl,--plugin-opt=O3,-O3,--gc-sections,--icf=safe" MAKEOPTS="-j12 -l12" 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" USE="acl adns alsa amd64 bash-completion berkdb bzip2 clang cli crypt dbus dri fortran gdbm iconv ipv6 libglvnd libnotify libtirpc lto multilib ncurses networkmanager nls nptl openmp pam pcre policykit pulseaudio readline seccomp split-usr sqlite ssl systemd tcpd udev unicode wayland xattr zlib" ABI_X86="64" ADA_TARGET="gnat_2018" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" 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 sse sse2 sse3 sse4_1 sse4_2 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" 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="postgres10 postgres11" PYTHON_SINGLE_TARGET="python3_9" PYTHON_TARGETS="python3_9" RUBY_TARGETS="ruby26" USERLAND="GNU" VIDEO_CARDS="nouveau" 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: CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LC_ALL, LINGUAS, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, RUSTFLAGS ``` Output of `emerge -pqv '=sys-devel/clang-12.0.0-r1::gentoo'`: ``` [ebuild NS ] sys-devel/clang-12.0.0-r1 [11.1.0] USE="static-analyzer -debug -default-compiler-rt -default-libcxx -default-lld -doc -llvm-libunwind% -test -xml" ABI_X86="(64) -32 (-x32)" LLVM_TARGETS="AMDGPU BPF NVPTX (X86) -AArch64 -ARC -ARM -AVR (-CSKY) -Hexagon -Lanai -MSP430 -Mips -PowerPC -RISCV -Sparc -SystemZ -VE -WebAssembly -XCore" PYTHON_SINGLE_TARGET="python3_9 -python3_8" [ebuild NS ] sys-libs/compiler-rt-sanitizers-12.0.0 [11.1.0-r1] USE="asan cfi clang dfsan gwp-asan hwasan libfuzzer lsan* memprof%* msan profile safestack scudo tsan ubsan xray (-shadowcallstack) -test" [ebuild NS ] sys-devel/clang-runtime-12.0.0 [11.1.0] USE="compiler-rt openmp sanitize -libcxx" ABI_X86="32 (64) (-x32)" ```
Disable -flto=thin from cflags, see https://forums.gentoo.org/viewtopic-p-8625903.html#8625903
Created attachment 717261 [details] Build log after lto is disabled while lld is still used
(In reply to Marco Genasci from comment #1) > Disable -flto=thin from cflags, see > https://forums.gentoo.org/viewtopic-p-8625903.html#8625903 After I disable lto while still using lld (since llvm and lld is compiled with LTO), it gives me a even longer stack bactrace. Maybe I should recompile the whole llvm toolchain without lto, but I think I'd better first upload the output to here.
The same kind of traceback also appeared when I was compiling `net-libs/nodejs-14.16.1`. It seems that my `clang-11` uses the `llvm-12` present on the system instead of using `llvm-11`. ``` Wrong types for attribute: inalloca nest noalias nocapture noundef nonnull readnone readonly signext zeroext byref(void) byval(void) preallocated(void) sret(void) align 1 dereferenceable(1) dereferenceable_or_null(1) call fastcc align 8 void @_ZNSt10unique_ptrIN2v88internal6torque12_GLOBAL__N_116InstanceTypeTreeESt14default_deleteIS4_EEaSEOS7_(%"class.std::unique_ptr.96"* nonnull %20, %"class.std::unique_ptr.96"* nonnull align 8 dereferenceable(8) %338) #17 Wrong types for attribute: inalloca nest noalias nocapture noundef nonnull readnone readonly signext zeroext byref(void) byval(void) preallocated(void) sret(void) align 1 dereferenceable(1) dereferenceable_or_null(1) call fastcc align 8 void @_ZNSt10unique_ptrIN2v88internal6torque12_GLOBAL__N_116InstanceTypeTreeESt14default_deleteIS4_EEaSEOS7_(%"class.std::unique_ptr.96"* nonnull %20, %"class.std::unique_ptr.96"* nonnull align 8 dereferenceable(8) %13) #17 in function _ZN2v88internal6torque21ImplementationVisitor21GenerateInstanceTypesERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE LLVM ERROR: Broken function found, compilation aborted! PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace. Stack dump: 0. Running pass 'Function Pass Manager' on module '/var/tmp/portage/net-libs/nodejs-14.16.1/work/node-v14.16.1/out/Release/obj.target/tools/v8_gypfiles/libtorque_base.a(instance-type-generator.o at 269526)'. 1. Running pass 'Module Verifier' on function '@_ZN2v88internal6torque21ImplementationVisitor21GenerateInstanceTypesERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE' #0 0x00007f390288ec43 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/lib/llvm/12/lib64/libLLVM-12.so+0x19cdc43) #1 0x00007f390288c020 llvm::sys::RunSignalHandlers() (/usr/lib/llvm/12/lib64/libLLVM-12.so+0x19cb020) #2 0x00007f390288f45a (/usr/lib/llvm/12/lib64/libLLVM-12.so+0x19ce45a) #3 0x00007f39056a7180 __restore_rt (/lib64/libpthread.so.0+0x12180) #4 0x00007f39009da29e raise (/lib64/libc.so.6+0x3829e) #5 0x00007f39009c4536 abort (/lib64/libc.so.6+0x22536) #6 0x00007f39027ba839 llvm::report_fatal_error(llvm::Twine const&, bool) (/usr/lib/llvm/12/lib64/libLLVM-12.so+0x18f9839) #7 0x00007f39027ba688 (/usr/lib/llvm/12/lib64/libLLVM-12.so+0x18f9688) #8 0x00007f3902a87b7f (/usr/lib/llvm/12/lib64/libLLVM-12.so+0x1bc6b7f) #9 0x00007f3902a06ed8 llvm::FPPassManager::runOnFunction(llvm::Function&) (/usr/lib/llvm/12/lib64/libLLVM-12.so+0x1b45ed8) #10 0x00007f3902a0e403 llvm::FPPassManager::runOnModule(llvm::Module&) (/usr/lib/llvm/12/lib64/libLLVM-12.so+0x1b4d403) #11 0x00007f3902a07870 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/usr/lib/llvm/12/lib64/libLLVM-12.so+0x1b46870) #12 0x00007f3903fb4a29 llvm::lto::opt(llvm::lto::Config const&, llvm::TargetMachine*, unsigned int, llvm::Module&, bool, llvm::ModuleSummaryIndex*, llvm::ModuleSummaryIndex const*, std::vector<unsigned char, std::allocator<unsigned char> > const&) (/usr/lib/llvm/12/lib64/libLLVM-12.so+0x30f3a29) #13 0x00007f3903fba744 (/usr/lib/llvm/12/lib64/libLLVM-12.so+0x30f9744) #14 0x00007f3903fba1a2 llvm::lto::thinBackend(llvm::lto::Config const&, unsigned int, std::function<std::unique_ptr<llvm::lto::NativeObjectStream, std::default_delete<llvm::lto::NativeObjectStream> > (unsigned int)>, llvm::Module&, llvm::ModuleSummaryIndex const&, llvm::StringMap<std::unordered_set<unsigned long, std::hash<unsigned long>, std::equal_to<unsigned long>, std::allocator<unsigned long> >, llvm::MallocAllocator> const&, llvm::DenseMap<unsigned long, llvm::GlobalValueSummary*, llvm::DenseMapInfo<unsigned long>, llvm::detail::DenseMapPair<unsigned long, llvm::GlobalValueSummary*> > const&, llvm::MapVector<llvm::StringRef, llvm::BitcodeModule, llvm::DenseMap<llvm::StringRef, unsigned int, llvm::DenseMapInfo<llvm::StringRef>, llvm::detail::DenseMapPair<llvm::StringRef, unsigned int> >, std::vector<std::pair<llvm::StringRef, llvm::BitcodeModule>, std::allocator<std::pair<llvm::StringRef, llvm::BitcodeModule> > > >&, std::vector<unsigned char, std::allocator<unsigned char> > const&) (/usr/lib/llvm/12/lib64/libLLVM-12.so+0x30f91a2) #15 0x00007f3903fb1189 (/usr/lib/llvm/12/lib64/libLLVM-12.so+0x30f0189) #16 0x00007f3903fb0a7d (/usr/lib/llvm/12/lib64/libLLVM-12.so+0x30efa7d) #17 0x00007f390282d234 (/usr/lib/llvm/12/lib64/libLLVM-12.so+0x196c234) #18 0x00007f390280cea7 (/usr/lib/llvm/12/lib64/libLLVM-12.so+0x194bea7) #19 0x00007f39056a45ea __pthread_once_slow (/lib64/libpthread.so.0+0xf5ea) #20 0x00007f390280cde0 (/usr/lib/llvm/12/lib64/libLLVM-12.so+0x194bde0) #21 0x00007f390282ce01 (/usr/lib/llvm/12/lib64/libLLVM-12.so+0x196be01) #22 0x00007f390282ca1e (/usr/lib/llvm/12/lib64/libLLVM-12.so+0x196ba1e) #23 0x00007f3900d80d35 (/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/libstdc++.so.6+0xd6d35) #24 0x00007f390569ccfe start_thread (/lib64/libpthread.so.0+0x7cfe) #25 0x00007f3900a9914f clone (/lib64/libc.so.6+0xf714f) ```
(In reply to Marco Genasci from comment #1) > Disable -flto=thin from cflags, see > https://forums.gentoo.org/viewtopic-p-8625903.html#8625903 I rebuilt sys-devel/llvm-12 with LTO disabled and when building sys-devel/clang-12 with gcc with no lto, it still failed.
Created attachment 721726 [details] The build.log of clang-12 using gcc with no LTO after llvm-12 is rebuilt with no LTO