mirror of
https://github.com/apple/swift.git
synced 2026-10-20 19:13:47 +02:00
Forward -DLLVM_ENABLE_INDEX_STORE to the LLVM and Swift host cmake
configures so each compile emits an index store. The flag is gated
on the host compiler accepting -index-store-path via the existing
check_{c,cxx}_compiler_flag probe in HandleLLVMOptions.cmake, so it
is a no-op for compilers that don't support it. Pass
--llvm-enable-index-store=0 to opt out.
HandleLLVMOptions.cmake's snippet only appends -index-store-path to
CMAKE_C_FLAGS / CMAKE_CXX_FLAGS, so swiftc invocations need parallel
hooks. swift/CMakeLists.txt mirrors the same pattern for the Swift
compile language: it probes CMAKE_Swift_COMPILER via the existing
swift_supports_compiler_arguments helper (so the wiring also no-ops
against an old swiftc), then emits the flag through
$<COMPILE_LANGUAGE:Swift>. This covers any target built via
standard CMake Swift support.
Two custom swiftc invocation paths bypass that hook:
* stdlib/cmake/modules/SwiftSource.cmake's _compile_swift_files
drives every stdlib variant, SDK overlay, and core library
compile via add_custom_command. The append is gated on
num_outputs > 1 (i.e. file-map mode, one .o per .swift). In
single-output WMO mode swiftc cannot match per-source index
unit tokens to inputs and bails with "index output filenames
do not match input source files" - FrontendTool.cpp:2379 calls
out this exact limitation as a FIXME.
* SwiftCompilerSources/CMakeLists.txt builds the libswift
compiler modules with -wmo -c -o module.o for many input
sources, which is the broken WMO+single-output mode above. We
therefore deliberately do NOT emit -index-store-path on this
path - the libswift compiler modules are intentionally left
out of the IndexStore until the upstream FIXME lands or the
build switches to per-source outputs via an output-file-map.
With those caveats the swift compiler's C++ sources, the stdlib
and SDK overlays, the swift-syntax / standard CMake Swift targets,
and llvm/clang itself all land in the same IndexStore.