Skip to content

Commit 92bab38

Browse files
naveen-sethmahesh-attarde
authored andcommitted
[clang][modules] Ensure -nostdlib causes no manifest to be reported (llvm#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.
1 parent b7170c2 commit 92bab38

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

clang/lib/Driver/Driver.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6613,6 +6613,9 @@ std::string Driver::GetStdModuleManifestPath(const Compilation &C,
66136613
const ToolChain &TC) const {
66146614
std::string error = "<NOT PRESENT>";
66156615

6616+
if (C.getArgs().hasArg(options::OPT_nostdlib))
6617+
return error;
6618+
66166619
switch (TC.GetCXXStdlibType(C.getArgs())) {
66176620
case ToolChain::CST_Libcxx: {
66186621
auto evaluate = [&](const char *library) -> std::optional<std::string> {

clang/test/Driver/modules-print-library-module-manifest-path.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@
1818
// RUN: --target=x86_64-linux-gnu 2>&1 \
1919
// RUN: | FileCheck libcxx.cpp
2020

21+
// check that -nostdlib causes no library-provided module manifest to
22+
// be reported, even when libc++.modules.json is present.
23+
// RUN: %clang -print-library-module-manifest-path \
24+
// RUN: -nostdlib \
25+
// RUN: -resource-dir=%t/Inputs/usr/lib/x86_64-linux-gnu \
26+
// RUN: --target=x86_64-linux-gnu 2>&1 \
27+
// RUN: | FileCheck libcxx-no-module-json.cpp
28+
2129
// for macos there is a different directory structure
2230
// where the library and libc++.modules.json file are in lib
2331
// directly but headers are in clang/ver directory which

0 commit comments

Comments
 (0)