Skip to content

Commit

Permalink
add GCC constraints so that we can disambiguate platforms with the sa…
Browse files Browse the repository at this point in the history
…me GLIBC version
  • Loading branch information
nickbreen committed Sep 16, 2023
1 parent 2d1365b commit a871e03
Show file tree
Hide file tree
Showing 8 changed files with 129 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/bazel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 0 additions & 13 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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:

Expand Down
20 changes: 10 additions & 10 deletions executors/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
14 changes: 12 additions & 2 deletions platforms/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down
58 changes: 58 additions & 0 deletions platforms/gcc/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -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",
)
5 changes: 5 additions & 0 deletions platforms/glibc/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading

0 comments on commit a871e03

Please sign in to comment.