This is an archive of the discontinued LLVM Phabricator instance.

[libc++] Fix modules and benchmarks CI builds when incomplete features are disabled
ClosedPublic

Authored by ldionne on Feb 4 2022, 1:51 PM.

Details

Diff Detail

Event Timeline

ldionne created this revision.Feb 4 2022, 1:51 PM
ldionne requested review of this revision.Feb 4 2022, 1:51 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 4 2022, 1:51 PM
Herald added a reviewer: Restricted Project. · View Herald Transcript
ldionne updated this revision to Diff 406511.Feb 7 2022, 9:44 AM

Try to fix the CI. Hopefully defining NOMINMAX shouldn't be required anymore on Windows -- CI will tell.

ldionne updated this revision to Diff 406575.Feb 7 2022, 12:37 PM

Push/pop min and max in filesystem_helper.h

ldionne updated this revision to Diff 406835.Feb 8 2022, 8:09 AM

Try to fix remaining CI issues.

ldionne accepted this revision as: Restricted Project.Feb 8 2022, 11:43 AM
This revision was not accepted when it landed; it landed in state Needs Review.Feb 8 2022, 12:15 PM
This revision was automatically updated to reflect the committed changes.

Hi this commit broke the lldb greendragon bots.

https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/41225/

crashlog backtrace:

0 clang 0x0000000110741acb llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 43
1 clang 0x00000001107407c8 llvm::sys::RunSignalHandlers() + 248
2 clang 0x0000000110740ef0 llvm::sys::CleanupOnSignal(unsigned long) + 208
3 clang 0x00000001106638ca (anonymous namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long) + 106
4 clang 0x0000000110663abe CrashRecoverySignalHandler(int) + 110
5 libsystem_platform.dylib 0x00007fff6c8655fd _sigtramp + 29
6 libsystem_platform.dylib 0x00007fc2c50d7e00 _sigtramp + 18446743813201799200
7 libsystem_c.dylib 0x00007fff6c737808 abort + 120
8 libsystem_c.dylib 0x00007fff6c736ac6 err + 0
9 clang 0x000000011124c7f0 llvm::BitstreamWriter::~BitstreamWriter() + 608
10 clang 0x00000001113e56e9 clang::PCHGenerator::~PCHGenerator() + 41
11 clang 0x0000000111241360 clang::MultiplexConsumer::~MultiplexConsumer() + 128
12 clang 0x000000011114f1bb clang::CompilerInstance::~CompilerInstance() + 683
13 clang 0x000000011115e1b1 compileModuleImpl(clang::CompilerInstance&, clang::SourceLocation, llvm::StringRef, clang::FrontendInputFile, llvm::StringRef, llvm::StringRef, llvm::function_ref<void (clang::CompilerInstance&)>, llvm::function_ref<void (clang::CompilerInstance&)>) + 4481
14 clang 0x000000011115feff compileModuleAndReadASTImpl(clang::CompilerInstance&, clang::SourceLocation, clang::SourceLocation, clang::Module*, llvm::StringRef) + 1903
15 clang 0x0000000111159a8b compileModuleAndReadAST(clang::CompilerInstance&, clang::SourceLocation, clang::SourceLocation, clang::Module*, llvm::StringRef) + 1947
16 clang 0x0000000111158ebc clang::CompilerInstance::findOrCompileModuleAndReadAST(llvm::StringRef, clang::SourceLocation, clang::SourceLocation, bool) + 3676
17 clang 0x0000000111159e17 clang::CompilerInstance::loadModule(clang::SourceLocation, llvm::ArrayRef<std::1::pair<clang::IdentifierInfo*, clang::SourceLocation> >, clang::Module::NameVisibilityKind, bool) + 679
18 clang 0x0000000113540ce6 clang::Preprocessor::HandleHeaderIncludeOrImport(clang::SourceLocation, clang::Token&, clang::Token&, clang::SourceLocation, clang::DirectoryLookup const*, clang::FileEntry const*) + 7910
19 clang 0x0000000113538e12 clang::Preprocessor::HandleIncludeDirective(clang::SourceLocation, clang::Token&, clang::DirectoryLookup const*, clang::FileEntry const*) + 162
20 clang 0x0000000113539a2d clang::Preprocessor::HandleDirective(clang::Token&) + 2461
21 clang 0x000000011350a037 clang::Lexer::LexTokenInternal(clang::Token&, bool) + 6343
22 clang 0x0000000113507857 clang::Lexer::Lex(clang::Token&) + 119
23 clang 0x000000011357add4 clang::Preprocessor::Lex(clang::Token&) + 84
24 clang 0x00000001123c33e6 clang::Parser::Initialize() + 5030
25 clang 0x00000001122efa26 clang::ParseAST(clang::Sema&, bool, bool) + 438
26 clang 0x00000001111ffbc3 clang::FrontendAction::Execute() + 99
27 clang 0x0000000111155f4f clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 863
28 clang 0x000000011128ada5 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 709
29 clang 0x000000010ecb86dc cc1_main(llvm::ArrayRef<char const*>, char const*, void*) + 2108
30 clang 0x000000010ecb3aee ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) + 286
31 clang 0x0000000110f7cdd7 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef> >, std::
1::basic_string<char, std::1::char_traits<char>, std::1::allocator<char> >*, bool*) const::$_4>(long) + 23
32 clang 0x00000001106637dc llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) + 236
33 clang 0x0000000110f7c848 clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef> >, std::1::basic_string<char, std::1::char_traits<char>, std::1::allocator<char> >*, bool*) const + 296
34 clang 0x0000000110f45233 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&) const + 739
35 clang 0x0000000110f4565d clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::
1::pair<int, clang::driver::Command const*> >&) const + 125
36 clang 0x0000000110f5fe2b clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::__1::pair<int, clang::driver::Command const*> >&) + 395
37 clang 0x000000010ecb307f main + 9663
38 libdyld.dylib 0x00007fff6c668cc9 start + 1
39 libdyld.dylib 0x0000000000000027 start + 18446603338697503583
clang-15: error: clang frontend command failed with exit code 134 (use -v to see invocation)
clang version 15.0.99 (http://labmaster3.local/git/llvm-project.git 3dce6b329ce3efa1d51f1101a08cff31ecdbeb12)
Target: x86_64-apple-darwin19.5.0
Thread model: posix
InstalledDir: /Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/bin
clang-15: error: unable to execute command: Abort trap: 6
clang-15: note: diagnostic msg: Error generating preprocessed source(s).
make: *** [main.o] Error 134

The reason it took us this look to find the issue is because there was a cmake error on the bots that caused the build to fail before, but a local git revert 506cf6dc048835c598b654e43ed8f723a42e39ba and ninja check-lldb-unit && bin/lldb-do-test -p TestStateAfterExpression.py does not crash like the build does.

Please revert this change or fix it as soon as possible! Thanks

Hi this commit broke the lldb greendragon bots.

https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/41225/

crashlog backtrace:

[...]

Target: x86_64-apple-darwin19.5.0
Thread model: posix
InstalledDir: /Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/bin
clang-15: error: unable to execute command: Abort trap: 6
clang-15: note: diagnostic msg: Error generating preprocessed source(s).
make: *** [main.o] Error 134

That's not really helpful -- can you please reduce some more? I'm not even able to run the LLDB tests locally, it complains about missing SWIG even though I did install it. Regardless, it looks like at the end of the day your bot is running something like this:

"/Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/bin/clang"  -fmodules -gmodules -fmodules-cache-path=/Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/lldb-test-build.noindex/module-cache-clang/lldb-api -gmodules -fcxx-modules -std=c++11 -g -O0 -fno-builtin -isysroot "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk" -arch x86_64  -I/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/packages/Python/lldbsuite/test/make/../../../../../include -I/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/test/API/functionalities/thread/state_after_expression -I/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/packages/Python/lldbsuite/test/make -include /Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/packages/Python/lldbsuite/test/make/test_common.h  -fno-limit-debug-info  -fmodules -gmodules -fmodules-cache-path=/Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/lldb-test-build.noindex/module-cache-clang/lldb-api -gmodules -fcxx-modules -std=c++11   --driver-mode=g++ -MT main.o -MD -MP -MF main.d -c -o main.o /Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/test/API/functionalities/thread/state_after_expression/main.cpp

So I think this is just a modules bug in Clang. I'll be happy to investigate if I can reproduce it.

Also, LLDB is still using the deprecated LLVM_ENABLE_PROJECTS build for libc++ and libc++abi -- please move to LLVM_ENABLE_RUNTIMES as documented here: https://libcxx.llvm.org/BuildingLibcxx.html.

That's not really helpful -- can you please reduce some more? I'm not even able to run the LLDB tests locally, it complains about missing SWIG even though I did install it. Regardless, it looks like at the end of the day your bot is running something like this:

Other things I'd need to know -- do you folks build your own Clang? It seems like it's a tip-of-trunk Clang, right? I assume you're building it with Assertions enabled? Any other settings you're using? The LLDB build is so complex that there's no way I'll be able to fix this if you don't provide a bit more information.

I managed to reproduce with a freshly-built Clang + libc++ and this:

echo "#include <cstddef>" | xcrun ./build/default/bin/clang++ -fmodules -xc++ - -fsyntax-only

This is caused by making the __config header a textual header. However, adding -Xclang -fmodules-local-submodule-visibility fixes the issue:

echo "#include <cstddef>" | xcrun ./build/default/bin/clang++ -fmodules -xc++ - -Xclang -fmodules-local-submodule-visibility -fsyntax-only

works just fine. And in fact, that's how we run our own Modules build (which we set up specifically to avoid breaking LLDB).

Could LLDB build with that flag so that our flags match?

Are you suggesting we drop support for building libcxx without local submodule visibility? I'm not sure that's an acceptable regression.

To answer your other question: The lldb-cmake bot build LLDB and clang with modules enabled, but that doesn't actually matter. What's breaking is running the LLDB testsuite when it's using the just-built clang to compile C++ tests with -fcxx-modules (without local submodule visibility).

Could LLDB [tests] build with that flag so that our flags match?

If the plan is to not support building libcxx without local submodule visibility, should -fcxx-modules imply -fmodules-local-submodule-visibility ?

Are you suggesting we drop support for building libcxx without local submodule visibility? I'm not sure that's an acceptable regression.

Let's put it that way: libc++ already doesn't support it, because it doesn't work and we don't test it. From our side, the situation is that we've done a huge amount of work to support modules because we knew a few projects were using it (LLDB being the biggest one I'm aware of), despite that being rather painful and very light on return on investment. Modules in Clang have some bugs that have been biting us, making things difficult. The only thing that's on our radar is whatever we test, and at the moment it's modules with local submodule visibility.

If there is a reason for us to support modules without local submodule visibility, then yes, we can look into supporting it, however I think the correct order is:

  1. Make sure LLDB uses an officially supported and tested way to build and use libc++ (which you partially address in 547a667ceeb6, thanks for that)
  2. Tell us about the fact that you'd like modules to be supported without local submodule visibility (that's clear now)
  3. Then we make any changes necessary to support it
  4. LLDB switches to modules without local submodule visibility

I think the friction here comes from the fact that LLDB (1) consciously decides to live on the edge by using a ToT libc++, and (2) doesn't give us a way to put LLDB on our radar by providing a pre-commit CI bot that would run the data formatters. This leads to this situation where we broke you, but we were not even aware that you *could* be broken. I thought the story of breaking LLDB data formatters (which used to happen frequently) was completely done because we added the right modules CI bot, but it seems like there was still a difference in the flag.

Anyway I'm immediately going to look into what's necessary to support modules without local submodule visibility, but I guess this question is still open:

If the plan is to not support building libcxx without local submodule visibility, should -fcxx-modules imply -fmodules-local-submodule-visibility ?

I don't know the answer to that. In fact, my initial impression would be that we want to support the "basic" form of modules, i.e. just -fmodules. Is there a reason to support more than that?

I think the friction here comes from the fact that LLDB (1) consciously decides to live on the edge by using a ToT libc++, and (2) doesn't give us a way to put LLDB on our radar by providing a pre-commit CI bot that would run the data formatters.

I'm not sure I agree with that characterization: LLDB doesn't live on the edge, it's a sibling project of libcxx inside the llvm-project monorepo and the bots test ToT of llvm-project.

It's by the way not an LLDB dataformatter that broke, but a clang invocation compiling a .cpp file (part of the LLDB test suite) using -fmodules -fcxxmodules ran into an assertion. LLDB is just the messenger :-)

LLDB is just the messenger

I take that back. I just realized that this also break LLDB's own importing of the C++ standard library.

_build.ninja.debug/bin/lldb-dotest -p TestImportStdModule.py
...
Assertion failed: ((ID || !Mod) && "asked for module ID for non-local, non-imported module"), function getSubmoduleID, file ASTWriter.cpp, line 2650.

I need to check whether LLDB uses a separate compiler instance for that or if the same compiler invocation is also used to import Objective-C modules.

Push/pop min and max in filesystem_helper.h

The change to push/pop those in filesystem_helper.h broke testing any other library than libc++, as the standard headers now require libc++ internal headers (<__undef_macros>) and macros (_LIBCPP_PUSH_MACROS, _LIBCPP_POP_MACROS).

How would you prefer to fix that - reinstate the -DNOMINMAX in the testing config, or just use a plain #undef max in the test support header? Or spell out the corresponding push/pop directives with compiler conditionals?

v.g.vassilev added inline comments.
libcxx/include/module.modulemap
10

I believe the issue that is being fixed in https://reviews.llvm.org/D119468 can be fixed by removing export std_config as clang seems to only be able to re-export submodules. Moreover, std_config is purely textual and there is nothing to export anyways.

We see such issue on our infrastructure and the suggested fix seem to work.

@ldionne, @aprantl, would it make sense to try it instead, as we should probably really treat __config and __config_site as textual?

Herald added a project: Restricted Project. · View Herald TranscriptJan 19 2023, 2:27 PM
ldionne added inline comments.Jan 25 2023, 10:28 PM
libcxx/include/module.modulemap
10

If it fixes an issue you are seeing, a patch is welcome. It would be nice if there was a way to reproduce the issue you are seeing, though.

v.g.vassilev added inline comments.
libcxx/include/module.modulemap
10

https://reviews.llvm.org/D119468 fixes it but my claim is that's the wrong fix as __config and __config_site are macro-only headers. Do we expect defining a macro in the includer to change the contents of these headers?

If we do they should be treated just like the assert header file, i.e. always marked as textual header file. We could protect the headers which must be textual similar to what we already do in llvm: https://github.com/llvm/llvm-project/blob/d94a315ee3ecf0fb03cf1c7422e120d9d0e95d00/llvm/cmake/modules/HandleLLVMOptions.cmake#L605-L610

We track the issue here https://github.com/root-project/root/issues/10861 The issue seems quite similar to https://www.mail-archive.com/llvm-bugs@lists.llvm.org/msg51401.html

I added a patch here: https://reviews.llvm.org/D142805