[flang-commits] [clang] [flang] [flang][driver] Add support for -isysroot in the frontend (PR #77365)
Leandro Lupori via flang-commits
flang-commits at lists.llvm.org
Mon Jan 15 13:45:28 PST 2024
luporl wrote:
> > If the compiler is built with `DEFAULT_SYSROOT`, the `-isysroot` option is ignored. Is that the expected behavior? My local MacOS build (with `-DDEFAULT_SYSROOT="$(xcrun --show-sdk-path)"`) has `isysroot.f90` failed.
>
> I expected `-isysroot` to override `DEFAULT_SYSROOT`. I'll take a look at that, thanks for reporting it.
This behavior is inherited from clang: https://github.com/llvm/llvm-project/blob/main/clang/lib/Driver/ToolChains/Darwin.cpp#L430
Only `--sysroot` overrides `DEFAULT_SYSROOT`.
It seems to me that, before `DEFAULT_SYSROOT` support was added, the original intention was to make `--sysroot` take precedence over `--isysroot`, if both were specified at command line: https://github.com/llvm/llvm-project/commit/980920a321550306e49a099bf3b082e39ad8965e.
I think `-isysroot` should have preference over `DEFAULT_SYSROOT`, but:
- I don't have much knowledge about the driver.
- Since this has been the behavior for a long time, I fear that changing it may break some use case.
- Some refactoring would need to be done, to make it possible to find out if what is being overridden is `DEFAULT_SYSROOT` or `--sysroot`.
An alternative would be to also support `--sysroot` on Flang, to be able to change it when `DEFAULT_SYSROOT` is used.
As for the `isysroot.f90` test, I guess it would need to be removed, unless there is some way to run it only when `DEFAULT_SYSROOT` is not set. But it doesn't seem worth the trouble, as`exec.f90` ends up testing `-isysroot`, when `DEFAULT_SYSROOT` is not specified at config time.
My preference is to add support for `--sysroot` on Flang and remove `isysroot.f90`.
@kkwli, @banach-space, what are your thoughts on this?
https://github.com/llvm/llvm-project/pull/77365
More information about the flang-commits
mailing list