Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor to support cross-compilation #98

Merged
merged 1 commit into from
Sep 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
LLVM toolchain for Bazel [![Tests](https://github.com/grailbio/bazel-toolchain/actions/workflows/tests.yml/badge.svg)](https://github.com/grailbio/bazel-toolchain/actions/workflows/tests.yml) [![Migration](https://github.com/grailbio/bazel-toolchain/actions/workflows/migration.yml/badge.svg)](https://github.com/grailbio/bazel-toolchain/actions/workflows/migration.yml)
=================

-------

Required minimum bazel version: 4.0.0

-------

To use this toolchain, include this section in your WORKSPACE:
```python
# Change master to the git tag you want.
Expand Down
2 changes: 1 addition & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ filegroup(
)

llvm_toolchain(
name = "llvm_toolchain_linux_sysroot",
name = "llvm_toolchain_with_sysroot",
llvm_version = "12.0.0",
sysroot = {
"linux-x86_64": "@org_chromium_sysroot_linux_x64//:sysroot",
Expand Down
2 changes: 1 addition & 1 deletion tests/scripts/linux_sysroot_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ apt-get -qq -y install apt-utils curl pkg-config zip g++ zlib1g-dev unzip python

# Run tests
cd /src
tests/scripts/run_tests.sh -t '@llvm_toolchain_linux_sysroot//:cc-toolchain-k8-linux'
tests/scripts/run_tests.sh -t '@llvm_toolchain_with_sysroot//:cc-toolchain-x86_64-linux'
"""
done
74 changes: 11 additions & 63 deletions toolchain/BUILD.toolchain.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -15,87 +15,35 @@
package(default_visibility = ["//visibility:public"])

load("@rules_cc//cc:defs.bzl", "cc_toolchain", "cc_toolchain_suite")
load("%{cc_toolchain_config_bzl}", "cc_toolchain_config")

exports_files(["Makevars"])

# Needed for old style --cpu and --compiler command line flags when using
# crosstool_top.
# TODO: Delete this and rely on toolchain registration mechanism alone.
cc_toolchain_suite(
name = "toolchain",
toolchains = {
"k8|clang": ":cc-clang-k8-linux",
"k8|clang": ":cc-clang-x86_64-linux",
"aarch64|clang": ":cc-clang-aarch64-linux",
"darwin|clang": ":cc-clang-darwin",
"k8": ":cc-clang-k8-linux",
"darwin|clang": ":cc-clang-x86_64-darwin",
"k8": ":cc-clang-x86_64-linux",
"aarch64": ":cc-clang-aarch64-linux",
"darwin": ":cc-clang-darwin",
"darwin": ":cc-clang-x86_64-darwin",
},
)

load(":cc_toolchain_config.bzl", "cc_toolchain_config")

cc_toolchain_config(
name = "local_linux_k8",
cpu = "k8",
)

cc_toolchain_config(
name = "local_linux_aarch64",
cpu = "aarch64",
)

cc_toolchain_config(
name = "local_darwin",
cpu = "darwin",
)

toolchain(
name = "cc-toolchain-darwin",
exec_compatible_with = [
"@platforms//cpu:x86_64",
"@platforms//os:osx",
],
target_compatible_with = [
"@platforms//cpu:x86_64",
"@platforms//os:osx",
],
toolchain = ":cc-clang-darwin",
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
)

toolchain(
name = "cc-toolchain-k8-linux",
exec_compatible_with = [
"@platforms//cpu:x86_64",
"@platforms//os:linux",
],
target_compatible_with = [
"@platforms//cpu:x86_64",
"@platforms//os:linux",
],
toolchain = ":cc-clang-k8-linux",
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
)

toolchain(
name = "cc-toolchain-aarch64-linux",
exec_compatible_with = [
"@platforms//cpu:aarch64",
"@platforms//os:linux",
],
target_compatible_with = [
"@platforms//cpu:aarch64",
"@platforms//os:linux",
],
toolchain = ":cc-clang-aarch64-linux",
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
)
# Following filegroup targets are used when not using absolute paths and shared
# between different toolchains.

filegroup(
name = "empty",
srcs = [],
)

filegroup(
name = "cc_wrapper",
name = "cc-wrapper",
srcs = ["bin/cc_wrapper.sh"],
)

Expand Down
Loading