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...
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.
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.
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)
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.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
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 buildseems to work fine without further setup.)How do I make
./gradlew buildNativework? Currently, task:pkl-cli:alpineExecutableAmd64fails with:Further up I see:
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 buildNativesucceeded. So I think I'm pretty close...@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 linuxExecutableAarch64or./gradlew linuxExecutableAmd64depending 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.
@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.Setting up the JDK is mentioned separately. I think "Setup Gradle on your system" should be either detailed or removed.
@bioball commented on GitHub (Feb 6, 2024):
That sounds good!
Feel free to submit a PR for this too (a separate one)
@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.