Verified Commit 78498b38 authored by Bohdan Parkhomchuk's avatar Bohdan Parkhomchuk 💬 Committed by GitLab
Browse files

ci(windows): cross-compile orbit.exe for Windows x86_64

parent 45a78ab5
Loading
Loading
Loading
Loading
+33 −0
Original line number Diff line number Diff line
@@ -44,6 +44,38 @@ local-cli-build-linux-arm64:
  variables:
    ARCH: aarch64

local-cli-build-windows-amd64:
  extends:
    - .job-template
    - .sccache-template
    - .local-cli-release-rules
  stage: build
  needs: []
  tags:
    - saas-linux-xlarge-amd64
  timeout: 90m
  variables:
    PLATFORM: windows
    ARCH: x86_64
    LLVM_MINGW_VERSION: "20260505"
    CC_x86_64_pc_windows_gnullvm: x86_64-w64-mingw32-clang
    CXX_x86_64_pc_windows_gnullvm: x86_64-w64-mingw32-clang++
    AR_x86_64_pc_windows_gnullvm: x86_64-w64-mingw32-ar
    CARGO_TARGET_X86_64_PC_WINDOWS_GNULLVM_LINKER: x86_64-w64-mingw32-clang++
    RUSTFLAGS: "-C link-arg=-static-libgcc -C link-arg=-static-libstdc++"
  artifacts:
    paths:
      - orbit-local-windows-x86_64.zip
    expire_in: 7 days
  before_script:
    - !reference [.sccache-template, before_script]
    - apt-get update -qq && apt-get install -y -qq --no-install-recommends file xz-utils zip
    - ./scripts/ci/install-llvm-mingw.sh
    - export PATH="/opt/llvm-mingw/bin:$PATH"
  script:
    - ./scripts/build-local-cli.sh
    - sccache --show-stats || true

.local-cli-build-darwin:
  extends:
    - .local-cli-release-rules
@@ -111,6 +143,7 @@ local-cli-publish:
  needs:
    - local-cli-build-linux-amd64
    - local-cli-build-linux-arm64
    - local-cli-build-windows-amd64
    - local-cli-code-sign
  before_script:
    - apk add --no-cache bash curl coreutils
+25 −8
Original line number Diff line number Diff line
@@ -2,12 +2,16 @@
set -euo pipefail

# Build the `orbit` local CLI binary and package it as
# orbit-local-<platform>-<arch>.tar.gz in the repository root. The binary
# inside the archive is `orbit`; the `orbit-local-` prefix on the archive
# matches the orbit-local crate name and disambiguates from the gkg-server
# image release. PLATFORM/ARCH default to the host (linux/macOS amd64 or
# arm64). Supported triples: {x86_64,aarch64}-unknown-linux-gnu and
# {x86_64,aarch64}-apple-darwin.
# orbit-local-<platform>-<arch>.(tar.gz|zip) in the repository root.
# The binary inside the archive is `orbit` (or `orbit.exe` on Windows); the
# `orbit-local-` prefix on the archive matches the orbit-local crate name and
# disambiguates from the gkg-server image release. PLATFORM/ARCH default to
# the host (linux/macOS amd64 or arm64).
#
# Supported triples:
#   {x86_64,aarch64}-unknown-linux-gnu
#   {x86_64,aarch64}-apple-darwin
#   x86_64-pc-windows-gnullvm        (cross-compiled with llvm-mingw on Linux)

PLATFORM="${PLATFORM:-$(uname -s)}"
PLATFORM=$(echo "$PLATFORM" | tr '[:upper:]' '[:lower:]')
@@ -30,6 +34,11 @@ case "$PLATFORM" in
            x86_64)  TARGET="x86_64-unknown-linux-gnu" ;;
        esac
        ;;
    windows)
        case "$ARCH" in
            x86_64) TARGET="x86_64-pc-windows-gnullvm" ;;
        esac
        ;;
esac

if [ -z "${TARGET:-}" ]; then
@@ -44,6 +53,14 @@ echo "Building orbit for $PLATFORM/$ARCH ($TARGET)"
# Bundle libduckdb (compile from C++) so the released binary is self-contained.
cargo build --release --locked --bin orbit --target "$TARGET" --features duckdb-client/bundled

BIN_DIR="target/${TARGET}/release"

if [ "$PLATFORM" = "windows" ]; then
    ARCHIVE="orbit-local-${PLATFORM}-${ARCH}.zip"
    (cd "$BIN_DIR" && zip "$OLDPWD/$ARCHIVE" orbit.exe)
else
    ARCHIVE="orbit-local-${PLATFORM}-${ARCH}.tar.gz"
tar -czvf "$ARCHIVE" -C "target/${TARGET}/release" orbit
    tar -czvf "$ARCHIVE" -C "$BIN_DIR" orbit
fi

echo "created $ARCHIVE"
+22 −0
Original line number Diff line number Diff line
#!/usr/bin/env bash
# Install llvm-mingw under /opt/llvm-mingw. We delete libc++/libunwind
# import libs so the linker can't pick them up alongside the static
# archives `-static-libstdc++` requested — without this the build links
# both and orbit.exe ends up needing libc++.dll/libunwind.dll at runtime.
set -euo pipefail

VERSION="${LLVM_MINGW_VERSION:-20260505}"
ROOT="/opt/llvm-mingw"
TARBALL="llvm-mingw-${VERSION}-ucrt-ubuntu-22.04-x86_64.tar.xz"

curl -fsSL "https://github.com/mstorsjo/llvm-mingw/releases/download/${VERSION}/${TARBALL}" \
    | tar -xJ -C /opt
mv "/opt/llvm-mingw-${VERSION}-ucrt-ubuntu-22.04-x86_64" "$ROOT"

rm -f \
    "$ROOT/x86_64-w64-mingw32/lib/libc++.dll.a" \
    "$ROOT/x86_64-w64-mingw32/lib/libunwind.dll.a" \
    "$ROOT/x86_64-w64-mingw32/bin/libc++.dll" \
    "$ROOT/x86_64-w64-mingw32/bin/libunwind.dll"

"$ROOT/bin/x86_64-w64-mingw32-clang" --version | head -1
+1 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ ARTIFACTS=(
  "orbit-local-linux-aarch64.tar.gz"
  "orbit-local-darwin-x86_64.tar.gz"
  "orbit-local-darwin-aarch64.tar.gz"
  "orbit-local-windows-x86_64.zip"
)

for artifact in "${ARTIFACTS[@]}"; do