Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XCode SDK path changed; clang's sysroot is wrong. #2211

Closed
1 of 7 tasks
hv15 opened this issue Dec 7, 2020 · 3 comments
Closed
1 of 7 tasks

XCode SDK path changed; clang's sysroot is wrong. #2211

hv15 opened this issue Dec 7, 2020 · 3 comments
Assignees
Labels
Area: Apple investigate Collect additional information, like space on disk, other tool incompatibilities etc. OS: macOS

Comments

@hv15
Copy link

hv15 commented Dec 7, 2020

Description

Hi, just today we noticed that when compiling our software on the MacOS image, we get the following warning:
clang: warning: no such sysroot directory: '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk' [-Wmissing-sysroot]. This then leads to errors when trying to compile valid C sources.

Area for Triage:

Apple and XCode

Question, Bug, or Feature?:

Question

Virtual environments affected

  • Ubuntu 16.04
  • Ubuntu 18.04
  • Ubuntu 20.04
  • macOS 10.15
  • macOS 11.0
  • Windows Server 2016 R2
  • Windows Server 2019

Expected behavior
We should be able to compile our code fine using Clang.

Actual behavior
When compiling, we get the following error:

clang: warning: no such sysroot directory: '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk' [-Wmissing-sysroot]
In file included from /tmp/SAC_8aZX2e/fun1.c:1:
In file included from /tmp/SAC_8aZX2e/header.h:278:
In file included from /usr/local/include/sac2c/1.3.3-MijasCosta-523-gf6fdf/debug/sac.h:30:
/usr/local/include/sac2c/1.3.3-MijasCosta-523-gf6fdf/debug/runtime/distmem_h/distmem.h:26:10: fatal error: 'stdlib.h' file not found
#include <stdlib.h>
         ^~~~~~~~~~
1 error generated.
abort: System failed to execute shell
abort: command
abort: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc   -march=native -mtune=native  -pedantic -g  -D_DARWIN_C_SOURCE  -fbracket-depth=2048 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -Wall -Wextra -Weverything -Wno-padded -Wno-documentation -Wstrict-prototypes -Wno-unused-parameter -Wno-reserved-id-macro -Wno-shadow -Wno-undef -Wno-conversion -Wno-missing-prototypes -Wno-unused-function -Wno-covered-switch-default -Wno-format-nonliteral -Wno-switch-enum -Wno-missing-noreturn -Wno-float-equal -Wno-vla -Wno-unused-macros -Wno-cast-align -Wno-cast-qual -Wno-documentation-unknown-command -Wno-gnu-zero-variadic-macro-arguments -Wno-alloca -Wno-poison-system-directories -Wno-atomic-implicit-seq-cst -std=gnu99 -pedantic -Wno-unused -fno-builtin  -I.  -DHAVE_CONFIG_H -I/Users/runner/work/Stdlib/build/include -I/Users/runner/work/Stdlib/Stdlib/include -DFULLTYPES -DEXT_STDLIB -DSAC_TARGET_STRING=\"seq\" -DSAC_MODEXT_STRING=\".dylib\" -DSAC_TARGET_ENV_STRING=\"host\" -DSAC_SBI_STRING=\"seq\" -DSAC_RC_METHOD=SAC_RCM_local -DSAC_BACKEND_C99 -DSAC_MT_LIB_ -DSAC_MT_MODE=0 -DSAC_DO_RTSPEC=0 -DSAC_DO_CUDA_ALLOC=SAC_CA_system -DSAC_DO_CUDA_SYNC=1 -I/usr/local/include/sac2c/1.3.3-MijasCosta-523-gf6fdf/debug -c -o /tmp/SAC_8aZX2e/fun1.o /tmp/SAC_8aZX2e/fun1.c
abort: with exit code 1

Repro steps
This affects our repo, see relevant example given through our PR: SacBase/Stdlib#43

The code in this instance doesn't matter, rather our compiler tool (sac2c) which we are using in the above project to compile a standard library, uses a hard-coded path for the sysroot flag. We determine that path when compiling sac2c, which we did on a MacOS 10.15 system (not image). This was about 3 months ago. I think that between then and now some changes (maybe XCode update per #2073) has changed this path.

Is there some generic path we can use instead?

@al-cheb al-cheb added investigate Collect additional information, like space on disk, other tool incompatibilities etc. OS: macOS and removed needs triage labels Dec 7, 2020
@maxim-lobanov
Copy link
Contributor

maxim-lobanov commented Dec 7, 2020

Hello @hv15 , default Xcode was changed from 12.0 to 12.2 recently on Hosted images. See #2056
Xcode 12.2 doesn't contain MacOSX10.15.sdk so looks like it causes your failures.

ls -la /Applications/Xcode_12.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs
echo "-----------"
ls -la /Applications/Xcode_12.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs

returns

total 0
drwxr-xr-x  5 runner  wheel  160 Nov 30 22:02 .
drwxr-xr-x  6 runner  wheel  192 Sep 19 01:50 ..
drwxr-xr-x  4 runner  wheel  128 Aug 10 17:36 DriverKit19.0.sdk
drwxr-xr-x  8 runner  wheel  256 Aug 10 17:36 MacOSX.sdk
lrwxr-xr-x  1 runner  wheel   10 Nov 30 21:59 MacOSX10.15.sdk -> MacOSX.sdk
-----------
total 0
drwxr-xr-x  5 runner  wheel  160 Nov 30 23:07 .
drwxr-xr-x  6 runner  wheel  192 Oct 24 02:20 ..
drwxr-xr-x  5 runner  wheel  160 Oct 19 20:33 DriverKit20.0.sdk
drwxr-xr-x  7 runner  wheel  224 Oct 19 20:33 MacOSX.sdk
lrwxr-xr-x  1 runner  wheel   10 Nov 30 23:05 MacOSX11.0.sdk -> MacOSX.sdk

If you still need to use Xcode 12.0, #2056 contains the way to switch Xcode

Update:
In your code you use /Applications/Xcode.app. This path points to default Xcode that can be changed.
I suggest to hardcode some specific Xcode (like 12.0) that works for you.
The paths for all Xcode versions can be found in docs: https://github.com/actions/virtual-environments/blob/main/images/macos/macos-10.15-Readme.md#xcode

@maxim-lobanov maxim-lobanov self-assigned this Dec 7, 2020
@hv15
Copy link
Author

hv15 commented Dec 7, 2020

Hi @maxim-lobanov, thanks for the quick reply. I didn't realise one could switch the Xcode version, excellent!

In your code you use /Applications/Xcode.app. This path points to default Xcode that can be changed.
I suggest to hardcode some specific Xcode (like 12.0) that works for you.
The paths for all Xcode versions can be found in docs: https://github.com/actions/virtual-environments/blob/main/images/macos/macos-10.15-Readme.md#xcode

Spot on, just working to fix that!!! Thanks for your help!

@tangobravo62
Copy link

The same problem resurfaces again after switching to OS X 11.1 and XCode 12.3. The SDK now is MacOSX11.1.sdk, but clang requests MacOSX11.0.sdk. Workaround is to create a symlink:

user@localhost ~ % ll /Library/Developer/CommandLineTools/SDKs
total 0
lrwxr-xr-x  1 root  wheel   14 20 Jan 18:24 MacOSX.sdk -> MacOSX11.1.sdk
drwxr-xr-x  8 root  wheel  256  9 Jul  2020 MacOSX10.15.sdk
lrwxr-xr-x  1 root  wheel   55 20 Jan 18:34 MacOSX11.0.sdk -> /Library/Developer/CommandLineTools/SDKs/MacOSX11.1.sdk
drwxr-xr-x  7 root  wheel  224 30 Nov 13:33 MacOSX11.1.sdk

A better solution would be to not request a specific version of the Mac OS SDK at all, but the generic MacOSX.sdk, which will – given a correct installation of XCode and XCode Command Line Tools – always point to the current version of the SDK.

akien-mga added a commit to akien-mga/overgrowth that referenced this issue Apr 3, 2023
For whatever reason CMake seems to infer "12.6" as SDK version, because
the GitHub Action macOS runner is based on macOS 12.6. But that number
doesn't match the SDK version, which should be 13.1 here.

This seems to be a long running issue with GitHub Actions' macOS runner:
actions/runner-images#2211

Though I can't tell if it's a CMake bug or a GitHub Actions image setup
issue.
akien-mga added a commit to akien-mga/overgrowth that referenced this issue Apr 3, 2023
For whatever reason CMake seems to infer "12.6" as SDK version, because
the GitHub Action macOS runner is based on macOS 12.6. But that number
doesn't match the SDK version, which should be 13.1 here.

This seems to be a long running issue with GitHub Actions' macOS runner:
actions/runner-images#2211

Though I can't tell if it's a CMake bug or a GitHub Actions image setup
issue.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Apple investigate Collect additional information, like space on disk, other tool incompatibilities etc. OS: macOS
Projects
None yet
Development

No branches or pull requests

4 participants