This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Explicitly set libcxx paths when USE_SYSTEM_LIBCXX is provided
ClosedPublic

Authored by fdeazeve on Mar 23 2023, 5:25 AM.

Details

Summary

For tests marked as "USE_SYSTEM_LIBCXX", the expectation is that the
system's standard library should be used. However, the implementation of
this flag is such that we simply don't pass _any_ libcxxx-related flags
to Clang; in turn, Clang will use its defaults.

For a Clang/Libcxx pair compiled together, Clang defaults to:

  1. The headers of the sibling libcxx.
  2. The libraries of the system.

This mismatch is actually a bug in the driver; once fixed, however, (2)
would point to the sibling libcxx as well, which is _not_ what test
authors intended with the USE_SYSTEM_LIBCXX flag.

As such, this patch explicitly sets a path to the system's libraries.
This change is done only in Apple platforms so that we can test this
works in this case first.

Diff Detail

Event Timeline

fdeazeve created this revision.Mar 23 2023, 5:25 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 23 2023, 5:25 AM
fdeazeve requested review of this revision.Mar 23 2023, 5:25 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 23 2023, 5:25 AM
Michael137 accepted this revision.Mar 23 2023, 5:29 AM

Makes sense to me, thanks!

This revision is now accepted and ready to land.Mar 23 2023, 5:29 AM
Michael137 added inline comments.Mar 23 2023, 5:30 AM
lldb/packages/Python/lldbsuite/test/make/Makefile.rules
434

Should we add a hard error if we get here with an empty SDKROOT?

Typo in commit message and description:
USE_SYSTEM_LIBCXX should be USE_SYSTEM_STDLIB

fdeazeve added inline comments.Mar 23 2023, 5:36 AM
lldb/packages/Python/lldbsuite/test/make/Makefile.rules
434

I thought about this, but at the start of this file we have this:

# Handle SDKROOT on Darwin
#----------------------------------------------------------------------

ifeq "$(OS)" "Darwin"
    ifeq "$(SDKROOT)" ""
	# We haven't otherwise set the SDKROOT, so set it now to macosx
	SDKROOT := $(shell xcrun --sdk macosx --show-sdk-path)
    endif
endif

So it would be a bit redundant...
But I think you're right that we could have an error in case someone, someday, changes the logic above.

Michael137 added inline comments.Mar 23 2023, 5:40 AM
lldb/packages/Python/lldbsuite/test/make/Makefile.rules
434

Yea don't feel too strongly about it, since as you say, the check is at the top of the file already

fdeazeve updated this revision to Diff 507711.Mar 23 2023, 5:41 AM

Fix typos in commit message.
Add hard error in case SDKROOT is not set.

JDevlieghere accepted this revision.Mar 23 2023, 8:43 AM

LGTM

lldb/packages/Python/lldbsuite/test/make/Makefile.rules
434
fdeazeve updated this revision to Diff 507756.Mar 23 2023, 8:48 AM

Improve error message

fdeazeve updated this revision to Diff 507757.Mar 23 2023, 8:49 AM

Fix typo in error msg