[clang] b555c99 - [clang][modules] Ensure -nostdlib causes no manifest to be reported (#161110)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 29 05:45:54 PDT 2025
Author: Naveen Seth Hanig
Date: 2025-09-29T14:45:51+02:00
New Revision: b555c991e4208cd4829b2dfd0bcb8b2afd0c1292
URL: https://github.com/llvm/llvm-project/commit/b555c991e4208cd4829b2dfd0bcb8b2afd0c1292
DIFF: https://github.com/llvm/llvm-project/commit/b555c991e4208cd4829b2dfd0bcb8b2afd0c1292.diff
LOG: [clang][modules] Ensure -nostdlib causes no manifest to be reported (#161110)
When -nostdlib is specified, Clang should not report any
library‑provided module manifest, even if a manifest for the default
standard library is present.
Added:
Modified:
clang/lib/Driver/Driver.cpp
clang/test/Driver/modules-print-library-module-manifest-path.cpp
Removed:
################################################################################
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index f110dbab3e5a5..85a1335785542 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -6613,6 +6613,9 @@ std::string Driver::GetStdModuleManifestPath(const Compilation &C,
const ToolChain &TC) const {
std::string error = "<NOT PRESENT>";
+ if (C.getArgs().hasArg(options::OPT_nostdlib))
+ return error;
+
switch (TC.GetCXXStdlibType(C.getArgs())) {
case ToolChain::CST_Libcxx: {
auto evaluate = [&](const char *library) -> std::optional<std::string> {
diff --git a/clang/test/Driver/modules-print-library-module-manifest-path.cpp b/clang/test/Driver/modules-print-library-module-manifest-path.cpp
index 7606713bfa22a..af0f124477cf8 100644
--- a/clang/test/Driver/modules-print-library-module-manifest-path.cpp
+++ b/clang/test/Driver/modules-print-library-module-manifest-path.cpp
@@ -18,6 +18,14 @@
// RUN: --target=x86_64-linux-gnu 2>&1 \
// RUN: | FileCheck libcxx.cpp
+// check that -nostdlib causes no library-provided module manifest to
+// be reported, even when libc++.modules.json is present.
+// RUN: %clang -print-library-module-manifest-path \
+// RUN: -nostdlib \
+// RUN: -resource-dir=%t/Inputs/usr/lib/x86_64-linux-gnu \
+// RUN: --target=x86_64-linux-gnu 2>&1 \
+// RUN: | FileCheck libcxx-no-module-json.cpp
+
// for macos there is a
diff erent directory structure
// where the library and libc++.modules.json file are in lib
// directly but headers are in clang/ver directory which
More information about the cfe-commits
mailing list