Skip to content

Commit 1f3602f

Browse files
authored
feat: unify gcc binaries and sysroot (#183)
We already built gcc for the sysroot, so this commit switches the binaries we use for the toolchain from buildroot to our own gcc builds.
1 parent 3ab8b0b commit 1f3602f

30 files changed

Lines changed: 786 additions & 536 deletions

.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
docs/*.md linguist-generated=true
2+
sysroot/gcc-toolchain-aarch64.tar.xz filter=lfs diff=lfs merge=lfs -text
3+
sysroot/gcc-toolchain-armv7.tar.xz filter=lfs diff=lfs merge=lfs -text
4+
sysroot/gcc-toolchain-x86_64.tar.xz filter=lfs diff=lfs merge=lfs -text

.github/workflows/default.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ jobs:
2525
runs-on: ${{ matrix.os }}
2626
steps:
2727
- uses: actions/checkout@v4
28+
with:
29+
lfs: true
2830
- uses: bazel-contrib/setup-bazel@0.15.0
2931
with:
3032
bazelisk-cache: true
@@ -46,6 +48,8 @@ jobs:
4648
runs-on: ubuntu-22.04
4749
steps:
4850
- uses: actions/checkout@v4
51+
with:
52+
lfs: true
4953
- uses: bazel-contrib/setup-bazel@0.15.0
5054
with:
5155
bazelisk-cache: true
@@ -68,6 +72,8 @@ jobs:
6872
runs-on: ubuntu-22.04
6973
steps:
7074
- uses: actions/checkout@v4
75+
with:
76+
lfs: true
7177
- uses: bazel-contrib/setup-bazel@0.15.0
7278
with:
7379
bazelisk-cache: true
@@ -83,6 +89,8 @@ jobs:
8389
runs-on: ubuntu-22.04
8490
steps:
8591
- uses: actions/checkout@v4
92+
with:
93+
lfs: true
8694
- uses: bazel-contrib/setup-bazel@0.15.0
8795
with:
8896
bazelisk-cache: true
@@ -104,6 +112,8 @@ jobs:
104112
runs-on: ${{ matrix.os }}
105113
steps:
106114
- uses: actions/checkout@v4
115+
with:
116+
lfs: true
107117
- uses: bazel-contrib/setup-bazel@0.15.0
108118
with:
109119
bazelisk-cache: true

WORKSPACE

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@ load("//:internal.bzl", "internal_dependencies")
2525

2626
internal_dependencies()
2727

28-
load("@rules_pkg//:deps.bzl", "rules_pkg_dependencies")
29-
30-
rules_pkg_dependencies()
31-
3228
load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
3329

3430
bazel_skylib_workspace()
@@ -51,14 +47,25 @@ gcc_register_toolchain(
5147

5248
gcc_register_toolchain(
5349
name = "gcc_toolchain_x86_64",
54-
sysroot_variant = "x86_64-X11",
5550
target_arch = ARCHS.x86_64,
5651
)
5752

5853
load("@rules_foreign_cc//foreign_cc:repositories.bzl", "rules_foreign_cc_dependencies")
5954

6055
rules_foreign_cc_dependencies()
6156

57+
load("@bazel_features//:deps.bzl", "bazel_features_deps")
58+
59+
bazel_features_deps()
60+
61+
load("@rules_python//python:repositories.bzl", "py_repositories")
62+
63+
py_repositories()
64+
6265
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
6366

6467
protobuf_deps()
68+
69+
load("@rules_pkg//:deps.bzl", "rules_pkg_dependencies")
70+
71+
rules_pkg_dependencies()

docs/defs.md

Lines changed: 4 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/avl/avl.BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ cc_library(
2222
srcs = ["plotlib/xwin11/Xwin2.c"],
2323
defines = ["UNDERSCORE", "NDEBUG"],
2424
linkopts = ["-lX11"],
25-
features = ["no_libstdcxx"],
2625
)
2726

2827
fortran_library(

examples/hello_world_c/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ build_test(
3131
cc_binary(
3232
name = "hello_world_c",
3333
srcs = ["main.c"],
34-
features = ["no_libstdcxx"],
3534
)
3635

3736
platform_transition_filegroup(

examples/hello_world_cpp/BUILD.bazel

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
load("@aspect_bazel_lib//lib:transitions.bzl", "platform_transition_filegroup")
1919
load("@bazel_skylib//rules:build_test.bzl", "build_test")
2020
load("@rules_pkg//pkg:tar.bzl", "pkg_tar")
21+
load("//rules_cc:defs.bzl", "cc_binary", "cc_library", "cc_test")
2122

2223
build_test(
2324
name = "hello_world_cpp_build_test",
@@ -70,7 +71,7 @@ cc_binary(
7071
name = "hello_world_cpp_static",
7172
srcs = ["main.cpp"],
7273
data = ["names.txt"],
73-
features = ["static_libstdcxx"],
74+
static_libstdcxx = True,
7475
)
7576

7677
platform_transition_filegroup(

examples/lapack/BUILD.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# See the License for the specific language governing permissions and
1616
# limitations under the License.
1717

18-
load("@rules_foreign_cc//foreign_cc:defs.bzl", "make")
18+
load("@rules_foreign_cc//foreign_cc:make.bzl", "make")
1919

2020
_libs = [
2121
"liblapack.a",
@@ -43,7 +43,7 @@ make(
4343
lib_source = "@lapack//:srcs",
4444
out_static_libs = _libs,
4545
postfix_script = "\n".join([
46-
"cp {0} $$INSTALLDIR$$/lib/{0}".format(lib)
46+
"mv $$EXT_BUILD_ROOT/external/lapack/{0} $$INSTALLDIR/lib/{0}".format(lib)
4747
for lib in _libs
4848
]),
4949
targets = [

examples/protobuf/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
load("@aspect_bazel_lib//lib:transitions.bzl", "platform_transition_filegroup")
1919
load("@bazel_skylib//rules:build_test.bzl", "build_test")
20-
load("@rules_cc//cc:defs.bzl", "cc_proto_library")
20+
load("@com_google_protobuf//bazel:cc_proto_library.bzl", "cc_proto_library")
2121
load("@rules_pkg//pkg:tar.bzl", "pkg_tar")
2222
load("@rules_proto//proto:defs.bzl", "proto_library")
2323

internal.bzl

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ load("//examples/lapack:patches.bzl", "LAPACK_PATCHES")
2424

2525
# buildifier: disable=function-docstring
2626
def internal_dependencies():
27-
maybe(
28-
http_archive,
27+
http_archive(
2928
name = "io_bazel_stardoc",
3029
sha256 = "dfbc364aaec143df5e6c52faf1f1166775a5b4408243f445f44b661cfdc3134f",
3130
urls = [
@@ -34,33 +33,36 @@ def internal_dependencies():
3433
],
3534
)
3635

37-
maybe(
38-
http_archive,
36+
http_archive(
3937
name = "aspect_bazel_lib",
4038
sha256 = "a7e356f8a5cb8bf1e9be38c2c617ad22f5a1606792e839fc040971bdfbecf971",
4139
strip_prefix = "bazel-lib-1.40.2",
4240
url = "https://github.com/aspect-build/bazel-lib/archive/refs/tags/v1.40.2.tar.gz",
4341
)
4442

45-
maybe(
46-
http_archive,
43+
http_archive(
4744
name = "rules_foreign_cc",
48-
sha256 = "2a4d07cd64b0719b39a7c12218a3e507672b82a97b98c6a89d38565894cf7c51",
49-
strip_prefix = "rules_foreign_cc-0.9.0",
50-
url = "https://github.com/bazelbuild/rules_foreign_cc/archive/0.9.0.tar.gz",
45+
sha256 = "32759728913c376ba45b0116869b71b68b1c2ebf8f2bcf7b41222bc07b773d73",
46+
strip_prefix = "rules_foreign_cc-0.15.1",
47+
url = "https://github.com/bazel-contrib/rules_foreign_cc/releases/download/0.15.1/rules_foreign_cc-0.15.1.tar.gz",
5148
)
5249

53-
maybe(
54-
http_archive,
50+
http_archive(
51+
name = "rules_python",
52+
sha256 = "7b9039c31e909cf59eeaea8ccbdc54f09f7ebaeb9609b94371c7de45e802977c",
53+
strip_prefix = "rules_python-1.5.0",
54+
url = "https://github.com/bazel-contrib/rules_python/releases/download/1.5.0/rules_python-1.5.0.tar.gz",
55+
)
56+
57+
http_archive(
5558
name = "openssl",
5659
build_file_content = _ALL_SRCS,
5760
sha256 = "40dceb51a4f6a5275bde0e6bf20ef4b91bfc32ed57c0552e2e8e15463372b17a",
5861
strip_prefix = "openssl-1.1.1n",
5962
url = "https://www.openssl.org/source/openssl-1.1.1n.tar.gz",
6063
)
6164

62-
maybe(
63-
http_archive,
65+
http_archive(
6466
name = "lapack",
6567
build_file_content = _ALL_SRCS,
6668
patch_cmds = LAPACK_PATCHES,
@@ -69,27 +71,24 @@ def internal_dependencies():
6971
url = "https://github.com/Reference-LAPACK/lapack/archive/refs/tags/v3.12.0.tar.gz",
7072
)
7173

72-
maybe(
73-
http_archive,
74+
http_archive(
7475
name = "avl",
7576
build_file = "@//:examples/avl/avl.BUILD.bazel",
7677
sha256 = "6d62e563578b79795a84958cfe4e221a4c9847fbeb4a821d45bc049934fc6a90",
7778
strip_prefix = "Avl",
7879
url = "https://web.mit.edu/drela/Public/web/avl/avl3.40b.tgz",
7980
)
8081

81-
maybe(
82-
http_archive,
82+
http_archive(
8383
name = "com_google_protobuf",
84-
sha256 = "930c2c3b5ecc6c9c12615cf5ad93f1cd6e12d0aba862b572e076259970ac3a53",
85-
strip_prefix = "protobuf-3.21.12",
86-
urls = [
87-
"https://github.com/protocolbuffers/protobuf/archive/v3.21.12.tar.gz",
88-
],
84+
patches = ["//third_party/patches:com_google_protobuf.patch"],
85+
patch_args = ["-p1"],
86+
sha256 = "008a11cc56f9b96679b4c285fd05f46d317d685be3ab524b2a310be0fbad987e",
87+
strip_prefix = "protobuf-29.3",
88+
url = "https://github.com/protocolbuffers/protobuf/releases/download/v29.3/protobuf-29.3.tar.gz",
8989
)
9090

91-
maybe(
92-
http_archive,
91+
http_archive(
9392
name = "rules_pkg",
9493
sha256 = "8f9ee2dc10c1ae514ee599a8b42ed99fa262b757058f65ad3c384289ff70c4b8",
9594
urls = [

0 commit comments

Comments
 (0)