Skip to content

Commit

Permalink
ci(java/binding): Use zigbuild for glibc 2.17 support (#3664)
Browse files Browse the repository at this point in the history
* ci(java/binding): Use zigbuild for glibc 2.17 support

Signed-off-by: Xuanwo <[email protected]>

* Fix build

Signed-off-by: Xuanwo <[email protected]>

* Add zigbuild support

Signed-off-by: Xuanwo <[email protected]>

* Fix script

Signed-off-by: Xuanwo <[email protected]>

* Fix build

Signed-off-by: Xuanwo <[email protected]>

* Use new glibc

Signed-off-by: Xuanwo <[email protected]>

* Let's try

Signed-off-by: Xuanwo <[email protected]>

* Build with 2.17 glibc

Signed-off-by: Xuanwo <[email protected]>

---------

Signed-off-by: Xuanwo <[email protected]>
  • Loading branch information
Xuanwo authored Nov 27, 2023
1 parent 049ce8d commit 682d38c
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 7 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/release_java.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ on:
# Staging JARs on Apache Nexus repository for RCs. Read more on
# https://opendal.apache.org/docs/contributing/release#release-maven-artifacts
- 'v[0-9]+.[0-9]+.[0-9]+-rc.[0-9]+'
pull_request:
branches:
- main
paths:
- ".github/workflows/release_java.yml"
- "bindings/java/tools/build.py"
workflow_dispatch:

jobs:
Expand Down Expand Up @@ -63,6 +69,10 @@ jobs:
version: "23.4"
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Setup linux for zigbuild
if: "contains(matrix.os, 'ubuntu-latest')"
run: pip install cargo-zigbuild

- name: Setup linux-aarch_64
if: "contains(matrix.classifier, 'linux-aarch_64')"
run: |
Expand All @@ -80,6 +90,7 @@ jobs:
-Djni.classifier=${{ matrix.classifier }} \
-Dcargo-build.profile=release \
-Dcargo-build.features=services-all \
-Dcargo-build.enableZigbuild=true \
-DaltStagingDirectory=local-staging \
-DskipRemoteStaging=true \
-DserverId=apache.releases.https \
Expand Down
3 changes: 2 additions & 1 deletion bindings/java/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ services-all = [
"services-mysql",
"services-redb",
"services-redis",
"services-rocksdb",
# FIXME: rocksdb will lead to "cannot allocate memory in static TLS block" while linking.
# "services-rocksdb",
"services-sled",
"services-supabase",
"services-tikv",
Expand Down
3 changes: 3 additions & 0 deletions bindings/java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
<!-- customized properties -->
<cargo-build.profile>dev</cargo-build.profile>
<cargo-build.features>default</cargo-build.features>
<cargo-build.enableZigbuild>false</cargo-build.enableZigbuild>
<cargo-build.target/> <!-- override cargo build target; e.g., use musl instead -->
<jni.classifier>${os.detected.classifier}</jni.classifier>

Expand Down Expand Up @@ -196,6 +197,8 @@
<argument>${cargo-build.profile}</argument>
<argument>--features</argument>
<argument>${cargo-build.features}</argument>
<argument>--enable-zigbuild</argument>
<argument>${cargo-build.enableZigbuild}</argument>
</arguments>
</configuration>
</execution>
Expand Down
25 changes: 19 additions & 6 deletions bindings/java/tools/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,35 @@ def get_cargo_artifact_name(classifier: str) -> str:
parser.add_argument('--target', type=str, default='')
parser.add_argument('--profile', type=str, default='dev')
parser.add_argument('--features', type=str, default='default')
parser.add_argument('--enable-zigbuild', type=str, default='false')
args = parser.parse_args()

cmd = ['cargo', 'build', '--color=always', f'--profile={args.profile}']

if args.features:
cmd += ['--features', args.features]

if args.target:
target = args.target
else:
target = classifier_to_target(args.classifier)

# Setup target.
command = ['rustup', 'target', 'add', target]
print('$ ' + subprocess.list2cmdline(command))
subprocess.run(command, cwd=basedir, check=True)
cmd += ['--target', target]

# Enable zigbuild if flag enabled and we are building linux target
enable_zigbuild = args.enable_zigbuild == 'true' and 'linux' in target

cmd = ['cargo',
'zigbuild' if enable_zigbuild else 'build',
'--color=always',
f'--profile={args.profile}']

if args.features:
cmd += ['--features', args.features]

if enable_zigbuild:
# Pin glibc to 2.17 if zigbuild has been enabled.
cmd += ['--target', f'{target}.2.17']
else:
cmd += ['--target', target]

output = basedir / 'target' / 'bindings'
Path(output).mkdir(exist_ok=True, parents=True)
Expand Down

0 comments on commit 682d38c

Please sign in to comment.