llvm-project/clang/test/Modules/gmodules-codegenopts.c
Ben Langmuir 9fbf5cfebc
[clang][modules] Partially revert 48d0eb518 to fix -gmodules output (#124003)
With the changes in 48d0eb518, the CodeGenOptions used to emit .pcm
files with -fmodule-format=obj (-gmodules) were the ones from the
original invocation, rather than the ones specifically crafted for
outputting the pcm. This was causing the pcm to be written with only the
debug info and without the __clangast section in some cases (e.g. -O2).
This unforunately was not covered by existing tests, because compiling
and loading a module within a single compilation load the ast content
from the in-memory module cache rather than reading it from the pcm file
that was written. This broke bootstrapping a build of clang with modules
enabled on Darwin.

rdar://143418834
2025-01-22 16:24:56 -08:00

18 lines
800 B
C

// UNSUPPORTED: target={{.*}}-zos{{.*}}, target={{.*}}-aix{{.*}}
// Check that the output from -gmodules can be loaded back by the compiler in
// the presence of certain options like optimization level that could break
// output. Note: without compiling twice the module is loaded from the in-memory
// module cache not load it from the object container.
// RUN: rm -rf %t
// RUN: %clang_cc1 -x objective-c -fmodules -fmodule-format=obj \
// RUN: -fimplicit-module-maps -fmodules-cache-path=%t %s \
// RUN: -I %S/Inputs -verify -O2
// Compile again, confirming we can load the module.
// RUN: %clang_cc1 -x objective-c -fmodules -fmodule-format=obj \
// RUN: -fimplicit-module-maps -fmodules-cache-path=%t %s \
// RUN: -I %S/Inputs -verify -O2
@import DebugObjC;
// expected-no-diagnostics