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

build: Pre-installing #58

Merged
merged 20 commits into from
Nov 10, 2024
Merged

build: Pre-installing #58

merged 20 commits into from
Nov 10, 2024

Conversation

obiwac
Copy link
Member

@obiwac obiwac commented Nov 9, 2024

Resolves #56

This is going to be the big new feature in v0.2.2.

One issue I'm having on macOS specifically is that, since dyld doesn't do /lib searching by default (when you link the full path of the library you're linking against is stored), pre-installing will fail. A solution to this would be to pre-install in the final destination, but that makes things difficult when we encounter the "already compiled" or "already linked" situation, because we'll need to install it in that situation too.

The dyld(1) manpage provides a solution to this under "DYNAMIC LIBRARY LOADING", but I think it's probably best to accomodate things how they are intended and push through with pre-installing to the final destination.

Update: this is done now (and has the added benefit of simplifying things a bit). I have a new issue on macOS though. When initially linking, the dynamic shared library install name is set to the path of the library in .bob/bob. When installing though, we need to update this using install_name_tool.

This poses a bit of a challenge though, as we need to figure out exactly what something is being linked against to be able to update it's path. Actually Bob v0.1.0 may have the solution to this issue; just pass dynamic libraries to link as an array.

I need to think about this some more but the easiest solution might just be to set the rpath and do the "non-accomodating" solution. Hint: otool can be used to inspect all these values on a library or a binary.

macOS is winding up being a little annoying to support 😄 But I had been warned that libraries were complicated and different on macOS.

Update 2 (final solution):

  • When linking a shared object, set its install ID to @rpath/lib/libwhatever.so. This means that any rpath we set on another shared library or executable will be substituted for @rpath.
  • When linking a shared object or an executable, set -rpath "@loader_path/..". That way, when looking for libwhatever.so, we'll look in @loader_path/../lib/libwhatever.so, which will work both in the temporary install prefix and relatively wherever we install.

This excellent blog post is what helped me grasp this.

Here's all that's left to do:

  • Make dylib parameter when (pre)installing smarter, i.e. infer this instead of having to pass this around the place.
  • Attempt to pre-install always, even when "already xxx". Actually, anything which is installed from a cookie should be pre-installed.
  • Can use this opportunity to make a kind of cookie_to_output function so we can log that out when linking (instead of just saying "Linking...").
  • Log the fact that we pre-install instead of being quiet. Also, once we've preinstalled, don't just say "already installed" again. Be smart about this.

@obiwac obiwac added the feature New feature, yo label Nov 9, 2024
@obiwac obiwac changed the title build: Incrementally install build: Pre-installing Nov 9, 2024
@obiwac obiwac marked this pull request as ready for review November 10, 2024 00:39
@obiwac obiwac merged commit d6a6d4d into main Nov 10, 2024
8 checks passed
@obiwac obiwac deleted the feature/incremental-install branch November 10, 2024 00:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature, yo
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Linker can't depend on previous build steps
1 participant