This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Create flag to use a custom libcxx in tests
AbandonedPublic

Authored by fdeazeve on Aug 19 2022, 11:40 AM.

Details

Summary

When running LLDB tests with a separately built copy of libcxx, it may
be necessary to also use the nostdinc++ and cxx-isystem flags, so
that Clang doesn't keep multiple paths to the standard library in its
include search list. This is particularly important when also running
LLDB tests using older versions of clang, which may not deal with
multiple standard libraries properly.

These issues have all been seen in the LLDB matrix green dragon bot,
which ensures that tip-of-trunk LLDBs can debug code compiled with older
versions of Clang/libcxx.

Once this is merged, llvm-zorg can be updated to use the flags. Local
testing has been done by compiling the project with:

-DLLDB_TEST_USER_ARGS="--custom-libcpp=<invalid_path>

We verified that all LLDB tests failed to find standard library files.
Then we fixed the invalid path to point to a proper libcxx, and the
tests passed.

A similar effect could have been accomplished by repurposing either
CXXFLAGS or CXXFLAGS_EXTRAS, but these are already for many different
purposes, so we choose to isolate the new behavior into a new
environment variable.

We also choose to keep the logic of formatting the flags inside the
Makefile, as that's where we can check which compiler is being used, as
it is already done in other places there.

Diff Detail

Event Timeline

fdeazeve created this revision.Aug 19 2022, 11:40 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 19 2022, 11:40 AM
fdeazeve requested review of this revision.Aug 19 2022, 11:40 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 19 2022, 11:40 AM
fdeazeve updated this revision to Diff 454073.Aug 19 2022, 11:43 AM

Fixed typo in commit message

aprantl accepted this revision.Aug 19 2022, 12:05 PM

That looks nice and clean!

This revision is now accepted and ready to land.Aug 19 2022, 12:05 PM
JDevlieghere requested changes to this revision.Aug 19 2022, 1:18 PM
JDevlieghere added inline comments.
lldb/packages/Python/lldbsuite/test/dotest.py
338–339

Please don't rely on environment variables to pass arguments to the Make invocation. This makes it really tedious to debug make invocations. Instead, pass these explicitly as part of the make invocation from the builders (packages/Python/lldbsuite/test/builders/).

This revision now requires changes to proceed.Aug 19 2022, 1:18 PM
aprantl added inline comments.Aug 19 2022, 1:25 PM
lldb/packages/Python/lldbsuite/test/dotest.py
338–339

That is a very good point. Maybe we should just fix the -E option, which doesn't work anyway due to Makefiles setting CFLAGS_EXTRAS and use that.

JDevlieghere added inline comments.Aug 19 2022, 1:28 PM
lldb/packages/Python/lldbsuite/test/dotest.py
338–339

I think a specific flag is fine, we already have something similar for using the "hermetic" libc++ (I left a comment below about that). We should see if we can unify this.

lldb/packages/Python/lldbsuite/test/dotest_args.py
175

We should also think about how this interacts with --hermetic-libcxx (and make the name of the options consistent).

aprantl added inline comments.Aug 19 2022, 1:30 PM
lldb/packages/Python/lldbsuite/test/dotest.py
338–339

It looks like (apart from making -E not use CFLAGS_EXTRAS but a fresh variable) we should use that mechanism for all the options passed using os.environ().

fdeazeve added inline comments.Aug 19 2022, 2:20 PM
lldb/packages/Python/lldbsuite/test/dotest.py
338–339

I'm a bit puzzled by the Builder class, since I don't recall encountering it while tracing the variables from CMake to the final Makefile invocation. I'll try to figure this out based on your patch.

lldb/packages/Python/lldbsuite/test/dotest_args.py
175

If I understand correctly, that flag is a more restricted behaviour of what is being implemented here: hermetic-libcxx is _only_ about looking for a libcxx built alongside LLDB / Clang, whereas this patch allows an arbitrary libcxx to be used (the use cases we're aiming for don't even use a Clang built alongside LLDB).

I believe hermetic-libcxx can be implemented in terms of the new functionality being added here, but I'll look some more at your patch to make sure that's the case

fdeazeve abandoned this revision.Aug 19 2022, 3:02 PM

Abandoning in favour of D132263