Re: Compiling GCC for different x86 CPU generation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



There is this IMO important sentence in the gcc docs regarding --with-gmp etc:

"These flags are applicable to the host platform only. When building a cross compiler, they will not be used to configure target libraries."
https://gcc.gnu.org/install/configure.html



Andrew Janke wrote on 07/24/2018 07:00 AM:
Hi, GCC folks,

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.

Doing the build on the Ivy Bridge Mac and using the locally-built GCC's
gfortran there works, so I think this is in fact an architecture-mismatch issue.

Passing a variety of CFLAGS/CXXFLAGS isn't working. And even adding
--disable-bootstrap to the "configure" step results in the same issue.

Here's my "configure" call:

../configure \
--build=x86_64-apple-darwin17.6.0 \
--prefix=/Applications/Octave-4.4.0.app/Contents/Resources/usr/Cellar/gcc_8.1.0/8.1.0
\
--libdir=/Applications/Octave-4.4.0.app/Contents/Resources/usr/Cellar/gcc_8.1.0/8.1.0
/lib/gcc/8 \
--enable-languages=c,c++,objc,obj-c++,fortran \
--program-suffix=-8 \
--with-gmp=/Applications/Octave-4.4.0.app/Contents/Resources/usr/opt/gmp_6.1.2 \
--with-mpfr=/Applications/Octave-4.4.0.app/Contents/Resources/usr/opt/mpfr_4.0.1
\
--with-mpc=/Applications/Octave-4.4.0.app/Contents/Resources/usr/opt/libmpc_1.1.0
\
--with-isl=/Applications/Octave-4.4.0.app/Contents/Resources/usr/opt/isl_0.19 \
--with-system-zlib \
--enable-checking=release \
--with-pkgversion="Homebrew GCC 8.1.0" \
--disable-nls

And my "make" invocation:

make CFLAGS=-march=core2 CXXFLAGS=-march=core2 CFLAGS_FOR_TARGET=-march=core2
CXXFLAGS_FOR_TARGET=-march=core2 BOOT_CFLAGS=-march=core2
BOOT_CXXFLAGS=-march=core2

Can anyone tell me if I'm doing this the right way, and what I could do to fix
it?

Original bug report from my project if you're interested in seeing the history:
https://github.com/octave-app/octave-app-bundler/issues/42

Cheers,
Andrew Janke





[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux