Skip to content

Do the simplest thing to build with musl #10

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

Merged
merged 2 commits into from
Sep 27, 2024
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: 5 additions & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ build:java21 --tool_java_runtime_version=remotejdk_21
import %workspace%/tools/javacopts.bazelrc

# For release, stamp binaries, use optimized mode w/ minimum line table debugging.
build:release --stamp -c opt --copt=-gmlt
build:release --stamp -c opt

# Use the RBE instance in the kythe-repo project
build:remote --remote_instance_name=projects/kythe-repo/instances/default_instance --bes_instance_name=kythe-repo
Expand Down Expand Up @@ -124,6 +124,10 @@ build:remote --repo_env=KYTHE_DO_NOT_DETECT_BAZEL_TOOLCHAINS=1
build:remote --extra_toolchains=//tools/build_rules/lexyacc:lexyacc_remote_toolchain
build:remote --extra_toolchains=//tools/build_rules/external_tools:external_tools_remote_toolchain

# Build fully static binaries linked against musl on Linux.
common:static --platforms=//platforms:linux_x86_64_musl
common:static-arm64 --platforms=//platforms:linux_arm64_musl

build:remote --action_env=LEIN_JAVA_CMD=

build:prepush --verbose_failures --noshow_loading_progress --noshow_progress
Expand Down
18 changes: 18 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,21 @@ git_repository(
commit = "133d89a6069ce253a92d32a93fdb7db9ef100e9d",
remote = "https://github.com/erenon/bazel_clang_tidy.git",
)

http_archive(
name = "musl_toolchains",
sha256 = "26cacffab74e10f0840c83b0be9193dc6deccfbc8ec1cf6f8362dc61d0057fa1",
url = "https://github.com/bazel-contrib/musl-toolchain/releases/download/v0.1.15/musl_toolchain-v0.1.15.tar.gz",
)

load("@musl_toolchains//:repositories.bzl", "load_musl_toolchains")

load_musl_toolchains(
extra_target_compatible_with = [
"@//toolchains:musl_on",
],
)

load("@musl_toolchains//:toolchains.bzl", "register_musl_toolchains")

register_musl_toolchains()
23 changes: 23 additions & 0 deletions platforms/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package(default_visibility = ["//visibility:public"])

# Target this platforms with --platforms for a static build linked against musl libc.
# Only meant to be used as a target platform.
platform(
name = "linux_x86_64_musl",
constraint_values = [
"@platforms//cpu:x86_64",
"@platforms//os:linux",
"//toolchains:musl_on",
],
)

# Target this platforms with --platforms for a static build linked against musl libc.
# Only meant to be used as a target platform.
platform(
name = "linux_arm64_musl",
constraint_values = [
"@platforms//cpu:arm64",
"@platforms//os:linux",
"//toolchains:musl_on",
],
)
23 changes: 23 additions & 0 deletions toolchains/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
constraint_setting(
name = "use_musl",
default_constraint_value = ":musl_off",
visibility = [
"//visibility:public",
],
)

constraint_value(
name = "musl_on",
constraint_setting = ":use_musl",
visibility = [
"//visibility:public",
],
)

constraint_value(
name = "musl_off",
constraint_setting = ":use_musl",
visibility = [
"//visibility:public",
],
)