Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 884789

Summary: sys-devel/gcc:12[jit] -B build with -march & -mtune constraints for a target, libgccjit generates hard coded host cpu class instructions
Product: Gentoo Linux Reporter: CaptainBlood <luc_pierard_de_maujouy>
Component: Current packagesAssignee: Gentoo Toolchain Maintainers <toolchain>
Status: UNCONFIRMED ---    
Severity: normal CC: jasmin+gentoo
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
See Also: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66594
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107230
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: gcc build log on skylake
app-editors/emacs build log on core2 target
binary generated on target, working only on gcc building host

Description CaptainBlood 2022-12-08 00:31:39 UTC
Created attachment 840891 [details]
gcc build log on skylake

sys-devel/gcc:12[jit] build on skylake with -march=core2 -mtune=core works fine on targeted system as long as libgccjit is not involved.
libgccjit runs fine on targeted system, but generates skylake class instructions.
When applying test in app-editors/emacs build log,
ibgccjit is somehow core2 compliant as binary is build.
This binary fails to run on core2, but runs fine on skylake.
Comment 1 CaptainBlood 2022-12-08 00:42:33 UTC
Created attachment 840893 [details]
app-editors/emacs build log on core2 target
Comment 2 CaptainBlood 2022-12-08 00:48:07 UTC
Created attachment 840895 [details]
binary generated on target, working only on gcc building host
Comment 3 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-12-09 21:26:25 UTC
Related forums post: https://forums.gentoo.org/viewtopic-t-1159653.html
Comment 4 CaptainBlood 2022-12-10 10:48:41 UTC
https://gcc.gnu.org/onlinedocs/jit/internals/index.html#environment-variables

Shows how things are hardcoded in libgccjit.
That makes things a little harder when trying to workaround by replacement from other distro binaries.

That could plead for stage3 to add sys-devel/gcc USE=jit.
It would at least fit my use case ;)

Thks 4 the gcc.gnu.org links, although they suggest how things are unlikely to happen any soon :(
Comment 5 CaptainBlood 2022-12-13 15:54:26 UTC
Binary package has been made available here:

https://gitlab.com/gentoo-pdm/sys-devel/gcc/pdm-gcc/gcc-12-core2-compatible-binary-package

Hopefully repository is in public access.
Plz let me know if isn't.
Comment 6 CaptainBlood 2022-12-14 11:40:40 UTC
Albeit there was no rationale to do so,
I've updated target to gcc-12.2.1_p20221210 built using core2 profiled gcc-12.2.1_p20221203 on skylake host.
It so happened the above reported failing sequence hence succeeded.

I don't see any host portage env changes, manual or upstream, that would explain this new result, besides the use of a core2 targeted compilter to build
Comment 7 CaptainBlood 2022-12-14 12:12:22 UTC
Sorry, something borked while typing in here...

... of a core2 targeted compiler to build a core2 targeted compiler upgrade.

stable portage has been upgraded on 2022-12-09, but I doubt it played any role in the fix.

Will retry to build core2 targeted from skylake build just to make sure bug is real.

Happy to close now, and ready to build app-editors/emacs[jit] on an over a decade old laptop.
Comment 8 CaptainBlood 2022-12-29 00:22:02 UTC
It so happened here after building twice in a row gcc-12.2.1_p20221203.tbz2 with -march=core2 -mtune=core2 on a skylake host, I forgot to reinstall its -march=native -mtune=native build.

Consequently a single pass pass upgrade to 12.2.1_p20221224 with -march=native -mtune=native on that same skylake host should provide a libgccjit that generates binaries with core2 level instructions.

I did the test generating a binary with the new libgccjit on the skylake and tried to run it on a core2 CPU where it executed fine.

So the hypothesis for 2 passes to build a libgccjit that matches -march!=native -mtune!=native with a gcc build with -march=native -mtune=native is getting confirmed here.

For that reason I propose to cancel RESOLVED to let a wider scope to the issue.

I have no idea if that issue is package related or upstream related.
jit feature issues seems to have a low -P3 as of this writing.