https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90330

--- Comment #17 from Matt Thompson <matthew.thompson at nasa dot gov> ---
Iain,

The (In reply to Iain Sandoe from comment #16)
> Hi Matt,
> 
> (In reply to Matt Thompson from comment #15)
> 
> > I seem to still have issues. I downloaded 9.2.0 this morning and built it
> > with:
> > 
> > $ ../gcc-9.2.0/configure
> > --prefix=/Users/mathomp4/installed/Core/gcc-gfortran/9.2.0
> > --enable-languages=c,c++,fortran --disable-multilib
> > --with-native-system-header-dir=/usr/include
> > --with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk |& tee
> > configure.log
> > $ make -j4 |& tee make.log
> > $ make install |& tee makeinstall.log
> 
> a) --disable-multilib should no longer be needed [that PR was fixed on 9.2]

Okay. I'll remove that.

> 
> b) (remind me) what is the "--with-native-system-header-dir=/usr/include"
> meant to provide?  It seems like you are maybe mixing cross-configuration
> options with native ones...

This was my attempt to try to work around the fact that Apple no longer
supplies a /usr/include:

https://developer.apple.com/documentation/xcode_release_notes/xcode_10_release_notes#3035624

Now, I'm not sure that gcc itself needs /usr/include, but many of the libraries
and more I compile with gcc seem to assume it. And I've gotten to the point
where I just couldn't figure out how to pass '-isysroot' down to code like f2py
(gcc is called by f2py but f2py only passes down Fortran flags. And I just
*cannot* get our CMake system to pass CFLAGS='-isysroot...' to the gcc call
within f2py).

So, I thought I'd look around and saw that Homebrew built a little differently:

https://github.com/Homebrew/homebrew-core/blob/master/Formula/gcc.rb

adding:
      elsif MacOS.version >= :mojave
        # System headers are no longer located in /usr/include
        args << "--with-native-system-header-dir=/usr/include"
        args <<
"--with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk"

My hope was perhaps this would "embed" in gcc the fact that sysroot is not in
/usr/include but was in
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include and so f2py
would work again.

Is it just the --with-sysroot that I'd need to "hardcode" a gcc with that
sysroot?

I have tried the same configure line with gcc 8.2.0 loaded, but I get:

checking whether we are cross compiling... configure: error: in
`/Users/mathomp4/src/GCC/gcc-9.2.0-BUILD-820loaded':
configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details

So that's not right.

Now, that said, I can run that same link step that fails with clang g++ and
*explicitly* use g++-8.2.0 and it seems to work:

/Users/mathomp4/installed/Core/gcc-gfortran/8.2.0/bin/g++ -std=gnu++98    -g
-O2 -DIN_GCC     -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W
-Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wmissing-format-attribute
-Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros
-Wno-overlength-strings   -DHAVE_CONFIG_H  -o cc1plus \
      cp/cp-lang.o c-family/stub-objc.o cp/call.o cp/class.o cp/constexpr.o
cp/constraint.o cp/cp-gimplify.o cp/cp-objcp-common.o cp/cp-ubsan.o cp/cvt.o
cp/cxx-pretty-print.o cp/decl.o cp/decl2.o cp/dump.o cp/error.o cp/except.o
cp/expr.o cp/friend.o cp/init.o cp/lambda.o cp/lex.o cp/logic.o cp/mangle.o
cp/method.o cp/name-lookup.o cp/optimize.o cp/parser.o cp/pt.o cp/ptree.o
cp/repo.o cp/rtti.o cp/search.o cp/semantics.o cp/tree.o cp/typeck.o
cp/typeck2.o cp/vtable-class-hierarchy.o attribs.o incpath.o
c-family/c-common.o c-family/c-cppbuiltin.o c-family/c-dump.o
c-family/c-format.o c-family/c-gimplify.o c-family/c-indentation.o
c-family/c-lex.o c-family/c-omp.o c-family/c-opts.o c-family/c-pch.o
c-family/c-ppoutput.o c-family/c-pragma.o c-family/c-pretty-print.o
c-family/c-semantics.o c-family/c-ada-spec.o c-family/c-ubsan.o
c-family/known-headers.o c-family/c-attribs.o c-family/c-warn.o
c-family/c-spellcheck.o i386-c.o darwin-c.o cc1plus-checksum.o libbackend.a
main.o libcommon-target.a libcommon.a ../libcpp/libcpp.a
../libdecnumber/libdecnumber.a libcommon.a ../libcpp/libcpp.a
./../intl/libintl.a -liconv  ../libbacktrace/.libs/libbacktrace.a
../libiberty/libiberty.a ../libdecnumber/libdecnumber.a 
-L/Users/mathomp4/src/GCC/gcc-9.2.0-BUILD/./isl/.libs  -lisl
-L/Users/mathomp4/src/GCC/gcc-9.2.0-BUILD/./gmp/.libs
-L/Users/mathomp4/src/GCC/gcc-9.2.0-BUILD/./mpfr/src/.libs
-L/Users/mathomp4/src/GCC/gcc-9.2.0-BUILD/./mpc/src/.libs -lmpc -lmpfr -lgmp  
-L./../zlib -lz

After that if i unload the gcc 8.2.0 module, the make install succeeds.

Note, looking at Homebrew again, I do see they also build with:

  make BOOT_LDFLAGS=-Wl,-headerpad_max_install_names

would that help?

> 
> > I was hoping 9.2.0 would fix this. :(
> 
> I am very happy to try and help you fix this - and to patch trunk / 9.3 if
> there's a bug - but right now the builds I've done (both with GCC as
> bootstrap - for Ada and with clang as bootstrap) have succeeded on
> Darwin9..Darwin18.

Reply via email to