Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 637634 - dev-libs/nss-3.33 build fails on k6-2+ processor (i586-class) with illegal instruction
Summary: dev-libs/nss-3.33 build fails on k6-2+ processor (i586-class) with illegal in...
Status: RESOLVED UPSTREAM
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Mozilla Gentoo Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-11-15 19:41 UTC by Calvin Walton
Modified: 2017-11-20 15:32 UTC (History)
0 users

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


Attachments
emerge --info (emerge-info-k6.txt,4.62 KB, text/plain)
2017-11-15 19:41 UTC, Calvin Walton
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Calvin Walton 2017-11-15 19:41:32 UTC
Created attachment 504448 [details]
emerge --info

Hi,

When attempting to build nss on my K6-2+ [1] system, the build fails partway through when it tries to run a just-built executable, which gives an Illegal instruction error:

/var/tmp/portage/dev-libs/nss-3.33/work/nss-3.33/nss-abi_x86_32.x86/./coreconf/nsinstall/Linux4.13_x86_i586-pc-linux-gnu-gcc_glibc_PTH_OPT.OBJ/nsinstall -t -m 775 Linux2.6_x86_i586-pc-linux-gnu-gcc_glibc_PTH_OPT.OBJ/mangle ../../../dist/Linux2.6_x86_i586-pc-linux-gnu-gcc_glibc_PTH_OPT.OBJ/bin
make[3]: Leaving directory '/var/tmp/portage/dev-libs/nss-3.33/work/nss-3.33/nss-abi_x86_32.x86/cmd/shlibsign/mangle'
cd Linux2.6_x86_i586-pc-linux-gnu-gcc_glibc_PTH_OPT.OBJ ; sh '/var/tmp/portage/dev-libs/nss-3.33/work/nss-3.33/nss-abi_x86_32.x86/cmd/shlibsign/.'/sign.sh '/var/tmp/portage/dev-libs/nss-3.33/work/nss-3.33/nss-abi_x86_32.x86/cmd/shlibsign/../../dist/Linux2.6_x86_i586-pc-linux-gnu-gcc_glibc_PTH_OPT.OBJ' \
'/var/tmp/portage/dev-libs/nss-3.33/work/nss-3.33/nss-abi_x86_32.x86/cmd/shlibsign/Linux2.6_x86_i586-pc-linux-gnu-gcc_glibc_PTH_OPT.OBJ' Linux \
'/var/tmp/portage/dev-libs/nss-3.33/temp/fakedir' '/var/tmp/portage/dev-libs/nss-3.33/work/nss-3.33/nss-abi_x86_32.x86/cmd/shlibsign/../../dist/Linux2.6_x86_i586-pc-linux-gnu-gcc_glibc_PTH_OPT.OBJ/lib/libsoftokn3.so'
/var/tmp/portage/dev-libs/nss-3.33/work/nss-3.33/nss-abi_x86_32.x86/cmd/shlibsign/./sign.sh: line 36: cd: /var/tmp/portage/dev-libs/nss-3.33/temp/fakedir: No such file or directory
/var/tmp/portage/dev-libs/nss-3.33/work/nss-3.33/nss-abi_x86_32.x86/cmd/shlibsign/Linux2.6_x86_i586-pc-linux-gnu-gcc_glibc_PTH_OPT.OBJ/shlibsign -v -i /var/tmp/portage/dev-libs/nss-3.33/work/nss-3.33/nss-abi_x86_32.x86/cmd/shlibsign/../../dist/Linux2.6_x86_i586-pc-linux-gnu-gcc_glibc_PTH_OPT.OBJ/lib/libsoftokn3.so
/var/tmp/portage/dev-libs/nss-3.33/work/nss-3.33/nss-abi_x86_32.x86/cmd/shlibsign/./sign.sh: line 13: 30345 Illegal instruction     (core dumped) "${2}"/shlibsign -v -i "${5}"
make[2]: *** [Makefile:92: ../../dist/Linux2.6_x86_i586-pc-linux-gnu-gcc_glibc_PTH_OPT.OBJ/lib/libsoftokn3.chk] Error 132
make[2]: Leaving directory '/var/tmp/portage/dev-libs/nss-3.33/work/nss-3.33/nss-abi_x86_32.x86/cmd/shlibsign'
make[1]: *** [../coreconf/rules.mk:101: libs] Error 2
make[1]: Leaving directory '/var/tmp/portage/dev-libs/nss-3.33/work/nss-3.33/nss-abi_x86_32.x86/cmd'
make: *** [coreconf/rules.mk:101: libs] Error 2
make: Leaving directory '/var/tmp/portage/dev-libs/nss-3.33/work/nss-3.33/nss-abi_x86_32.x86'

In the system logs, I see this:

Nov 12 19:33:43 mai kernel: traps: shlibsign[852] trap invalid opcode ip:b7aaceb6 sp:bf89c3d4 error:0 in libfreebl3.so[b7aa3000+81000]
Nov 12 19:33:44 mai systemd-coredump[854]: Process 852 (shlibsign) of user 250 dumped core.
                                           
                                           Stack trace of thread 852:
                                           #0  0x00000000b7aaceb6 n/a (/var/tmp/portage/dev-libs/nss-3.33/work/nss-3.33/nss-abi_x86_32.x86/dist/Linux2.6_x86_i586-pc-linux-gnu-gcc_glibc_PTH_OPT.OBJ/lib/libfreebl3.so)


I'm using
CFLAGS="-march=i586 -mtune=k6-3 -O2 -pipe"
CHOST="i586-pc-linux-gnu"
which should be safe options for this processor (emerge --info attached).

Note that if I manually build nss using the instructions from here: https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSS/NSS_Sources_Building_Testing
Then the build is successful, and the test suite runs ok. This makes me think that the issue is due to something the gentoo ebuild is doing.

1) Note that the K6-2+ is a die-shrunk K6-III with half the on-die cache disabled. The Linux kernel identifies it as a K6-III.
Comment 1 Mike Gilbert gentoo-dev 2017-11-15 20:07:32 UTC
This line looks suspicious.

https://gitweb.gentoo.org/repo/gentoo.git/tree/dev-libs/nss/nss-3.33.ebuild#n118
Comment 2 Ian Stakenvicius (RETIRED) gentoo-dev 2017-11-15 20:12:22 UTC
There are bits of code in NSS that expect SSE2, iirc; that said, freebsd seems to have patches that get around it, i'm looking into that now.
Comment 3 Calvin Walton 2017-11-15 20:29:58 UTC
As I mentioned, manually building vanilla nss (using "make nss_build_all BUILD_OPT=1" from a source checkout made yesterday) does appear to work correctly on this machine - I'm currently running the test suite from that build, and it's gotten a significant part of the way through without any errors.
Comment 4 Ian Stakenvicius (RETIRED) gentoo-dev 2017-11-15 20:39:40 UTC
when you built it by hand you fed it the same CFLAGS, CC, etc as what emerge would?  If not, could you try again?
Comment 5 Calvin Walton 2017-11-15 21:03:54 UTC
I haven't been able to figure out how to convince the nss build system to use specific CFLAGS/CXXFLAGS values (my initial attempt overrode some require include paths, causing a quick build failure).
If you have any hints, please let me know.
Comment 6 Calvin Walton 2017-11-15 21:16:51 UTC
After reading some makefiles, I'm now running this command to do a fresh build:

CC=i586-pc-linux-gnu-gcc CCC=i586-pc-linux-gnu-g++ CFLAGS="-march=i586 -mtune=k6-3 -O2 -pipe" CXXFLAGS="-march=i586 -mtune=k6-3 -O2 -pipe" XCFLAGS="-march=i586 -mtune=k6-3 -O2 -pipe" make nss_build_all

I'll let you know the result once it finishes (with a 500mhz single-core, this will take a while).
Comment 7 Calvin Walton 2017-11-15 22:07:41 UTC
Alright, so when I manually compile nss using the same CFLAGS and compiler as emerge was using, I am getting the exact same build error as a result. I guess that means it is an upstream problem :/
Comment 8 Calvin Walton 2017-11-17 13:33:52 UTC
This actually seems to have been solved upstream with nss 3.34! I notice that the ebuild has RESTRICT="test", so I'm not sure how to run the test suite to make sure, but at least the build no longer fails!
Comment 9 Ian Stakenvicius (RETIRED) gentoo-dev 2017-11-17 17:15:57 UTC
(In reply to Calvin Walton from comment #8)
> This actually seems to have been solved upstream with nss 3.34! I notice
> that the ebuild has RESTRICT="test", so I'm not sure how to run the test
> suite to make sure, but at least the build no longer fails!

You may need to temporarily modify the ebuild to remove that restriction, and then you can run 'ebuild nss-3.34.ebuild digest clean test' to determine if tests pass or not.  Alternatively, ebuild nss-3.34.ebuild compile, then cd ${S} and 'make test' or whatever the command is to run the test suite by hand.

If 3.34 is good for you then we'll just drop 3.33 and consider this bug resolved/upstream.
Comment 10 Calvin Walton 2017-11-19 03:18:21 UTC
After some further testing, it's looking like nss 3.34 is working properly for me, thanks.

My next goal is gonna be getting rustc working, but that's a matter for another bug ;)
Comment 11 Ian Stakenvicius (RETIRED) gentoo-dev 2017-11-20 15:32:46 UTC
Thanks for the report!