Skip to content

feat: Add s390x architecture support via cross-compilation#5300

Draft
Lan Yao (lyao-77) wants to merge 2 commits intomasterfrom
feat/s390x-cross-compilation
Draft

feat: Add s390x architecture support via cross-compilation#5300
Lan Yao (lyao-77) wants to merge 2 commits intomasterfrom
feat/s390x-cross-compilation

Conversation

@lyao-77
Copy link
Member

Summary

This PR adds support for building librdkafka for the s390x (IBM Z) architecture using cross-compilation on AMD64 hosts, avoiding the performance and stability issues associated with QEMU emulation.

Motivation

Enterprise customers operating IBM LinuxOne/Z infrastructure require librdkafka artifacts for s390x architecture. Building under QEMU emulation is too slow (5-10x) and unstable. Cross-compilation provides fast, reliable builds on existing AMD64 CI infrastructure.

Changes

New Files

packaging/tools/Dockerfile.s390x

  • Multi-stage Dockerfile using BuildKit cross-compilation
  • Uses tonistiigi/xx:1.5.0 toolkit for cross-compilation helpers
  • Builds s390x binaries natively on AMD64 platform
  • Includes all dependencies: SSL, SASL, ZSTD, LZ4

packaging/tools/build-s390x-cross.sh

  • Build script wrapping docker buildx
  • Produces tar.gz artifacts compatible with existing build system
  • Includes SHA256 verification

Modified Files

.semaphore/semaphore.yml

  • Added "Linux s390x: release artifact cross-compilation builds" block
  • Runs on AMD64 agents (no s390x machines required)
  • Produces artifacts matching AMD64/ARM64 naming convention:
    • p-librdkafka__plat-linux__dist-ubuntu__arch-s390x__lnk-std__extra-gssapi
    • p-librdkafka__plat-linux__dist-ubuntu__arch-s390x__lnk-all
  • Added s390x dependency to "Packaging" block

Technical Approach

Cross-Compilation Strategy

  • Build host: AMD64 (native)
  • Target architecture: s390x
  • Cross-compiler: s390x-linux-gnu-gcc/g++
  • Configuration: ./configure --host=s390x-linux-gnu

Why Cross-Compilation vs QEMU?

Approach Build Time Stability CI Agent
QEMU Emulation 5-10x slower Compiler crashes possible AMD64 + QEMU
Cross-Compilation (this PR) Native speed Stable AMD64 only

Testing

Local Testing

# Build s390x artifacts
packaging/tools/build-s390x-cross.sh artifacts/librdkafka-s390x.tar.gz

# Verify architecture
tar xzf artifacts/librdkafka-s390x.tar.gz
file usr/local/lib/librdkafka.so.1
# Expected: ELF 64-bit MSB shared object, IBM S/390

CI Testing

  • Semaphore pipeline will build s390x artifacts on tag releases
  • Artifacts will be uploaded to workflow artifacts with proper naming

Future Improvements

  • Add --disable-gssapi variant (currently only builds with gssapi)
  • Consider alpine musl variant for s390x
  • Add native s390x agent support if Semaphore provides it

Related Work

Co-Authored-By: Claude Sonnet 4.5 [email protected]

This commit adds support for building librdkafka for the s390x (IBM Z)
architecture using cross-compilation on AMD64 hosts, avoiding the
performance and stability issues associated with QEMU emulation.

## Changes

### New Files

**packaging/tools/Dockerfile.s390x**
- Multi-stage Dockerfile using BuildKit cross-compilation
- Uses tonistiigi/xx:1.5.0 toolkit for cross-compilation helpers
- Builds s390x binaries natively on AMD64 platform
- Avoids QEMU emulation during compilation (only used for verification)
- Includes all dependencies: SSL, SASL, ZSTD, LZ4

**packaging/tools/build-s390x-cross.sh**
- Build script for s390x cross-compilation
- Wraps docker buildx with appropriate flags
- Produces tar.gz artifacts compatible with existing build system
- Includes SHA256 verification

### Modified Files

**.semaphore/semaphore.yml**
- Added "Linux s390x: release artifact cross-compilation builds" block
- Runs on AMD64 agents with QEMU and buildx setup
- Produces s390x artifacts with naming convention matching AMD64/ARM64
- Added s390x dependency to "Packaging" block

## Technical Approach

### Cross-Compilation Strategy
- Build host: AMD64 (native)
- Target architecture: s390x
- Cross-compiler: s390x-linux-gnu-gcc/g++
- Configuration: `./configure --host=s390x-linux-gnu`

### Why Cross-Compilation vs QEMU?

**QEMU Emulation Issues:**
- 5-10x slower build times
- Compiler instability (potential segfaults)
- Complex dependency issues

**Cross-Compilation Benefits:**
- Fast builds (native AMD64 performance)
- Stable and reliable
- Well-supported by librdkafka's autotools build system

## Artifact Naming Convention

Following existing pattern:
```
p-librdkafka__plat-linux__dist-ubuntu__arch-s390x__lnk-std__extra-gssapi
p-librdkafka__plat-linux__dist-ubuntu__arch-s390x__lnk-all
```

## Testing

Build can be tested locally with:
```bash
packaging/tools/build-s390x-cross.sh artifacts/librdkafka-s390x.tar.gz
```

Verify architecture:
```bash
tar xzf artifacts/librdkafka-s390x.tar.gz
file usr/local/lib/librdkafka.so.1
# Expected: ELF 64-bit MSB shared object, IBM S/390
```

## Future Improvements

- Add --disable-gssapi variant (currently builds with gssapi)
- Consider alpine musl variant for s390x
- Add native s390x agent support if Semaphore provides it

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
@lyao-77 Lan Yao (lyao-77) requested a review from a team as a code owner February 4, 2026 23:58
Copilot AI review requested due to automatic review settings February 4, 2026 23:58
@confluent-cla-assistant
Copy link

🎉 All Contributor License Agreements have been signed. Ready to merge.
Please push an empty commit if you would like to re-run the checks to verify CLA status for all contributors.

@lyao-77 Lan Yao (lyao-77) marked this pull request as draft February 4, 2026 23:58
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds support for building librdkafka for the s390x (IBM Z) architecture using cross-compilation on AMD64 hosts, avoiding performance issues with QEMU emulation.

Changes:

  • Introduces Docker-based cross-compilation tooling for s390x builds using BuildKit and the tonistiigi/xx toolkit
  • Adds Semaphore CI pipeline configuration to produce s390x release artifacts on AMD64 agents
  • Creates build artifacts compatible with existing naming conventions for other architectures

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
packaging/tools/Dockerfile.s390x Multi-stage Dockerfile implementing cross-compilation for s390x using BuildKit and cross-compilation toolchain
packaging/tools/build-s390x-cross.sh Build script wrapper for Docker buildx that produces tar.gz artifacts with SHA256 verification
.semaphore/semaphore.yml CI pipeline configuration adding s390x cross-compilation build jobs and packaging dependency

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- name: 'Build: cross-compiled glibc'
env_vars:
- name: ARTIFACT_KEY
value: p-librdkafka__plat-linux__dist-ubuntu__arch-s390x__lnk-all
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

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

The artifact key 'p-librdkafka__plat-linux__dist-ubuntu__arch-s390x__lnk-all' suggests this build includes all linkage types, but the comment indicates it's building with gssapi, which is inconsistent with the naming. The build should either actually exclude gssapi (to match the 'lnk-all' naming convention) or the artifact key should be renamed to clarify that gssapi is included.

Suggested change
value: p-librdkafka__plat-linux__dist-ubuntu__arch-s390x__lnk-all
value: p-librdkafka__plat-linux__dist-ubuntu__arch-s390x__lnk-all__extra-gssapi

Copilot uses AI. Check for mistakes.
## Changes

### Dockerfile.s390x
- Added libcurl4-openssl-dev to cross-compilation dependencies
- Set CC, CXX, AR, RANLIB explicitly in configure command
- Switched from --install-deps to using system packages
- Fixed PKG_CONFIG_PATH for cross-compilation

### semaphore.yml
- **TEMPORARY:** Enable s390x build on feat/s390x-cross-compilation branch for testing
- Simplified to single test job (will restore both variants after successful test)
- Added TODO comments to remind removal of test conditions

## Testing

This commit allows the s390x build to run in Semaphore CI for validation.
After successful build, will:
1. Remove branch condition (keep only tag condition)
2. Restore both build variants (with/without gssapi)
3. Ready for production use

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
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.

2 participants