Skip to content

Commit

Permalink
Remove unused musl toolchain (#1401)
Browse files Browse the repository at this point in the history
Summary: We build musl as an external library and no longer need
to pull it in as a toolchain.

Type of change: /kind cleanup

Test Plan: All existing builds and tests continue to work.

Signed-off-by: Vihang Mehta <[email protected]>
  • Loading branch information
vihangm authored Jun 1, 2023
1 parent 026841f commit 068161f
Show file tree
Hide file tree
Showing 11 changed files with 6 additions and 238 deletions.
4 changes: 1 addition & 3 deletions bazel/cc_toolchains/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
load("//bazel/cc_toolchains:gcc.bzl", "gcc_x86_64_gnu", "gcc_x86_64_static_musl")
load("//bazel/cc_toolchains:gcc.bzl", "gcc_x86_64_gnu")
load("//bazel/cc_toolchains:llvm_libs.bzl", "llvm_variant_settings")
load("//bazel/cc_toolchains:settings.bzl", "settings")

Expand All @@ -27,8 +27,6 @@ llvm_variant_settings()

gcc_x86_64_gnu()

gcc_x86_64_static_musl()

constraint_setting(
name = "is_exec",
default_constraint_value = ":is_exec_true",
Expand Down
128 changes: 0 additions & 128 deletions bazel/cc_toolchains/gcc.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -126,132 +126,4 @@ def _gcc_x86_64_gnu():
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
)

def _gcc_x86_64_static_musl():
tool_paths = {
"ar": "/usr/bin/ar",
"cpp": "/usr/bin/cpp",
"dwp": "/usr/bin/dwp",
"gcc": "/usr/bin/gcc-12",
"gcov": "/usr/bin/gcov",
"ld": "/usr/bin/ld.gold",
# TODO(zasgar): Fix this or remove this.
"llvm-cov": "/opt/clang-15.0/bin/llvm-cov",
"nm": "/usr/bin/nm",
"objcopy": "/usr/bin/objcopy",
"objdump": "/usr/bin/objdump",
"strip": "/usr/bin/strip",
}

musl_gcc_lib_path = "/opt/gcc-musl-11.2.0/lib/gcc/x86_64-alpine-linux-musl/11.2.0"
musl_sysroot_lib_path = "/opt/gcc-musl-11.2.0/x86_64-alpine-linux-musl/lib"

builtin_includes = [
"/opt/gcc-musl-11.2.0/x86_64-alpine-linux-musl/include/c++/11.2.0",
"/opt/gcc-musl-11.2.0/x86_64-alpine-linux-musl/include/c++/11.2.0/x86_64-alpine-linux-musl",
"/opt/gcc-musl-11.2.0/x86_64-alpine-linux-musl/include/c++/11.2.0/backward",
"/opt/gcc-musl-11.2.0/x86_64-alpine-linux-musl/include",
"/opt/gcc-musl-11.2.0/lib/gcc/x86_64-alpine-linux-musl/11.2.0/include",
]

cc_toolchain_config(
name = "gcc_config_x84_64_static_musl",
cpu = "k8",
compiler = "gcc",
toolchain_identifier = "gcc-x86_64-linux-static-musl",
host_system_name = "x86_64-unknown-linux-musl",
target_system_name = "x86_64-unknown-linux-musl",
target_libc = "musl_unknown",
abi_version = "gcc",
abi_libc_version = "musl_unknown",
cxx_builtin_include_directories = builtin_includes,
tool_paths = tool_paths,
compile_flags = [
"-fstack-protector",
"-Wall",
"-Wunused-but-set-parameter",
"-Wno-free-nonheap-object",
"-fno-omit-frame-pointer",
"-nostdinc",
] + [
"-isystem" + path
for path in builtin_includes
],
cxx_flags = [
"-std=c++17",
"-nostdinc++",
],
opt_compile_flags = [
"-g0",
"-O2",
"-D_FORTIFY_SOURCE=1",
"-DNDEBUG",
"-ffunction-sections",
"-fdata-sections",
],
dbg_compile_flags = ["-g"],
link_flags = [
"-nostdlib",
"-Wl,-no-as-needed",
"-Wl,-z,relro,-z,now",
"-pass-exit-codes",
],
unfiltered_link_flags = [
"-L" + musl_gcc_lib_path,
"-L" + musl_sysroot_lib_path,
"-Wl,-Bstatic,-lm,-lc,-lstdc++,-lm,-lgcc,-lgcc_eh,-Bdynamic",
],
opt_link_flags = ["-Wl,--gc-sections"],
unfiltered_compile_flags = [
"-fno-canonical-system-headers",
"-Wno-builtin-macro-redefined",
"-D__DATE__=\"redacted\"",
"-D__TIMESTAMP__=\"redacted\"",
"-D__TIME__=\"redacted\"",
],
coverage_compile_flags = ["--coverage"],
coverage_link_flags = ["--coverage"],
supports_start_end_lib = True,
# The -nostdlib flag means we have to provide our own c runtime objects.
custom_c_runtime_paths = {
"gcc": musl_gcc_lib_path,
"sysroot": musl_sysroot_lib_path,
},
)

cc_toolchain(
name = "cc-compiler-gcc-x86_64-static-musl",
toolchain_identifier = "gcc-x86_64-linux-static-musl",
toolchain_config = "gcc_config_x84_64_static_musl",
# TODO(james): figure out what these files values do, and if we need them.
all_files = ":empty",
ar_files = ":empty",
as_files = ":empty",
compiler_files = ":empty",
dwp_files = ":empty",
linker_files = ":empty",
objcopy_files = ":empty",
strip_files = ":empty",
supports_param_files = 1,
module_map = None,
)

native.toolchain(
name = "cc-toolchain-gcc-x86_64-static-musl",
exec_compatible_with = [
"@platforms//cpu:x86_64",
"@platforms//os:linux",
],
target_compatible_with = [
"@platforms//cpu:x86_64",
"@platforms//os:linux",
],
target_settings = [
":compiler_gcc",
":libc_version_static_musl",
],
toolchain = ":cc-compiler-gcc-x86_64-static-musl",
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
)

gcc_x86_64_gnu = _gcc_x86_64_gnu
gcc_x86_64_static_musl = _gcc_x86_64_static_musl
1 change: 0 additions & 1 deletion bazel/cc_toolchains/settings.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ HOST_GLIBC_VERSION = "glibc_host"
def _settings():
libc_versions = sysroot_libc_versions + [
HOST_GLIBC_VERSION,
"static_musl",
]
string_flag(
name = "libc_version",
Expand Down
1 change: 0 additions & 1 deletion bazel/cc_toolchains/toolchains.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ def _pl_register_cc_toolchains():

native.register_toolchains(
"//bazel/cc_toolchains:cc-toolchain-gcc-x86_64-gnu",
"//bazel/cc_toolchains:cc-toolchain-gcc-x86_64-static-musl",
)

pl_register_cc_toolchains = _pl_register_cc_toolchains
9 changes: 0 additions & 9 deletions bazel/toolchain_transitions.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,6 @@
load("@com_github_fmeum_rules_meta//meta:defs.bzl", "meta")
load("//bazel/test_runners/qemu_with_kernel:runner.bzl", "qemu_with_kernel_interactive_runner")

cc_static_musl_binary = meta.wrap_with_transition(
native.cc_binary,
{
"@//bazel/cc_toolchains:compiler": meta.replace_with("gcc"),
"@//bazel/cc_toolchains:libc_version": meta.replace_with("static_musl"),
},
executable = True,
)

java_graal_binary = meta.wrap_with_transition(
native.java_binary,
{
Expand Down
8 changes: 4 additions & 4 deletions docker.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
DOCKER_IMAGE_TAG=202305310009
LINTER_IMAGE_DIGEST=bc1886d97aa63e816803211370e71d96ce265f8a8237f3ba9f2b71f56ab601ad
DEV_IMAGE_DIGEST=5500a95f9e8c32e3a1f3ab5ede50bfeeeed48075cbcee3dc356b369ac535fc9a
DEV_IMAGE_WITH_EXTRAS_DIGEST=790709678b428f1e39c5ab0b8e39b81659ec697083c3cebc1c93b8c3c5b75a0c
DOCKER_IMAGE_TAG=202305312341
LINTER_IMAGE_DIGEST=a8c72d02e7c5926494cde50a0e946341a9b8cac9ca75516457c60b72a86e3964
DEV_IMAGE_DIGEST=d45138904b68dbe488e8be9874552ce8e00be55e6f5efa69011b10da6b2e3def
DEV_IMAGE_WITH_EXTRAS_DIGEST=7857373d44ead2c8dbf43a5e1af5ba83c093b366f6e10b58167ab8bb9184f8a7
2 changes: 1 addition & 1 deletion tools/chef/base_image_version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
202305101040
202305312341
6 changes: 0 additions & 6 deletions tools/chef/cookbooks/px_dev/attributes/linux_debs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,3 @@
"https://storage.googleapis.com/pixie-dev-public/clang/#{default['clang-linters']['version']}/clang-linters-#{default['clang-linters']['version']}.deb"
default['clang-linters']['deb_sha256'] =
'8a954e9a7e89cf97f91a3bea0119422f6c2f8044380bd204e56b96a098637a2c'

default['gcc-musl']['version'] = '11.2.0'
default['gcc-musl']['deb'] =
"https://storage.googleapis.com/pixie-dev-public/gcc-musl-libs-#{default['gcc-musl']['version']}.deb"
default['gcc-musl']['deb_sha256'] =
'ba52df92bce02f3c2bc53604466e0fac8844f941ae6d2d44061e48403f5752fb'
2 changes: 0 additions & 2 deletions tools/chef/cookbooks/px_dev/recipes/linux.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,3 @@
command 'systemctl enable docker'
action :run
end

include_recipe 'px_dev::linux_gcc_musl'
31 changes: 0 additions & 31 deletions tools/chef/cookbooks/px_dev/recipes/linux_gcc_musl.rb

This file was deleted.

52 changes: 0 additions & 52 deletions tools/docker/musl_cross_image/Dockerfile

This file was deleted.

0 comments on commit 068161f

Please sign in to comment.