Skip to content
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

cross-compile s390x on x86_64 hosts #262

Merged
merged 4 commits into from
Feb 14, 2024
Merged
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
6 changes: 3 additions & 3 deletions .github/actions/veristat_baseline_compare/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ inputs:
runs:
using: "composite"
steps:
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: ${{ inputs.baseline_name }}
if-no-files-found: error
Expand All @@ -20,7 +20,7 @@ runs:
# - get baseline log from cache
# - compare it to current run
- if: ${{ github.event_name == 'pull_request' }}
uses: actions/cache/restore@v3
uses: actions/cache/restore@v4
with:
key: ${{ inputs.baseline_name }}
restore-keys: |
Expand All @@ -43,7 +43,7 @@ runs:
"${{ github.workspace }}/${{ inputs.baseline_name }}"

- if: ${{ github.event_name == 'push' }}
uses: actions/cache/save@v3
uses: actions/cache/save@v4
with:
key: ${{ inputs.baseline_name }}-${{ github.run_id }}
path: '${{ github.workspace }}/${{ inputs.baseline_name }}'
11 changes: 11 additions & 0 deletions .github/scripts/matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,16 @@ def runs_on(self) -> List[str]:
return ["self-hosted", self.arch.value]
return [DEFAULT_RUNNER]

@property
def build_runs_on(self) -> List[str]:
if is_managed_repo():
# Build s390x on x86_64
return [
"self-hosted",
self.arch.value == "s390x" and Arch.X86_64.value or self.arch.value,
]
return [DEFAULT_RUNNER]

@property
def tests(self) -> Dict[str, Any]:
tests_list = [
Expand Down Expand Up @@ -103,6 +113,7 @@ def to_dict(self) -> Dict[str, Any]:
"build_release": self.build_release,
"runs_on": self.runs_on,
"tests": self.tests,
"build_runs_on": self.build_runs_on,
}


Expand Down
26 changes: 24 additions & 2 deletions .github/scripts/tar-artifact.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,28 @@ set -eux
arch="${1}"
toolchain="${2}"

# Convert a platform (as returned by uname -m) to the kernel
# arch (as expected by ARCH= env).
platform_to_kernel_arch() {
case $1 in
s390x)
echo "s390"
;;
aarch64)
echo "arm64"
;;
riscv64)
echo "riscv"
;;
x86_64)
echo "x86"
;;
*)
echo "$1"
;;
esac
}

# Remove intermediate object files that we have no use for. Ideally
# we'd just exclude them from tar below, but it does not provide
# options to express the precise constraints.
Expand All @@ -14,7 +36,7 @@ find selftests/ -name "*.o" -a ! -name "*.bpf.o" -print0 | \
# Strip debug information, which is excessively large (consuming
# bandwidth) while not actually being used (the kernel does not use
# DWARF to symbolize stacktraces).
strip --strip-debug "${KBUILD_OUTPUT}"/vmlinux
"${arch}"-linux-gnu-strip --strip-debug "${KBUILD_OUTPUT}"/vmlinux

additional_file_list=()
if [ "${GITHUB_REPOSITORY}" == "kernel-patches/vmtest" ]; then
Expand All @@ -29,7 +51,7 @@ if [ "${GITHUB_REPOSITORY}" == "kernel-patches/vmtest" ]; then
)
fi

image_name=$(make -s image_name)
image_name=$(make ARCH="$(platform_to_kernel_arch "${arch}")" -s image_name)

# zstd is installed by default in the runner images.
tar -cf - \
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/kernel-build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ on:
required: true
type: string
description: The runners to run the test on. This is a json string representing an array of labels.
build_runs_on:
required: true
type: string
description: The runners to run the builds on. This is a json string representing an array of labels.
llvm-version:
required: true
type: string
Expand Down Expand Up @@ -61,7 +65,7 @@ jobs:
arch: ${{ inputs.arch }}
toolchain_full: ${{ inputs.toolchain_full }}
toolchain: ${{ inputs.toolchain }}
runs_on: ${{ inputs.runs_on }}
runs_on: ${{ inputs.build_runs_on }}
llvm-version: ${{ inputs.llvm-version }}
kernel: ${{ inputs.kernel }}
download_sources: ${{ inputs.download_sources }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/kernel-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
REPO_PATH: ""
KBUILD_OUTPUT: kbuild-output/
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
# We fetch an actual bit of history here to facilitate incremental
# builds (which may check out some earlier upstream change).
with:
Expand All @@ -72,7 +72,7 @@ jobs:
run: |
bash .github/scripts/get-commit-metadata.sh
- name: Pull recent KBUILD_OUTPUT contents
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ${{ env.KBUILD_OUTPUT }}
key: kbuild-output-${{ inputs.arch }}-${{ inputs.toolchain_full }}-${{ steps.get-commit-metadata.outputs.branch }}-${{ steps.get-commit-metadata.outputs.timestamp }}-${{ steps.get-commit-metadata.outputs.commit }}
Expand Down Expand Up @@ -134,7 +134,7 @@ jobs:
# Only on pushed changes are build artifacts actually cached, because
# of github.com/actions/cache's cache isolation logic.
rm -rf "${KBUILD_OUTPUT}"
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: vmlinux-${{ inputs.arch }}-${{ inputs.toolchain_full }}${{ inputs.release && '-release' || '' }}
if-no-files-found: error
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/kernel-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ jobs:
# booleans are weird in GH.
CONTINUE_ON_ERROR: ${{ inputs.continue_on_error }}
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: vmlinux-${{ inputs.arch }}-${{ inputs.toolchain_full }}
path: .
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/kernel-veristat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ jobs:
KBUILD_OUTPUT: kbuild-output/
ARCH_AND_TOOL: ${{ inputs.arch }}-${{ inputs.toolchain }}
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: vmlinux-${{ env.ARCH_AND_TOOL }}
path: .
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@master
env:
Expand All @@ -28,7 +28,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Run black
uses: psf/black@stable
with:
Expand All @@ -48,7 +48,7 @@ jobs:
repository: ['bpf', 'vmtest', 'bar']
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: run script
run: |
python3 .github/scripts/matrix.py
Expand All @@ -59,7 +59,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Run unittests
run: python3 -m unittest scripts/tests/*.py
working-directory: .github
3 changes: 2 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
outputs:
build-matrix: ${{ steps.set-matrix-impl.outputs.build_matrix }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- id: set-matrix-impl
run: |
python3 .github/scripts/matrix.py
Expand All @@ -44,6 +44,7 @@ jobs:
toolchain_full: ${{ matrix.toolchain.fullname }}
toolchain: ${{ matrix.toolchain.name }}
runs_on: ${{ toJSON(matrix.runs_on) }}
build_runs_on: ${{ toJSON(matrix.build_runs_on) }}
llvm-version: ${{ matrix.toolchain.version }}
kernel: ${{ matrix.kernel }}
tests: ${{ toJSON(matrix.tests) }}
Expand Down
14 changes: 14 additions & 0 deletions ci/diffs/0099-selftest-cross-compile.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
index a38a3001527c..a403a9d5c529 100644
--- a/tools/testing/selftests/bpf/Makefile
+++ b/tools/testing/selftests/bpf/Makefile
@@ -171,7 +171,8 @@ INCLUDE_DIR := $(SCRATCH_DIR)/include
BPFOBJ := $(BUILD_DIR)/libbpf/libbpf.a
ifneq ($(CROSS_COMPILE),)
HOST_BUILD_DIR := $(BUILD_DIR)/host
-HOST_SCRATCH_DIR := $(OUTPUT)/host-tools
+#HOST_SCRATCH_DIR := $(OUTPUT)/host-tools
+HOST_SCRATCH_DIR := $(SCRATCH_DIR)
HOST_INCLUDE_DIR := $(HOST_SCRATCH_DIR)/include
else
HOST_BUILD_DIR := $(BUILD_DIR)
Loading