On 7/24/18 1:58 AM, Marc Glisse wrote:
On Tue, 24 Jul 2018, Andrew Janke wrote:
I am having difficulty compiling GCC for a different generation of x86
CPU. I would like to produce a portable/redistributable build of GCC
to be distributed along with a packaging of GNU Octave. So I would
like to build it for the Core2 architecture, even though my build box
has a Skylake CPU.
This is for GCC 8.1.0 on macOS.
It seems like setting "-march=core2" in CFLAGS, BOOT_CFLAGS, and
CFLAGS_FOR_TARGET is the way to do this, but it doesn't seem to be
working. When I do the build, and then copy the built GCC to an older
Ivy Bridge Mac, and attempt to use gfortran to compile a program, it
errors out with an "internal compiler error: Illegal instruction: 4"
error message.
Here you are supposed to use a debugger to find out what instruction
this is and where it is (could be in libgmp for instance).
>
Thanks.
I'm trying to use gdb 8.0.1 to do this, but it doesn't seem to be
stopping the program when SIGILL is raised for the illegal instruction.
Or maybe SIGILL isn't being raised, and something else is happening? Is
gfortran doing something special that's preventing the debugger from
capturing it, or maybe I'm using the debugger wrong?
[~/tmp/test_gfortran]
$ cat hello_world.f90
program hello
print *, "Hello World!"
end program hello
[~/tmp/test_gfortran]
$ sudo gdb -q
/Applications/Octave-4.4.0.app/Contents/Resources/usr/bin/gfortran
Reading symbols from
/Applications/Octave-4.4.0.app/Contents/Resources/usr/bin/gfortran...(no
debugging symbols found)...done.
(gdb) r hello_world.f90
Starting program:
/Applications/Octave-4.4.0.app/Contents/Resources/usr/bin/gfortran
hello_world.f90
[New Thread 0xd03 of process 812]
warning: unhandled dyld version (15)
<built-in>: internal compiler error: Illegal instruction: 4
libbacktrace could not find executable to open
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://gcc.gnu.org/bugs/> for instructions.
[Inferior 1 (process 812) exited with code 01]
(gdb) bt
No stack.
(gdb) info signals SIGILL
Signal Stop Print Pass to program Description
SIGILL Yes Yes Yes Illegal instruction
(gdb)
I haven't been able to figure out how to get lldb to do a breakpoint at
the illegal instruction, either.
This is with "csrutil disable" done, so gdb works. I couldn't get the
code signing method to work.
I think the "unhandled dyld version (15)" is a red herring, since GDB
8.0.1 doesn't include
https://github.com/bminor/binutils-gdb/commit/4bbd4ef219c5b4c7d437618ba8937af86dd1032e,
which updates the maximum handled dyld version.
Cheers,
Andrew