Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 723324 - =dev-libs/nss-3.52 fails to cross compile to aarch64
Summary: =dev-libs/nss-3.52 fails to cross compile to aarch64
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Cross compilation support
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-05-16 08:45 UTC by tt_1
Modified: 2020-06-19 07:58 UTC (History)
2 users (show)

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


Attachments
build.log from cross compiling (build.log,4.47 KB, text/x-log)
2020-05-16 08:46 UTC, tt_1
Details
output from emerge --info (emerge-info,5.18 KB, text/plain)
2020-05-16 08:48 UTC, tt_1
Details
output from cross-emerge --info (emerge-info-cross,4.66 KB, text/plain)
2020-05-16 08:49 UTC, tt_1
Details

Note You need to log in before you can comment on or make changes to this bug.
Description tt_1 2020-05-16 08:45:14 UTC
there's an error somewhere in the arch detection, and I'm really sorry but the way the ebuild is coded it simply breaks my brain, I don't understand how it works. Anyway, here's the error: 


>>> Emerging (1 of 1) dev-libs/nss-3.52::gentoo for /usr/aarch64-unknown-linux-gnu/
 * nss-3.52.tar.gz BLAKE2B SHA512 size ;-) ...                                                                                                                                   [ ok ]
>>> Unpacking source...
>>> Unpacking nss-3.52.tar.gz to /usr/aarch64-unknown-linux-gnu/tmp/portage/dev-libs/nss-3.52/work
>>> Source unpacked in /usr/aarch64-unknown-linux-gnu/tmp/portage/dev-libs/nss-3.52/work
>>> Preparing source in /usr/aarch64-unknown-linux-gnu/tmp/portage/dev-libs/nss-3.52/work/nss-3.52/nss ...
 * Applying nss-3.47-gentoo-fixups.patch ...                                                                                                                                     [ ok ]
 * Applying nss-3.21-gentoo-fixup-warnings.patch ...                                                                                                                             [ ok ]
 * Applying nss-3.23-hppa-byte_order.patch ...                                                                                                                                   [ ok ]
 * Will copy sources from /usr/aarch64-unknown-linux-gnu/tmp/portage/dev-libs/nss-3.52/work/nss-3.52/nss
 * .arm64: copying to /usr/aarch64-unknown-linux-gnu/tmp/portage/dev-libs/nss-3.52/work/nss-3.52/nss-.arm64
 * strip-flags: CFLAGS: changed '-O2 -pipe -fomit-frame-pointer' to '-O2 -pipe'
 * strip-flags: CXXFLAGS: changed '-O2 -pipe -fomit-frame-pointer' to '-O2 -pipe'
>>> Source prepared.
>>> Configuring source in /usr/aarch64-unknown-linux-gnu/tmp/portage/dev-libs/nss-3.52/work/nss-3.52/nss ...
 * .arm64: running multilib-minimal_abi_src_configure
>>> Source configured.
>>> Compiling source in /usr/aarch64-unknown-linux-gnu/tmp/portage/dev-libs/nss-3.52/work/nss-3.52/nss ...
 * .arm64: running multilib-minimal_abi_src_compile
make -j12 -j1 -C coreconf CC=i686-pc-linux-gnu-gcc USE_64=1 
make: Entering directory '/usr/aarch64-unknown-linux-gnu/tmp/portage/dev-libs/nss-3.52/work/nss-3.52/nss-.arm64/coreconf'
../coreconf/arch.mk:150: CPU_ARCH is not x86_64, disabling -mavx2
cd nsinstall; make export
make[1]: Entering directory '/usr/aarch64-unknown-linux-gnu/tmp/portage/dev-libs/nss-3.52/work/nss-3.52/nss-.arm64/coreconf/nsinstall'
make[1]: Nothing to be done for 'export'.
make[1]: Leaving directory '/usr/aarch64-unknown-linux-gnu/tmp/portage/dev-libs/nss-3.52/work/nss-3.52/nss-.arm64/coreconf/nsinstall'
cd nsinstall; make libs
make[1]: Entering directory '/usr/aarch64-unknown-linux-gnu/tmp/portage/dev-libs/nss-3.52/work/nss-3.52/nss-.arm64/coreconf/nsinstall'
i686-pc-linux-gnu-gcc -o Linux5.4_x86_64_i686-pc-linux-gnu-gcc_glibc_PTH_64_OPT.OBJ/nsinstall.o -c -std=c99 -O2 -fno-strict-aliasing -fPIC  -m64 -pipe -ffunction-sections -fdata-sections -DHAVE_STRERROR -DLINUX -Dlinux -Wall -Wshadow -DNSS_NO_GCC48 -DXP_UNIX -UDEBUG -DNDEBUG -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_SOURCE -DSQL_MEASURE_USE_TEMP_DIR -D_REENTRANT -DNSS_DISABLE_AVX2 -DNSS_NO_INIT_SUPPORT -DSEED_ONLY_DEV_URANDOM -DUSE_UTIL_DIRECTLY -DNO_NSPR_10_SUPPORT -DSSL_DISABLE_DEPRECATED_CIPHER_SUITE_NAMES -I../../dist/Linux5.4_x86_64_i686-pc-linux-gnu-gcc_glibc_PTH_64_OPT.OBJ/include -I../../dist/public/coreconf -I../../dist/private/coreconf -I../../dist/Linux5.4_x86_64_i686-pc-linux-gnu-gcc_glibc_PTH_64_OPT.OBJ/include/dbm -O2 -pipe nsinstall.c
cc1: error: CPU you selected does not support x86-64 instruction set
make[1]: *** [../../coreconf/rules.mk:393: Linux5.4_x86_64_i686-pc-linux-gnu-gcc_glibc_PTH_64_OPT.OBJ/nsinstall.o] Error 1
make[1]: Leaving directory '/usr/aarch64-unknown-linux-gnu/tmp/portage/dev-libs/nss-3.52/work/nss-3.52/nss-.arm64/coreconf/nsinstall'
make: *** [../coreconf/rules.mk:101: libs] Error 2
make: Leaving directory '/usr/aarch64-unknown-linux-gnu/tmp/portage/dev-libs/nss-3.52/work/nss-3.52/nss-.arm64/coreconf'


from this input: 

[ebuild  N    ~] dev-libs/nss-3.52::gentoo to /usr/aarch64-unknown-linux-gnu/ USE="-cacert -utils" 0 KiB
Comment 1 tt_1 2020-05-16 08:46:42 UTC
Created attachment 639502 [details]
build.log from cross compiling
Comment 2 tt_1 2020-05-16 08:48:46 UTC
Created attachment 639504 [details]
output from emerge --info
Comment 3 tt_1 2020-05-16 08:49:12 UTC
Created attachment 639506 [details]
output from cross-emerge --info
Comment 4 tt_1 2020-05-16 08:53:07 UTC
If anyone goes through the logs and is confused about i686 toolchain and x86_64 kernel: this setup is a i686 stage3, which I unpacked and chroot into for trying to build up a i686 to aarch64 based cross compiler toolchain. 

The reason for doing this is that I'm trying to find the reason for a weird header missmatch bug in cross compiling firefox from amd64 host to arm64 target, and feeling I'm the only one doing this I needed another data point to get more evidence. 

cross compiling dev-libs/nss from amd64 host to arm64 target works, same with amd64 host and armv7 target
Comment 5 James Le Cuirot gentoo-dev 2020-05-20 19:09:26 UTC
Yeah, judging by the output, it's specifically 32-bit building for 64-bit that breaks here.
Comment 6 James Le Cuirot gentoo-dev 2020-05-20 19:35:32 UTC
> make -j12 -j1 -C coreconf CC=i686-pc-linux-gnu-gcc USE_64=1

This is the smoking gun. ABI is presumably arm64 so mybits must be set to USE_64=1. The buildbits=$(nssbits BUILD_) call returns nothing in the 32-bit CBUILD case. We then have ${buildbits:-${mybits}} later and therein lies the problem. Please retry with the : removed, so it's just ${buildbits-${mybits}}.
Comment 7 tt_1 2020-05-20 20:08:06 UTC
thank you so much for your answer, I tried this: 

diff --git a/nss-3.52.ebuild b/nss-3.52.ebuild
index 3014f80..eb6d244 100644
--- a/nss-3.52.ebuild
+++ b/nss-3.52.ebuild
@@ -177,7 +177,7 @@ multilib_src_compile() {
 	NSPR_LIB_DIR="${T}/fakedir" \
 	emake -j1 -C coreconf \
 		CC="$(tc-getBUILD_CC)" \
-		${buildbits:-${mybits}}
+		${buildbits-${mybits}}
 	makeargs+=( NSINSTALL="${PWD}/$(find -type f -name nsinstall)" )
 
 	# Then build the target tools.

and it worked, as in: 

1. native i686
2. i686 to aarch64

3. native amd64
4. amd64 to armv7
5. amd64 to aarch64


I'm still amazed about the uproar one simple missplaced colon has caused :D
Comment 8 James Le Cuirot gentoo-dev 2020-05-21 08:46:07 UTC
Mozilla team, I'll apply this in a week if you don't raise any concerns.
Comment 9 tt_1 2020-06-07 07:24:02 UTC
so, are there any objections against this?
Comment 10 Larry the Git Cow gentoo-dev 2020-06-07 11:26:44 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=925c79e2672da8f8bb4995b38735721f6ba863b9

commit 925c79e2672da8f8bb4995b38735721f6ba863b9
Author:     James Le Cuirot <chewi@gentoo.org>
AuthorDate: 2020-06-07 11:22:03 +0000
Commit:     James Le Cuirot <chewi@gentoo.org>
CommitDate: 2020-06-07 11:26:19 +0000

    dev-libs/nss: Fix cross-compiling from 32-bit to 64-bit
    
    Closes: https://bugs.gentoo.org/723324
    Package-Manager: Portage-2.3.100, Repoman-2.3.22
    Signed-off-by: James Le Cuirot <chewi@gentoo.org>

 dev-libs/nss/nss-3.51.1.ebuild | 2 +-
 dev-libs/nss/nss-3.51.ebuild   | 2 +-
 dev-libs/nss/nss-3.52.1.ebuild | 2 +-
 dev-libs/nss/nss-3.52.ebuild   | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
Comment 11 tt_1 2020-06-19 07:50:34 UTC
hey, I'm reopening as the fix has been reverted with the bump of nss-3.53.1

propably without the intention, or were there any objections? @mozilla
Comment 12 Larry the Git Cow gentoo-dev 2020-06-19 07:58:30 UTC
The bug has been closed via the following commit(s):

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

commit b34443de419cfc164c98101594abcdb6f4000654
Author:     Lars Wendler <polynomial-c@gentoo.org>
AuthorDate: 2020-06-19 07:58:18 +0000
Commit:     Lars Wendler <polynomial-c@gentoo.org>
CommitDate: 2020-06-19 07:58:25 +0000

    dev-libs/nss: Re-add aarch64 cross compile fix
    
    Closes: https://bugs.gentoo.org/723324
    Package-Manager: Portage-2.3.101, Repoman-2.3.22
    Signed-off-by: Lars Wendler <polynomial-c@gentoo.org>

 dev-libs/nss/nss-3.53.1.ebuild | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)