Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 888771 - [Crossdev] Pthreads are required to build libgomp at cross-gcc-stage2
Summary: [Crossdev] Pthreads are required to build libgomp at cross-gcc-stage2
Status: UNCONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: AMD64 Linux
: Normal normal (vote)
Assignee: Cross compilation support
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-12-28 17:49 UTC by smalcom
Modified: 2024-03-28 17:37 UTC (History)
7 users (show)

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


Attachments
All related journals (crossdev_journals.tar.xz,375.33 KB, application/xz)
2022-12-28 17:54 UTC, smalcom
Details
stage 2 build logs (cross-armv7a-hardfloat-linux-gnueabihf-gcc-stage2.log.xz,61.61 KB, application/x-xz)
2023-02-21 10:51 UTC, Alexander Puchmayr
Details
emerge info + gcc stage2 build logs (emerge_and_gcc_build_logs.tar.xz,136.55 KB, application/xz)
2023-06-25 01:48 UTC, Raffaello D. Di Napoli
Details

Note You need to log in before you can comment on or make changes to this bug.
Description smalcom 2022-12-28 17:49:58 UTC
Trying to build Aarch64 toolchain:
> sudo crossdev -S -t aarch64-unknown-linux-gnu

at stage "Emerging cross-gcc-stage2 ..." i got error:
> configure: error: Pthreads are required to build libgomp
in "/var/log/portage/cross-aarch64-unknown-linux-gnu-gcc-stage2.log".

Also tried last version of tools with
> sudo crossdev -C aarch64-unknown-linux-gnu
> sudo crossdev -S -t aarch64-unknown-linux-gnu
and got same error.


Reproducible: Always

Steps to Reproduce:
sudo crossdev -S -t aarch64-unknown-linux-gnu
Actual Results:  
configure: error: Pthreads are required to build libgomp

Expected Results:  
All installed without error

emerge --info:

Portage 3.0.41 (python 3.10.9-final-0, default/linux/amd64/17.1/no-multilib, gcc-11, glibc-2.36-r5, 4.19.267-gentoo.sm1 x86_64)
=================================================================
System uname: Linux-4.19.267-gentoo.sm1-x86_64-AMD_FX-tm-8320_Eight-Core_Processor-with-glibc2.36
KiB Mem:    16387692 total,   4048448 free
KiB Swap:          0 total,         0 free
Timestamp of repository gentoo: Wed, 28 Dec 2022 10:30:01 +0000
Head commit of repository gentoo: 372a5a07454d9639208967a510bc62462267a7d8
sh bash 5.1_p16-r2
ld GNU ld (Gentoo 2.38 p4) 2.38
app-misc/pax-utils:        1.3.5::gentoo
app-shells/bash:           5.1_p16-r2::gentoo
dev-java/java-config:      2.3.1::gentoo
dev-lang/perl:             5.36.0-r1::gentoo
dev-lang/python:           3.10.9::gentoo, 3.11.1::gentoo
dev-lang/rust-bin:         1.65.0::gentoo
dev-util/cmake:            3.24.3::gentoo
dev-util/meson:            0.63.3::gentoo
sys-apps/baselayout:       2.9::gentoo
sys-apps/openrc:           0.45.2-r2::gentoo
sys-apps/sandbox:          2.29::gentoo
sys-devel/autoconf:        2.13-r7::gentoo, 2.71-r5::gentoo
sys-devel/automake:        1.16.5::gentoo
sys-devel/binutils:        2.38-r2::gentoo
sys-devel/binutils-config: 5.4.1::gentoo
sys-devel/gcc:             10.4.1_p20221208::gentoo, 11.3.1_p20221209::gentoo
sys-devel/gcc-config:      2.8::gentoo
sys-devel/libtool:         2.4.7::gentoo
sys-devel/llvm:            15.0.6::gentoo
sys-devel/make:            4.3::gentoo
sys-kernel/linux-headers:  5.15-r3::gentoo (virtual/os-headers)
sys-libs/glibc:            2.36-r5::gentoo
Repositories:

gentoo
    location: /mnt/stor5/var/db/repos/gentoo
    sync-type: rsync
    sync-uri: rsync://rsync.gentoo.org/gentoo-portage
    priority: -1000
    sync-rsync-verify-metamanifest: yes
    sync-rsync-extra-opts: 
    sync-rsync-verify-jobs: 1
    sync-rsync-verify-max-age: 24

booboo
    location: /mnt/stor5/var/lib/layman/booboo
    masters: gentoo
    priority: 50

gerislay
    location: /mnt/stor5/var/lib/layman/gerislay
    masters: gentoo
    priority: 50

phackerlay
    location: /mnt/stor5/var/lib/layman/phackerlay
    masters: gentoo
    priority: 50

ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="*"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-O2 -pipe -mtune=native"
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/php/fpm-php8.1/ext-active/ /etc/php/phpdbg-php8.1/ext-active/ /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-O2 -pipe -mtune=native"
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 XDG_STATE_HOME"
FCFLAGS="-O2 -pipe -mtune=native"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs binpkg-multi-instance buildpkg buildpkg-live compressdebug 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 splitdebug strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2 -pipe -mtune=native"
GENTOO_MIRRORS="http://distfiles.gentoo.org"
LANG="ru_RU.utf8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
LEX="flex"
LINGUAS="en ru"
MAKEOPTS="-j6"
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="X aac acl acpi alsa amd64 bzip2 cdr cups curl dbus djvu dri dvd dvdr exif ffmmpeg flac fontconfig ftp gif git gnutls gsm gui gzip iconv icu idn imlib jpeg jpeg2k lcms libglvnd luajit lz4 lzma lzo magic matroska mikmod mng modplug mp3 mp4 mtp musepack nls ogg openal opengl openmp opus pcre pdf png readline sdl slang smp sound speex split-usr startup-notification subversion svg syslog test-rust theora threads tiff timidity truetype udev unicode usb v4l vaapi vcd vdpau vnc vorbis wavpack webp x264 xattr xcb xinerama xpm xv xvid zip zlib" ABI_X86="64" APACHE2_MODULES="alias auth_basic auth_digest authn_core authz_core authz_host autoindex dir mime session socache_shmcb status unixd" CPU_FLAGS_X86="aes avx f16c fma3 fma4 mmx mmxext pclmul popcnt sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3 xop" ELIBC="glibc" GRUB_PLATFORMS="pc" INPUT_DEVICES="evdev" KERNEL="linux" L10N="en ru" LLVM_TARGETS="AMDGPU X86" LUA_SINGLE_TARGET="luajit" PYTHON_SINGLE_TARGET="python3_10" PYTHON_TARGETS="python3_10" USERLAND="GNU" VIDEO_CARDS="radeon radeonsi"
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, 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
Comment 1 smalcom 2022-12-28 17:54:53 UTC
Created attachment 845495 [details]
All related journals
Comment 2 zabrinski 2023-02-15 17:59:59 UTC
If it helps:
"crossdev" runs without error using glibc-2.33-r13 (and before).
Error "pthreads" occurs first when using glibc-2.34-r10.
Comment 3 Alexander Puchmayr 2023-02-21 10:51:55 UTC
Created attachment 853482 [details]
stage 2 build logs

Same happened here creating an armv7a cross-compiler gcc-12
Comment 4 zabrinski 2023-02-24 20:10:16 UTC
Not a solution, but compiling aarch64/glibc with USE=static-libs cured the problem for me.
(repeated from https://forums.gentoo.org/viewtopic-t-1157929.html)
Comment 5 Raffaello D. Di Napoli 2023-06-25 01:36:22 UTC
Just ran into this myself. In my case, the gcc lib that fails to find pthreads is libatomic, but everything else matches what I found in this ticket, including the workaround: adding USE=static-libs to cross-aarch64-unknown-linux-gnueabi/glibc allowed cross-aarch64-unknown-linux-gnueabi/gcc stage2 to build successfully.

Worth noting that I had a working cross-compiler before, then didn’t upgrade this box for some 2 years, and after upgrading @world I started running into this error. This would indicate it’s a regression. I tried using gcc-11.3.1_p20230427 (the second-latest stable) as cross-compiler, but that didn’t make a difference; only adding USE=static-libs did.

I suspect more and more people will be running into this, as they install or update their working cross-toolchain and find that stage2 builds are broken.
Comment 6 Raffaello D. Di Napoli 2023-06-25 01:40:21 UTC
Oh, and I did not try downgrading glibc because there’s only one stable version of glibc for arm64, so I didn’t see the point since I wouldn’t care to see a masked package build successfully.
Comment 7 Raffaello D. Di Napoli 2023-06-25 01:48:11 UTC
Created attachment 864588 [details]
emerge info + gcc stage2 build logs
Comment 8 Alexander Puchmayr 2023-11-02 09:26:27 UTC
Indeed, as zabrinski@gmx.de pointed out, adding static-libs to package use helps. In my case this looked like:

$ cat /etc/portage/package.use/cross-armv7a
cross-armv7a-unknown-linux-gnueabihf/glibc      static-libs

Note that it has to be the cross compiled glibc and not the host glibc!
Comment 9 Petre Rodan 2024-01-24 10:20:31 UTC
tried to run
crossdev --stable --target aarch64_be-unknown-linux-gnu  or
emerge -q cross-aarch64_be-unknown-linux-gnu/gcc
but it kept failing with

checking for __atomic_fetch_op for size 8... yes
checking for __atomic_fetch_op for size 16... no
checking whether byte ordering is bigendian... yes
checking for the word size... 8
configure: error: Pthreads are required to build libatomic
make[1]: *** [Makefile:17012: configure-target-libatomic] Error 1
make[1]: Leaving directory '/dev/shm/portage/cross-aarch64_be-unknown-linux-gnu/gcc-13.2.1_p20240113-r1/work/build'

none of the magic fixes from the comments above have worked, so I came up with my own, which worked for me:

--- 8< --------------
echo '!<arch>' > /usr/aarch64_be-unknown-linux-gnu/usr/lib64/libpthread.a
--- >8 --------------

voila. perfection. that file was missing on in my BE toolchain, but present in /usr/aarch64-unknown-linux-gnu (the little endian toolchain).
merging the cross gcc now works without problems.

should I open a new ticket for my case or is it close enough to this ticket here?

my use flags:

[ebuild   R    ] cross-aarch64_be-unknown-linux-gnu/gcc-13.2.1_p20240113-r1:13::crossdev  USE="cxx hardened openmp (pie) (ssp) zstd -ada -cet -custom-cflags -d -debug -default-stack-clash-protection -default-znow -doc -fixed-point -fortran -go -graphite -ieee-long-double -jit -libssp -lto -modula2 (-multilib) -nls -objc -objc++ -objc-gc (-pch) -pgo -sanitize -systemtap -test -valgrind -vanilla -vtv" 0 KiB
[ebuild   R    ] cross-aarch64_be-unknown-linux-gnu/glibc-2.38-r9:2.2::crossdev  USE="caps crypt (ssp) -audit -cet -compile-locales -custom-cflags -doc -gd -hash-sysv-compat -headers-only -multiarch (-multilib) -multilib-bootstrap -nscd -perl -profile (-selinux) -stack-realign -static-libs -suid -systemd -systemtap -test -vanilla" 0 KiB
Comment 10 Emanuel Czirai 2024-03-28 17:37:01 UTC
Surprisingly, the workaround in Comment 9 worked(I had the same compile error). Thank you!

# cat /usr/aarch64-unknown-linux-gnu/usr/lib64/libpthread.a
!<arch>

I didn't try the other workarounds.

Used for this:
# crossdev --target aarch64-unknown-linux-gnu