Skip to content

Commit

Permalink
fix: use relative paths for tools (#16)
Browse files Browse the repository at this point in the history
* feat: check-in unix_cc_configure.bzl from upstream

https://github.com/bazelbuild/bazel/blob/38c586f9/tools/cpp/unix_cc_configure.bzl

Signed-off-by: Thulio Ferraz Assis <[email protected]>

* fix: use relative paths for tools

Also, remove the hardcoding of rpath and dynamic linker as they produce
non-hermetic and non-deterministic output.

Signed-off-by: Thulio Ferraz Assis <[email protected]>

* feat: add prs to ci

Signed-off-by: Thulio Ferraz Assis <[email protected]>

* downgrade: x86_64 toolchain

Signed-off-by: Thulio Ferraz Assis <[email protected]>
  • Loading branch information
f0rmiga authored Apr 28, 2022
1 parent 02ad06b commit 8cecae7
Show file tree
Hide file tree
Showing 12 changed files with 1,004 additions and 261 deletions.
3 changes: 1 addition & 2 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
build --action_env CC=/bin/false
build --incompatible_enable_cc_toolchain_resolution
build --extra_toolchains=@gcc_toolchain//:toolchain
build --extra_toolchains=@gcc_toolchain_armv7//:toolchain

test --sandbox_default_allow_network=false
test --test_output=errors
Expand Down
2 changes: 2 additions & 0 deletions .fasterci/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ workflows:
on:
push:
branches: [master]
pull_request:
branches: [master]
steps:
- name: bazel test
bazel:
Expand Down
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docs/*.md linguist-generated=true
39 changes: 24 additions & 15 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -21,40 +21,49 @@ load("//toolchain:defs.bzl", "gcc_register_toolchain")
flags = [
"-Wall",
"-Wextra",
"-Werror",
"-fdiagnostics-color=always",
]

gcc_register_toolchain(
name = "gcc_toolchain",
url = "https://toolchains.bootlin.com/downloads/releases/toolchains/x86-64/tarballs/x86-64--glibc--stable-2021.11-5.tar.bz2",
sha256 = "6fe812add925493ea0841365f1fb7ca17fd9224bab61a731063f7f12f3a621b0",
strip_prefix = "x86-64--glibc--stable-2021.11-5",
target_arch = "x86_64",
hardcode_sysroot_ld_linux = True,
hardcode_sysroot_rpath = True,
bazel_gcc_toolchain_workspace_name = "",
extra_cflags = flags,
extra_cxxflags = flags,
sha256 = "522d773fa2a89b88126129d9c62e27df7bfb6647d885de432cdec618f68a38bc",
strip_prefix = "x86-64-core-i7--glibc--stable-2018.11-1",
target_arch = "x86_64",
url = "https://toolchains.bootlin.com/downloads/releases/toolchains/x86-64-core-i7/tarballs/x86-64-core-i7--glibc--stable-2018.11-1.tar.bz2",
)

gcc_register_toolchain(
name = "gcc_toolchain_aarch64",
url = "https://toolchains.bootlin.com/downloads/releases/toolchains/aarch64/tarballs/aarch64--glibc--stable-2021.11-1.tar.bz2",
bazel_gcc_toolchain_workspace_name = "",
extra_cflags = flags,
extra_cxxflags = flags,
sha256 = "dec070196608124fa14c3f192364c5b5b057d7f34651ad58ebb8fc87959c97f7",
strip_prefix = "aarch64--glibc--stable-2021.11-1",
target_arch = "aarch64",
extra_cflags = flags,
extra_cxxflags = flags,
url = "https://toolchains.bootlin.com/downloads/releases/toolchains/aarch64/tarballs/aarch64--glibc--stable-2021.11-1.tar.bz2",
)

gcc_register_toolchain(
name = "gcc_toolchain_armv7",
url = "https://toolchains.bootlin.com/downloads/releases/toolchains/armv7-eabihf/tarballs/armv7-eabihf--glibc--stable-2018.11-1.tar.bz2",
sha256 = "c8d4d3ca70442652e0e72f57ae6e878375640508f1e08de3152f63414c43b2e4",
strip_prefix = "armv7-eabihf--glibc--stable-2018.11-1",
target_arch = "armv7",
bazel_gcc_toolchain_workspace_name = "",
binary_prefix = "arm",
platform_directory = "arm-buildroot-linux-gnueabihf",
extra_cflags = flags,
extra_cxxflags = flags,
platform_directory = "arm-buildroot-linux-gnueabihf",
sha256 = "c8d4d3ca70442652e0e72f57ae6e878375640508f1e08de3152f63414c43b2e4",
strip_prefix = "armv7-eabihf--glibc--stable-2018.11-1",
target_arch = "armv7",
url = "https://toolchains.bootlin.com/downloads/releases/toolchains/armv7-eabihf/tarballs/armv7-eabihf--glibc--stable-2018.11-1.tar.bz2",
)

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

rules_foreign_cc_dependencies()

load("@rules_perl//perl:deps.bzl", "perl_register_toolchains", "perl_rules_dependencies")

perl_rules_dependencies()
perl_register_toolchains()
9 changes: 4 additions & 5 deletions docs/defs.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

60 changes: 60 additions & 0 deletions examples/openssl/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
load("@aspect_bazel_lib//lib:transitions.bzl", "platform_transition_filegroup")
load("@bazel_tools//tools/build_defs/pkg:pkg.bzl", "pkg_tar")
load("@rules_foreign_cc//foreign_cc:defs.bzl", "configure_make")

configure_make(
name = "openssl",
configure_command = "Configure",
configure_in_place = True,
configure_options = select({
"//platforms/config:aarch64_linux": ["linux-aarch64"],
"//platforms/config:armv7_linux": ["linux-generic32"],
"//platforms/config:x86_64_linux": ["linux-generic64"],
}) + [
"no-comp",
"no-idea",
"no-weak-ssl-ciphers",
"no-shared",
],
env = {
"PERL": "$$EXT_BUILD_ROOT$$/$(PERL)",
},
lib_name = "openssl",
lib_source = "@openssl//:srcs",
out_static_libs = [
"libssl.a",
"libcrypto.a",
],
targets = [
"install_sw",
"install_ssldirs",
],
toolchains = ["@rules_perl//:current_toolchain"],
visibility = ["//visibility:public"],
)

platform_transition_filegroup(
name = "openssl_linux_aarch64",
target_platform = "//platforms:aarch64_linux",
srcs = [":openssl"],
)

pkg_tar(
name = "openssl_linux_aarch64_tar",
srcs = [":openssl_linux_aarch64"],
include_runfiles = True,
strip_prefix = "/",
)

platform_transition_filegroup(
name = "openssl_linux_armv7",
target_platform = "//platforms:armv7_linux",
srcs = [":openssl"],
)

pkg_tar(
name = "openssl_linux_armv7_tar",
srcs = [":openssl_linux_armv7"],
include_runfiles = True,
strip_prefix = "/",
)
36 changes: 36 additions & 0 deletions internal.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,39 @@ def internal_dependencies():
strip_prefix = "bazel-lib-0.9.6",
url = "https://github.com/aspect-build/bazel-lib/archive/refs/tags/v0.9.6.tar.gz",
)

maybe(
http_archive,
name = "rules_perl",
sha256 = "5696d108f749e300560362a3b7201f1f57b6ae451b0a0176e5f0a979ebf8e192",
strip_prefix = "rules_perl-3f52cee1916f6fc1c499da4a89d7f065a287ae29",
url = "https://github.com/bazelbuild/rules_perl/archive/3f52cee1916f6fc1c499da4a89d7f065a287ae29.tar.gz",
)

maybe(
http_archive,
name = "rules_foreign_cc",
sha256 = "6041f1374ff32ba711564374ad8e007aef77f71561a7ce784123b9b4b88614fc",
strip_prefix = "rules_foreign_cc-0.8.0",
url = "https://github.com/bazelbuild/rules_foreign_cc/archive/0.8.0.tar.gz",
)

maybe(
http_archive,
name = "openssl",
build_file_content = _ALL_SRCS,
sha256 = "40dceb51a4f6a5275bde0e6bf20ef4b91bfc32ed57c0552e2e8e15463372b17a",
strip_prefix = "openssl-1.1.1n",
url = "https://www.openssl.org/source/openssl-1.1.1n.tar.gz",
)

_ALL_SRCS = """\
filegroup(
name = "srcs",
srcs = glob(
include = ["**"],
exclude = ["**/* *"],
),
visibility = ["//visibility:public"],
)
"""
12 changes: 9 additions & 3 deletions toolchain/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")

exports_files(
["config.bzl"],
visibility = ["//visibility:public"],
)

exports_files(
glob(["*.bzl"]),
visibility = [
"//docs:__pkg__",
],
visibility = ["//docs:__pkg__"],
)

bzl_library(
name = "defs",
srcs = ["defs.bzl"],
deps = [
"@bazel_tools//tools/cpp:lib_cc_configure.bzl",
"@bazel_skylib//lib:collections",
"@bazel_skylib//lib:dicts",
"@bazel_skylib//lib:paths",
"//toolchain:unix_cc_configure.bzl",
],
visibility = ["//visibility:public"],
)
Loading

0 comments on commit 8cecae7

Please sign in to comment.