diff --git a/.github/workflows/bazel.yml b/.github/workflows/bazel.yml index 50af62e..78f3666 100644 --- a/.github/workflows/bazel.yml +++ b/.github/workflows/bazel.yml @@ -81,7 +81,7 @@ jobs: - uses: actions/checkout@v3 - name: Work around https://github.com/actions/upload-artifact/issues/92 run: echo "bazel_out=$(bazel info output_path)" >> $GITHUB_ENV - - name: Bazel Build with BuildBuddy + - name: Bazel Build run: bazel build hellos tars rpms debs - name: Bazel Test run: bazel test platform-{hello,tar,rpm,deb}-test-suite diff --git a/BUILD.bazel b/BUILD.bazel index d6ae088..ebf9d84 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -5,19 +5,6 @@ load("@rules_pkg//pkg:mappings.bzl", "pkg_attributes", "pkg_files") load(":defs.bzl", "platforms", "platforms_test") load("@rules_cc//cc:defs.bzl", "cc_binary") -genrule( - name = "trivial", - srcs = ["hello.c"], - outs = ["trivial.txt"], - cmd = """ - exec | tee $@ - pwd - cat /etc/os-release - find -ls - stat hello.c - """, -) - # Not built directly, but if done so will fail to build as CppCompile etcetera # are configured to *only* build in a container. # This *can* be built directly in an arbitrary container by overriding the diff --git a/README.md b/README.md index 8cd0ca1..bfebbf4 100644 --- a/README.md +++ b/README.md @@ -24,13 +24,13 @@ We want to target platforms with varied GLIBC versions. fedora:38 redhat RPM 2.37 glibc-2.37-4.fc38.x86_64 rockylinux:8 redhat RPM 2.28 glibc-2.28-211.el8.x86_64 rockylinux:9 redhat RPM 2.34 glibc-2.34-60.el9.x86_64 - ubuntu:focal debian DEB 2.36 libc6=2.36-0ubuntu4 - ubuntu:jammy debian DEB 2.37 libc6=2.37-0ubuntu2 + ubuntu:focal debian DEB 2.31 libc6=2.31-0ubuntu9.9 + ubuntu:jammy debian DEB 2.35 libc6=2.35-0ubuntu3.1 We could use https://github.com/wheybags/glibc_version_header to link to lowest-common denominator GLIBC symbols. But, glibc 2.34 has a hard break where you cannot compile with 2.34 and have it work with older -glibc versions ven if you use those version headers. It will always +glibc versions even if you use those version headers. It will always link `__libc_start_main@GLIBC_2.34`. So, to target various versions of GLIBC we need to be clever-er. @@ -44,6 +44,7 @@ So, we sort of have a sparse matrix of GLIBC versions: - 2.34 *** hard break `__libc_start_main@GLIBC_2.34`! - 2.36 - 2.37 +- 2.38 By OS/Family/Packaging: diff --git a/executors/docker-compose.yaml b/executors/docker-compose.yaml index 1dbe54e..4621956 100644 --- a/executors/docker-compose.yaml +++ b/executors/docker-compose.yaml @@ -1,60 +1,60 @@ services: centos-6: - command: ["sh", "-c", "ld --version; gcc --version; python3 --version; rpm --version"] + command: ["sh", "-c", "ldd --version; gcc --version; python3 --version; rpm --version"] image: ghcr.io/nickbreen/bz-platforms2/executors/centos:6 build: context: centos/6 dockerfile: Containerfile centos-7: - command: ["sh", "-c", "ld --version; gcc --version; python3 --version; rpm --version"] + command: ["sh", "-c", "ldd --version; gcc --version; python3 --version; rpm --version"] image: ghcr.io/nickbreen/bz-platforms2/executors/centos:7 build: context: centos/7 dockerfile: Containerfile debian-11: - command: ["sh", "-c", "ld --version; gcc --version; python3 --version"] + command: ["sh", "-c", "ldd --version; gcc --version; python3 --version"] image: ghcr.io/nickbreen/bz-platforms2/executors/debian:11 build: context: debian/11 dockerfile: Containerfile debian-12: - command: ["sh", "-c", "ld --version; gcc --version; python3 --version"] + command: ["sh", "-c", "ldd --version; gcc --version; python3 --version"] image: ghcr.io/nickbreen/bz-platforms2/executors/debian:12 build: context: debian/12 dockerfile: Containerfile fedora-37: - command: ["sh", "-c", "ld --version; gcc --version; python3 --version; rpm --version"] + command: ["sh", "-c", "ldd --version; gcc --version; python3 --version; rpm --version"] image: ghcr.io/nickbreen/bz-platforms2/executors/fedora:37 build: context: fedora/37 dockerfile: Containerfile fedora-38: - command: ["sh", "-c", "ld --version; gcc --version; python3 --version; rpm --version"] + command: ["sh", "-c", "ldd --version; gcc --version; python3 --version; rpm --version"] image: ghcr.io/nickbreen/bz-platforms2/executors/fedora:38 build: context: fedora/38 dockerfile: Containerfile rockylinux-8: - command: ["sh", "-c", "ld --version; gcc --version; python3 --version; rpm --version"] + command: ["sh", "-c", "ldd --version; gcc --version; python3 --version; rpm --version"] image: ghcr.io/nickbreen/bz-platforms2/executors/rockylinux:8 build: context: rockylinux/8 dockerfile: Containerfile rockylinux-9: - command: ["sh", "-c", "ld --version; gcc --version; python3 --version; rpm --version"] + command: ["sh", "-c", "ldd --version; gcc --version; python3 --version; rpm --version"] image: ghcr.io/nickbreen/bz-platforms2/executors/rockylinux:9 build: context: rockylinux/9 dockerfile: Containerfile ubuntu-focal: - command: ["sh", "-c", "ld --version; gcc --version; python3 --version"] + command: ["sh", "-c", "ldd --version; gcc --version; python3 --version"] image: ghcr.io/nickbreen/bz-platforms2/executors/ubuntu:focal build: context: ubuntu/focal dockerfile: Containerfile ubuntu-jammy: - command: ["sh", "-c", "ld --version; gcc --version; python3 --version"] + command: ["sh", "-c", "ldd --version; gcc --version; python3 --version"] image: ghcr.io/nickbreen/bz-platforms2/executors/ubuntu:jammy build: context: ubuntu/jammy diff --git a/platforms/BUILD.bazel b/platforms/BUILD.bazel index fbfb01e..4679930 100644 --- a/platforms/BUILD.bazel +++ b/platforms/BUILD.bazel @@ -7,6 +7,7 @@ platform( "@platforms//os:linux", "//platforms/family:redhat", "//platforms/glibc:2.12", + "//platforms/gcc:4.4.7", ], exec_properties = { "container-image": "docker://ghcr.io/nickbreen/bz-platforms2/executors/centos:6", @@ -20,6 +21,7 @@ platform( "@platforms//os:linux", "//platforms/family:redhat", "//platforms/glibc:2.17", + "//platforms/gcc:4.8.5", ], exec_properties = { "container-image": "docker://ghcr.io/nickbreen/bz-platforms2/executors/centos:7", @@ -33,6 +35,7 @@ platform( "@platforms//os:linux", "//platforms/family:debian", "//platforms/glibc:2.31", + "//platforms/gcc:10.2.1", ], exec_properties = { "container-image": "docker://ghcr.io/nickbreen/bz-platforms2/executors/debian:11", @@ -46,6 +49,7 @@ platform( "@platforms//os:linux", "//platforms/family:debian", "//platforms/glibc:2.36", + "//platforms/gcc:12.2.0", ], exec_properties = { "container-image": "docker://ghcr.io/nickbreen/bz-platforms2/executors/debian:12", @@ -59,6 +63,7 @@ platform( "@platforms//os:linux", "//platforms/family:redhat", "//platforms/glibc:2.36", + "//platforms/gcc:12.3.1", ], exec_properties = { "container-image": "docker://ghcr.io/nickbreen/bz-platforms2/executors/fedora:37", @@ -72,6 +77,7 @@ platform( "@platforms//os:linux", "//platforms/family:redhat", "//platforms/glibc:2.37", + "//platforms/gcc:13.2.1", ], exec_properties = { "container-image": "docker://ghcr.io/nickbreen/bz-platforms2/executors/fedora:38", @@ -85,6 +91,7 @@ platform( "@platforms//os:linux", "//platforms/family:redhat", "//platforms/glibc:2.28", + "//platforms/gcc:8.5.0", ], exec_properties = { "container-image": "docker://ghcr.io/nickbreen/bz-platforms2/executors/rockylinux:8", @@ -98,6 +105,7 @@ platform( "@platforms//os:linux", "//platforms/family:redhat", "//platforms/glibc:2.34", + "//platforms/gcc:11.3.1", ], exec_properties = { "container-image": "docker://ghcr.io/nickbreen/bz-platforms2/executors/rockylinux:9", @@ -110,7 +118,8 @@ platform( "@platforms//cpu:x86_64", "@platforms//os:linux", "//platforms/family:debian", - "//platforms/glibc:2.34", + "//platforms/glibc:2.31", + "//platforms/gcc:9.4.0", ], exec_properties = { "container-image": "docker://ghcr.io/nickbreen/bz-platforms2/executors/ubuntu:focal", @@ -123,7 +132,8 @@ platform( "@platforms//cpu:x86_64", "@platforms//os:linux", "//platforms/family:debian", - "//platforms/glibc:2.37", + "//platforms/glibc:2.35", + "//platforms/gcc:11.4.0", ], exec_properties = { "container-image": "docker://ghcr.io/nickbreen/bz-platforms2/executors/ubuntu:jammy", diff --git a/platforms/gcc/BUILD.bazel b/platforms/gcc/BUILD.bazel new file mode 100644 index 0000000..9b75308 --- /dev/null +++ b/platforms/gcc/BUILD.bazel @@ -0,0 +1,58 @@ +package(default_visibility = ["//visibility:public"]) + +constraint_setting(name = "gcc") + +constraint_value( + name = "4.4.7", + constraint_setting = ":gcc", +) + +constraint_value( + name = "4.8.5", + constraint_setting = ":gcc", +) + +constraint_value( + name = "8.5.0", + constraint_setting = ":gcc", +) + +constraint_value( + name = "9.4.0", + constraint_setting = ":gcc", +) + +constraint_value( + name = "10.2.1", + constraint_setting = ":gcc", +) + +constraint_value( + name = "11.3.1", + constraint_setting = ":gcc", +) + +constraint_value( + name = "13.1.1", + constraint_setting = ":gcc", +) + +constraint_value( + name = "11.4.0", + constraint_setting = ":gcc", +) + +constraint_value( + name = "12.2.0", + constraint_setting = ":gcc", +) + +constraint_value( + name = "12.3.1", + constraint_setting = ":gcc", +) + +constraint_value( + name = "13.2.1", + constraint_setting = ":gcc", +) diff --git a/platforms/glibc/BUILD.bazel b/platforms/glibc/BUILD.bazel index 00d12db..dc7f400 100644 --- a/platforms/glibc/BUILD.bazel +++ b/platforms/glibc/BUILD.bazel @@ -27,6 +27,11 @@ constraint_value( constraint_setting = ":glibc", ) +constraint_value( + name = "2.35", + constraint_setting = ":glibc", +) + constraint_value( name = "2.36", constraint_setting = ":glibc", diff --git a/toolchains/cc/BUILD.bazel b/toolchains/cc/BUILD.bazel index 42b5a0f..8784765 100644 --- a/toolchains/cc/BUILD.bazel +++ b/toolchains/cc/BUILD.bazel @@ -65,6 +65,17 @@ opt_link_flags = ["-Wl,--gc-sections"] # and empty set of files to provide to the cc_toolchain rule. filegroup(name = "exec-platform-provided") +# While these are named for OS/version they are actually just +# the combinations of GCC and GLIBC available on each of those OS/versions. + +# Family constraints are included as redhat family OS's and debian family OS's +# have different GCC include paths. + +# Note that these are resolved for platform a platform by matching constraints. +# Which means that as long they match it's a candidate toolchain. E.g. +# "@platforms//cpu:x86_64", "@platforms//os:linux", +# "//platforms/family:*", "//platforms/glibc:*", "//platforms/gcc:*" + # C toolchains - vary gcc/glibc versions and include paths by platform. # We need to define each platform's specific combination of GNU C version and # GNU libc version. @@ -112,12 +123,14 @@ toolchain( "@platforms//os:linux", "//platforms/family:redhat", "//platforms/glibc:2.12", + "//platforms/gcc:4.4.7", ], target_compatible_with = [ "@platforms//cpu:x86_64", "@platforms//os:linux", "//platforms/family:redhat", "//platforms/glibc:2.12", + "//platforms/gcc:4.4.7", ], toolchain = ":cc/centos/6", toolchain_type = "@bazel_tools//tools/cpp:toolchain_type", @@ -167,12 +180,14 @@ toolchain( "@platforms//os:linux", "//platforms/family:redhat", "//platforms/glibc:2.17", + "//platforms/gcc:4.8.5", ], target_compatible_with = [ "@platforms//cpu:x86_64", "@platforms//os:linux", "//platforms/family:redhat", "//platforms/glibc:2.17", + "//platforms/gcc:4.8.5", ], toolchain = ":cc/centos/7", toolchain_type = "@bazel_tools//tools/cpp:toolchain_type", @@ -221,12 +236,14 @@ toolchain( "@platforms//os:linux", "//platforms/family:redhat", "//platforms/glibc:2.28", + "//platforms/gcc:8.5.0", ], target_compatible_with = [ "@platforms//cpu:x86_64", "@platforms//os:linux", "//platforms/family:redhat", "//platforms/glibc:2.28", + "//platforms/gcc:8.5.0", ], toolchain = ":cc/rockylinux/8", toolchain_type = "@bazel_tools//tools/cpp:toolchain_type", @@ -275,12 +292,14 @@ toolchain( "@platforms//os:linux", "//platforms/family:redhat", "//platforms/glibc:2.34", + "//platforms/gcc:11.3.1", ], target_compatible_with = [ "@platforms//cpu:x86_64", "@platforms//os:linux", "//platforms/family:redhat", "//platforms/glibc:2.34", + "//platforms/gcc:11.3.1", ], toolchain = ":cc/rockylinux/9", toolchain_type = "@bazel_tools//tools/cpp:toolchain_type", @@ -329,12 +348,14 @@ toolchain( "@platforms//os:linux", "//platforms/family:redhat", "//platforms/glibc:2.36", + "//platforms/gcc:12.3.1", ], target_compatible_with = [ "@platforms//cpu:x86_64", "@platforms//os:linux", "//platforms/family:redhat", "//platforms/glibc:2.36", + "//platforms/gcc:12.3.1", ], toolchain = ":cc/fedora/37", toolchain_type = "@bazel_tools//tools/cpp:toolchain_type", @@ -383,12 +404,14 @@ toolchain( "@platforms//os:linux", "//platforms/family:redhat", "//platforms/glibc:2.37", + "//platforms/gcc:13.2.1", ], target_compatible_with = [ "@platforms//cpu:x86_64", "@platforms//os:linux", "//platforms/family:redhat", "//platforms/glibc:2.37", + "//platforms/gcc:13.2.1", ], toolchain = ":cc/fedora/38", toolchain_type = "@bazel_tools//tools/cpp:toolchain_type", @@ -437,12 +460,14 @@ toolchain( "@platforms//os:linux", "//platforms/family:debian", "//platforms/glibc:2.31", + "//platforms/gcc:10.2.1", ], target_compatible_with = [ "@platforms//cpu:x86_64", "@platforms//os:linux", "//platforms/family:debian", "//platforms/glibc:2.31", + "//platforms/gcc:10.2.1", ], toolchain = ":cc/debian/11", toolchain_type = "@bazel_tools//tools/cpp:toolchain_type", @@ -491,12 +516,14 @@ toolchain( "@platforms//os:linux", "//platforms/family:debian", "//platforms/glibc:2.36", + "//platforms/gcc:12.2.0", ], target_compatible_with = [ "@platforms//cpu:x86_64", "@platforms//os:linux", "//platforms/family:debian", "//platforms/glibc:2.36", + "//platforms/gcc:12.2.0", ], toolchain = ":cc/debian/12", toolchain_type = "@bazel_tools//tools/cpp:toolchain_type", @@ -504,7 +531,7 @@ toolchain( cc_toolchain_config( name = "config/ubuntu/focal", - abi_libc_version = "glibc-2.34", + abi_libc_version = "glibc-2.31", abi_version = "gcc-9.4.0", compile_flags = compile_flags, compiler = "gcc-9.4.0", @@ -520,7 +547,7 @@ cc_toolchain_config( link_libs = link_libs, opt_compile_flags = opt_compile_flags, opt_link_flags = opt_link_flags, - target_libc = "glibc-2.34", + target_libc = "glibc-2.31", target_system_name = "linux-gnu", tool_paths = tool_paths, toolchain_identifier = "k8_ubuntu_focal", @@ -544,13 +571,15 @@ toolchain( "@platforms//cpu:x86_64", "@platforms//os:linux", "//platforms/family:debian", - "//platforms/glibc:2.34", + "//platforms/glibc:2.31", + "//platforms/gcc:9.4.0", ], target_compatible_with = [ "@platforms//cpu:x86_64", "@platforms//os:linux", "//platforms/family:debian", - "//platforms/glibc:2.34", + "//platforms/glibc:2.31", + "//platforms/gcc:9.4.0", ], toolchain = ":cc/ubuntu/focal", toolchain_type = "@bazel_tools//tools/cpp:toolchain_type", @@ -558,7 +587,7 @@ toolchain( cc_toolchain_config( name = "config/ubuntu/jammy", - abi_libc_version = "glibc-2.38", + abi_libc_version = "glibc-2.35", abi_version = "gcc-11.4.0", compile_flags = compile_flags, compiler = "gcc-11.4.0", @@ -574,7 +603,7 @@ cc_toolchain_config( link_libs = link_libs, opt_compile_flags = opt_compile_flags, opt_link_flags = opt_link_flags, - target_libc = "glibc-2.38", + target_libc = "glibc-2.35", target_system_name = "linux-gnu", tool_paths = tool_paths, toolchain_identifier = "k8_ubuntu_jammy", @@ -598,13 +627,15 @@ toolchain( "@platforms//cpu:x86_64", "@platforms//os:linux", "//platforms/family:debian", - "//platforms/glibc:2.38", + "//platforms/glibc:2.35", + "//platforms/gcc:11.4.0", ], target_compatible_with = [ "@platforms//cpu:x86_64", "@platforms//os:linux", "//platforms/family:debian", - "//platforms/glibc:2.38", + "//platforms/glibc:2.35", + "//platforms/gcc:11.4.0", ], toolchain = ":cc/ubuntu/jammy", toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",