Misc cleanups (#216)

- Prepare for BCR release as 0.10.0
- Rename repo name to toolchains_llvm
- Upgrade Go version in tests and remove -nopie flag
- Combine lint and tests workflow
This commit is contained in:
Siddhartha Bagaria 2023-09-14 00:03:26 -07:00 committed by GitHub
parent 1cf6ea867f
commit bb94933b62
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 91 additions and 64 deletions

View File

@ -1,25 +0,0 @@
name: Pull Request
on: [pull_request]
concurrency:
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true
# NOTE: This current setup does not post annotations to PRs.
# https://github.com/marketplace/actions/trunk-check#getting-inline-annotations-for-fork-prs
permissions: read-all
jobs:
trunk_check:
name: Trunk Check Runner
runs-on: ubuntu-latest
permissions:
checks: write # For trunk to post annotations
contents: read # For repo checkout
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Trunk Check
uses: trunk-io/trunk-action@v1

View File

@ -1,14 +1,26 @@
name: Tests name: Tests
on: on:
push:
branches: [master]
pull_request: pull_request:
branches: [master] branches: [master]
concurrency:
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true
permissions: read-all permissions: read-all
jobs: jobs:
lint:
runs-on: ubuntu-latest
permissions:
checks: write # For trunk to post annotations
contents: read # For repo checkout
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Trunk Check
uses: trunk-io/trunk-action@v1
test: test:
strategy: strategy:
fail-fast: false fail-fast: false
@ -25,7 +37,7 @@ jobs:
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: test - name: Test
env: env:
USE_BAZEL_VERSION: ${{ matrix.bazel_version }} USE_BAZEL_VERSION: ${{ matrix.bazel_version }}
USE_BZLMOD: ${{ matrix.bzlmod }} USE_BZLMOD: ${{ matrix.bzlmod }}
@ -40,7 +52,7 @@ jobs:
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: external_test - name: Test
env: env:
USE_BAZEL_VERSION: ${{ matrix.bazel_version }} USE_BAZEL_VERSION: ${{ matrix.bazel_version }}
USE_BZLMOD: ${{ matrix.bzlmod }} USE_BZLMOD: ${{ matrix.bzlmod }}
@ -63,19 +75,19 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: test - name: Test
run: tests/scripts/${{ matrix.script }}_test.sh run: tests/scripts/${{ matrix.script }}_test.sh
xcompile_test: xcompile_test:
runs-on: macos-latest runs-on: macos-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: test - name: Test
run: tests/scripts/run_xcompile_tests.sh run: tests/scripts/run_xcompile_tests.sh
abs_paths_test: abs_paths_test:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: test - name: Test
run: tests/scripts/run_tests.sh -t @llvm_toolchain_with_absolute_paths//:cc-toolchain-x86_64-linux run: tests/scripts/run_tests.sh -t @llvm_toolchain_with_absolute_paths//:cc-toolchain-x86_64-linux
sys_paths_test: sys_paths_test:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -88,5 +100,5 @@ jobs:
ext: .tar.xz ext: .tar.xz
local_path: /tmp/llvm-15 local_path: /tmp/llvm-15
run: wget --no-verbose "https://github.com/llvm/llvm-project/releases/download/${release}/${archive}${ext}" && tar -xf "${archive}${ext}" && mv "${archive}" "${local_path}" run: wget --no-verbose "https://github.com/llvm/llvm-project/releases/download/${release}/${archive}${ext}" && tar -xf "${archive}${ext}" && mv "${archive}" "${local_path}"
- name: test - name: Test
run: tests/scripts/run_tests.sh -t @llvm_toolchain_with_system_llvm//:cc-toolchain-x86_64-linux run: tests/scripts/run_tests.sh -t @llvm_toolchain_with_system_llvm//:cc-toolchain-x86_64-linux

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
/bazel-*
/tests/bazel-* /tests/bazel-*
/toolchain/tools/__pycache__ /toolchain/tools/__pycache__
/toolchain/tools/host_os_key.pyc /toolchain/tools/host_os_key.pyc

View File

@ -1,9 +1,23 @@
# Copyright 2023 The Bazel Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
module( module(
name = "llvm_toolchain", name = "toolchains_llvm",
version = "0.0.0", version = "0.10.0",
compatibility_level = 0, compatibility_level = 0,
) )
bazel_dep(name = "bazel_skylib", version = "1.4.2") bazel_dep(name = "bazel_skylib", version = "1.4.2")
bazel_dep(name = "rules_cc", version = "0.0.8") bazel_dep(name = "rules_cc", version = "0.0.8")
bazel_dep(name = "platforms", version = "0.0.6") bazel_dep(name = "platforms", version = "0.0.7")

View File

@ -24,11 +24,11 @@ Minimum bazel version: **6.0.0** (6.1.0 if using blzmod)
If you're using `bzlmod`, add the following to `MODULE.bazel`: If you're using `bzlmod`, add the following to `MODULE.bazel`:
```starlark ```starlark
bazel_dep(name = "llvm_toolchain", version = "0.9") bazel_dep(name = "toolchains_llvm", version = "0.10.0")
llvm = use_extension("@llvm_toolchain//toolchain/extensions:llvm.bzl", "llvm") llvm = use_extension("@toolchains_llvm//toolchain/extensions:llvm.bzl", "llvm")
llvm.toolchain( llvm.toolchain(
llvm_version = "15.0.6", llvm_version = "16.0.0",
) )
use_repo(llvm, "llvm_toolchain") use_repo(llvm, "llvm_toolchain")
@ -46,25 +46,25 @@ BAZEL_TOOLCHAIN_TAG = "0.9"
BAZEL_TOOLCHAIN_SHA = "95f0bab6982c7e5a83447e08bf32fa7a47f210169da5e5ec62411fef0d8e7f59" BAZEL_TOOLCHAIN_SHA = "95f0bab6982c7e5a83447e08bf32fa7a47f210169da5e5ec62411fef0d8e7f59"
http_archive( http_archive(
name = "com_grail_bazel_toolchain", name = "toolchains_llvm",
sha256 = BAZEL_TOOLCHAIN_SHA, sha256 = BAZEL_TOOLCHAIN_SHA,
strip_prefix = "bazel-toolchain-{tag}".format(tag = BAZEL_TOOLCHAIN_TAG), strip_prefix = "bazel-toolchain-{tag}".format(tag = BAZEL_TOOLCHAIN_TAG),
canonical_id = BAZEL_TOOLCHAIN_TAG, canonical_id = BAZEL_TOOLCHAIN_TAG,
url = "https://github.com/grailbio/bazel-toolchain/archive/refs/tags/{tag}.tar.gz".format(tag = BAZEL_TOOLCHAIN_TAG), url = "https://github.com/grailbio/bazel-toolchain/archive/refs/tags/{tag}.tar.gz".format(tag = BAZEL_TOOLCHAIN_TAG),
) )
load("@com_grail_bazel_toolchain//toolchain:deps.bzl", "bazel_toolchain_dependencies") load("@toolchains_llvm//toolchain:deps.bzl", "bazel_toolchain_dependencies")
bazel_toolchain_dependencies() bazel_toolchain_dependencies()
load("@com_grail_bazel_toolchain//toolchain:rules.bzl", "llvm_toolchain") load("@toolchains_llvm//toolchain:rules.bzl", "llvm_toolchain")
llvm_toolchain( llvm_toolchain(
name = "llvm_toolchain", name = "llvm_toolchain",
llvm_version = "16.0.0", llvm_version = "16.0.0",
) )
load("@llvm_toolchain//:toolchains.bzl", "llvm_register_toolchains") load("@toolchains_llvm//:toolchains.bzl", "llvm_register_toolchains")
llvm_register_toolchains() llvm_register_toolchains()
``` ```
@ -194,7 +194,7 @@ The following mechanisms are available for using an LLVM toolchain:
attribute. When using a bazel package path, each of the values is typically attribute. When using a bazel package path, each of the values is typically
a package in the user's workspace or configured through `local_repository` or a package in the user's workspace or configured through `local_repository` or
`http_archive`; the BUILD file of the package should be similar to `http_archive`; the BUILD file of the package should be similar to
`@com_grail_bazel_toolchain//toolchain:BUILD.llvm_repo`. If using only `@toolchains_llvm//toolchain:BUILD.llvm_repo`. If using only
`http_archive`, maybe consider using the `urls` attribute instead to get more `http_archive`, maybe consider using the `urls` attribute instead to get more
flexibility if you need. flexibility if you need.
4. All the above options rely on host OS information, and are not suited for 4. All the above options rely on host OS information, and are not suited for
@ -233,7 +233,7 @@ the [test script](tests/scripts/run_xcompile_tests.sh) for cross-compilation.
```sh ```sh
bazel build \ bazel build \
--platforms=@com_grail_bazel_toolchain//platforms:linux-x86_64 \ --platforms=@toolchains_llvm//platforms:linux-x86_64 \
--extra_toolchains=@llvm_toolchain_with_sysroot//:cc-toolchain-x86_64-linux \ --extra_toolchains=@llvm_toolchain_with_sysroot//:cc-toolchain-x86_64-linux \
//... //...
``` ```

View File

@ -13,5 +13,5 @@
# limitations under the License. # limitations under the License.
workspace( workspace(
name = "com_grail_bazel_toolchain", name = "toolchains_llvm",
) )

View File

@ -1,13 +1,27 @@
module(name = "com_grail_bazel_toolchain_tests") # Copyright 2023 The Bazel Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
bazel_dep(name = "llvm_toolchain", version = "0.8.2", repo_name = "com_grail_bazel_toolchain") module(name = "toolchains_llvm_tests")
bazel_dep(name = "toolchains_llvm", version = "0.0.0")
local_path_override( local_path_override(
module_name = "llvm_toolchain", module_name = "toolchains_llvm",
path = "..", path = "..",
) )
bazel_dep(name = "bazel_skylib", version = "1.4.2") bazel_dep(name = "bazel_skylib", version = "1.4.2")
bazel_dep(name = "platforms", version = "0.0.6") bazel_dep(name = "platforms", version = "0.0.7")
bazel_dep(name = "rules_cc", version = "0.0.8") bazel_dep(name = "rules_cc", version = "0.0.8")
bazel_dep(name = "rules_go", version = "0.41.0", repo_name = "io_bazel_rules_go") bazel_dep(name = "rules_go", version = "0.41.0", repo_name = "io_bazel_rules_go")
bazel_dep(name = "rules_foreign_cc", version = "0.9.0") bazel_dep(name = "rules_foreign_cc", version = "0.9.0")
@ -38,6 +52,15 @@ git_override(
remote = "https://github.com/bazelbuild/rules_rust.git", remote = "https://github.com/bazelbuild/rules_rust.git",
) )
go_sdk = use_extension("@io_bazel_rules_go//go:extensions.bzl", "go_sdk")
go_sdk.download(
name = "go_sdk",
version = "1.21.0",
)
use_repo(go_sdk, "go_toolchains")
register_toolchains("@go_toolchains//:all")
rust = use_extension("@rules_rust//rust:extensions.bzl", "rust") rust = use_extension("@rules_rust//rust:extensions.bzl", "rust")
rust.toolchain(edition = "2021") rust.toolchain(edition = "2021")
use_repo( use_repo(
@ -47,7 +70,7 @@ use_repo(
register_toolchains("@rust_toolchains//:all") register_toolchains("@rust_toolchains//:all")
llvm = use_extension("@com_grail_bazel_toolchain//toolchain/extensions:llvm.bzl", "llvm") llvm = use_extension("@toolchains_llvm//toolchain/extensions:llvm.bzl", "llvm")
# When updating this version, also update the versions associated with # When updating this version, also update the versions associated with
# llvm_toolchain below, sys_paths_test in the workflows file, and xcompile_test # llvm_toolchain below, sys_paths_test in the workflows file, and xcompile_test

View File

@ -12,19 +12,19 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
workspace(name = "com_grail_bazel_toolchain_tests") workspace(name = "toolchains_llvm_tests")
local_repository( local_repository(
name = "com_grail_bazel_toolchain", name = "toolchains_llvm",
path = "..", path = "..",
) )
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@com_grail_bazel_toolchain//toolchain:deps.bzl", "bazel_toolchain_dependencies") load("@toolchains_llvm//toolchain:deps.bzl", "bazel_toolchain_dependencies")
bazel_toolchain_dependencies() bazel_toolchain_dependencies()
load("@com_grail_bazel_toolchain//toolchain:rules.bzl", "llvm_toolchain") load("@toolchains_llvm//toolchain:rules.bzl", "llvm_toolchain")
# When updating this version, also update the versions associated with # When updating this version, also update the versions associated with
# llvm_toolchain below, sys_paths_test in the workflows file, and xcompile_test # llvm_toolchain below, sys_paths_test in the workflows file, and xcompile_test
@ -186,11 +186,14 @@ http_archive(
], ],
) )
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies") load("@io_bazel_rules_go//go:deps.bzl", "go_download_sdk", "go_rules_dependencies")
go_rules_dependencies() go_rules_dependencies()
go_register_toolchains(version = "1.20.5") go_download_sdk(
name = "go_sdk",
version = "1.21.0",
)
# For testing rules_rust. # For testing rules_rust.

View File

@ -1,4 +1,4 @@
workspace(name = "com_grail_bazel_toolchain_tests") workspace(name = "toolchains_llvm_tests")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

View File

@ -50,10 +50,10 @@ CONF_FILES = [
genrule( genrule(
name = "configure", name = "configure",
srcs = [("@com_grail_bazel_toolchain//tests/openssl:" + f) for f in CONF_FILES], srcs = [("@toolchains_llvm_tests//openssl:" + f) for f in CONF_FILES],
outs = CONF_FILES, outs = CONF_FILES,
cmd = "\n".join([ cmd = "\n".join([
"cp $(location @com_grail_bazel_toolchain//tests/openssl:{0}) $(location {0})".format(f) "cp $(location @toolchains_llvm_tests//openssl:{0}) $(location {0})".format(f)
for f in CONF_FILES for f in CONF_FILES
]), ]),
visibility = ["//visibility:private"], visibility = ["//visibility:private"],

View File

@ -31,7 +31,6 @@ fi
test_args=( test_args=(
"${common_test_args[@]}" "${common_test_args[@]}"
"--linkopt=-nopie" # Not needed after https://github.com/bazelbuild/rules_go/pull/3692.
"--copt=-Wno-deprecated-builtins" # https://github.com/abseil/abseil-cpp/issues/1201 "--copt=-Wno-deprecated-builtins" # https://github.com/abseil/abseil-cpp/issues/1201
) )

View File

@ -36,7 +36,7 @@ echo ""
echo "Testing static linked user libraries and dynamic linked system libraries" echo "Testing static linked user libraries and dynamic linked system libraries"
build_args=( build_args=(
--incompatible_enable_cc_toolchain_resolution --incompatible_enable_cc_toolchain_resolution
--platforms=@com_grail_bazel_toolchain//platforms:linux-x86_64 --platforms=@toolchains_llvm//platforms:linux-x86_64
--extra_toolchains=@llvm_toolchain_with_sysroot//:cc-toolchain-x86_64-linux --extra_toolchains=@llvm_toolchain_with_sysroot//:cc-toolchain-x86_64-linux
--symlink_prefix=/ --symlink_prefix=/
--color=yes --color=yes

View File

@ -1,8 +1,8 @@
"""LLVM extension for use with bzlmod""" """LLVM extension for use with bzlmod"""
load("@llvm_toolchain//toolchain:rules.bzl", "llvm_toolchain") load("@toolchains_llvm//toolchain:rules.bzl", "llvm_toolchain")
load( load(
"@llvm_toolchain//toolchain/internal:repo.bzl", "@toolchains_llvm//toolchain/internal:repo.bzl",
_llvm_config_attrs = "llvm_config_attrs", _llvm_config_attrs = "llvm_config_attrs",
_llvm_repo_attrs = "llvm_repo_attrs", _llvm_repo_attrs = "llvm_repo_attrs",
) )