[flang-commits] [flang] [flang] Fix failure of regression tests on macOS (PR #151812)
Leandro Lupori via flang-commits
flang-commits at lists.llvm.org
Mon Aug 4 12:10:05 PDT 2025
luporl wrote:
> > However, I was not sure which tests exactly need the flag, so I tried removing it in testing and found that all tests were passed.
>
> If I remove `-isysroot` from tests, I see the following failures:
>
> ```
> check-flang:
> Flang :: Integration/iso-fortran-binding.cpp
> check-flang-rt:
> flang-rt :: Driver/ctofortran.f90
> flang-rt :: Runtime/no-cpp-dep.c
> flang-rt-Unit :: Runtime/./RuntimeTests/NoArgv/FdateNotSupported (this test was already failing)
> ```
>
> So, when not using `DEFAULT_SYSROOT` or `SDKROOT`, `-isysroot` is needed, so that the system libraries are found.
>
Actually, these tests are all failing now. I hadn't noticed it because I always use `DEFAULT_SYSROOT`.
There are multiple issues:
- As @parabola94 mentioned in the linked issue, CMake doesn't set `CMAKE_OSX_SYSROOT` by default anymore, as it did when `-isysroot` was added to `%flang`, but only if `SDKROOT` is set. We will need to get its value from somewhere else. Compiler-rt build sets `-isysroot`, so we can probably reuse its logic. This can be done in a separate PR.
- In `darwin-version.f90`, `-isysroot` can't be used because it overrides the macosx version set by `-target`.
- `iso-fortran-binding.cpp` should be refactored, to build the test with `%clang` instead of trying to figure out where it is from `%flang`.
> What is the issue with `SDKROOT`? Should the tests be using the SDK specified in it when it is set? If so, this could be easily changed in `llvm-project/flang/test/lit.cfg.py`.
>
>From what I understood, setting `SDKROOT` when running CMake (4.0 or higher) sets `CMAKE_OSX_SYSROOT`, which adds `-isysroot` to `%flang`, overriding the macosx version set by `-target`, which makes `darwin-version.f90` fail.
> Since there are only 3 tests that need `-isysroot`, another option is to not include it by default and add a new substitution, such as `%isysroot_flag`, and then use it only in the tests above.
IMHO, considering the `darwin-version.f90` issue, this seems the best option.
The idea of adding `-isysroot` to `%flang` was to make things work transparently on macOS.
But there are only a few tests that need it, and every now and then people forget about `%flang_fc1` and use `%flang -fc1` instead, which works on all other architectures.
https://github.com/llvm/llvm-project/pull/151812
More information about the flang-commits
mailing list