Skip to content

Commit c3f96ac

Browse files
authored
Revert "[Fix] Disable fdefine-target-os-macros for now" (#78353)
llvm/llvm-test-suite#65 fixed the llvm-test-suite errors. Reapply the change to enable `fdefine-target-os-macros` by default for Darwin targets. This reverts commit 63be986.
1 parent f3190c7 commit c3f96ac

File tree

2 files changed

+14
-19
lines changed

2 files changed

+14
-19
lines changed

clang/lib/Driver/ToolChains/Darwin.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2917,6 +2917,10 @@ void Darwin::addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
29172917
// to fix the same problem with C++ headers, and is generally fragile.
29182918
if (!sdkSupportsBuiltinModules(TargetPlatform, SDKInfo))
29192919
CC1Args.push_back("-fbuiltin-headers-in-system-modules");
2920+
2921+
if (!DriverArgs.hasArgNoClaim(options::OPT_fdefine_target_os_macros,
2922+
options::OPT_fno_define_target_os_macros))
2923+
CC1Args.push_back("-fdefine-target-os-macros");
29202924
}
29212925

29222926
void Darwin::addClangCC1ASTargetOptions(

clang/test/Driver/fdefine-target-os-macros.c

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
// RUN: %clang -### --target=arm64-apple-darwin %s 2>&1 | FileCheck %s --check-prefix=DARWIN-DEFAULT
2-
// DARWIN-DEFAULT-NOT: "-fdefine-target-os-macros"
2+
// DARWIN-DEFAULT: "-fdefine-target-os-macros"
33

44
// RUN: %clang -### --target=arm-none-linux-gnu %s 2>&1 | FileCheck %s --check-prefix=NON-DARWIN-DEFAULT
55
// RUN: %clang -### --target=x86_64-pc-win32 %s 2>&1 | FileCheck %s --check-prefix=NON-DARWIN-DEFAULT
66
// NON-DARWIN-DEFAULT-NOT: "-fdefine-target-os-macros"
77

8-
// RUN: %clang -dM -E --target=arm64-apple-macos \
9-
// RUN: -fdefine-target-os-macros %s 2>&1 \
8+
// RUN: %clang -dM -E --target=arm64-apple-macos %s 2>&1 \
109
// RUN: | FileCheck %s -DMAC=1 \
1110
// RUN: -DOSX=1 \
1211
// RUN: -DIPHONE=0 \
@@ -21,8 +20,7 @@
2120
// RUN: -DLINUX=0 \
2221
// RUN: -DUNIX=0
2322

24-
// RUN: %clang -dM -E --target=arm64-apple-ios \
25-
// RUN: -fdefine-target-os-macros %s 2>&1 \
23+
// RUN: %clang -dM -E --target=arm64-apple-ios %s 2>&1 \
2624
// RUN: | FileCheck %s -DMAC=1 \
2725
// RUN: -DOSX=0 \
2826
// RUN: -DIPHONE=1 \
@@ -37,8 +35,7 @@
3735
// RUN: -DLINUX=0 \
3836
// RUN: -DUNIX=0
3937

40-
// RUN: %clang -dM -E --target=arm64-apple-ios-macabi \
41-
// RUN: -fdefine-target-os-macros %s 2>&1 \
38+
// RUN: %clang -dM -E --target=arm64-apple-ios-macabi %s 2>&1 \
4239
// RUN: | FileCheck %s -DMAC=1 \
4340
// RUN: -DOSX=0 \
4441
// RUN: -DIPHONE=1 \
@@ -53,8 +50,7 @@
5350
// RUN: -DLINUX=0 \
5451
// RUN: -DUNIX=0
5552

56-
// RUN: %clang -dM -E --target=arm64-apple-ios-simulator \
57-
// RUN: -fdefine-target-os-macros %s 2>&1 \
53+
// RUN: %clang -dM -E --target=arm64-apple-ios-simulator %s 2>&1 \
5854
// RUN: | FileCheck %s -DMAC=1 \
5955
// RUN: -DOSX=0 \
6056
// RUN: -DIPHONE=1 \
@@ -69,8 +65,7 @@
6965
// RUN: -DLINUX=0 \
7066
// RUN: -DUNIX=0
7167

72-
// RUN: %clang -dM -E --target=arm64-apple-tvos \
73-
// RUN: -fdefine-target-os-macros %s 2>&1 \
68+
// RUN: %clang -dM -E --target=arm64-apple-tvos %s 2>&1 \
7469
// RUN: | FileCheck %s -DMAC=1 \
7570
// RUN: -DOSX=0 \
7671
// RUN: -DIPHONE=1 \
@@ -85,8 +80,7 @@
8580
// RUN: -DLINUX=0 \
8681
// RUN: -DUNIX=0
8782

88-
// RUN: %clang -dM -E --target=arm64-apple-tvos-simulator \
89-
// RUN: -fdefine-target-os-macros %s 2>&1 \
83+
// RUN: %clang -dM -E --target=arm64-apple-tvos-simulator %s 2>&1 \
9084
// RUN: | FileCheck %s -DMAC=1 \
9185
// RUN: -DOSX=0 \
9286
// RUN: -DIPHONE=1 \
@@ -101,8 +95,7 @@
10195
// RUN: -DLINUX=0 \
10296
// RUN: -DUNIX=0
10397

104-
// RUN: %clang -dM -E --target=arm64-apple-watchos \
105-
// RUN: -fdefine-target-os-macros %s 2>&1 \
98+
// RUN: %clang -dM -E --target=arm64-apple-watchos %s 2>&1 \
10699
// RUN: | FileCheck %s -DMAC=1 \
107100
// RUN: -DOSX=0 \
108101
// RUN: -DIPHONE=1 \
@@ -117,8 +110,7 @@
117110
// RUN: -DLINUX=0 \
118111
// RUN: -DUNIX=0
119112

120-
// RUN: %clang -dM -E --target=arm64-apple-watchos-simulator \
121-
// RUN: -fdefine-target-os-macros %s 2>&1 \
113+
// RUN: %clang -dM -E --target=arm64-apple-watchos-simulator %s 2>&1 \
122114
// RUN: | FileCheck %s -DMAC=1 \
123115
// RUN: -DOSX=0 \
124116
// RUN: -DIPHONE=1 \
@@ -133,8 +125,7 @@
133125
// RUN: -DLINUX=0 \
134126
// RUN: -DUNIX=0
135127

136-
// RUN: %clang -dM -E --target=arm64-apple-driverkit \
137-
// RUN: -fdefine-target-os-macros %s 2>&1 \
128+
// RUN: %clang -dM -E --target=arm64-apple-driverkit %s 2>&1 \
138129
// RUN: | FileCheck %s -DMAC=1 \
139130
// RUN: -DOSX=0 \
140131
// RUN: -DIPHONE=0 \

0 commit comments

Comments
 (0)