llvm-project/clang/test/Driver/target-override.c
Dan McGregor 0d7eba1aee [Driver] Allow target override containing . in executable name
The gcc compatible driver has support for overriding the default
target based on the driver's executable name, for instance
x86_64-pc-linux-gnu-clang will set the default target to
x86_64-pc-linux-gnu.

Previously, this failed when the target contained a minor version, for
example x86_64-pc-freebsd13.1, so instead of finding the file's
stem, use the whole file name, but strip off any '.exe' from the tail.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D135284
2022-10-26 16:52:32 -07:00

21 lines
787 B
C

// REQUIRES: shell
// REQUIRES: x86-registered-target
// RUN: rm -rf %t && mkdir %t
// RUN: ln -s %clang %t/i386-clang
// RUN: ln -s %clang %t/x86_64-pc-freebsd13.1-clang
// Check if invocation of "foo-clang" adds option "-target foo".
//
// RUN: %t/i386-clang -c -### %s 2>&1 | FileCheck -check-prefix CHECK-TG1 %s
// CHECK-TG1: Target: i386
// Check if invocation of "foo-clang --target=bar" overrides option "-target foo".
//
// RUN: %t/i386-clang -c --target=x86_64 -### %s 2>&1 | FileCheck -check-prefix CHECK-TG2 %s
// CHECK-TG2: Target: x86_64
/// Check if invocation of "arch-vendor-osX.Y-clang" adds option "-target arch-vendor-osX.Y".
// RUN: %t/x86_64-pc-freebsd13.1-clang -c -### %s 2>&1 | FileCheck -check-prefix CHECK-TG3 %s
// CHECK-TG3: Target: x86_64-pc-freebsd13.1