stdlib.h compilation error for macports gcc9.

Chris Jones jonesc at hep.phy.cam.ac.uk
Sun Feb 7 23:34:08 UTC 2021



> On 7 Feb 2021, at 11:25 pm, Carlo Tambuatco <oraclmaster at gmail.com> wrote:
> 
> 
> 
> 
>> On Feb 7, 2021, at 6:18 PM, Christopher Jones <jonesc at hep.phy.cam.ac.uk> wrote:
>> 
>> 
>> what happens if you set SDKROOT and then try again
>> 
>> 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.


Mostly, if you didn’t manually specify the SDK to use it was just luck it worked. Its always been the recommendation to explicitly specify it.

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

> 
> 
> 
> 
>>>> On 7 Feb 2021, at 11:12 pm, Carlo Tambuatco <oraclmaster at gmail.com> wrote:
>>>> 
>>>> 
>>>> 
>>>> On Feb 7, 2021, at 5:39 PM, Christopher Jones <jonesc at hep.phy.cam.ac.uk> 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.
>>>> 
>>>> https://github.com/macports/macports-ports/commit/e8866c5019d60832527850b4e50fdc1de8878716#diff-5aeb3e82f6999f57229a816d2877a6232489c3484ac3e6716cb7e62b5a82696f
>>>> 
>>>> 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
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>>> 
>>>>> On 7 Feb 2021, at 10:24 pm, Carlo Tambuatco <oraclmaster at gmail.com> wrote:
>>>>> 
>>>>> 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 <jonesc at hep.phy.cam.ac.uk> wrote:
>>>>>> 
>>>>>> 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 <oraclmaster at gmail.com> 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
>>>>>> > 
>> 
> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macports.org/pipermail/macports-users/attachments/20210207/98fc0862/attachment.htm>


More information about the macports-users mailing list