mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
When Swift passes search paths to clang, it does so directly into the HeaderSearch. That means that those paths get ordered inconsistently compared to the equivalent clang flag, and causes inconsistencies when building clang modules with clang and with Swift. Instead of touching the HeaderSearch directly, pass Swift search paths as driver flags, just do them after the -Xcc ones. Swift doesn't have a way to pass a search path to clang as -isystem, only as -I which usually isn't the right flag. Add an -Isystem Swift flag so that those paths can be passed to clang as -isystem. rdar://93951328
52 lines
2.0 KiB
Swift
52 lines
2.0 KiB
Swift
// Make sure that Swift's search paths order the same as the corresponding clang flags
|
|
// In particular, they should all come before the default usr/local/include
|
|
|
|
// RUN: %empty-directory(%t)
|
|
// RUN: split-file %s %t
|
|
|
|
// RUN: %target-clang -isysroot %t/sdk -I%t/sdk/custom/include -fmodules -fmodules-cache-path=%t/mcp1 -fsyntax-only %t/SearchPathOrder.m
|
|
// RUN: %target-clang -isysroot %t/sdk -isystem %t/sdk/custom/include -fmodules -fmodules-cache-path=%t/mcp2 -fsyntax-only %t/SearchPathOrder.m
|
|
// RUN: %target-clang -isysroot %t/sdk -F%t/sdk/custom/Frameworks -fmodules -fmodules-cache-path=%t/mcp3 -fsyntax-only %t/SearchPathOrder.m
|
|
// RUN: %target-clang -isysroot %t/sdk -iframework %t/sdk/custom/Frameworks -fmodules -fmodules-cache-path=%t/mcp4 -fsyntax-only %t/SearchPathOrder.m
|
|
|
|
// RUN: %target-swift-frontend -sdk %t/sdk -typecheck -I %t/sdk/custom/include -module-cache-path %t/mcp5 %t/SearchPathOrder.swift
|
|
// RUN: %target-swift-frontend -sdk %t/sdk -typecheck -Isystem %t/sdk/custom/include -module-cache-path %t/mcp6 %t/SearchPathOrder.swift
|
|
// RUN: %target-swift-frontend -sdk %t/sdk -typecheck -F %t/sdk/custom/Frameworks -module-cache-path %t/mcp7 %t/SearchPathOrder.swift
|
|
// RUN: %target-swift-frontend -sdk %t/sdk -typecheck -Fsystem %t/sdk/custom/Frameworks -module-cache-path %t/mcp8 %t/SearchPathOrder.swift
|
|
|
|
// If both clang and Swift error then it's a problem with this test.
|
|
// If only Swift errors then it's a problem with the clang importer search paths code.
|
|
|
|
//--- sdk/usr/local/include/module.modulemap
|
|
module Module {
|
|
module bomb { header "bomb.h" }
|
|
}
|
|
|
|
//--- sdk/usr/local/include/bomb.h
|
|
#error "bomb"
|
|
|
|
|
|
//--- sdk/custom/include/module.modulemap
|
|
module Module {
|
|
module good { header "good.h" }
|
|
}
|
|
|
|
//--- sdk/custom/include/good.h
|
|
|
|
//--- sdk/custom/Frameworks/Module.framework/Modules/module.modulemap
|
|
framework module Module {
|
|
module good { header "good.h" }
|
|
}
|
|
|
|
//--- sdk/custom/Frameworks/Module.framework/Headers/good.h
|
|
|
|
|
|
|
|
|
|
|
|
//--- SearchPathOrder.m
|
|
@import Module;
|
|
|
|
//--- SearchPathOrder.swift
|
|
import Module
|