Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 884789 - sys-devel/gcc:12[jit] -B build with -march & -mtune constraints for a target, libgccjit generates hard coded host cpu class instructions
Summary: sys-devel/gcc:12[jit] -B build with -march & -mtune constraints for a target...
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Toolchain Maintainers
Depends on:
Reported: 2022-12-08 00:31 UTC by CaptainBlood
Modified: 2023-05-10 16:09 UTC (History)
1 user (show)

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

gcc build log on skylake (sys-devel:gcc-12.2.1_p20221203:20221207-115413.log.xz,312.98 KB, application/x-xz)
2022-12-08 00:31 UTC, CaptainBlood
app-editors/emacs build log on core2 target (app-editors:emacs-29.0.9999-r1:20221207-230858.log,18.91 KB, text/x-log)
2022-12-08 00:42 UTC, CaptainBlood
binary generated on target, working only on gcc building host (tut01-hello-world,16.45 KB, application/x-sharedlib)
2022-12-08 00:48 UTC, CaptainBlood

Note You need to log in before you can comment on or make changes to this bug.
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:
Comment 4 CaptainBlood 2022-12-10 10:48:41 UTC

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 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:

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.