This is an archive of the discontinued LLVM Phabricator instance.

[lldb/Platform] Skip very slow xcrun queries for simulator platforms, NFC
ClosedPublic

Authored by vsk on Mar 9 2021, 10:53 AM.

Details

Summary

GetXcodeSDK() consistently takes over 1 second to complete if the
queried SDK is missing, because xcrun doesn't cache negative lookups.

Because there are multiple simulator platforms, this can add 4+ seconds
to lldb -b some_object_file.o.

To work around this, skip the call to GetXcodeSDK() when setting up
simulator platforms if the specified arch doesn't have what looks like a
simulator triple.

Some other ways to fix this:

  • Fix caching in xcrun (rdar://74882205)
  • Test for arch compat before calling SomePlatform::CreateInstance() (much larger change)

Diff Detail

Event Timeline

vsk requested review of this revision.Mar 9 2021, 10:53 AM
vsk created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptMar 9 2021, 10:53 AM
JDevlieghere added inline comments.Mar 9 2021, 9:46 PM
lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
533

We should extract this into a little helper function to avoid the code (and comment) duplication.

534

Is it equivalent to return nullptr here to passing an empty string as the sdk?

vsk added inline comments.Mar 10 2021, 12:13 PM
lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
534

I don't know, but I don't think so -- shouldn't that amount to dropping the -sdk argument here?:

auto xcrun = [](const std::string &sdk,
                llvm::StringRef developer_dir = "") -> std::string {
  std::string xcrun_cmd = "xcrun --show-sdk-path --sdk " + sdk;
vsk updated this revision to Diff 329733.Mar 10 2021, 12:14 PM

Use a helper function, respect the force argument.

This revision is now accepted and ready to land.Mar 10 2021, 1:04 PM
This revision was landed with ongoing or failed builds.Mar 10 2021, 1:57 PM
This revision was automatically updated to reflect the committed changes.