Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ld: support -dynamic_lookup_library #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mathstuf
Copy link

@mathstuf mathstuf commented Jun 3, 2020

This causes all symbols found in the specified library to be looked up
at load time. The library itself is not linked by the output library at
all.

The main use case for this is creating compiled modules for dynamic
languages (e.g., Ruby or Python) where the application loading the
module provides the interpreter's symbols. This allows the compiled
module to be agnostic to the installation of the interpreter. That is,
it can link against the Apple-provided Python, but be run with an
Anaconda-provided interpreter.

@@ -4575,6 +4575,10 @@ int OutputFile::compressedOrdinalForAtom(const ld::Atom* target)
// regular ordinal
const ld::dylib::File* dylib = dynamic_cast<const ld::dylib::File*>(target->file());
if ( dylib != NULL ) {
// Handle -dynamic_lookup_library
if ( dylib->forcedDynamicLookupLinked() )
return BIND_SPECIAL_DYLIB_FLAT_LOOKUP;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is also BIND_SPECIAL_DYLIB_MAIN_EXECUTABLE. However, I suspect this is more geared towards the case where the symbols are actually in the main executable which is not the case for the libpython use case.

@mathstuf
Copy link
Author

mathstuf commented Jun 3, 2020

@Bigcheese Bruno and I talked about this in Kona 2019, but I can't seem to find his GitHub handle.

@seanm
Copy link

seanm commented Aug 2, 2022

I don't think Apple pays attention to github pull requests, so I filed FB10995337 in their bugtracker.

This causes all symbols found in the specified library to be looked up
at load time. The library itself is not linked by the output library at
all.

The main use case for this is creating compiled modules for dynamic
languages (e.g., Ruby or Python) where the application loading the
module provides the interpreter's symbols. This allows the compiled
module to be agnostic to the installation of the interpreter. That is,
it can link against the Apple-provided Python, but be run with an
Anaconda-provided interpreter.
@mathstuf
Copy link
Author

mathstuf commented Feb 6, 2023

Updated to actually compile based on testing within the cctools-port project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants