llvm-project/clang/test/Driver/driverkit-path.c
Ian Anderson 33275d0a08
[clang][driver][darwin] Base the platform prefix on the SDK, not the target (#171970)
The search path prefix is really a property of the SDK, and not the
target triple. The target is just being used as a proxy for the SDK.
That's problematic when the SDK being used doesn't match the target
assumption, and the prefix should be taken from the SDK rather than hard
coded.

Parse the SupportedTargets, which is what holds the platform prefix, in
DarwinSDKInfo. SupportedTargets contains an entry for the SDK's
canonical name, and that entry holds a valid OS value so use that
instead of the hard coded map. Include the environment which is also
relevant in some situations, and the vendor and object format in case
they're useful later. Skip architectures because they typically aren't
used for doing platform matching.
2026-01-05 23:42:32 +00:00

40 lines
2.5 KiB
C

// UNSUPPORTED: system-windows
// Windows is unsupported because we use the Unix path separator `\`.
// RUN: %clang %s -target x86_64-apple-driverkit19.0 -mlinker-version=0 \
// RUN: -isysroot %S/Inputs/DriverKit19.0.sdk -### 2>&1 \
// RUN: | FileCheck %s --check-prefix=LD64-OLD
// RUN: %clang %s -target x86_64-apple-driverkit19.0 -mlinker-version=604.99 \
// RUN: -isysroot %S/Inputs/DriverKit19.0.sdk -### 2>&1 \
// RUN: | FileCheck %s --check-prefix=LD64-OLD
// RUN: %clang %s -target x86_64-apple-driverkit19.0 -mlinker-version=605.0 \
// RUN: -isysroot %S/Inputs/DriverKit19.0.sdk -### 2>&1 \
// RUN: | FileCheck %s --check-prefix=LD64-OLD
// RUN: %clang %s -target x86_64-apple-driverkit19.0 -mlinker-version=605.1 \
// RUN: -isysroot %S/Inputs/DriverKit19.0.sdk -### 2>&1 \
// RUN: | FileCheck %s --check-prefix=LD64-NEW
int main() { return 0; }
// LD64-OLD: "-isysroot" "[[PATH:[^"]*]]Inputs/DriverKit19.0.sdk"
// LD64-OLD: "-L[[PATH]]Inputs/DriverKit19.0.sdk/System/DriverKit/usr/lib"
// LD64-OLD: "-F[[PATH]]Inputs/DriverKit19.0.sdk/System/DriverKit/System/Library/Frameworks"
// LD64-NEW: "-isysroot" "[[PATH:[^"]*]]Inputs/DriverKit19.0.sdk"
// LD64-NEW-NOT: "-L[[PATH]]Inputs/DriverKit19.0.sdk/System/DriverKit/usr/lib"
// LD64-NEW-NOT: "-F[[PATH]]Inputs/DriverKit19.0.sdk/System/DriverKit/System/Library/Frameworks"
// LD64-NEW-NOT: "-F[[PATH]]Inputs/DriverKit19.0.sdk/System/DriverKit/System/Library/SubFrameworks"
// RUN: %clang %s -target x86_64-apple-driverkit19.0 -isysroot %S/Inputs/DriverKit19.0.sdk -x c++ -### 2>&1 \
// RUN: | FileCheck %s -DSDKROOT=%S/Inputs/DriverKit19.0.sdk --check-prefix=INC
// RUN: %clang %s -target x86_64-apple-driverkit21.0.1 -isysroot %S/Inputs/DriverKit21.0.1.sdk -x c++ -### 2>&1 \
// RUN: | FileCheck %s -DSDKROOT=%S/Inputs/DriverKit21.0.1.sdk --check-prefix=INC
// RUN: %clang %s -target x86_64-apple-driverkit23.0 -isysroot %S/Inputs/DriverKit23.0.sdk -x c++ -### 2>&1 \
// RUN: | FileCheck %s -DSDKROOT=%S/Inputs/DriverKit23.0.sdk --check-prefix=INC
//
// INC: "-isysroot" "[[SDKROOT]]"
// INC: "-internal-isystem" "[[SDKROOT]]/System/DriverKit/usr/local/include"
// INC: "-internal-isystem" "{{.+}}/lib{{(64)?}}/clang/{{[^/ ]+}}/include"
// INC: "-internal-externc-isystem" "[[SDKROOT]]/System/DriverKit/usr/include"
// INC: "-internal-iframework" "[[SDKROOT]]/System/DriverKit/System/Library/Frameworks"
// INC: "-internal-iframework" "[[SDKROOT]]/System/DriverKit/System/Library/SubFrameworks"