Skip to content

Commit

Permalink
[Fix] Disable fdefine-target-os-macros for now (#74886)
Browse files Browse the repository at this point in the history
#74676 landed the work to
implement `-fdefine-target-os-macros` and enabled the extension for the
Darwin driver. However it is breaking some test builds. Leave the
extension disabled for now until we can fix/workaround the build
failures.
  • Loading branch information
zixu-w committed Dec 8, 2023
1 parent 21213f3 commit c9b4bb9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
4 changes: 0 additions & 4 deletions clang/lib/Driver/ToolChains/Darwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2916,10 +2916,6 @@ void Darwin::addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
// to fix the same problem with C++ headers, and is generally fragile.
if (!sdkSupportsBuiltinModules(TargetPlatform, SDKInfo))
CC1Args.push_back("-fbuiltin-headers-in-system-modules");

if (!DriverArgs.hasArgNoClaim(options::OPT_fdefine_target_os_macros,
options::OPT_fno_define_target_os_macros))
CC1Args.push_back("-fdefine-target-os-macros");
}

void Darwin::addClangCC1ASTargetOptions(
Expand Down
29 changes: 19 additions & 10 deletions clang/test/Driver/fdefine-target-os-macros.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
// RUN: %clang -### --target=arm64-apple-darwin %s 2>&1 | FileCheck %s --check-prefix=DARWIN-DEFAULT
// DARWIN-DEFAULT: "-fdefine-target-os-macros"
// DARWIN-DEFAULT-NOT: "-fdefine-target-os-macros"

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

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

// RUN: %clang -dM -E --target=arm64-apple-ios %s 2>&1 \
// RUN: %clang -dM -E --target=arm64-apple-ios \
// RUN: -fdefine-target-os-macros %s 2>&1 \
// RUN: | FileCheck %s -DMAC=1 \
// RUN: -DOSX=0 \
// RUN: -DIPHONE=1 \
Expand All @@ -35,7 +37,8 @@
// RUN: -DLINUX=0 \
// RUN: -DUNIX=0

// RUN: %clang -dM -E --target=arm64-apple-ios-macabi %s 2>&1 \
// RUN: %clang -dM -E --target=arm64-apple-ios-macabi \
// RUN: -fdefine-target-os-macros %s 2>&1 \
// RUN: | FileCheck %s -DMAC=1 \
// RUN: -DOSX=0 \
// RUN: -DIPHONE=1 \
Expand All @@ -50,7 +53,8 @@
// RUN: -DLINUX=0 \
// RUN: -DUNIX=0

// RUN: %clang -dM -E --target=arm64-apple-ios-simulator %s 2>&1 \
// RUN: %clang -dM -E --target=arm64-apple-ios-simulator \
// RUN: -fdefine-target-os-macros %s 2>&1 \
// RUN: | FileCheck %s -DMAC=1 \
// RUN: -DOSX=0 \
// RUN: -DIPHONE=1 \
Expand All @@ -65,7 +69,8 @@
// RUN: -DLINUX=0 \
// RUN: -DUNIX=0

// RUN: %clang -dM -E --target=arm64-apple-tvos %s 2>&1 \
// RUN: %clang -dM -E --target=arm64-apple-tvos \
// RUN: -fdefine-target-os-macros %s 2>&1 \
// RUN: | FileCheck %s -DMAC=1 \
// RUN: -DOSX=0 \
// RUN: -DIPHONE=1 \
Expand All @@ -80,7 +85,8 @@
// RUN: -DLINUX=0 \
// RUN: -DUNIX=0

// RUN: %clang -dM -E --target=arm64-apple-tvos-simulator %s 2>&1 \
// RUN: %clang -dM -E --target=arm64-apple-tvos-simulator \
// RUN: -fdefine-target-os-macros %s 2>&1 \
// RUN: | FileCheck %s -DMAC=1 \
// RUN: -DOSX=0 \
// RUN: -DIPHONE=1 \
Expand All @@ -95,7 +101,8 @@
// RUN: -DLINUX=0 \
// RUN: -DUNIX=0

// RUN: %clang -dM -E --target=arm64-apple-watchos %s 2>&1 \
// RUN: %clang -dM -E --target=arm64-apple-watchos \
// RUN: -fdefine-target-os-macros %s 2>&1 \
// RUN: | FileCheck %s -DMAC=1 \
// RUN: -DOSX=0 \
// RUN: -DIPHONE=1 \
Expand All @@ -110,7 +117,8 @@
// RUN: -DLINUX=0 \
// RUN: -DUNIX=0

// RUN: %clang -dM -E --target=arm64-apple-watchos-simulator %s 2>&1 \
// RUN: %clang -dM -E --target=arm64-apple-watchos-simulator \
// RUN: -fdefine-target-os-macros %s 2>&1 \
// RUN: | FileCheck %s -DMAC=1 \
// RUN: -DOSX=0 \
// RUN: -DIPHONE=1 \
Expand All @@ -125,7 +133,8 @@
// RUN: -DLINUX=0 \
// RUN: -DUNIX=0

// RUN: %clang -dM -E --target=arm64-apple-driverkit %s 2>&1 \
// RUN: %clang -dM -E --target=arm64-apple-driverkit \
// RUN: -fdefine-target-os-macros %s 2>&1 \
// RUN: | FileCheck %s -DMAC=1 \
// RUN: -DOSX=0 \
// RUN: -DIPHONE=0 \
Expand Down

0 comments on commit c9b4bb9

Please sign in to comment.