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

Refactor static / dynamic linking into build options #546

Closed
wants to merge 3 commits into from

Conversation

zanieb
Copy link
Member

@zanieb zanieb commented Feb 27, 2025

A bit on the fence about where to put this, i.e., it could be a part of the target triple? Trying this out to start.

The goal here is to untangle the static vs shared builds from musl per #542 so we can ship both kinds in #541

@zanieb zanieb added ci:dry-run platform:linux Specific to the Linux platform libc:musl labels Feb 27, 2025
@zanieb zanieb removed the ci:dry-run label Feb 27, 2025
@zanieb zanieb marked this pull request as ready for review March 5, 2025 19:33
@zanieb
Copy link
Member Author

zanieb commented Mar 5, 2025

After trying #547 I think this is a little simpler because we otherwise have to sanitize all the targets when building packages, e.g., <triple>-static is not a valid configure --host target.

Comment on lines 58 to 65
# Construct possible options, we use a set here for canonical ordering
options = set()
options.update({"debug", "noopt", "pgo", "lto", "pgo+lto"})
options.update({f"freethreaded+{option}" for option in options})
link_modes = {"static", "shared"}
options.update(
{f"{option}+{link_mode}" for link_mode in link_modes for option in options}
)
Copy link
Member Author

Choose a reason for hiding this comment

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

I don't like this, especially since it's repeated. I will refactor this further separately.

@zanieb
Copy link
Member Author

zanieb commented Mar 5, 2025

Some history on shared / static fields can be found by following #241

@zanieb zanieb removed the libc:musl label Mar 5, 2025
zanieb added a commit that referenced this pull request Mar 11, 2025
As a consequence of #540 I was playing with these concepts and decided
to explore it.

This includes #546 (could be merged separately or together), which
separates "static" builds from the "musl" triple specifically in favor
of a dedicated build option.

The main implementation downside here is that `$ORIGIN` doesn't work
with DT_NEEDED so we need to use RUNPATH instead, which can cause the
wrong library to be loaded if LD_LIBRARY_PATH is set. Given the current
builds aren't usable at all, I think this is a fine trade-off. We can
explore alternatives in the future, like statically linking just
libpython.

Another caveat here: for consistency with the glibc builds, we're
changing the "default" musl build to be dynamically linked. This is a
breaking change in the release artifacts. The statically linked musl
build will include a `+static` suffix. We could do something for
backwards compatibility here, but I _think_ this probably makes sense in
the long term. My primary concern is that consumers that combine
releases (such as uv) would need to encode this change (e.g., toggle the
expectation based on the python-build-standalone version tag).

It's challenging to test changes to the release artifact handling.
Regardless of approach, this will need a follow-up to adjust that
accordingly.
@zanieb
Copy link
Member Author

zanieb commented Mar 11, 2025

Merged via #541

@zanieb zanieb closed this Mar 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform:linux Specific to the Linux platform
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant