Skip to content

Conversation

@cyndyishida
Copy link
Member

Before this patch, compilations using modules &
-mspeculative-load-hardening failed because it was not consistent whether this option impacts module compatibility.

This repairs it by always treating it as benign. This was determined by checking if the option enables any kind of preprocessor checks and comparing how the compiler handles a similar option that impacts codegen (-fvisibility=hidden) but is more widely used.

resolves: rdar://163985667

Before this patch, compilations using modules &
-mspeculative-load-hardening because of a configuration mismatch because
it was not consistent whether this option impacts module compatibility.

This repairs it by always treating it as benign. This was determined by
checking if the option enables any kind of preprocessor checks and
comparing how the compiler handles a similiar option that impacts codegen
(-fvisibility=hidden) but is more widely used.
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Nov 5, 2025
@llvmbot
Copy link
Member

llvmbot commented Nov 5, 2025

@llvm/pr-subscribers-clang

Author: Cyndy Ishida (cyndyishida)

Changes

Before this patch, compilations using modules &
-mspeculative-load-hardening failed because it was not consistent whether this option impacts module compatibility.

This repairs it by always treating it as benign. This was determined by checking if the option enables any kind of preprocessor checks and comparing how the compiler handles a similar option that impacts codegen (-fvisibility=hidden) but is more widely used.

resolves: rdar://163985667


Full diff: https://github.com/llvm/llvm-project/pull/166640.diff

2 Files Affected:

  • (modified) clang/include/clang/Basic/LangOptions.def (+1-1)
  • (modified) clang/test/ClangScanDeps/strip-codegen-args.m (+6)
diff --git a/clang/include/clang/Basic/LangOptions.def b/clang/include/clang/Basic/LangOptions.def
index d3cca82b4bdff..40fc66ea12e34 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -454,7 +454,7 @@ LANGOPT(BranchTargetEnforcement, 1, 0, NotCompatible, "Branch-target enforcement
 LANGOPT(BranchProtectionPAuthLR, 1, 0, NotCompatible, "Use PC as a diversifier using PAuthLR NOP instructions.")
 LANGOPT(GuardedControlStack, 1, 0, NotCompatible, "Guarded control stack enabled")
 
-LANGOPT(SpeculativeLoadHardening, 1, 0, NotCompatible, "Speculative load hardening enabled")
+LANGOPT(SpeculativeLoadHardening, 1, 0, Benign, "Speculative load hardening enabled")
 
 LANGOPT(RelativeCXXABIVTables, 1, 0, NotCompatible,
         "Use an ABI-incompatible v-table layout that uses relative references")
diff --git a/clang/test/ClangScanDeps/strip-codegen-args.m b/clang/test/ClangScanDeps/strip-codegen-args.m
index 71171f4983386..f2cec6281f7df 100644
--- a/clang/test/ClangScanDeps/strip-codegen-args.m
+++ b/clang/test/ClangScanDeps/strip-codegen-args.m
@@ -16,6 +16,7 @@
 // CHECK-NOT:          "-flto"
 // CHECK-NOT:          "-fno-autolink"
 // CHECK-NOT:          "-mrelax-relocations=no"
+// CHECK-NOT:          "-mspeculative-load-hardening"
 // CHECK:            ]
 // CHECK:            "name": "A"
 // CHECK:          }
@@ -39,6 +40,11 @@
     "command": "clang -Imodules/A -fmodules -fmodules-cache-path=DIR/module-cache -fimplicit-modules -O2 -flto=full -fsyntax-only DIR/t3.m",
     "file": "DIR/t2.m"
   }
+  {
+    "directory": "DIR",
+    "command": "clang -Imodules/A -fmodules -fmodules-cache-path=DIR/module-cache -fimplicit-modules -O2 -mspeculative-load-hardening -fsyntax-only DIR/t3.m",
+    "file": "DIR/t3.m"
+  }
 ]
 
 //--- modules/A/module.modulemap

@cyndyishida cyndyishida merged commit e700f15 into llvm:main Nov 6, 2025
11 of 12 checks passed
@cyndyishida cyndyishida deleted the eng/PR-fixSLH branch November 6, 2025 04:38
cyndyishida added a commit to cyndyishida/llvm-project that referenced this pull request Nov 6, 2025
llvm#166640)

Before this patch, compilations using modules &
`-mspeculative-load-hardening` failed because it was not consistent
whether this option impacts module compatibility.

This repairs it by always treating it as benign. This was determined by
checking if the option enables any kind of preprocessor checks and
comparing how the compiler handles a similar option that impacts codegen
(-fvisibility=hidden) but is more widely used.

resolves: rdar://163985667
(cherry picked from commit e700f15)
cyndyishida added a commit to swiftlang/llvm-project that referenced this pull request Nov 7, 2025
llvm#166640)

Before this patch, compilations using modules &
`-mspeculative-load-hardening` failed because it was not consistent
whether this option impacts module compatibility.

This repairs it by always treating it as benign. This was determined by
checking if the option enables any kind of preprocessor checks and
comparing how the compiler handles a similar option that impacts codegen
(-fvisibility=hidden) but is more widely used.

resolves: rdar://163985667
(cherry picked from commit e700f15)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants