I don’t know if this is a result of updating to the latest macports gcc9, or the update of XCode, but
all of a sudden when I try to build my C++ program which includes <cstdio> I get this strange chain reaction of errors. In file included from /opt/local/include/gcc9/c++/ext/string_conversions.h:41, from /opt/local/include/gcc9/c++/bits/basic_string.h:6493, from /opt/local/include/gcc9/c++/string:55, from /opt/local/include/gcc9/c++/bits/locale_classes.h:40, from /opt/local/include/gcc9/c++/bits/ios_base.h:41, from /opt/local/include/gcc9/c++/ios:42, from /opt/local/include/gcc9/c++/ostream:38, from /opt/local/include/gcc9/c++/iostream:39, from ../../standard_includes.h:1, from E2.5.2.cpp:1: /opt/local/include/gcc9/c++/cstdlib:75:15: fatal error: stdlib.h: No such file or directory 75 | #include_next <stdlib.h> From my makefile this seems to be the offending includes statement: #include <iostream> #include <cstdio> I’ve googled and it seems that it can’t find stdlib.h, even though it is on my CPATH environment variable: export CPATH=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include:/usr/local/include:/opt/local/include:/usr/local/dart-sdk/include:/Library/Frameworks/R.framework/Resources/include |
It sounds like your builds are not correctly specifying the SDK gcc is to use. There are a number of ways you can do this, either by pass it via a compiler flag, by running the complication through xcrun, or by setting the SDKROOT variables to the required path. Cheers Chris > On 7 Feb 2021, at 9:25 pm, Carlo Tambuatco <[hidden email]> wrote: > > I don’t know if this is a result of updating to the latest macports gcc9, or the update of XCode, but > all of a sudden when I try to build my C++ program which includes <cstdio> I get this strange > chain reaction of errors. > > In file included from /opt/local/include/gcc9/c++/ext/string_conversions.h:41, > from /opt/local/include/gcc9/c++/bits/basic_string.h:6493, > from /opt/local/include/gcc9/c++/string:55, > from /opt/local/include/gcc9/c++/bits/locale_classes.h:40, > from /opt/local/include/gcc9/c++/bits/ios_base.h:41, > from /opt/local/include/gcc9/c++/ios:42, > from /opt/local/include/gcc9/c++/ostream:38, > from /opt/local/include/gcc9/c++/iostream:39, > from ../../standard_includes.h:1, > from E2.5.2.cpp:1: > /opt/local/include/gcc9/c++/cstdlib:75:15: fatal error: stdlib.h: No such file or directory > 75 | #include_next <stdlib.h> > > > From my makefile this seems to be the offending includes statement: > > #include <iostream> > #include <cstdio> > > > I’ve googled and it seems that it can’t find stdlib.h, even though it is on my CPATH environment variable: > > export CPATH=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include:/usr/local/include:/opt/local/include:/usr/local/dart-sdk/include:/Library/Frameworks/R.framework/Resources/include > |
Well what's odd is I'm only getting this error after upgrading to the latest macports gcc9. Indeed when I use the XCode provided clang version of gcc, it finds all the required libraries. My CPATH environment variable was sufficient to specify the locations of the libraries before the upgrade, so the question is, what changed post-upgrade? On Sun, Feb 7, 2021, 5:03 PM Chris Jones <[hidden email]> wrote:
|
macOS 11 brought big changes to how Apple versions its SDKs. They now potentially change each minor update, and as such we had to figure out how to deal with this.
gcc is built against a specific SDK, and to handle this unpredictably it was recently changed to use the unversioned SDK, instead of a versioned one, where required. Are you on maOS 11 ? please post the output you get from your failing build, showing the full command line you use, and the full output, and include the -v option to get additional diagnostic output. Chris
|
Using macOS Catalina 10.15.7 Here’s my CPATH environment variable, which up until the gcc9 upgrade, worked fine to relay the location of relevant include paths: CPATH=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include:/usr/local/include:/opt/local/include:/usr/local/dart-sdk/include:/Library/Frameworks/R.framework/Resources/include Also, here’s the contents of my SDKs directory in XCode 12.4: pwd = /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs drwxr-xr-x 5 root wheel 160 Nov 30 07:27 DriverKit20.2.sdk/ drwxr-xr-x 7 root wheel 224 Nov 30 07:27 MacOSX.sdk/ lrwxr-xr-x 1 root wheel 10 Jan 27 04:53 MacOSX11.1.sdk -> MacOSX.sdk/ So it seems I’m using the SDK for macOS 11.1… Here’s the full output of the error using the -v option: g++ -v -std=c++11 -c E2.5.2.cpp -o E2.5.2.o Using built-in specs. COLLECT_GCC=g++ Target: x86_64-apple-darwin19 Configured with: /opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_lang_gcc9/gcc9/work/gcc-9.3.0/configure --prefix=/opt/local --build=x86_64-apple-darwin19 --enable-languages=c,c++,objc,obj-c++,lto,fortran,jit --libdir=/opt/local/lib/gcc9 --includedir=/opt/local/include/gcc9 --infodir=/opt/local/share/info --mandir=/opt/local/share/man --datarootdir=/opt/local/share/gcc-9 --with-local-prefix=/opt/local --with-system-zlib --disable-nls --program-suffix=-mp-9 --with-gxx-include-dir=/opt/local/include/gcc9/c++/ --with-gmp=/opt/local --with-mpfr=/opt/local --with-mpc=/opt/local --with-isl=/opt/local --enable-stage1-checking --disable-multilib --enable-lto --enable-libstdcxx-time --with-build-config=bootstrap-debug --with-as=/opt/local/bin/as --with-ld=/opt/local/bin/ld --with-ar=/opt/local/bin/ar --with-bugurl=https://trac.macports.org/newticket --enable-host-shared --disable-tls --with-pkgversion='MacPorts gcc9 9.3.0_5' --with-sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk Thread model: posix gcc version 9.3.0 (MacPorts gcc9 9.3.0_5) COLLECT_GCC_OPTIONS='-v' '-std=c++11' '-c' '-o' 'E2.5.2.o' '-mmacosx-version-min=10.15.0' '-asm_macosx_version_min=10.15' '-shared-libgcc' '-mtune=core2' /opt/local/libexec/gcc/x86_64-apple-darwin19/9.3.0/cc1plus -quiet -v -D__DYNAMIC__ E2.5.2.cpp -fPIC -quiet -dumpbase E2.5.2.cpp -mmacosx-version-min=10.15.0 -mtune=core2 -auxbase-strip E2.5.2.o -std=c++11 -version -o /var/folders/yh/ywbbh6_w8xl9_6006s6dywd80000gr/T//cc1Ruczn.s GNU C++11 (MacPorts gcc9 9.3.0_5) version 9.3.0 (x86_64-apple-darwin19) compiled by GNU C version 9.3.0, GMP version 6.2.1, MPFR version 4.1.0, MPC version 1.2.1, isl version isl-0.22.1-GMP GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/opt/local/include" ignoring nonexistent directory "/opt/local/lib/gcc9/gcc/x86_64-apple-darwin19/9.3.0/../../../../../x86_64-apple-darwin19/include" ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include" ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks" ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/Library/Frameworks" #include "..." search starts here: #include <...> search starts here: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include /usr/local/include /opt/local/include /usr/local/dart-sdk/include /Library/Frameworks/R.framework/Resources/include /opt/local/include/gcc9/c++/ /opt/local/include/gcc9/c++//x86_64-apple-darwin19 /opt/local/include/gcc9/c++//backward /opt/local/lib/gcc9/gcc/x86_64-apple-darwin19/9.3.0/include /opt/local/lib/gcc9/gcc/x86_64-apple-darwin19/9.3.0/include-fixed End of search list. GNU C++11 (MacPorts gcc9 9.3.0_5) version 9.3.0 (x86_64-apple-darwin19) compiled by GNU C version 9.3.0, GMP version 6.2.1, MPFR version 4.1.0, MPC version 1.2.1, isl version isl-0.22.1-GMP GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: 45101e0fe9cd9377caa0fee122dd387a In file included from /opt/local/include/gcc9/c++/ext/string_conversions.h:41, from /opt/local/include/gcc9/c++/bits/basic_string.h:6493, from /opt/local/include/gcc9/c++/string:55, from /opt/local/include/gcc9/c++/bits/locale_classes.h:40, from /opt/local/include/gcc9/c++/bits/ios_base.h:41, from /opt/local/include/gcc9/c++/ios:42, from /opt/local/include/gcc9/c++/ostream:38, from /opt/local/include/gcc9/c++/iostream:39, from ../../standard_includes.h:1, from E2.5.2.cpp:1: /opt/local/include/gcc9/c++/cstdlib:75:15: fatal error: stdlib.h: No such file or directory 75 | #include_next <stdlib.h> | ^~~~~~~~~~ compilation terminated. make: *** [../../Makefile-Template:10: E2.5.2.o] Error 1
|
export SDKROOT=`xcrun --show-sdk-path` ?
|
Hm… that seems to have done the trick. So, what changed between upgrades to gcc9…? It worked fine before.
|
On 7 Feb 2021, at 11:25 pm, Carlo Tambuatco <[hidden email]> wrote:
Before the various 11.x SDKs came out the name used for each major 10.x version was the same. This changed with 11 such that now the exact versioned name changes a lot more regularly. Gcc has a single sdk version backed into it, which it includes in its defsult sesrch paths and if that happens to match what you have installed, it will work. But this is relying on luck, so its better to specify it yourself. Personally I put that line to set SDKROOT into my shell profile, and then just forget about it. Chris
|
In reply to this post by Carlo Tambuatco
Our fix changed the baked-in gcc SDK reference from using the
MacOSX11.x and above to MacOSX.sdk. that fixes a number of broken systems, but not all it appears. Perhaps we should find a way to broaden that down to including MacOSX10.15+ as well, if Catalina is going to be using the MacOSX11.x SDK. Luckily it appears our previous fix was not responsible for this -- just not broad enough to fix even more issues people have. And -- baking the SDK into gcc at all is just a pain. It should just use SDKROOT and it was supposed to do that after Iain's fixes. Ken |
Administrator
|
On Feb 7, 2021, at 17:57, Ken Cunningham wrote: > Perhaps we should find a way to broaden that down to including MacOSX10.15+ as well, if Catalina is going to be using the MacOSX11.x SDK. Why stop at 10.15? For several macOS versions before that, the last compatible Xcode version might include only a newer SDK that does not match the OS version. |
Administrator
|
On Feb 8, 2021, at 12:34, Ken Cunningham wrote:
> On 2021-02-08, at 10:02 AM, Ryan Schmidt wrote: > >> On Feb 7, 2021, at 17:57, Ken Cunningham wrote: >> >>> Perhaps we should find a way to broaden that down to including MacOSX10.15+ as well, if Catalina is going to be using the MacOSX11.x SDK. >> >> Why stop at 10.15? For several macOS versions before that, the last compatible Xcode version might include only a newer SDK that does not match the OS version. > > Well I can't keep up any more with the rapidly changing opinions. > > I have been under the impression you were (more or less) dead-set against this. > > <https://lists.macports.org/pipermail/macports-dev/2020-December/042774.html> > > I was happy to get 11.x accepted, at least for GCC. Well I did say there that "This is not a new problem in macOS 11; it has been a problem anytime we use an SDK, and certainly since 10.14." I'm in favor of consistency; it would be inconsistent to accommodate SDK-version-does-not-match-OS-version on some OS versions but not others. We pointed out the types of problems that can arise from trying to use an SDK that does not match the OS version in projects that have not specifically been coded to anticipate that scenario. You went ahead with the change for gcc anyway, so I assume that means you determined that it was not a problem for gcc. |
Free forum by Nabble | Edit this page |