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 BABASHKA_STATIC with musl C library #827

Conversation

thiagokokada
Copy link
Contributor

@thiagokokada thiagokokada commented May 9, 2021

This is the recommended way to build static binaries with GraalVM by the documentation and multiple issues on GitHub. See:

The reason that building a statically binary with glibc is complicated is explained in the glib documentation:

https://sourceware.org/glibc/wiki/FAQ#Even_statically_linked_programs_need_some_shared_libraries_which_is_not_acceptable_for_me.__What_can_I_do.3F

To build a static binary with Dockerfile, use:

$ docker build -t babashka . \
    --build-arg BABASHKA_STATIC=true \
    --build-arg BABASHKA_USE_MUSL=true \
    --build-arg BABASHKA_XMX="-J-Xmx16g" # musl builds needs more memory, but maybe "-J-Xmx8g" is sufficient?

This is the recommended way to build static binaries with GraalVM by the
documentation and multiple issues on GitHub. See:

- https://www.graalvm.org/reference-manual/native-image/StaticImages/
- oracle/graal#571 (comment)

The reason that building a statically binary with glibc is complicated
is explained in the glib documentation:

https://sourceware.org/glibc/wiki/FAQ#Even_statically_linked_programs_need_some_shared_libraries_which_is_not_acceptable_for_me.__What_can_I_do.3F

To build a static binary with Dockerfile, use:

```
$ docker build -t babashka . \
    --build-arg BABASHKA_STATIC=true \
    --build-arg BABASHKA_USE_MUSL=true \
    --build-arg BABASHKA_XMX="-J-Xmx16g"
```
@thiagokokada thiagokokada marked this pull request as draft May 9, 2021 17:55
@thiagokokada
Copy link
Contributor Author

Pre-built version for testing:
babashka-0.4.1-SNAPSHOT-linux-amd64-static-musl.tar.gz

@thiagokokada
Copy link
Contributor Author

@thiagokokada
Copy link
Contributor Author

Building with BABASHKA_XMX="-J-Xmx8g" works, with the default (BABASHKA_XMX="-J-Xmx3g") it doesn't.

@thiagokokada
Copy link
Contributor Author

Closing it in favor of @lispyclouds approach (it is being tested on babashka/pod-babashka-aws#36 first).

@thiagokokada thiagokokada deleted the add-musl-libraries-to-static-build branch May 9, 2021 19:14
@thiagokokada thiagokokada restored the add-musl-libraries-to-static-build branch May 9, 2021 21:47
@thiagokokada thiagokokada deleted the add-musl-libraries-to-static-build branch May 9, 2021 21:49
@thiagokokada thiagokokada restored the add-musl-libraries-to-static-build branch May 9, 2021 22:19
@thiagokokada thiagokokada deleted the add-musl-libraries-to-static-build branch May 10, 2021 02:02
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.

None yet

1 participant