[Driver] Disable -fobjc-constant-literals by default (#195000)

Disable the feature by default in the driver so it is no longer
implicitly enabled for ObjC compilations as there are unresolved issues
(see
https://github.com/llvm/llvm-project/pull/185130#issuecomment-4298886165).
Users can still opt in explicitly with -fobjc-constant-literals.
This commit is contained in:
Akira Hatanaka
2026-04-30 11:24:20 -07:00
committed by GitHub
parent e3b7ce5ae7
commit 4d154f6ea5
2 changed files with 22 additions and 1 deletions

View File

@@ -4278,7 +4278,7 @@ static void RenderObjCOptions(const ToolChain &TC, const Driver &D,
bool EnableConstantLiterals =
Args.hasFlag(options::OPT_fobjc_constant_literals,
options::OPT_fno_objc_constant_literals,
/*default=*/true) &&
/*default=*/false) &&
Runtime.hasConstantLiteralClasses();
if (EnableConstantLiterals)
CmdArgs.push_back("-fobjc-constant-literals");

View File

@@ -0,0 +1,21 @@
// RUN: %clang -### -target arm64-apple-macosx11 -c %s 2>&1 \
// RUN: | FileCheck %s --check-prefix=DEFAULT
// RUN: %clang -### -target arm64-apple-macosx11 -fobjc-constant-literals -c %s 2>&1 \
// RUN: | FileCheck %s --check-prefix=ENABLED
// RUN: %clang -### -target arm64-apple-macosx11 -fno-objc-constant-literals -c %s 2>&1 \
// RUN: | FileCheck %s --check-prefix=DISABLED
// DEFAULT-NOT: -fobjc-constant-literals
// DEFAULT-NOT: -fconstant-nsnumber-literals
// DEFAULT-NOT: -fconstant-nsarray-literals
// DEFAULT-NOT: -fconstant-nsdictionary-literals
// ENABLED: -fobjc-constant-literals
// ENABLED: -fconstant-nsnumber-literals
// ENABLED: -fconstant-nsarray-literals
// ENABLED: -fconstant-nsdictionary-literals
// DISABLED-NOT: -fobjc-constant-literals
// DISABLED-NOT: -fconstant-nsnumber-literals
// DISABLED-NOT: -fconstant-nsarray-literals
// DISABLED-NOT: -fconstant-nsdictionary-literals