Skip to content

Build duckdb_java linux-amd64-musl #120

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

Closed
wants to merge 12 commits into from

Conversation

hrl20
Copy link
Contributor

@hrl20 hrl20 commented Jan 7, 2025

Build duckdb_java for Alpine linux on amd64

(arm64 is possible but takes 4+ hours on the default GHA runner, so skipping for now)

Copy link
Contributor

@carlopi carlopi left a comment

Choose a reason for hiding this comment

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

Main question: can we get away from static linking the libc++ ?
I see that working with, question is if we can manage without.

@hrl20
Copy link
Contributor Author

hrl20 commented Jan 16, 2025

Main question: can we get away from static linking the libc++ ? I see that working with, question is if we can manage without.

I think in general this will not work because the standard alpine distribution doesn't include these libraries. Not linking it means requiring users to always install them in their Alpine containers when they want to use duckdb. This error happened trying to run duckdb (libstdc++ and libgcc linked) in the standard Metabase container which uses alpine, and loading httpfs (no libstdc++ and libgcc linked).

Screenshot 2024-10-29 at 1 43 20 AM (1)

Also this does mean the extensions need to have statically linked libstdc++ and libgcc. Idk if there's a better solution here.

@carlopi
Copy link
Contributor

carlopi commented Jan 16, 2025

But I think the problem here is that v1.1.2 has no concept (yet) of musl.

Would it be possible to run the same workflow again using a recent duckdb commit (such as 09cef57892 the one currently backed in duckdb-java)

@hrl20
Copy link
Contributor Author

hrl20 commented Jan 21, 2025

But I think the problem here is that v1.1.2 has no concept (yet) of musl.

Would it be possible to run the same workflow again using a recent duckdb commit (such as 09cef57892 the one currently backed in duckdb-java)

I tried this again on this branch and it still fails /tmp/libduckdb_java14876668067405368824.so: Error loading shared library libstdc++.so.6: No such file or directory (needed by /tmp/libduckdb_java14876668067405368824.so)

@staubt
Copy link

staubt commented Apr 22, 2025

Hello
Is it planned to bring that to one of the next releases?
I would like to use duckdb java with an alpine base image.

@staticlibs
Copy link
Collaborator

@staubt

Hi, yes, preliminary JDBC v1.3.0.x is going to include the build with musl libc. Though it was found that on some workloads DuckDB on musl may be multiple times slower than DuckDB on glibc, so should be used with caution.

Also, may I ask which JDK build are you considering to use on Alpine, is it glibc-based or musl-based?

@staubt
Copy link

staubt commented Apr 23, 2025

Hi
Thanks for the fast answer. The Alpine image I want to use is musl-based.

@carlopi
Copy link
Contributor

carlopi commented May 13, 2025

@hrl20: I realize my previous comments are void, thanks for the explanation.

@carlopi
Copy link
Contributor

carlopi commented May 13, 2025

@staticlibs: unsure how to proceed, I think it's more appropriate for you to make a call

staticlibs added a commit to staticlibs/duckdb-java that referenced this pull request May 19, 2025
This change adds experimental support for building JDBC driver with
musl libc on x86_64 and aarch64 Linux. It is based on duckdb#120 PR.

New artifacts are NOT combined into the unified JAR, instead they are
published to Maven with custom classifiers `linux_amd64_musl` and
`linux_aarch64_musl`.

Co-authored-by: hrl20 <[email protected]>
staticlibs added a commit that referenced this pull request May 19, 2025
This change adds experimental support for building JDBC driver with
musl libc on x86_64 and aarch64 Linux. It is based on #120 PR.

New artifacts are NOT combined into the unified JAR, instead they are
published to Maven with custom classifiers `linux_amd64_musl` and
`linux_aarch64_musl`.

Co-authored-by: hrl20 <[email protected]>
@staticlibs
Copy link
Collaborator

@hrl20

Thanks for this PR, and sorry for the long waiting time with it! I've incorporated it into #226, the nightly dev version can be used now from the Maven snapshots repo:

    <dependencies>
        <dependency>
            <groupId>org.duckdb</groupId>
            <artifactId>duckdb_jdbc</artifactId>
            <version>1.3.0-SNAPSHOT</version>
	    <classifier>linux_amd64_musl</classifier>
        </dependency>
    <dependencies>
    <repositories>
        <repository>
            <id>oss-sonatype</id>
            <name>oss-sonatype</name>
            <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
    </repositories>

Notable changes from the original PR:

  • x86_64 and aarch64 builds with musl libc are NOT added to the main "universal" JAR. They are published as standalone arch-specific JARs with classifiers linux_amd64_musl and linux_aarch64_musl
  • libstdc++ is NOT linked statically, it is required to run apk add libstdc++ when preparing Alpine containers
  • aarch64 build is added the same way as amd64 one, but prebuilt extensions are not yet available for linux_aarch64_musl so it is not very useful right now

@staticlibs staticlibs closed this May 19, 2025
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.

5 participants