Plan: Distribute pre-built cross-compiled runtimes in ponyc releases #4980
Closed
SeanTAllen
started this conversation in
ponyc
Replies: 1 comment
|
Reworked as #5591 and superseded by it. ponyc is fully on embedded LLD now, so the linker comes from the target triple and there is no |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Cross-compilation to Linux targets via embedded LLD (#4964) works. The problem is getting the runtime libraries to users who don't want to build LLVM from source. Right now, if you install ponyc via ponyup, you can't cross-compile without cloning the ponyc repo and running
make libs+make cross-libponyrt. That's a non-starter for most people.The fix: bundle pre-built cross-compiled runtimes (libponyrt + CRT objects) directly in the ponyc release tarballs. Install ponyc, get cross-compilation support for free. No separate downloads, no extra steps.
Change Type
Added (new feature). PR gets a
changelog - addedlabel and a release notes file.What Gets Bundled
Each host platform's tarball includes cross-compiled runtimes for the other supported Linux targets:
x86-64 host tarball includes:
aarch64-unknown-linux-gnuriscv64-unknown-linux-gnuarm-unknown-linux-gnueabiarm-unknown-linux-gnueabihfarm64 host tarball includes:
x86_64-unknown-linux-gnuriscv64-unknown-linux-gnuarm-unknown-linux-gnueabiarm-unknown-linux-gnueabihfThe total size increase is about 2MB per tarball. Negligible.
Install Tree Layout
Cross-runtimes go in
lib/<triple>/alongside the native runtime:x86-64 host:
arm64 host:
Using the full triple for directory names keeps things unambiguous and matches the
--triplecompiler flag. The convention scales to future targets without any structural changes.Which Tarballs
x86-64 and arm64 Linux glibc (Ubuntu) tarballs. These are the primary cross-compilation hosts. Alpine, macOS, and Windows tarballs are unchanged.
User Workflow
The user still sets
PONYPATHmanually. A future compiler enhancement could auto-discover runtimes inlib/<triple>/when--tripleis specified, but that's a separate issue.Implementation
Makefile changes
Two things need to happen. First, a
cross_namevariable that controls the cross-build output directory. Right now both arm and armhf usearch=armv7-a, which means they'd write to the same directory if built in the same job.cross_namedefaults to$(arch)so existing tier-2 CI is unaffected, but the nightly/release builds can set it to the triple to keep outputs separate.Second, a
cross-installtarget that copies cross-compiled artifacts into the install prefix. It mirrors the nativeinstalltarget's logic for libponyrt.a, libponyrt-pic.a, and the CRT objects.Docker images
Two sets of Docker image changes are needed.
Ubuntu builder images get cross-compiler packages added. One-time change in the
ponyc-ci-dockerfilesrepo.x86-64 builders (
ponyc-ci-x86-64-unknown-linux-ubuntu24.04-builderand 22.04 variant):gcc-aarch64-linux-gnugcc-riscv64-linux-gnugcc-arm-linux-gnueabigcc-arm-linux-gnueabihfarm64 builder (
ponyc-ci-arm64-unknown-linux-ubuntu24.04-builder):gcc-x86-64-linux-gnugcc-riscv64-linux-gnugcc-arm-linux-gnueabigcc-arm-linux-gnueabihfExisting CI cross-arm and cross-armhf images switch from Linaro GCC 7.5.0 (2019) tarballs to Ubuntu apt packages (
gcc-arm-linux-gnueabi,gcc-arm-linux-gnueabihf). The base image is Ubuntu 24.04 with GCC 13+, so apt provides a much newer compiler than the frozen Linaro release. This eliminates the Linaro dependency entirely — all ARM cross-compilation uses apt-provided compilers, so CI validation and nightly/release builds use identical toolchains.Nightly and release scripts
The existing nightly/release scripts (
x86-64-nightly.bash,arm64-nightly.bash,x86-64-release.bash,arm64-release.bash) are shared across Linux Ubuntu, Linux Alpine, and macOS builds. Cross-compiled runtimes only apply to Ubuntu (glibc) builds. Rather than adding guards or no-op calls to the shared scripts, four new explicitly-named scripts handle the Ubuntu builds:x86-64-nightly-with-cross-runtimes.basharm64-nightly-with-cross-runtimes.bashx86-64-release-with-cross-runtimes.basharm64-release-with-cross-runtimes.bashEach mirrors the corresponding existing script but adds cross-runtime build and install between
make installandtar. The existing scripts stay unchanged for macOS and Alpine. The workflow entries for Ubuntu switch to the new scripts.Cross-compilation stanzas in each script:
x86-64 host scripts build:
aarch64:
arch=armv8-a(consistent with native arm64 builds)cross_cc=aarch64-linux-gnu-gcc,cross_cxx=aarch64-linux-gnu-g++cross_cflags="-march=armv8-a -mtune=generic"(generic tuning — aarch64 targets span Graviton, Ampere, Cortex-A72/A76, and others)cross_llc_flags=-march=aarch64cross_name=aarch64-unknown-linux-gnuriscv64:
arch=rv64gccross_cc=riscv64-linux-gnu-gcc,cross_cxx=riscv64-linux-gnu-g++cross_cflags="-march=rv64gc -mtune=rocket"cross_llc_flags=-march=riscv64cross_name=riscv64-unknown-linux-gnuarm (soft-float):
arch=armv7-across_cc=arm-linux-gnueabi-gcc,cross_cxx=arm-linux-gnueabi-g++cross_cflags="-march=armv7-a -mtune=cortex-a9"cross_llc_flags="-O3;-march=arm"cross_name=arm-unknown-linux-gnueabiarm (hard-float):
arch=armv7-across_cc=arm-linux-gnueabihf-gcc,cross_cxx=arm-linux-gnueabihf-g++cross_cflags="-march=armv7-a -mtune=cortex-a9"cross_llc_flags="-O3;-march=arm"cross_name=arm-unknown-linux-gnueabihfarm64 host scripts build:
x86-64:
arch=x86-64(consistent with native x86-64 builds; CMake auto-adds-mcx16whenCMAKE_SYSTEM_PROCESSORisx86-64)cross_cc=x86_64-linux-gnu-gcc,cross_cxx=x86_64-linux-gnu-g++cross_cflags="-march=x86-64 -mtune=generic"cross_llc_flags=-march=x86-64cross_name=x86_64-unknown-linux-gnuriscv64:
arch=rv64gccross_cc=riscv64-linux-gnu-gcc,cross_cxx=riscv64-linux-gnu-g++cross_cflags="-march=rv64gc -mtune=rocket"cross_llc_flags=-march=riscv64cross_name=riscv64-unknown-linux-gnuarm (soft-float):
arch=armv7-across_cc=arm-linux-gnueabi-gcc,cross_cxx=arm-linux-gnueabi-g++cross_cflags="-march=armv7-a -mtune=cortex-a9"cross_llc_flags="-O3;-march=arm"cross_name=arm-unknown-linux-gnueabiarm (hard-float):
arch=armv7-across_cc=arm-linux-gnueabihf-gcc,cross_cxx=arm-linux-gnueabihf-g++cross_cflags="-march=armv7-a -mtune=cortex-a9"cross_llc_flags="-O3;-march=arm"cross_name=arm-unknown-linux-gnueabihfTier-2 CI for cross-compilation
The three existing cross-compilation CI jobs (riscv64, arm, armhf) all cross-compile from x86-64. Two additional categories of CI coverage are needed:
aarch64 cross-compilation from x86-64: New
cross-aarch64Docker image and workflow job, following the existing pattern.x86-64 cross-compilation from arm64: New
cross-x86-64Docker image and workflow job on arm64 runners.The riscv64/arm/armhf cross targets from arm64 hosts don't need separate CI jobs — they use the same cross-compilers and produce the same artifacts as from x86-64 hosts, and the cross-compilation machinery is validated by the existing jobs.
General Framework for Future Targets
Adding a new cross target is mechanical once this infrastructure is in place:
*-with-cross-runtimes.bashscriptsPotential future targets:
wasm32-unknown-unknown(different model, would need its own approach).Open Questions
LLC target inference: The
except_try_catch.llcompilation should be verified to produce correct-architecture object files even without explicitLL_FLAGS. The tier-2 CI tests pass, so it works in practice, but worth confirming.LLVM
-marchfor x86-64: Verify thatllc -march=x86-64is the correct LLVM target name for 64-bit x86 when cross-compilingexcept_try_catch.llfrom arm64.Tracks #4968.
All reactions