<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/137352>137352</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [clang] Driver does not select a default -isysroot when targeting macOS
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          bradking
      </td>
    </tr>
</table>

<pre>
    On most platforms, `clang hello.c` works out of the box for builds targeting the host platform.  However, as of LLVM/Clang 20.1.2, this is not the case on macOS:

```console
$ cat main.c
int main(void) { return 0; }
$ clang main.c
ld: library 'System' not found
clang: error: linker command failed with exit code 1 (use -v to see invocation)
$ cat hello.c
#include <stdio.h>
int main(void) { printf("Hello, world!"); return 0; }
$ clang hello.c
hello.c:1:10: fatal error: 'stdio.h' file not found
    1 | #include <stdio.h>
      |          ^~~~~~~~~
1 error generated.
```

Instead one must manually populate the `SDKROOT` environment variable (or pass `-isysroot`):

```console
$ export SDKROOT="$(xcrun --sdk macosx --show-sdk-path)"
$ clang main.c
$ clang hello.c
```

It seems reasonable to expect `clang` to select a default sysroot automatically on macOS even when `SDKROOT` is not set in the environment.

</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJx8VE1v4zYQ_TX0ZWCBpiTLOujgxGts0S0CNEXvlDiy2FAcgxzJyaW_vaAcJ2mwG4KGxSHn4z0-jo7RnjxiI8o7UR5WeuKBQtMGbZ6sP61aMi_Ng4eRIsPZae4pjFGoexBb2TntTzCgc5R1YivhQuEpAk0M1AMPCC09Q08B2sk6E4F1OCFbf1o2h48xM4DvdMEZQwquY4rw48fffwh1vF_SKJltMpU2ebARbARPvMTpdEQgD6PuHh5FvhdymVt5nR35SA6TSRXQaYZRW591Qu6tvy6E2s1kjVA1iOoOAvIUPEiR34GoDjfPpYw3X2dEvgdn26DDCwhVPb5ExlGoaimsp8kbIfeLVzqJIVC4uvgnDNDROGpvoNfWoYGL5QHw2TJ0ZBA2INRuigjrGZggIoL1M3WaLXmh6g9obvwnS2595yaDIPL7yMZSNoj826-RnoP13Au1E0p9T3ESvxcKzgi1EUqlTPnXhLynv33l-036yQS216zdO3ahqltZqoLeOvwfWQCQkFf38AUUWEY69DZE-e3f1yHkfnPNByf0GDSjyT7K4aqO33xk1AbII4xTTOT4STv3Amc6T04zLtISW_l4-P3Ph4e_krzRzzaQH9EzzDpY3TpM90QBzjrGdHpt40sMRJwyJfK-ViM-nykw3HLkh4XzQqjdcxcmD-t1NE9J2BSf02KgS7Ksz5qHFF6pn4vzZ9fzmQFOqhojBNSR_IKFKVWEHb-97gR70Z9LVg0Gez05hleUoCemUbPtFu5ujxBwRg-XAf0nBl9fbUQG6xeGP3CarmllmtzUea1X2GyqoizrbVUXq6GReV4azI3WdSex3ZVtUci-3m22pu5zWaxso6QqZaHKTVnWZZHJXdfWm6rYtuVOVlUrComjti5zbh4zCqeVjXHCZpNXealWTrfo4tIHlbpiVyq1xNAkh3U7naIopLOR43sItuyW5nn1KA9wCHbGAIbwhvUTdW8SuRL03hMX6lZTcM3AfI5JO-oo1PFkeZjarKNRqGPK_Pq3Pgf6BzsW6rggiUIdX8HMjfovAAD__0Jm1hk">