From 068161f473c7c06c0a48afadbed12f1c6b1625ac Mon Sep 17 00:00:00 2001 From: Vihang Mehta Date: Thu, 1 Jun 2023 16:05:53 -0700 Subject: [PATCH] Remove unused musl toolchain (#1401) 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 --- bazel/cc_toolchains/BUILD.bazel | 4 +- bazel/cc_toolchains/gcc.bzl | 128 ------------------ bazel/cc_toolchains/settings.bzl | 1 - bazel/cc_toolchains/toolchains.bzl | 1 - bazel/toolchain_transitions.bzl | 9 -- docker.properties | 8 +- tools/chef/base_image_version.txt | 2 +- .../cookbooks/px_dev/attributes/linux_debs.rb | 6 - tools/chef/cookbooks/px_dev/recipes/linux.rb | 2 - .../px_dev/recipes/linux_gcc_musl.rb | 31 ----- tools/docker/musl_cross_image/Dockerfile | 52 ------- 11 files changed, 6 insertions(+), 238 deletions(-) delete mode 100644 tools/chef/cookbooks/px_dev/recipes/linux_gcc_musl.rb delete mode 100644 tools/docker/musl_cross_image/Dockerfile diff --git a/bazel/cc_toolchains/BUILD.bazel b/bazel/cc_toolchains/BUILD.bazel index d47926f9925..5d47cf46146 100644 --- a/bazel/cc_toolchains/BUILD.bazel +++ b/bazel/cc_toolchains/BUILD.bazel @@ -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") @@ -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", diff --git a/bazel/cc_toolchains/gcc.bzl b/bazel/cc_toolchains/gcc.bzl index 4a1de9dbc7b..eebef675688 100644 --- a/bazel/cc_toolchains/gcc.bzl +++ b/bazel/cc_toolchains/gcc.bzl @@ -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 diff --git a/bazel/cc_toolchains/settings.bzl b/bazel/cc_toolchains/settings.bzl index 72382e28fe5..968b41a368a 100644 --- a/bazel/cc_toolchains/settings.bzl +++ b/bazel/cc_toolchains/settings.bzl @@ -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", diff --git a/bazel/cc_toolchains/toolchains.bzl b/bazel/cc_toolchains/toolchains.bzl index 9556736773b..7e4549f86c3 100644 --- a/bazel/cc_toolchains/toolchains.bzl +++ b/bazel/cc_toolchains/toolchains.bzl @@ -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 diff --git a/bazel/toolchain_transitions.bzl b/bazel/toolchain_transitions.bzl index c17beda8c79..65caa6e6c7b 100644 --- a/bazel/toolchain_transitions.bzl +++ b/bazel/toolchain_transitions.bzl @@ -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, { diff --git a/docker.properties b/docker.properties index 1076b40c901..ede2cc4b00d 100644 --- a/docker.properties +++ b/docker.properties @@ -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 diff --git a/tools/chef/base_image_version.txt b/tools/chef/base_image_version.txt index 224669e8d96..d94681b7a73 100644 --- a/tools/chef/base_image_version.txt +++ b/tools/chef/base_image_version.txt @@ -1 +1 @@ -202305101040 +202305312341 diff --git a/tools/chef/cookbooks/px_dev/attributes/linux_debs.rb b/tools/chef/cookbooks/px_dev/attributes/linux_debs.rb index 153fae52483..6aced06adf9 100644 --- a/tools/chef/cookbooks/px_dev/attributes/linux_debs.rb +++ b/tools/chef/cookbooks/px_dev/attributes/linux_debs.rb @@ -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' diff --git a/tools/chef/cookbooks/px_dev/recipes/linux.rb b/tools/chef/cookbooks/px_dev/recipes/linux.rb index 77ea0659df1..45a5af0c35e 100644 --- a/tools/chef/cookbooks/px_dev/recipes/linux.rb +++ b/tools/chef/cookbooks/px_dev/recipes/linux.rb @@ -67,5 +67,3 @@ command 'systemctl enable docker' action :run end - -include_recipe 'px_dev::linux_gcc_musl' diff --git a/tools/chef/cookbooks/px_dev/recipes/linux_gcc_musl.rb b/tools/chef/cookbooks/px_dev/recipes/linux_gcc_musl.rb deleted file mode 100644 index b8b9f562703..00000000000 --- a/tools/chef/cookbooks/px_dev/recipes/linux_gcc_musl.rb +++ /dev/null @@ -1,31 +0,0 @@ -# Copyright 2018- The Pixie 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. -# -# SPDX-License-Identifier: Apache-2.0 - -remote_file '/tmp/gcc_musl.deb' do - source node['gcc-musl']['deb'] - mode '0644' - checksum node['gcc-musl']['deb_sha256'] -end - -dpkg_package 'gcc-musl' do - source '/tmp/gcc_musl.deb' - action :install - version node['gcc-musl']['version'] -end - -file '/tmp/gcc_musl.deb' do - action :delete -end diff --git a/tools/docker/musl_cross_image/Dockerfile b/tools/docker/musl_cross_image/Dockerfile deleted file mode 100644 index ac957b2761e..00000000000 --- a/tools/docker/musl_cross_image/Dockerfile +++ /dev/null @@ -1,52 +0,0 @@ -# Copyright 2018- The Pixie 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. -# -# SPDX-License-Identifier: Apache-2.0 - -FROM ubuntu:22.04@sha256:67211c14fa74f070d27cc59d69a7fa9aeff8e28ea118ef3babc295a0428a6d21 - -ENV DEBIAN_FRONTEND=noninteractive -RUN apt-get update -y --fix-missing -RUN apt-get install -y ruby ruby-dev rubygems build-essential git wget patchelf -RUN gem install --no-document fpm - -WORKDIR / -RUN git clone --depth 1 https://github.com/richfelker/musl-cross-make.git - -WORKDIR /musl-cross-make -RUN echo '\n\ -TARGET=x86_64-alpine-linux-musl\n\ -GCC_VER=11.2.0\n\ -OUTPUT=/opt/gcc-musl-11.2.0\n\ -MUSL_CONFIG=CFLAGS="-fPIC" CXXFLAGS="-fPIC"\n\ -' > config.mak - -RUN make -j$(nproc) install - -# By default the cross-compiled gcc will link against libc.so instead of what alpine uses. -# Thist patch forces the cross-compiled gcc to produce shared links that appear the same as shared links from a native alpine toolchain. -RUN patchelf --set-soname libc.musl-x86_64.so.1 /opt/gcc-musl-11.2.0/x86_64-alpine-linux-musl/lib/libc.so - - -WORKDIR /opt -VOLUME /image -ENV deb_name gcc-musl-libs-11.2.0.deb -# At the moment, we only need the libs produced by the gcc cross build. If we need the full toolchain in the future -# the paths at the end of the command should be changed to just `gcc-musl-11.2.0` - -CMD ["sh", "-c", "fpm -p /image/${deb_name} \ - -s dir -t deb -n gcc-musl-libs -v 11.2.0 --prefix=/opt \ - gcc-musl-11.2.0/lib/gcc/x86_64-alpine-linux-musl/11.2.0 \ - gcc-musl-11.2.0/x86_64-alpine-linux-musl/lib \ - gcc-musl-11.2.0/x86_64-alpine-linux-musl/include"]