Opened 9 years ago
Closed 8 years ago
#51097 closed defect (invalid)
gcc5 -- xgcc internal compiler error: Illegal instruction: 4
Reported by: | gnw3 | Owned by: | MarcusCalhoun-Lopez (Marcus Calhoun-Lopez) |
---|---|---|---|
Priority: | Normal | Milestone: | |
Component: | ports | Version: | 2.3.4 |
Keywords: | Cc: | ryandesign (Ryan Carsten Schmidt), MarcusCalhoun-Lopez (Marcus Calhoun-Lopez) | |
Port: | gcc5 |
Description
Under El Capitan (10.11.4) on iMac 27-inch mid-2010 (i5-760), gfortran from the gcc5 binary install fails on even trivial programs with internal compiler error: Illegal instruction: 4. I tried to install from source after uninstalling gcc5 and libgcc, but hit the same error from xgcc.
On an iMac retina 27-inch late 2015 (i5-6500) the gcc5 binary install has no such issues, and the build from source compiles files that fail on the older machine.
Attachments (2)
Change History (18)
Changed 9 years ago by gnw3
Attachment: | gcc5_main.log added |
---|
comment:1 Changed 9 years ago by ryandesign (Ryan Carsten Schmidt)
Keywords: | ICE libgcc removed |
---|---|
Owner: | changed from macports-tickets@… to mww@… |
Sounds like a bug in gcc that you should report to the developers of gcc.
comment:2 Changed 9 years ago by gnw3
This is not a gcc bug but a mismatch between the macports binary gmp library and older CPU's. Installing "gmp +core2" should avoid the problem. I think gcc5 is built with "-march=core2", but gmp provides a "+core2" variant that was not used to build the macports "officila" binaries.
Several existing GCC bug reports were helpful in understanding the issue:
GCC Bug #6326 appears to be the same underlying bug and was traced to libgmp compiled for a CPU that was newer than the one being used to run gcc.
Another helpful report with a minimal example in C is gcc bug 68040 where it is suggested:
"This is probably an ICE that occurs earlier than reported with `--enabled-checking=release`. Configure with `--enable-checking=yes`."
I created a "gcc5ec" Portfile. The build failed at the same place, but gave a much more useful error message which led me to GCC Bug 6326.
This is serious issue for macports users because I often hear "macports gfortran doesn't work so I installed gfortran from <some unrelable source>" which then causes nasty problems for ports that need a particular gcc.
I suggest making "gmp +core2" the default, and adding a gcc* variant "+enable-checking" to be used for ICE bug reporting.
comment:3 follow-up: 5 Changed 9 years ago by ryandesign (Ryan Carsten Schmidt)
Cc: | ryandesign@… mcalhoun@… added |
---|
Thank you for this helpful information!
I don't know what to do about it though. Making gmp default to using the +core2 variant does not sound like a good solution because that will make gmp slower on Macs with newer processors than the Intel Core 2 (and might cause it to fail on Macs with older processors than the Intel Core 2, such as the original Intel Core processor). I'll Cc the maintainer of the gmp port for help.
Are you sure the reference to gcc bug 6326 is correct? I did not see a mention of gmp in that bug report and it is 14 years old.
comment:4 follow-up: 6 Changed 9 years ago by ryandesign (Ryan Carsten Schmidt)
Does just installing gmp with the +core2 variant fix the problem you're seeing? Or does gcc5 then need to be rebuilt to fix the problem?
comment:5 Changed 9 years ago by gnw3
Replying to ryandesign@…:
Thank you for this helpful information!
I don't know what to do about it though. Making gmp default to using the +core2 variant does not sound like a good solution because that will make gmp slower on Macs with newer processors than the Intel Core 2 (and might cause it to fail on Macs with older processors than the Intel Core 2, such as the original Intel Core processor). I'll Cc the maintainer of the gmp port for help.
Are you sure the reference to gcc bug 6326 is correct? I did not see a mention of gmp in that bug report and it is 14 years old.
Sorry, see comment #5 in 40734
This sort of issue is going to become more common as authors start to take advantage of newer CPU's to speed up bottlenecks. Could "port install" check the CPU type and warn users if a recompile would improve performance.
comment:6 Changed 9 years ago by gnw3
Replying to ryandesign@…:
Does just installing gmp with the +core2 variant fix the problem you're seeing? Or does gcc5 then need to be rebuilt to fix the problem?
Yes. Using locally compiled "gmp +core2" allows the macports' binary to work without a recompile.
comment:7 Changed 9 years ago by MarcusCalhoun-Lopez (Marcus Calhoun-Lopez)
GMP has a script config.guess
that prints "the host system CPU-VENDOR-OS."
The CPU value is used to set -mtune
, set -march
, and select assembly files to use.
The +core2
variant forces the CPU value to be core2.
With a little trial and error, we can probably narrow down the problem.
Since I can not reproduce this problem, I will need a little help.
- Does
port test gmp
report any errors? - What is the output of
config.guess
(located in the GMP source directory)?
With this information, we can modify the CPU specific code in configure
that is different from (the working) core2 code.
comment:8 Changed 9 years ago by gnw3
On the older system (iMac 27-inch mid-2010 (i5-760)) where the macports binary failed:
$ port test gmp Warning: MacPorts running without privileges. You may be unable to complete certain actions (e.g. install). ---> Fetching distfiles for gmp ---> Attempting to fetch gmp-6.1.0.tar.bz2 from http://mirrors.ibiblio.org/gnu/ftp/gnu/gmp ---> Verifying checksums for gmp ---> Extracting gmp ---> Applying patches to gmp ---> Configuring gmp ---> Building gmp ---> Testing gmp
I assume no news is good news. For this system, GMP used "/usr/bin/clang ... -mtune=corei7 -march=corei7
".
$ $(port dir gmp)/work/gmp-6.1.0/config.guess nehalem-apple-darwin15.4.0
The newer system (iMac Retina 5K, 27-inch, Late 2015, corei5):
$ $(port dir gmp)/work/gmp-6.1.0/config.guess skylake-apple-darwin15.4.0
For this sysmtem, GMP used "/usr/bin/clang ... -mtune=skylake -march=broadwell
"
Changed 9 years ago by MarcusCalhoun-Lopez (Marcus Calhoun-Lopez)
Attachment: | patch-configure.diff added |
---|
comment:9 Changed 9 years ago by MarcusCalhoun-Lopez (Marcus Calhoun-Lopez)
If all the tests passed, then we have to find out which of the nehalem specific configurations is causing the problem.
I have uploaded a patch that should turn nehalem-apple-darwinX.Y.Z
into core2-apple-darwinX.Y.Z
.
Since the +core2
variant is working, hopefully this patch works as well.
If it does, we can narrow the problem down further between assembly files and compiler flags.
Are you comfortable applying patch files?
comment:10 Changed 9 years ago by gnw3
I'd like to help, but I won't have access to MacOS again until May 18th at the earliest.
comment:11 Changed 8 years ago by gnw3
Back in MacOS land. Your patch does work on the older nehalim box:
$ diff Portfile.orig Portfile 7c7,8 < name gmp --- > name gmp-patched > 27a29,30 > dist_subdir gmp > distname gmp-${version} 36c39,40 < patch-Makefile.in.diff --- > patch-Makefile.in.diff \ > patch-configure.diff
$ sudo port test gmp-patched ---> Fetching distfiles for gmp-patched ---> Verifying checksums for gmp-patched ---> Extracting gmp-patched ---> Applying patches to gmp-patched ---> Configuring gmp-patched ---> Building gmp-patched ---> Testing gmp-patched
$ ./config.guess nehalem-apple-darwin15.4.0
comment:12 Changed 8 years ago by MarcusCalhoun-Lopez (Marcus Calhoun-Lopez)
Owner: | changed from mww@… to mcalhoun@… |
---|---|
Status: | new → assigned |
Does gcc now work with the patched version of gmp?
If so, we need to revert each change made by the patch until we figure out which change (or combination of changes) causes the problem.
Would you like me to post several variations on the patch or just make the changes yourself?
Thank you for your patience, but I do not know of any other way to track down the problem other than modify, test, modify, test, ....
comment:13 follow-up: 14 Changed 8 years ago by gnw3
I'm not entirely clear about the "problem". GMP works on the older system when compiled with the "+core2" option or when compiled locally (in which case I assume the configuration stage correctly identifies the processor and applies appropriate algorithms), but the macports binary fails. Since the macports binary did work on the newer iMac, I assume it was built on a system similar to the newer iMac. Are you hoping to create a variant that works for both nehalem and skylake?
gcc-mp-5 works for gmpbench using the "patched" library:
$ port installed gmp\* The following ports are currently installed: gmp @6.1.0_1 gmp-patched @6.1.0_1 (active)
$ export CC=gcc-mp-5 LIBS='-L/opt/local/lib -lgmp'
$ ./runbench ***** GMPbench version 0.2 ***** Using default CFLAGS = "-O3 -fomit-frame-pointer" Using CC = "gcc-mp-5" from your environment Using LIBS = "-L/opt/local/lib -lgmp" from your environment Using compilation command: gcc-mp-5 -O3 -fomit-frame-pointer foo.c -o foo -L/opt/local/lib -lgmp You may want to override CC, CFLAGS, and LIBS Using gmp version: 6.1.0 Compiling benchmarks Running benchmarks (propagated score accuracy exceeds printed intermediates) Category base Program multiply (weight=1) GMPbench.base.multiply(128) 6.22e+07 GMPbench.base.multiply(512) 1.413e+07 GMPbench.base.multiply(8192) 1.472e+05 GMPbench.base.multiply(131072) 2585 GMPbench.base.multiply(2097152) 97.4 GMPbench.base.multiply(128,128) 6.226e+07 GMPbench.base.multiply(512,512) 9.424e+06 GMPbench.base.multiply(8192,8192) 9.16e+04 GMPbench.base.multiply(131072,131072) 1805 GMPbench.base.multiply(2097152,2097152) 64 GMPbench.base.multiply(15000,10000) 4.836e+04 GMPbench.base.multiply(20000,10000) 3.804e+04 GMPbench.base.multiply(30000,10000) 2.42e+04 GMPbench.base.multiply(16777216,512) 360 GMPbench.base.multiply(16777216,262144) 15.3 GMPbench.base.multiply 32587 Program divide (weight=1) GMPbench.base.divide(8192,32) 1.302e+06 GMPbench.base.divide(8192,64) 1.311e+06 GMPbench.base.divide(8192,128) 8.202e+05 GMPbench.base.divide(8192,4096) 2.239e+05 GMPbench.base.divide(131072,65536) 2390 GMPbench.base.divide(8388608,4194304) 13.2 GMPbench.base.divide(8192,8064) 1.029e+07 GMPbench.base.divide(16777216,262144) 7.47 GMPbench.base.divide 30557 Program gcd (weight=0.5) GMPbench.base.gcd(128,128) 2.688e+06 GMPbench.base.gcd(512,512) 2.777e+05 GMPbench.base.gcd(8192,8192) 7234 GMPbench.base.gcd(131072,131072) 124 GMPbench.base.gcd(1048576,1048576) 6.54 GMPbench.base.gcd 5349.1 Program gcdext (weight=0.5) GMPbench.base.gcdext(128,128) 1.233e+06 GMPbench.base.gcdext(512,512) 2.307e+05 GMPbench.base.gcdext(8192,8192) 5657 GMPbench.base.gcdext(131072,131072) 90.4 GMPbench.base.gcdext(1048576,1048576) 4.28 GMPbench.base.gcdext 3621.2 GMPbench.base 16365 Category app Program rsa (weight=1) GMPbench.app.rsa(512) 2.417e+04 GMPbench.app.rsa(1024) 4457 GMPbench.app.rsa(2048) 663 GMPbench.app.rsa 4148.9 Program pi (weight=1) GMPbench.app.pi(10000) 666 GMPbench.app.pi(100000) 32.9 GMPbench.app.pi(1000000) 1.8 GMPbench.app.pi 34.039 GMPbench.app 375.8 GMPbench: 2479.9
$ port installed gmp\* The following ports are currently installed: gmp @6.1.0_1 (active) gmp-patched @6.1.0_1
$ ./runbench ***** GMPbench version 0.2 ***** Using default CFLAGS = "-O3 -fomit-frame-pointer" Using CC = "gcc-mp-5" from your environment Using LIBS = "-L/opt/local/lib -lgmp" from your environment Using compilation command: gcc-mp-5 -O3 -fomit-frame-pointer foo.c -o foo -L/opt/local/lib -lgmp You may want to override CC, CFLAGS, and LIBS Using gmp version: 6.1.0 Compiling benchmarks Running benchmarks (propagated score accuracy exceeds printed intermediates) Category base Program multiply (weight=1) GMPbench.base.multiply(128) 6.229e+07 GMPbench.base.multiply(512) 1.409e+07 GMPbench.base.multiply(8192) 1.464e+05 GMPbench.base.multiply(131072) 2591 GMPbench.base.multiply(2097152) 96.9 GMPbench.base.multiply(128,128) 6.22e+07 GMPbench.base.multiply(512,512) 9.426e+06 GMPbench.base.multiply(8192,8192) 9.599e+04 GMPbench.base.multiply(131072,131072) 1874 GMPbench.base.multiply(2097152,2097152) 64 GMPbench.base.multiply(15000,10000) 4.798e+04 GMPbench.base.multiply(20000,10000) 3.785e+04 GMPbench.base.multiply(30000,10000) 2.413e+04 GMPbench.base.multiply(16777216,512) 356 GMPbench.base.multiply(16777216,262144) 15.2 GMPbench.base.multiply 32675 Program divide (weight=1) GMPbench.base.divide(8192,32) 1.303e+06 GMPbench.base.divide(8192,64) 1.312e+06 GMPbench.base.divide(8192,128) 8.2e+05 GMPbench.base.divide(8192,4096) 2.383e+05 GMPbench.base.divide(131072,65536) 2439 GMPbench.base.divide(8388608,4194304) 13.4 GMPbench.base.divide(8192,8064) 1.029e+07 GMPbench.base.divide(16777216,262144) 7.52 GMPbench.base.divide 30962 Program gcd (weight=0.5) GMPbench.base.gcd(128,128) 2.264e+06 GMPbench.base.gcd(512,512) 2.769e+05 GMPbench.base.gcd(8192,8192) 7310 GMPbench.base.gcd(131072,131072) 125 GMPbench.base.gcd(1048576,1048576) 6.58 GMPbench.base.gcd 5191 Program gcdext (weight=0.5) GMPbench.base.gcdext(128,128) 1.414e+06 GMPbench.base.gcdext(512,512) 2.232e+05 GMPbench.base.gcdext(8192,8192) 5703 GMPbench.base.gcdext(131072,131072) 91.3 GMPbench.base.gcdext(1048576,1048576) 4.33 GMPbench.base.gcdext 3719.1 GMPbench.base 16442 Category app Program rsa (weight=1) GMPbench.app.rsa(512) 2.496e+04 GMPbench.app.rsa(1024) 4692 GMPbench.app.rsa(2048) 700 GMPbench.app.rsa 4344.3 Program pi (weight=1) GMPbench.app.pi(10000) 668 GMPbench.app.pi(100000) 33 GMPbench.app.pi(1000000) 1.81 GMPbench.app.pi 34.171 GMPbench.app 385.29 GMPbench: 2517
comment:14 Changed 8 years ago by MarcusCalhoun-Lopez (Marcus Calhoun-Lopez)
Replying to gnwiii@…:
I'm not entirely clear about the "problem". GMP works on the older system when compiled with the "+core2" option or when compiled locally (in which case I assume the configuration stage correctly identifies the processor and applies appropriate algorithms), but the macports binary fails. Since the macports binary did work on the newer iMac, I assume it was built on a system similar to the newer iMac. Are you hoping to create a variant that works for both nehalem and skylake?
Perhaps I misunderstood the problem.
Please correct any misstatements.
- On an iMac 27-inch mid-2010 machine:
- default gmp
- with prebuilt gcc/libgcc, compiler fails
- building gcc/libgcc fails
- gmp with +core2 variant
- with prebuilt gcc/libgcc, everything works
- default gmp
- On an iMac retina 27-inch late 2015 machine:
- default gmp
- with prebuilt gcc/libgcc, everything works
- default gmp
If this is in fact the case, then I am simply trying to track down what aspect of GMP causes the problem:
- the fact that GMP builds with
-mtune=corei7
- the fact that GMP builds with
-march=corei7
- the processor specific assembly code GMP uses
- some combination of the above
I am certainly open to suggestions on better ways to proceed.
At this point, I am not sure whether this is a GMP problem, a GCC problem, an i5-760 quirk, or simply a misalignment of compiler flags.
Thank you for your patience.
If this is a GMP issue, we could create code specifically for this processor that make is use the +core2 variant.
If might run slower, but at least it would run.
We could also engage the upstream developers, but we would need more information on what the issue is.
Just a side note: the command archive_sites
should force gmp should to always build locally.
comment:15 Changed 8 years ago by MarcusCalhoun-Lopez (Marcus Calhoun-Lopez)
No response in quite some time.
Is there still an issue?
comment:16 Changed 8 years ago by MarcusCalhoun-Lopez (Marcus Calhoun-Lopez)
Resolution: | → invalid |
---|---|
Status: | assigned → closed |
With no further response, there is not much that can be done.
Please feel free to reopen if problem persists.
main.log from "install -s gcc5"