Skip to content

Cross compile tools for ARM (aarch64) #394

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
name: perfspect
- name: run test
run: |
tar -xf perfspect*
Copy link
Contributor

@harp-intel harp-intel Jul 3, 2025

Choose a reason for hiding this comment

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

So close! This issue is also preventing my internal tests from running. Instead of, or in addition to, this change...

It would work best if the ARM build was in a separate artifact. So, the upload perfspect step (line 22) needs to be modified to only include perfspect.tgz. And, add an additional step to upload the ARM build.

tar -xf perfspect.tgz
cp .github/mock_mlc perfspect/tools/x86_64/
cd perfspect
mkdir output
Expand Down
7 changes: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
/perfspect
/perfspect-aarch64
/perfspect.log
/perfspect_202*
/debug_out
/tools/bin
/tools/bin-aarch64
/dist
/internal/script/resources/x86_64
/test
/__debug_bin*.log
/internal/script/resources/aarch64
//test
/__debug_bin*.log
31 changes: 26 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,24 @@ VERSION := $(VERSION_NUMBER)_$(COMMIT_DATE)_$(COMMIT_ID)

default: perfspect

GO=CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go
GOFLAGS=-trimpath -mod=readonly -gcflags="all=-spectre=all -N -l" -asmflags="all=-spectre=all" -ldflags="-X perfspect/cmd.gVersion=$(VERSION) -s -w"
GOFLAGS_COMMON=-trimpath -mod=readonly -ldflags="-X perfspect/cmd.gVersion=$(VERSION) -s -w"
GO=CGO_ENABLED=0 GOOS=linux go

# Build the perfspect binary
.PHONY: perfspect
perfspect:
$(GO) build $(GOFLAGS) -o $@
GOARCH=amd64 $(GO) build $(GOFLAGS_COMMON) -gcflags="all=-spectre=all -N -l" -asmflags="all=-spectre=all" -o $@

# Build the perfspect binary for AARCH64
.PHONY: perfspect-aarch64
perfspect-aarch64:
GOARCH=arm64 $(GO) build $(GOFLAGS_COMMON) -o $@

# Copy prebuilt tools to script resources
.PHONY: resources
resources:
mkdir -p internal/script/resources/x86_64
mkdir -p internal/script/resources/aarch64
ifneq ("$(wildcard /prebuilt/tools)","") # /prebuilt/tools is a directory in the container
cp -r /prebuilt/tools/* internal/script/resources/x86_64
else # copy dev system tools to script resources
Expand All @@ -33,20 +39,34 @@ else # no prebuilt tools found
@echo "No prebuilt tools found in /prebuilt/tools or tools/bin"
endif
endif
ifneq ("$(wildcard /prebuild/tools/bin-aarch64)","")
cp -r tools/bin-aarch64/* internal/script/resources/aarch64
else # copy dev system tools to script resources
ifneq ("$(wildcard tools/bin-aarch64)","")
cp -r tools/bin-aarch64/* internal/script/resources/aarch64
else # no prebuilt tools found
@echo "No prebuilt tools (aarch64) found in /prebuilt/tools or tools/bin-aarch64"
endif
endif


# Build the distribution package
.PHONY: dist
dist: resources check perfspect
dist: resources check perfspect perfspect-aarch64
rm -rf dist/perfspect
mkdir -p dist/perfspect/tools/x86_64
mkdir -p dist/perfspect/tools/aarch64
cp LICENSE dist/perfspect/
cp THIRD_PARTY_PROGRAMS dist/perfspect/
cp NOTICE dist/perfspect/
cp targets.yaml dist/perfspect/
cp perfspect dist/perfspect/
cd dist && tar -czf perfspect.tgz perfspect
cd dist && md5sum perfspect.tgz > perfspect.tgz.md5.txt
# for aarch64 dist, overwrite perfspect binary
cp perfspect-aarch64 dist/perfspect/perfspect
cd dist && tar -czf perfspect-aarch64.tgz perfspect
cd dist && md5sum perfspect-aarch64.tgz > perfspect-aarch64.tgz.md5.txt
rm -rf dist/perfspect
echo '{"version": "$(VERSION_NUMBER)", "date": "$(COMMIT_DATE)", "time": "$(COMMIT_TIME)", "commit": "$(COMMIT_ID)" }' | jq '.' > dist/manifest.json
ifneq ("$(wildcard /prebuilt)","") # /prebuilt is a directory in the container
Expand Down Expand Up @@ -94,7 +114,7 @@ check_static:
.PHONY: check_license
check_license:
@echo "Confirming source files have license headers..."
@for f in `find . -type f ! -path './perfspect_202*' ! -path './tools/bin/*' ! -path './internal/script/resources/*' ! -path './scripts/.venv/*' ! -path './test/output/*' ! -path './debug_out/*' ! -path './tools/perf-archive/*' ! -path './tools/avx-turbo/*' \( -name "*.go" -o -name "*.s" -o -name "*.html" -o -name "Makefile" -o -name "*.sh" -o -name "*.Dockerfile" -o -name "*.py" \)`; do \
@for f in `find . -type f ! -path './perfspect_202*' ! -path './tools/bin/*' ! -path './tools/bin-aarch64/*' ! -path './internal/script/resources/*' ! -path './scripts/.venv/*' ! -path './test/output/*' ! -path './debug_out/*' ! -path './tools/perf-archive/*' ! -path './tools/avx-turbo/*' \( -name "*.go" -o -name "*.s" -o -name "*.html" -o -name "Makefile" -o -name "*.sh" -o -name "*.Dockerfile" -o -name "*.py" \)`; do \
if ! grep -E 'SPDX-License-Identifier: BSD-3-Clause' "$$f" >/dev/null; then echo "Error: license not found: $$f"; fail=1; fi; \
done; if [ -n "$$fail" ]; then exit 1; fi

Expand Down Expand Up @@ -150,3 +170,4 @@ clean: sweep
rm -f perfspect
sudo rm -rf dist
rm -rf internal/script/resources/x86_64/*
rm -rf internal/script/resources/aarch64/*
1 change: 1 addition & 0 deletions builder/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ id=$(docker create perfspect-tools:$TAG foo)
# Copy the tools from the temporary container to your local disk
# Note: not used in build process, but useful to have around
docker cp "$id":/bin ./tools
docker cp "$id":/bin-aarch64 ./tools/bin-aarch64

# Remove the temporary container
docker rm "$id"
Expand Down
Loading