Improve development setup instructions #31

Open
opened 2025-12-30 01:19:43 +01:00 by adam · 4 comments
Owner

Originally created by @odenix on GitHub (Feb 5, 2024).

I'm trying to build Pkl on Ubuntu 22.04/WSL 2.0.14. (I'd prefer to build directly in Windows but ran into https://github.com/apple/pkl/issues/20 and failing tests.) After reading through DEVELOPMENT.adoc, I have the following questions:

What does "Setup Gradle on your system" entail? (./gradlew build seems to work fine without further setup.)

How do I make ./gradlew buildNative work? Currently, task :pkl-cli:alpineExecutableAmd64 fails with:

/usr/bin/ld: cannot find -lz: No such file or directory

Further up I see:

[7/7] Creating image...                                                                                  (0.0s @ 1.86GB)
Fatal error: java.lang.RuntimeException: There was an error linking the native image: Linker command exited with 1

Based on the linker command output, possible reasons for this include:
1. It appears as though libz:.a is missing. Please install it.

Installing package zlib1g-dev, which contains /usr/lib/x86_64-linux-gnu/libz.a, didn't solve the problem.

The good news is that after tinkering with the build scripts to exclude the Alpine build and test tasks, ./gradlew build buildNative succeeded. So I think I'm pretty close...

Originally created by @odenix on GitHub (Feb 5, 2024). I'm trying to build Pkl on Ubuntu 22.04/WSL 2.0.14. (I'd prefer to build directly in Windows but ran into https://github.com/apple/pkl/issues/20 and failing tests.) After reading through `DEVELOPMENT.adoc`, I have the following questions: What does "Setup Gradle on your system" entail? (`./gradlew build` seems to work fine without further setup.) How do I make `./gradlew buildNative` work? Currently, task `:pkl-cli:alpineExecutableAmd64` fails with: ``` /usr/bin/ld: cannot find -lz: No such file or directory ``` Further up I see: ``` [7/7] Creating image... (0.0s @ 1.86GB) Fatal error: java.lang.RuntimeException: There was an error linking the native image: Linker command exited with 1 Based on the linker command output, possible reasons for this include: 1. It appears as though libz:.a is missing. Please install it. ``` Installing package `zlib1g-dev`, which contains `/usr/lib/x86_64-linux-gnu/libz.a`, didn't solve the problem. The good news is that after tinkering with the build scripts to exclude the Alpine build and test tasks, `./gradlew build buildNative` succeeded. So I think I'm pretty close...
Author
Owner

@bioball commented on GitHub (Feb 6, 2024):

The Alpine executable depends on musl. You can see how we set it up in our CI here: https://github.com/apple/pkl/blob/main/.circleci/jobs/BuildNativeJob.pkl#L78-L90

But, if you just want to build it locally, you should be able to just do ./gradlew linuxExecutableAarch64 or ./gradlew linuxExecutableAmd64 depending on your architecture. But yeah, changing the build script to exclude the Alpine stuff works too!

For Gradle: I suppose that also implies setting up the JDK, but evidently enough you've already done that.

@bioball commented on GitHub (Feb 6, 2024): The Alpine executable depends on musl. You can see how we set it up in our CI here: https://github.com/apple/pkl/blob/main/.circleci/jobs/BuildNativeJob.pkl#L78-L90 But, if you just want to build it locally, you should be able to just do `./gradlew linuxExecutableAarch64` or `./gradlew linuxExecutableAmd64` depending on your architecture. But yeah, changing the build script to exclude the Alpine stuff works too! For Gradle: I suppose that also implies setting up the JDK, but evidently enough you've already done that.
Author
Owner

@odenix commented on GitHub (Feb 6, 2024):

Thanks for the pointers! I found more info here: https://www.graalvm.org/latest/reference-manual/native-image/guides/build-static-executables/#prerequisites-and-preparation

I think most (WSL) Linux users won't bother to set up a musl toolchain. But we'd still like to run the native build as advertised (./gradlew buildNative). How about only running the Alpine tasks if a musl toolchain (i.e., ~/staticdeps/bin/x86_64-linux-musl-gcc) is present? If this sounds good, I'll send a pull request.

For Gradle: I suppose that also implies setting up the JDK, but evidently enough you've already done that.

Setting up the JDK is mentioned separately. I think "Setup Gradle on your system" should be either detailed or removed.

@odenix commented on GitHub (Feb 6, 2024): Thanks for the pointers! I found more info here: https://www.graalvm.org/latest/reference-manual/native-image/guides/build-static-executables/#prerequisites-and-preparation I think most (WSL) Linux users won't bother to set up a musl toolchain. But we'd still like to run the native build as advertised (`./gradlew buildNative`). How about only running the Alpine tasks if a musl toolchain (i.e., `~/staticdeps/bin/x86_64-linux-musl-gcc`) is present? If this sounds good, I'll send a pull request. > For Gradle: I suppose that also implies setting up the JDK, but evidently enough you've already done that. Setting up the JDK is mentioned separately. I think "Setup Gradle on your system" should be either detailed or removed.
Author
Owner

@bioball commented on GitHub (Feb 6, 2024):

I think most (WSL) Linux users won't bother to set up a musl toolchain. But we'd still like to run the native build as advertised (./gradlew buildNative). How about only running the Alpine tasks if a musl toolchain (i.e., ~/staticdeps/bin/x86_64-linux-musl-gcc) is present? If this sounds good, I'll send a pull request.

That sounds good!

Setting up the JDK is mentioned separately. I think "Setup Gradle on your system" should be either detailed or removed

Feel free to submit a PR for this too (a separate one)

@bioball commented on GitHub (Feb 6, 2024): > I think most (WSL) Linux users won't bother to set up a musl toolchain. But we'd still like to run the native build as advertised (./gradlew buildNative). How about only running the Alpine tasks if a musl toolchain (i.e., ~/staticdeps/bin/x86_64-linux-musl-gcc) is present? If this sounds good, I'll send a pull request. That sounds good! > Setting up the JDK is mentioned separately. I think "Setup Gradle on your system" should be either detailed or removed Feel free to submit a PR for this too (a separate one)
Author
Owner

@odenix commented on GitHub (Feb 7, 2024):

Sent https://github.com/apple/pkl/pull/83 for the musl toolchain check.

I'll leave it to you to clarify the "setup Gradle" instructions because I don't know if/what setup you'd like to recommend.
All I can say is that I didn't have to set up anything to build this project.

@odenix commented on GitHub (Feb 7, 2024): Sent https://github.com/apple/pkl/pull/83 for the musl toolchain check. I'll leave it to you to clarify the "setup Gradle" instructions because I don't know if/what setup you'd like to recommend. All I can say is that I didn't have to set up anything to build this project.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/pkl#31