Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 799707 - =sys-devel/gcc-11.1.0-r1 fails to bootrap as a cross compiler with new libxcrypt changes
Summary: =sys-devel/gcc-11.1.0-r1 fails to bootrap as a cross compiler with new libxcr...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Toolchain Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: libxcrypt-migration
  Show dependency tree
 
Reported: 2021-07-01 12:26 UTC by tt_1
Modified: 2021-07-18 09:33 UTC (History)
4 users (show)

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


Attachments
compressed build log (cross-aarch64-unknown-linux-gnu-gcc-stage2.log.gz,200.20 KB, application/gzip)
2021-07-01 12:26 UTC, tt_1
Details
output from emerge --info (host) (emerge-info,5.35 KB, text/plain)
2021-07-01 12:27 UTC, tt_1
Details
hosts make.conf (make.conf,682 bytes, text/plain)
2021-07-03 07:16 UTC, tt_1
Details

Note You need to log in before you can comment on or make changes to this bug.
Description tt_1 2021-07-01 12:26:52 UTC
Created attachment 720783 [details]
compressed build log

I ran into this the other day, when I had USE="-crypt" in my hosts make.conf (for reasons I forgot) 

here is the error from the build log: 

/var/tmp/portage/cross-aarch64-unknown-linux-gnu/gcc-11.1.0-r1/work/gcc-11.1.0/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp:144:10: fatal error: crypt.h: No such file or directory
  144 | #include <crypt.h>
      |          ^~~~~~~~~
compilation terminated.
make[4]: *** [Makefile:615: sanitizer_platform_limits_posix.lo] Error 1
make[4]: *** Waiting for unfinished jobs....


I solved this by removing the USE="-crypt" from the hosts make.conf, but I'm unsure about what to do now, with the new changes ahead. Since this is only a chroot to test gcc-11 with, I already switched over to a hosts sys-libs/glibc without the crypt useflag. 

Should I add +crypt for the cross-glibc then - or is that not a longterm problem solver? I might guess the useflag will be removed, once the switch is complete. 

cross toolchain is: 

sys-devel/binutils-2.35.2
sys-kernel/linux-headers-5.10
sys-libs/glibc-2.33
sys-devel/gcc-11.1.0-r1

the full build log is attached as compressed gz
Comment 1 tt_1 2021-07-01 12:27:41 UTC
Created attachment 720786 [details]
output from emerge --info (host)
Comment 2 tt_1 2021-07-01 13:10:22 UTC
current workaround: 

emerge -pv cross-aarch64-unknown-linux-gnu/glibc

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild   R   ~] cross-aarch64-unknown-linux-gnu/glibc-2.33-r1:2.2::crossdev  USE="crypt* multiarch ssp static-libs -audit -caps -cet -compile-locales -custom-cflags -doc -gd -headers-only -multilib -multilib-bootstrap -nscd -profile (-selinux) -static-pie -suid -systemtap -test -vanilla" 0 KiB
Comment 3 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2021-07-01 20:33:20 UTC
Was libxcrypt[system] installed in this case?
Comment 4 tt_1 2021-07-01 20:37:22 UTC
yes, this was done in a chroot where I already performed the upgrade to libxcrypt[system] for the host. 

but the bug can also be triggered on a host where that move hasn't been made, simply by passing over USE="-crypt" to the cross-glibc. I did this accidentially via hosts make.conf a few days ago.
Comment 5 Joshua Kinard gentoo-dev 2021-07-01 22:44:46 UTC
Have you tried using sys-devel/crossdev to merge the cross-compiler in?  I just manually migrated my developer machine over to libxcrypt, and rebuilt my cross-compiler target (mips64) and it did not have any issues.  I did mask the 'crypt' USE for my cross-compiler target in /etc/portage/package.use and /etc/portage/profile/package.use.force, just like for sys-libs/glibc beforehand.

Make sure you're following this guide as well if you want to migrate early:
https://wiki.gentoo.org/wiki/Project:Toolchain/libcrypt_implementation
Comment 6 Ionen Wolkens gentoo-dev 2021-07-02 04:05:56 UTC
Just tried with cross aarch64 and stage2 went without issues on my libxcrypt system (both host and cross glibc have -crypt).

I find it curious that in your case it's trying to build libsanitizer at all, it doesn't for me. If anything crossdev tries to add -sanitize to package.use
Comment 7 tt_1 2021-07-02 08:44:49 UTC
here are the final useflags of cross-glibc and cross-gcc

Calculating dependencies... done!
[ebuild   R   ~] cross-aarch64-unknown-linux-gnu/glibc-2.33-r1:2.2::crossdev  USE="crypt multiarch ssp static-libs -audit -caps -cet -compile-locales -custom-cflags -doc -gd -headers-only -multilib -multilib-bootstrap -nscd -profile (-selinux) -static-pie -suid -systemtap -test -vanilla" 0 KiB
[ebuild   R   ~] cross-aarch64-unknown-linux-gnu/gcc-11.1.0-r1:11::crossdev  USE="cxx fortran nls nptl openmp pch pie sanitize ssp -ada -custom-cflags -d -debug -doc (-fixed-point) -go -graphite -hardened -jit -libssp -lto -multilib -objc -objc++ -objc-gc -pgo -systemtap -test -valgrind -vanilla -vtv -zstd" 0 KiB

I haven't touched any of those useflags, so you think this is a bug in crossdev where it should be USE="-sanitize" for cross-gcc?
Comment 8 Ionen Wolkens gentoo-dev 2021-07-02 09:00:23 UTC
From package.use/cross-aarch64-unknown-linux-gnu (created by crossdev):

cross-aarch64-unknown-linux-gnu/gcc -vtv -selinux -boundschecking -d -gcj -gtk -libffi -mudflap -objc -objc++ -objc-gc -fortran -go -jit -cxx -mpx -openmp -sanitize -vtv -multilib

Maybe you have something conflicting.
Comment 9 tt_1 2021-07-02 10:28:12 UTC
so here is my command to crossdev:

crossdev -S aarch64-unknown-linux-gnu --gcc 11.1.0-r1 --ov-output /var/lib/layman/crossdev/ --init-target
-                                                                                                                                                                                       
 * crossdev version:      20210621
 * Host Portage ARCH:     amd64
 * Host Portage System:   x86_64-pc-linux-gnu (i686-pc-linux-gnu x86_64-pc-linux-gnu)
 * Target Portage ARCH:   arm64
 * Target System:         aarch64-unknown-linux-gnu
 * Stage:                 4 (C/C++ compiler)
 * USE=multilib:          no
 * Target ABIs:           arm64

 * binutils:              binutils-[stable]
 * gcc:                   gcc-11.1.0-r1
 * headers:               linux-headers-[stable]
 * libc:                  glibc-[stable]

 * CROSSDEV_OVERLAY:      /var/lib/layman/crossdev/
 * PORT_LOGDIR:           /var/log/portage
 * PORTAGE_CONFIGROOT:    /
 * Portage flags:         

but still sanitize is not disabled in package.use: 

cat /etc/portage/package.use/cross-aarch64-unknown-linux-gnu 
cross-aarch64-unknown-linux-gnu/binutils -multilib
cross-aarch64-unknown-linux-gnu/linux-headers -selinux -multilib
cross-aarch64-unknown-linux-gnu/glibc -selinux -libraries -multilib
cross-aarch64-unknown-linux-gnu/gcc -vtv -selinux -boundschecking -d -gcj -gtk -libffi -mudflap -objc -objc++ -objc-gc -multilib


and nothing changed anywhere else inside of hosts /etc/portage: 
/etc/portage # grep -r sanitize
Comment 10 Andreas K. Hüttel archtester gentoo-dev 2021-07-02 21:01:16 UTC
it's odd indeed that you build the sanitizer

have you set a specific profile inside your crossdev environment?
see /usr/aarch64-unknown-linux-gnu/etc/portage
Comment 11 tt_1 2021-07-03 06:43:01 UTC
Did you mean to ask for the target of the make.profile symlink in that folder? That is the default symlink, pointing to /var/db/repos/gentoo/profiles/embedded

I also think that this problem is specific to gcc-11, I had the -crypt for longer period of time in my hosts make.conf, and it didn't trigger any problems with gcc-10 or gcc-9 based toolchains. Will double check in the evening.
Comment 12 tt_1 2021-07-03 07:16:40 UTC
Created attachment 721215 [details]
hosts make.conf
Comment 13 tt_1 2021-07-03 07:18:22 UTC
hosts profile is 

  [1]   default/linux/amd64/17.1 (stable) *
Comment 14 Cănărău Constantin 2021-07-03 13:16:37 UTC
I can confirm, same issue here:
fatal error: crypt.h: No such file or directory
  144 | #include <crypt.h>

As glibc crypt support will be gone at some point, I did:

aarch64-unknown-linux-gnu-emerge virtual/libcrypt 

libxcrypt system flag was set and gcc was able to compile with cross-aarch64-unknown-linux-gnu/glibc -crypt
Comment 15 tt_1 2021-07-03 13:20:29 UTC
(In reply to Cănărău Constantin from comment #14)
> I can confirm, same issue here:
> fatal error: crypt.h: No such file or directory
>   144 | #include <crypt.h>
> 
> As glibc crypt support will be gone at some point, I did:
> 
> aarch64-unknown-linux-gnu-emerge virtual/libcrypt 
> 
> libxcrypt system flag was set and gcc was able to compile with
> cross-aarch64-unknown-linux-gnu/glibc -crypt

so when stage2 cross-gcc failed, you emerged libxcrypt[system] into the half bootstrapped rootfs, and then continued with building the stage2 cross-gcc?
Comment 16 Cănărău Constantin 2021-07-04 12:48:02 UTC
(In reply to tt_1 from comment #15)
> 
> so when stage2 cross-gcc failed, you emerged libxcrypt[system] into the half
> bootstrapped rootfs, and then continued with building the stage2 cross-gcc?

No, I did that on an existing system. 
cross-aarch64-unknown-linux-gnu/glibc and cross-aarch64-unknown-linux-gnu/gcc were compiled before.

Changed glibc to -crypt according to: https://wiki.gentoo.org/wiki/Project:Toolchain/libcrypt_implementation

cross-aarch64-unknown-linux-gnu/glibc was recompiled automatically with success.
I tried to compile cross-aarch64-unknown-linux-gnu/gcc to see if everything is alright and it fail.

Then I tried the workaround with aarch64-unknown-linux-gnu-emerge virtual/libcrypt which pulled, among other dependencies, libxcrypt[system]
Comment 17 tt_1 2021-07-05 10:59:42 UTC
(In reply to Cănărău Constantin from comment #16)
> (In reply to tt_1 from comment #15)
> > 
> > so when stage2 cross-gcc failed, you emerged libxcrypt[system] into the half
> > bootstrapped rootfs, and then continued with building the stage2 cross-gcc?
> 
> No, I did that on an existing system. 
> cross-aarch64-unknown-linux-gnu/glibc and
> cross-aarch64-unknown-linux-gnu/gcc were compiled before.
> 
> Changed glibc to -crypt according to:
> https://wiki.gentoo.org/wiki/Project:Toolchain/libcrypt_implementation
> 
> cross-aarch64-unknown-linux-gnu/glibc was recompiled automatically with
> success.
> I tried to compile cross-aarch64-unknown-linux-gnu/gcc to see if everything
> is alright and it fail.
> 
> Then I tried the workaround with aarch64-unknown-linux-gnu-emerge
> virtual/libcrypt which pulled, among other dependencies, libxcrypt[system]

this bug is about the failure in bootstrapping the cross-gcc stage2 compiler with crossdev, populating the rootfs is another story. I will test it, when this bug has been dealt with.
Comment 18 Andreas K. Hüttel archtester gentoo-dev 2021-07-14 19:39:16 UTC
Unfortunately I can't reproduce this here. Crossdev works just fine.

(~amd64 chroot) crossdev ~ # crossdev -S --target aarch64-unknown-linux-gnu --gcc 11.1.0-r2
-                                                                                                                                                                                                     
 * crossdev version:      20210621
 * Host Portage ARCH:     amd64
 * Host Portage System:   x86_64-pc-linux-gnu (i686-pc-linux-gnu x86_64-pc-linux-gnu)
 * Target Portage ARCH:   arm64
 * Target System:         aarch64-unknown-linux-gnu
 * Stage:                 4 (C/C++ compiler)
 * USE=multilib:          no
 * Target ABIs:           arm64

 * binutils:              binutils-[stable]
 * gcc:                   gcc-11.1.0-r2
 * headers:               linux-headers-[stable]
 * libc:                  glibc-[stable]

 * CROSSDEV_OVERLAY:      /usr/local/portage/crossdev
 * PORT_LOGDIR:           /var/log/portage
 * PORTAGE_CONFIGROOT:    /
 * Portage flags:         
                                                                                                                                                                                                      
 * leaving metadata/layout.conf alone in /usr/local/portage/crossdev
                                                                                                                                                                                                      
 * Log: /var/log/portage/cross-aarch64-unknown-linux-gnu-binutils.log
 * Emerging cross-binutils ...                                                                                                                                                                  [ ok ]
 * Log: /var/log/portage/cross-aarch64-unknown-linux-gnu-gcc-stage1.log
 * Emerging cross-gcc-stage1 ...                                                                                                                                                                [ ok ]
 * Log: /var/log/portage/cross-aarch64-unknown-linux-gnu-linux-headers.log
 * Emerging cross-linux-headers ...                                                                                                                                                             [ ok ]
 * Log: /var/log/portage/cross-aarch64-unknown-linux-gnu-glibc.log
 * Emerging cross-glibc ...                                                                                                                                                                     [ ok ]
 * Log: /var/log/portage/cross-aarch64-unknown-linux-gnu-gcc-stage2.log
 * Emerging cross-gcc-stage2 ...                                                                                                                                                                [ ok ]
(~amd64 chroot) crossdev ~ #
Comment 19 Sergei Trofimovich (RETIRED) gentoo-dev 2021-07-14 20:39:44 UTC
Do yo have USE=sanitize in make.conf? That is a prerequisite to get stage2 to attempt to build it.
Comment 20 tt_1 2021-07-14 21:10:46 UTC
USE="+sanitize" is picked up from profile I believe, isn't it?
Comment 21 Ionen Wolkens gentoo-dev 2021-07-15 00:20:53 UTC
(In reply to tt_1 from comment #9)
> but still sanitize is not disabled in package.use: 
> [...]

How old are those package.use files that don't disable sanitize? I guess it's possible crossdev is not updating them.

I've been testing with a blank state, so may be why can't reproduce.
Comment 22 tt_1 2021-07-17 21:41:06 UTC
latest changes in toolchain.eclass solve this bug for native toolchains: https://github.com/gentoo/gentoo/commit/85c6de2213e35965d2e7c79c06d9e9b9d6af7e0d

do we have to patch crossdev, or what is the most likely outcome here?
Comment 23 Sergei Trofimovich (RETIRED) gentoo-dev 2021-07-17 22:04:48 UTC
On ~arch
    # USE=-crypt crossdev aarch64-unknown-linux-gnu
is enough to trigger sanitize build against /usr/$CTARGET without crypt.h

crossdev ignores DEPENDs for gcc and generally assumes low/no dependencies on target headers. Unfortunately USE=sanitize pulls in crypt.h (https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=85c6de2213e35965d2e7c79c06d9e9b9d6af7e0d would be effective for native builds).

The simplest workaround would be to disable USE=sanitize in gcc-stage2 in crossdev (the same way we do it for stage1) and rely on user to install libxcrypt later.
Comment 24 Sergei Trofimovich (RETIRED) gentoo-dev 2021-07-17 22:06:51 UTC
Until crossdev is fixed
    # USE=-sanitize crossdev aarch64-unknown-linux-gnu
or
    # USE=crypt crossdev aarch64-unknown-linux-gnu
should work as a workaround.
Comment 25 Larry the Git Cow gentoo-dev 2021-07-17 23:38:52 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/crossdev.git/commit/?id=5d7a0f2bd35ea01f24883bc2e21e1bda5458584e

commit 5d7a0f2bd35ea01f24883bc2e21e1bda5458584e
Author:     Sergei Trofimovich <slyfox@gentoo.org>
AuthorDate: 2021-07-17 23:37:58 +0000
Commit:     Sergei Trofimovich <slyfox@gentoo.org>
CommitDate: 2021-07-17 23:37:58 +0000

    crossdev: disable USE=sanitize for gcc-stage2 as well
    
    Reported-by: tt_1
    Bug: https://bugs.gentoo.org/799707
    Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>

 crossdev | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
Comment 26 Larry the Git Cow gentoo-dev 2021-07-17 23:51:58 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=14ecd1b309eafd75602966418ce9600c0e99cf0e

commit 14ecd1b309eafd75602966418ce9600c0e99cf0e
Author:     Sergei Trofimovich <slyfox@gentoo.org>
AuthorDate: 2021-07-17 23:51:09 +0000
Commit:     Sergei Trofimovich <slyfox@gentoo.org>
CommitDate: 2021-07-17 23:51:55 +0000

    sys-devel/crossdev: bump up to 20210718
    
    Single new change:
    - disable USE=sanitize for gcc-stage2 as well
    
    Reported-by: tt_1
    Closes: https://bugs.gentoo.org/799707
    Package-Manager: Portage-3.0.20, Repoman-3.0.3
    Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>

 sys-devel/crossdev/Manifest                 |  1 +
 sys-devel/crossdev/crossdev-20210718.ebuild | 35 +++++++++++++++++++++++++++++
 sys-devel/crossdev/crossdev-99999999.ebuild |  2 +-
 3 files changed, 37 insertions(+), 1 deletion(-)