Files
swift-mirror/test/ClangImporter/invocation-mcpu.swift
Ahmed Bougacha 1b5a94e219 [ClangImporter] Let clang pick default target CPU. (#80451)
Currently, ClangImporter has some logic to pick the default arm64
target CPU (when -target-cpu isn't passed) based on the target OS
and arch variant.

This was originally done long ago in 3cf3f42e98, and later
maintained through 49a6c8eb7b, because it was necessary when
clang (targeting darwin) relied on -arch to set this sort of default.

Clang has migrated to full -target triples for a while now, and has
sophisticated logic for picking default target CPUs and features based
on the target triple.

Currently, we override that by passing our -mcpu explicitly.
Instead, allow clang to pick its defaults, and only pass -mcpu
when asked via -target-cpu.

This is visible in the test, with arm64 macOS now defaulting to M1.
The same applies to simulators, per Triple::isTargetMachineMac.

rdar://148377686
2025-04-08 17:34:23 -07:00

13 lines
1018 B
Swift

// RUN: %swift %s -typecheck -parse-stdlib -dump-clang-diagnostics -target arm64e-apple-macos11.0 2>&1 | %FileCheck -check-prefix=CHECK-APPLE-M1 %s
// RUN: %swift %s -typecheck -parse-stdlib -dump-clang-diagnostics -target arm64-apple-ios13.0-simulator 2>&1 | %FileCheck -check-prefix=CHECK-APPLE-M1 %s
// CHECK-APPLE-M1: '-target-cpu' 'apple-m1' '-target-feature'
// RUN: %swift %s -typecheck -parse-stdlib -dump-clang-diagnostics -target arm64e-apple-ios13.0 2>&1 | %FileCheck -check-prefix=CHECK-APPLE-A12 %s
// CHECK-APPLE-A12: '-target-cpu' 'apple-a12' '-target-feature'
// RUN: %swift %s -typecheck -parse-stdlib -dump-clang-diagnostics -target arm64-apple-ios13.0 2>&1 | %FileCheck -check-prefix=CHECK-APPLE-A7 %s
// CHECK-APPLE-A7: '-target-cpu' 'apple-a7' '-target-feature'
// RUN: %swift %s -typecheck -parse-stdlib -dump-clang-diagnostics -target arm64-apple-ios13.0 -target-cpu apple-a16 2>&1 | %FileCheck -check-prefix=CHECK-APPLE-A16 %s
// CHECK-APPLE-A16: '-target-cpu' 'apple-a16' '-target-feature'