carlocab wrote:

> However, notably, even on Darwin, if you pass _both_ flags, you still get the 
> intended behavior of `-isysroot` affecting headers, and `--sysroot` affecting 
> libraries. Your change would break that.

What's the use-case for this?

Because for most users, you almost certainly don't want to mix headers and 
libraries of different versions, and keeping the existing behavior is 
essentially a big footgun when trying to build a useful toolchain on Darwin.

At Homebrew, we used to configure the toolchain with `DEFAULT_SYSROOT` but have 
recently switched that to setting the `--sysroot` flag in a Clang `.cfg` 
file.[^1] In either case, if you set `SDKROOT` in your environment or try to 
run our `clang` using Apple's `xcrun`, this becomes equivalent to setting 
`-isysroot` and you most likely will end up with headers that mismatch the 
libraries you try to link to.

It seems to me that getting rid of a footgun that can impact many users (our 
toolchain is installed [a few hundred thousand times a 
year](https://formulae.brew.sh/formula/llvm#default), see also the [downstream 
bug report](https://github.com/Homebrew/homebrew-core/issues/197277) I 
initially linked) might be worth breaking what currently seems to be a niche 
use-case of using headers and libraries of different versions. If you really 
wanted to do this, you can set `-Wl,-syslibroot`.

Of course, I'm open to alternatives that don't involve breaking anyone.

[^1]: We do this so that the toolchain can find the sysroot out of the box, 
when it wouldn't be able to otherwise.

https://github.com/llvm/llvm-project/pull/115993
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to