Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
52e790a
Add windows arm64 CC and CXX definition
dwhyrock Sep 4, 2025
24a92fc
add windows arm to arm compilers.yaml
dwhyrock Sep 4, 2025
a707b91
Add mingw to arm dockerfile
dwhyrock Sep 4, 2025
c2a2890
add mingw to base-arm
dwhyrock Sep 5, 2025
1231747
Add new windows-arm64 container
dwhyrock Sep 5, 2025
2560ea5
fix env var
dwhyrock Sep 5, 2025
fe07384
moving from up
dwhyrock Sep 5, 2025
4e9abf2
setup after apt install
dwhyrock Sep 5, 2025
2eecd69
try different mingw version
dwhyrock Sep 5, 2025
fc3fc6e
revert apt commands
dwhyrock Sep 5, 2025
d4602ce
no additional from yet
dwhyrock Sep 5, 2025
40dfff6
switch froms, try and compile
dwhyrock Sep 5, 2025
ea7f660
Use from down low
dwhyrock Sep 5, 2025
3ad74ae
messing with froms
dwhyrock Sep 5, 2025
aa17eec
skip copying
dwhyrock Sep 5, 2025
35d9413
Add find
dwhyrock Sep 5, 2025
e6adc45
be more explicit
dwhyrock Sep 5, 2025
f91c1c2
try which and see if the files are there
dwhyrock Sep 5, 2025
8d73b8e
grep for proper windows binary strings
dwhyrock Sep 5, 2025
7d580b8
cleaning up unneeded changes
dwhyrock Sep 8, 2025
8b32c09
removing unneeded changes
dwhyrock Sep 8, 2025
41bfb62
Adding release line and comments
dwhyrock Sep 8, 2025
aa0b410
Cleaning up docker template
dwhyrock Sep 8, 2025
75984c2
Removing set -x
dwhyrock Sep 8, 2025
60e096d
less noisy
dwhyrock Sep 8, 2025
bd4ae50
Add which for compiler path
dwhyrock Sep 10, 2025
37baedb
Fix name of compilter
dwhyrock Sep 10, 2025
56fbccd
Set env CGO_ENABLED to 1
dwhyrock Sep 11, 2025
6edf054
run some debug commands
dwhyrock Sep 11, 2025
eda17cf
remove normal mingw-w64 and set CC/CXX envs
dwhyrock Sep 11, 2025
d40c878
Add CGO_FLAGS
dwhyrock Sep 11, 2025
8649979
Try older llvm-mingw version
dwhyrock Sep 11, 2025
0c0f528
Try latest toolchain
dwhyrock Sep 11, 2025
bb21e29
move copy rootfs
dwhyrock Sep 11, 2025
66848b8
Add in no-addrsig
dwhyrock Sep 12, 2025
0a85818
empty commit to trigger CI
dwhyrock Sep 12, 2025
974ec12
Add new CGO_CFLAGS value w/ -fno-addrsig
dwhyrock Sep 12, 2025
c70ee42
Merge branch 'main' into add-windows-arm-crossbuild
dwhyrock Sep 19, 2025
e616089
empty commit to re-trigger CI
dwhyrock Sep 19, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ template: |
- `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-mips-debian12(-fips)?` - linux/mips64, linux/mips64el
- `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-ppc-debian12(-fips)?` - linux/ppc64, linux/ppc64le
- `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-s390x-debian12(-fips)?` - linux/s390x
- `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-windows-arm64-debian12(-fips)?` - linux/arm64, windows/arm64
### Changes
Expand Down
2 changes: 1 addition & 1 deletion go/Makefile.debian12
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
IMAGES := base main darwin armhf armel mips ppc s390x npcap
ARM_IMAGES := base-arm darwin-arm64
ARM_IMAGES := base-arm darwin-arm64 windows-arm64
DEBIAN_VERSION := 12
TAG_EXTENSION := -debian12

Expand Down
74 changes: 74 additions & 0 deletions go/windows-arm64/Dockerfile.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
ARG REPOSITORY
ARG VERSION
ARG TAG_EXTENSION=''

FROM ${REPOSITORY}/golang-crossbuild:${VERSION}-base-arm${TAG_EXTENSION}

#ARG LLVM_MINGW64_VER=20250826
ARG LLVM_MINGW64_VER=20250910
ARG LLVM_MINGW_UBUNTU_REL='22.04'
ARG LLVM_MINGW64_SRC="https://github.com/mstorsjo/llvm-mingw/releases/download"
ENV LLVM_MINGW64_VER="${LLVM_MINGW64_VER}"
ENV LLVM_MINGW64_SRC="$LLVM_MINGW64_SRC"

{{- if ne .DEBIAN_VERSION "12"}}
RUN echo "This Docker image will work only with Debian >12" && exit 1
{{- end }}

RUN \
apt-get -o Acquire::Check-Valid-Until=false update \
&& apt-get install -qq -y --no-install-recommends --allow-unauthenticated \
cmake \
patch \
libssl-dev \
libxml2-dev \
lzma-dev \
uuid-dev \
make \
bash \
wget \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /tmp
COPY --chmod=0755 scripts/setup-llvm-mingw64.sh /tmp/
RUN /tmp/setup-llvm-mingw64.sh

COPY --chmod=0755 scripts/install-llvm-mingw64.sh /tmp/install-llvm-mingw64.sh
RUN /tmp/install-llvm-mingw64.sh /tmp/llvm-mingw64 && rm -rf /tmp/*

COPY rootfs /

# Basic test
RUN which aarch64-w64-mingw32-gcc

RUN cd / \
&& aarch64-w64-mingw32-gcc helloWorld.c -o helloWorld.arm64 \
&& file helloWorld.arm64 \
&& file helloWorld.arm64 | grep -c 'PE32+ executable (console) Aarch64, for MS Windows'

RUN cd / \
&& aarch64-w64-mingw32uwp-gcc helloWorld.c -o helloWorld.arm64e \
&& file helloWorld.arm64e \
&& file helloWorld.arm64e | grep -c 'PE32+ executable (console) Aarch64, for MS Windows'

ENV CGO_ENABLED 1
#ENV CC aarch64-w64-mingw32-gcc
#ENV CXX aarch64-w64-mingw32-g++
ENV CGO_FLAGS="$CGO_FLAGS -I/usr/generic-w64-mingw32/include"
ENV CGO_CFLAGS="-fno-addrsig"
RUN go env

RUN aarch64-w64-mingw32-gcc --version

RUN go clean -cache -modcache -i -r

# Build-time metadata as defined at http://label-schema.org.
ARG BUILD_DATE
ARG IMAGE
ARG VCS_REF
ARG VCS_URL
LABEL org.label-schema.build-date=$BUILD_DATE \
org.label-schema.name=$IMAGE \
org.label-schema.vcs-ref=$VCS_REF \
org.label-schema.vcs-url=$VCS_URL \
org.label-schema.schema-version="1.0"
10 changes: 10 additions & 0 deletions go/windows-arm64/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
include ../Makefile.common

ifeq ($(DOCKER_MULTIARCH),1)
DOCKER_CMD := $(SELF_DIR)/../.buildkite/scripts/buildx.sh

push:
@echo "Already done by buildx (.buildkite/scripts/buildx.sh)."
atomic-push:
@echo "Already done by buildx (.buildkite/scripts/buildx.sh)."
endif
7 changes: 7 additions & 0 deletions go/windows-arm64/rootfs/compilers.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---

windows:
arm64:
CC: aarch64-w64-mingw32-gcc
CXX: aarch64-w64-mingw32-g++

5 changes: 5 additions & 0 deletions go/windows-arm64/rootfs/helloWorld.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include <stdio.h>
int main() {
printf("Hello, World!");
return 0;
}
53 changes: 53 additions & 0 deletions go/windows-arm64/scripts/install-llvm-mingw64.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/env bash
#
# Copied from: https://github.com/x1unix/docker-go-mingw/tree/20dfaff6efe8fe3a4ff588a58ccb31646cd2fd60
#
set -e
set -o pipefail

trap 'echo "$0: Error on line $LINENO" >&2' ERR

src="$1"
if [ -z "$src" ]; then
echo "Error: missing source dir"
exit 1
fi

base_dir='/usr'

echo ":: Installing llvm-mingw64..."
echo "Source dir: $src"

cd "$src" || exit 1
find . -mindepth 1 -maxdepth 1 -type d ! -name . | while read -r subdir; do
dst_dir="$(basename "$subdir")"

case "$dst_dir" in
bin)
perm=755
;;
*)
perm=644
;;
esac

find "$subdir" -type f | while read -r file; do
dst="$base_dir/${file/.\//}"
mkdir -p "$(dirname "$dst")"
install -m $perm "$file" "$dst"
done
done

echo ":: Restoring symlinks..."
while IFS= read -r line; do
src=$(echo "$line" | awk '{print $1}')
src="$base_dir/$src"

dest=$(echo "$line" | awk '{print $2}')
dest="$(realpath "$base_dir/$dest")"
ln -s "$dest" "$src"
done <symlinks.txt

echo ":: Cleanup"
cd ..
rm -rf "$src"
74 changes: 74 additions & 0 deletions go/windows-arm64/scripts/setup-llvm-mingw64.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/usr/bin/env bash
#
# Copied from: https://github.com/x1unix/docker-go-mingw/tree/20dfaff6efe8fe3a4ff588a58ccb31646cd2fd60
#
set -e
set -o pipefail

trap 'echo "$0: Error on line $LINENO" >&2' ERR

if [ -z "$LLVM_MINGW64_SRC" ]; then
echo "Error: LLVM_MINGW64_SRC is undefined"
env
exit 1
fi

if [ -z "$LLVM_MINGW_UBUNTU_REL" ]; then
echo "Error: LLVM_MINGW_UBUNTU_REL is undefined"
env
exit 1
fi

if [ -z "$LLVM_MINGW64_VER" ]; then
echo "Error: LLVM_MINGW64_VER is undefined"
env
exit 1
fi

apt update && apt install xz-utils --yes

case "$(uname -m)" in
aarch64 | arm64)
m_arch="aarch64"
;;
x86_64 | amd64)
m_arch="x86_64"
;;
*)
echo "Error: unsupported architecture $(uname -m)"
exit 1
;;
esac

pkg_dir="llvm-mingw-$LLVM_MINGW64_VER-ucrt-ubuntu-$LLVM_MINGW_UBUNTU_REL-$m_arch"
pkg_file="$pkg_dir.tar.xz"
src_url="$LLVM_MINGW64_SRC/$LLVM_MINGW64_VER/$pkg_file"
echo ":: Downloading $src_url ..."
wget "$src_url"
# wget -q --spider "$src_url"

if [ ! -f "$pkg_file" ]; then
echo "Error: can't find downloaded file $pkg_file"
ls -la
exit 1
fi

echo ":: Extracting file..."
tar -xf "$pkg_file"
rm "$pkg_file"

echo ":: Preparing file list..."
mv "$pkg_dir" llvm-mingw64
cd llvm-mingw64

# Keep llvm-mingw64 only for arm target to avoid conflict with gcc-mingw64
rm bin/x86_64* bin/i686*
rm -rf i686-w64-mingw32 x86_64-w64-mingw32

# Backup symlinks
find . -type l | while read -r symlink; do
src="${symlink/.\//}"
dst="$(dirname "$src")/$(readlink "$symlink")"
echo "$src $dst" >>symlinks.txt
rm "$symlink"
done