From 45fe650afee57cf011c69232d0ce277d862a78c2 Mon Sep 17 00:00:00 2001 From: Wangchong Zhou Date: Tue, 21 May 2024 16:09:57 +0800 Subject: [PATCH] feat(build): cross build for amazonlinux:2 x86_64 --- .github/matrix-full.yml | 2 +- BUILD.bazel | 21 +++++++++++++++++++ build/toolchain/BUILD | 8 +++++++ build/toolchain/managed_toolchain.bzl | 7 +++++++ build/toolchain/repositories.bzl | 8 +++++++ .../fixtures/amazonlinux-2-amd64.txt | 20 +++++------------- 6 files changed, 50 insertions(+), 16 deletions(-) diff --git a/.github/matrix-full.yml b/.github/matrix-full.yml index b514341ca321..a9b346134a7f 100644 --- a/.github/matrix-full.yml +++ b/.github/matrix-full.yml @@ -37,10 +37,10 @@ build-packages: # Amazon Linux - label: amazonlinux-2 - image: amazonlinux:2 package: rpm package-type: aws2 check-manifest-suite: amazonlinux-2-amd64 + bazel-args: --platforms=//:aws2-crossbuild-x86_64 - label: amazonlinux-2023 image: amazonlinux:2023 package: rpm diff --git a/BUILD.bazel b/BUILD.bazel index d330e7089ef2..5c52fc80094b 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -193,6 +193,16 @@ platform( for vendor in aarch64_glibc_distros ] +platform( + name = "aws2-crossbuild-x86_64", + constraint_values = [ + "@platforms//os:linux", + "@platforms//cpu:x86_64", + "//build/platforms/distro:aws2", + ":cross_build", + ], +) + # config_settings define a select() condition based on user-set constraint_values # see https://bazel.build/docs/configurable-attributes config_setting( @@ -216,12 +226,23 @@ config_setting( visibility = ["//visibility:public"], ) +config_setting( + name = "x86_64-linux-anylibc-cross", + constraint_values = [ + "@platforms//os:linux", + "@platforms//cpu:x86_64", + ":cross_build", + ], + visibility = ["//visibility:public"], +) + selects.config_setting_group( # matches all cross build platforms name = "any-cross", match_any = [ ":aarch64-linux-anylibc-cross", ":x86_64-linux-musl-cross", + ":x86_64-linux-anylibc-cross", ], visibility = ["//visibility:public"], ) diff --git a/build/toolchain/BUILD b/build/toolchain/BUILD index 9b870846acf7..e364acbd77e4 100644 --- a/build/toolchain/BUILD +++ b/build/toolchain/BUILD @@ -63,6 +63,14 @@ define_managed_toolchain( vendor = "alpine", ) +define_managed_toolchain( + arch = "x86_64", + gcc_version = aarch64_glibc_distros["aws2"], + libc = "gnu", + target_compatible_with = ["//build/platforms/distro:aws2"], + vendor = "aws2", +) + [ define_managed_toolchain( arch = "aarch64", diff --git a/build/toolchain/managed_toolchain.bzl b/build/toolchain/managed_toolchain.bzl index 793b335924e9..86d88868d5c2 100644 --- a/build/toolchain/managed_toolchain.bzl +++ b/build/toolchain/managed_toolchain.bzl @@ -143,6 +143,13 @@ def register_all_toolchains(name = None): vendor = "alpine", ) + register_managed_toolchain( + arch = "x86_64", + gcc_version = "7", + libc = "gnu", + vendor = "aws2", + ) + for vendor in aarch64_glibc_distros: register_managed_toolchain( arch = "aarch64", diff --git a/build/toolchain/repositories.bzl b/build/toolchain/repositories.bzl index d95e10c4d1b7..9c0b54d7841b 100644 --- a/build/toolchain/repositories.bzl +++ b/build/toolchain/repositories.bzl @@ -68,3 +68,11 @@ def toolchain_repositories(): strip_prefix = "aarch64-aws2-linux-gnu", build_file_content = build_file_content, ) + + http_archive( + name = "x86_64-aws2-linux-gnu-gcc-7", + url = "https://github.com/Kong/crosstool-ng-actions/releases/download/0.7.0/x86_64-aws2-linux-gnu-glibc-2.26-gcc-7.tar.gz", + sha256 = "645c242d13bf456ca59a7e9701e9d2f53336fd0497ccaff2b151da9921469985", + strip_prefix = "x86_64-aws2-linux-gnu", + build_file_content = build_file_content, + ) diff --git a/scripts/explain_manifest/fixtures/amazonlinux-2-amd64.txt b/scripts/explain_manifest/fixtures/amazonlinux-2-amd64.txt index cb5d0045ac2c..3d0e4868ebe3 100644 --- a/scripts/explain_manifest/fixtures/amazonlinux-2-amd64.txt +++ b/scripts/explain_manifest/fixtures/amazonlinux-2-amd64.txt @@ -5,47 +5,37 @@ - Path : /usr/local/kong/lib/engines-1.1/afalg.so Needed : - - libstdc++.so.6 - - libm.so.6 - libcrypto.so.1.1 - libdl.so.2 - libc.so.6 - Runpath : /usr/local/kong/lib + Rpath : /usr/local/kong/lib - Path : /usr/local/kong/lib/engines-1.1/capi.so Needed : - - libstdc++.so.6 - - libm.so.6 - libcrypto.so.1.1 - libdl.so.2 - libc.so.6 - Runpath : /usr/local/kong/lib + Rpath : /usr/local/kong/lib - Path : /usr/local/kong/lib/engines-1.1/padlock.so Needed : - - libstdc++.so.6 - - libm.so.6 - libcrypto.so.1.1 - libdl.so.2 - libc.so.6 - Runpath : /usr/local/kong/lib + Rpath : /usr/local/kong/lib - Path : /usr/local/kong/lib/libcrypto.so.1.1 Needed : - - libstdc++.so.6 - - libm.so.6 - libdl.so.2 - libc.so.6 - Runpath : /usr/local/kong/lib + Rpath : /usr/local/kong/lib - Path : /usr/local/kong/lib/libssl.so.1.1 Needed : - - libstdc++.so.6 - - libm.so.6 - libcrypto.so.1.1 - libdl.so.2 - libc.so.6 - Runpath : /usr/local/kong/lib + Rpath : /usr/local/kong/lib - Path : /usr/local/lib/lua/5.1/lfs.so Needed :