Pass the target and sysroot flags from the build to lit and make sure
they are included in the test cflags.
Details
- Reviewers
vitalybuka yln delcypher
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Looks sensible to me, but I don't understand the implications here.
Can you explain why this is needed/what doesn't work right now?
@phosek
In our case we build against an explicit sysroot or SDK, even when the host matches the target. This is to ensure that we don't accidentally introduce dependency on libraries (or their versions) that are only present on certain hosts. We noticed recently that test binaries don't follow the CMake configuration when we saw test failures that only affected some hosts. The goal of this change is to make the behavior CMake and lit more consistent.
compiler-rt/test/lit.common.cfg.py | ||
---|---|---|
699 | I haven't verified this but I think this very likely to break testing for Apple platforms. I don't think config.target_triple is set correctly. IIRC we rely on the target triple being inferred from the SDK and arch being used. This isn't a good situation to be in, explicit would definitely be better. | |
701 | We should check but I doubt this is configured correctly. It's probably correct for macOS but broken for other Apple platforms because I suspect config.sysroot might always be set to a macOS SDK path. |
The change is right in "spirit" but I think the current implementation will likely break things (or will work by accident). There is a fundamental difference between how compiler-rt is built for Apple platforms and other platforms. For Apple platforms we build all platforms and targets in a single CMake configure (IIUC other platforms have a CMake configure correspond to a single platform and arch). So there is no single sysroot or target triple.
The way this is currently handled for the the lit testing is we generate a lit test suite for each OS and architecture we want, e.g. from a template like
https://github.com/llvm/llvm-project/blob/main/compiler-rt/test/asan/lit.site.cfg.py.in
I think what the patch does here is fine to be the "default" (although I might prefer it to be set to something that causes on error by default on Apple platforms) but we need to make sure for all the generated testsuites that we override config.target_triple and config.sysroot to be the right thing.
We might also want to remote the sysroot from being set in the target_cflags because we already do that e.g.
# Autogenerated from /Volumes/user_data/dev/llvm/llvm.org/main/src/llvm-project/compiler-rt/test/asan/lit.site.cfg.py.in # Do not edit! # Allow generated file to be relocatable. from pathlib import Path def path(p): if not p: return '' return str((Path(__file__).parent / p).resolve()) # Tool-specific config options. config.name_suffix = "-arm64-ios" config.target_cflags = "-arch arm64 -stdlib=libc++ -miphoneos-version-min=9.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS15.4.sdk -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta " config.clang = "/Volumes/user_data/dev/llvm/llvm.org/main/builds/Debug/./bin/clang" config.bits = "64" config.arm_thumb = "" config.apple_platform = "ios" config.apple_platform_min_deployment_target_flag = "-miphoneos-version-min" config.asan_dynamic = True config.target_arch = "arm64" ...
We might want to create an Apple "platform/arch" specific "lit.common.configured.in" files that the existing testsuites (e.g. ASan) can include so we don't have to duplicate the logic across all the different test suites.
compiler-rt/test/lit.common.configured.in | ||
---|---|---|
11 | This will be the sysroot for macOS which is the wrong sysroot for all other Apple platforms. |
I haven't verified this but I think this very likely to break testing for Apple platforms. I don't think config.target_triple is set correctly. IIRC we rely on the target triple being inferred from the SDK and arch being used. This isn't a good situation to be in, explicit would definitely be better.