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

feat: Build with Alpine for static Linux binaries #42

Merged
merged 1 commit into from
Oct 10, 2024

Conversation

joeyparrish
Copy link
Member

This uses an Alpine Linux container to build truly static Linux binaries that do not depend on glibc at runtime.

Alpine uses musl instead of glibc, which enables this fully static build. With musl compiler wrappers in Ubuntu, you still end up importing glibc references through libstdc++. And since x265 uses C++, we can't eliminate these in Ubuntu without dropping HEVC support. Using Alpine, with its musl-native environment, allows us to avoid glibc and build fully static Linux binaries.

Closes #28

@joeyparrish
Copy link
Member Author

Here's a full CI run with the modified workflow: https://github.com/shaka-project/static-ffmpeg-binaries/actions/runs/11263885133

@mariocynicys mariocynicys self-assigned this Oct 9, 2024
This uses an Alpine Linux container to build truly static
Linux binaries that do not depend on glibc at runtime.

Alpine uses musl instead of glibc, which enables this fully static
build.  With musl compiler wrappers in Ubuntu, you still end up
importing glibc references through libstdc++.  And since x265 uses
C++, we can't eliminate these in Ubuntu without dropping HEVC support.
Using Alpine, with its musl-native environment, allows us to avoid
glibc and build fully static Linux binaries.

Closes #28
Copy link
Member

@mariocynicys mariocynicys left a comment

Choose a reason for hiding this comment

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

A couple of questions inline.
Tested locally and works :)
LGTM!

Comment on lines +25 to +28
# NOTE: disable OpenCL-based features because it uses dlopen and can interfere
# with static builds.
./configure \
--disable-opencl \
Copy link
Member

Choose a reason for hiding this comment

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

Q, so builds with these configurations aren't static anymore or the does building fail all together?

Copy link
Member Author

Choose a reason for hiding this comment

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

They aren't really static, since it uses dlopen to find OpenCL at runtime. Also, OpenCL isn't necessary for the H264 software codec.

Comment on lines +103 to +106
container:
image: ${{ matrix.container }}
# Access to the host filesystem is required to patch the environment for
# Alpine Linux support. See the first Alpine step below for details.
Copy link
Member

Choose a reason for hiding this comment

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

how things go when the matrix entry doesn't define a container? couldn't find it in github CI docs, but it seems to play nicely as we have green check marks on other platforms and the binaries are uploaded.

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 found that it just doesn't run in a container when image is blank. So this works nicely with the build matrix, and allows us to put some builds in containers and others not.

@joeyparrish joeyparrish merged commit 00b67bf into main Oct 10, 2024
7 checks passed
@joeyparrish joeyparrish deleted the linux-static-docker branch October 10, 2024 14:47
@github-actions github-actions bot added the status: archived Archived and locked; will not be updated label Dec 17, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: archived Archived and locked; will not be updated
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FFmpeg & FFprobe binarys segfault on Linux
3 participants