Page MenuHomePhabricator

Prevent double import of _lldb module
ClosedPublic

Authored by vadimcn on Sep 23 2018, 11:09 AM.

Details

Summary

This fixes llvm.org/pr39054

The fix itself is pretty simple:

  1. Register _lldb as a built-in module during initialization of script interpreter.
  2. Reverse the order of imports in __init__.py: first try to import by absolute name, which will find the built-in module in the context of lldb (and other hosts that embed liblldb), then try relative import, in case the module is being imported from Python interpreter.

Diff Detail

Repository
rL LLVM

Event Timeline

vadimcn created this revision.Sep 23 2018, 11:09 AM
vadimcn retitled this revision from Prevent double import of _lldb module on Windows to Prevent double import of _lldb module.Oct 6 2018, 8:21 PM

Changing title as it looks like this is not a Windows-only problem: https://github.com/rust-lang/rust/issues/54126.

The above illustrates why I think this needs to be fixed: Right now LLDB cannot be installed correctly unless the installer can preserve symlinks. Merely making a copy of LLDB files will break it, unless one is extra careful to use symlink-preserving copy, and I am not even sure what tool could be used on Windows to copy it correctly.

labath accepted this revision.Oct 6 2018, 11:33 PM

Sorry for the delay. I *think* this should be fine, but with these things its hard to tell whether it won't break someone's build/release setup. However, it does solve a real problem (I've hit this issue myself a couple of times on windows), so I think we should give it a try.

It might be good to note that this will only ever make a difference if one is using swig>=3.0.11.

This revision is now accepted and ready to land.Oct 6 2018, 11:33 PM

Thanks,
What changed in SWIG 3.0.11?

labath added a comment.Oct 7 2018, 1:52 AM

Thanks,
What changed in SWIG 3.0.11?

That's the version which added support for the moduleimport attribute. Before that, the modules were imported using a fixed algorithm (I am not sure whether that algorithm was compatible or not with what you're doing here.)

This revision was automatically updated to reflect the committed changes.