Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 903243 - net-libs/nodejs-18.14.2: Fails to compile with -march=native set in make.conf on Intel Core 2 Duo processor [workaround included]
Summary: net-libs/nodejs-18.14.2: Fails to compile with -march=native set in make.conf...
Status: UNCONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: AMD64 Linux
: Normal normal (vote)
Assignee: William Hubbs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-03-27 17:52 UTC by armouredheart
Modified: 2023-10-01 11:42 UTC (History)
2 users (show)

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


Attachments
Result of 'emerge --info' after applying workaround (nodejs-core2.txt,17.88 KB, text/plain)
2023-03-27 17:57 UTC, armouredheart
Details
build.log for failed emerge (nodejs-build.log,24.64 KB, text/x-log)
2023-03-27 20:52 UTC, armouredheart
Details
Output of 'gcc -march=native -Q --help=target' (gcc-output.txt,11.07 KB, text/plain)
2023-04-14 01:53 UTC, armouredheart
Details
Output of '/proc/cpuinfo' (cpuinfo.txt,1.87 KB, text/plain)
2023-04-14 01:54 UTC, armouredheart
Details
build log for 'march=native -mno-sse4' (nodejs-build-mno-sse4.log,24.89 KB, text/x-log)
2023-04-20 15:10 UTC, armouredheart
Details

Note You need to log in before you can comment on or make changes to this bug.
Description armouredheart 2023-03-27 17:52:48 UTC
Attempting to compile net-libs/nodejs-18.14.2 on Gentoo 5.15.75 on an Intel Core 2 Duo Thinkpad T500 results in the emerge failing partway through if '-march=native' in '/etc/portage/make.conf'. 

A workaround is to set -march=core2 in '/etc/portage/make.conf'.

Reproducible: Always

Steps to Reproduce:
1.Set '-march=native' in '/etc/portage/make.conf'.
2.Attempt to compile net-libs/nodejs-18.14.2 with portage.
3.Build will start but fail partway through.
Actual Results:  
The package failed to compile.

Expected Results:  
The package should have compiled.
Comment 1 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-03-27 17:54:35 UTC
Please always include the full build.log and emerge --info.
Comment 2 armouredheart 2023-03-27 17:57:33 UTC
Created attachment 859129 [details]
Result of 'emerge --info' after applying workaround

This is the result of 'emerge --info'  after changing '-march=native' to '-march=core2' in '/etc/portage/make.conf' and successfully compiling 'net-libs/nodejs-18.14.2'. No other changes were made and everything else was the same when the package failed to build.
Comment 3 armouredheart 2023-03-27 18:00:50 UTC
(In reply to Sam James from comment #1)
> Please always include the full build.log and emerge --info.
emerge --info was too long to fit in the "Additional Comments" section, so I had to attach it after posting.
Comment 4 Mike Gilbert gentoo-dev 2023-03-27 19:29:01 UTC
Please attach the full build log.
Comment 5 armouredheart 2023-03-27 20:52:27 UTC
Created attachment 859137 [details]
build.log for failed emerge

I switched '-march=core2' back to '-march=native' and attempted to emerge 'net-libs/nodejs-18.14.2' again. The build failed and this is the result.
Comment 6 Matt Turner gentoo-dev 2023-04-12 18:41:11 UTC
Can you post your /proc/cpuinfo file?
Comment 7 Matt Turner gentoo-dev 2023-04-12 18:44:08 UTC
Also the output of `gcc -march=native -Q --help=target` would be helpful.
Comment 8 armouredheart 2023-04-14 01:53:27 UTC
Created attachment 860037 [details]
Output of 'gcc -march=native -Q --help=target'
Comment 9 armouredheart 2023-04-14 01:54:30 UTC
Created attachment 860038 [details]
Output of '/proc/cpuinfo'
Comment 10 Matt Turner gentoo-dev 2023-04-15 16:30:02 UTC
Interesting. Your /proc/cpuinfo shows sse4_1 but not popcnt. Fortunately the GCC -march=native output agrees, so I think that means that it's probably not the GCC problem [*] I thought it was.

Diffing your output against `gcc -march=core2 -Q --help=target`, I see this:

> --- core2	2023-04-15 12:25:56.575149311 -0400
> +++ native	2023-04-15 12:26:10.885108020 -0400
> @@ -127,7 +127,7 @@
>    -mno-fancy-math-387         		[disabled]
>    -mno-push-args              		[disabled]
>    -mno-red-zone               		[disabled]
> -  -mno-sse4                   		[enabled]
> +  -mno-sse4                   		[disabled]
>    -mnop-mcount                		[disabled]
>    -momit-leaf-frame-pointer   		[disabled]
>    -mpc32                      		[disabled]
> @@ -169,7 +169,7 @@
>    -msse2avx                   		[disabled]
>    -msse3                      		[enabled]
>    -msse4                      		[disabled]
> -  -msse4.1                    		[disabled]
> +  -msse4.1                    		[enabled]
>    -msse4.2                    		[disabled]
>    -msse4a                     		[disabled]
>    -msse5                      		-mavx
> @@ -202,7 +202,7 @@
>    -mwidekl                    		[disabled]
>    -mx32                       		[disabled]
>    -mxop                       		[disabled]
> -  -mxsave                     		[disabled]
> +  -mxsave                     		[enabled]
>    -mxsavec                    		[disabled]
>    -mxsaveopt                  		[disabled]
>    -mxsaves                    		[disabled]

Notably, -mpopcnt is not changed:

>   -mpopcnt                    		[disabled]

So my suspicion is that something is incorrectly trying to use popcnt intrinsics, but keyed off of SSE 4.1 rather than popcnt availability. 

[*] for some CPUs -march=native enables some instructions that are not available on all CPUs in that family
Comment 11 Matt Turner gentoo-dev 2023-04-15 16:41:09 UTC
The function that's using the popcnt intrinsics is utf16_to_utf8_avx512i, so it's definitely not getting executed on your CPU.

I see from the build log:

> -DHAVE_SSSE3=1' '-DHAVE_SSE41=1' '-DHAVE_SSE42=1' '-DHAVE_AVX=1' '-DHAVE_AVX2=1'

which is probably fine. It's probably that it's compiling runtime-enabled code that won't be executed on your CPU.
Comment 12 Matt Turner gentoo-dev 2023-04-15 16:48:06 UTC
Instead of switching from -march=native to -march=core2, does simply adding -mno-sse4 allow it to build? Would be good to confirm.
Comment 13 armouredheart 2023-04-20 15:10:14 UTC
Created attachment 860435 [details]
build log for 'march=native -mno-sse4'
Comment 14 armouredheart 2023-04-20 15:10:53 UTC
(In reply to Matt Turner from comment #12)
> Instead of switching from -march=native to -march=core2, does simply adding
> -mno-sse4 allow it to build? Would be good to confirm.

nodejs fails to build with those settings.
Comment 15 Andreas K. Hüttel archtester gentoo-dev 2023-09-08 23:23:12 UTC
Any news here / is this still relevant?
Comment 16 PF4Public 2023-10-01 11:31:15 UTC
See also https://github.com/gentoo/gentoo/pull/32067