-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Segfault when building with gcc 7 #60
Comments
Note that switching back to gcc 6 for miniperl itself fixes it |
Can you post xconfig.sh and maybe also config.log from this build somewhere? No segfaults for me on x86_64 host with gcc 7.2.1, and valgrind reports nothing. |
Sure, here's a build log, xconfig.sh, and config.log https://gist.github.com/shlevy/ade184d2b0f2ff59f17e55e74e97ccfb. It's extra verbose to show all the extra flags we pass to our compiler. This is for |
Ok I think I got it. GCC 4.9 and above needs -fwrapv to build perl. The fix wasn't applied properly to gcc-7.x, and perl-cross failed to detect gcc version in your hardened setup anyway. This only matters for -O2 and above, in particular -Os builds work just fine. If possible, please try this branch: https://github.com/arsv/perl-cross/tree/nix The underlying issue: https://rt.perl.org/Public/Bug/Display.html?id=121505 |
Great, that worked! Do we need that patch for non-cross-compiled perl? NixOS/nixpkgs@b45fb43 |
Probably not. Unless you use perl-cross for native builds, which doesn't seem to be the case. Mainline Configure from perl-5.24 should be able to handle gcc-7, no changes are needed there. If unsure, check config.sh for -fwrapv in ccflags. |
I'm still seeing this with perl 5.24.1 cross compiled with perl-cross 1.9 via a gentoo ebuild. Are there any other possible fixes for this? "-fwrapv" is in my cflags. |
Same exact segfault? Can you post xconfig.sh and config.log somewhere? There's also -fno-strict-aliasing, but if -fwrapv is there the other one should be as well. Check also for -O3 or any standalone -f-something, especially if the target is unusual. Maybe try building it with -O0 or -Os. |
In developer containers or SDK, there has been a bug in cross-compiled perl that it crashes with segmentation fault. It has two different reasons: The first issue is that perl depends on perl-cross 1.1.4, which has a bug with gcc 7.x or newer, so that the necessary CFLAGS `-fwrapv` was not appended. This issue was fixed in perl-cross 1.1.9 or newer. So we just need to upgrade perl-cross to 1.2.2, the newest release. ``` CROSS_VER=1.2.2 ``` The other issue is that the CFLAGS `-O2` was given when building cross-compiled perl. We should replace the optimization flag with `-O0`, when it's built by the cross compiler. Without that, the segfault will not be fixed at all. ``` if tc-is-cross-compiler; then replace-flags -O? -O0 fi ``` How to test inside the Flatcar SDK environment: ``` LD_PRELOAD=/build/amd64-usr/usr/lib/libperl.so.5.24.1 /build/amd64-usr/usr/bin/perl -V ``` See also coreos/bugs#2369 coreos/bugs#2545 arsv/perl-cross#60
In developer containers or SDK, there has been a bug in cross-compiled perl that it crashes with segmentation fault. It has two different reasons: The first issue is that perl depends on perl-cross 1.1.4, which has a bug with gcc 7.x or newer, so that the necessary CFLAGS `-fwrapv` was not appended. This issue was fixed in perl-cross 1.1.9 or newer. So we just need to upgrade perl-cross to 1.2.2, the newest release. ``` CROSS_VER=1.2.2 ``` The other issue is that the CFLAGS `-O2` was given when building cross-compiled perl. We should replace the optimization flag with `-O0`, when it's built by the cross compiler. Without that, the segfault will not be fixed at all. ``` if tc-is-cross-compiler; then replace-flags -O? -O0 fi ``` How to test inside the Flatcar SDK environment: ``` LD_PRELOAD=/build/amd64-usr/usr/lib/libperl.so.5.24.1 /build/amd64-usr/usr/bin/perl -V ``` See also coreos/bugs#2369 coreos/bugs#2545 arsv/perl-cross#60
There has been a bug that cross-compiled perl crashes with segmentation fault. It has two different reasons: first, perl-cross didn't append CFLAGS `-fwrapv` in case of gcc 7.x or newer, and the other is that the CFLAGS still contained `-O2`. The first issue was recently fixed by setting `CROSS_VER` to `1.2.2`. On the other hand, the second issue is not fixed yet, so perl still segfaults in case of a cross-compiled version. So let's fix it by replacing `-O?` with `-O2`. For example, how to test inside a cross-compilation SDK environment: ``` LD_PRELOAD=/build/amd64-usr/usr/lib/libperl.so.5.24.1 /build/amd64-usr/usr/bin/perl -V ``` See also coreos/bugs#2369 coreos/bugs#2545 arsv/perl-cross#60 Signed-off-by: Dongsu Park <[email protected]>
I had this problem back in February. I think I stumbled across this report, worked around it, then forgot about it until just now when I ran into it again. I can confirm that I usually use |
Current defaults are |
|
Oh hai @chewi, fancy seeing you here. Just reporting that under cross compile, the built perl still segfaults this way w/ perl 5.30.3 w/ cross 1.3.4 & GCC 10. This caused a significant amount of "fun" for building a scratch VM for m68k as it means autoconf and friends like to fail :) Fortunately, with enough brute force, natively building perl under emulation was achievable, and didn't suffer this problem. |
For issues like this, it would be really nice to have config.sh from the failing cross build, and also the one from a successful build if available. It's very difficult to tell what's going on otherwise. Given the rest of this issue, the first thing I would be looking for is which compiler flags were actually used for either build. |
We recently switched nixpkgs to gcc 7, and now our perl cross-builds fail with:
The text was updated successfully, but these errors were encountered: