Brian Silverman | 7d89e28 | 2021-11-17 17:36:54 -0800 | [diff] [blame^] | 1 | #!/bin/bash |
| 2 | # Copyright 2021 The Bazel Authors. |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | |
| 16 | set -euo pipefail |
| 17 | |
| 18 | source "$(dirname "${BASH_SOURCE[0]}")/bazel.sh" |
| 19 | "${bazel}" version |
| 20 | |
| 21 | binpath="$("${bazel}" info bazel-bin)/tests/stdlib_test" |
| 22 | |
| 23 | check_with_image() { |
| 24 | if "${CI:-false}"; then |
| 25 | # macOS GitHub Action Runners do not have docker installed on them. |
| 26 | return |
| 27 | fi |
| 28 | local image="$1" |
| 29 | docker run --rm --mount "type=bind,source=${binpath},target=/stdlib_test" "${image}" /stdlib_test |
| 30 | } |
| 31 | |
| 32 | echo "" |
| 33 | echo "Testing static linked user libraries and dynamic linked system libraries" |
| 34 | build_args=( |
| 35 | --incompatible_enable_cc_toolchain_resolution |
| 36 | --platforms=//platforms:linux-x86_64 |
| 37 | --extra_toolchains=@llvm_toolchain_with_sysroot//:cc-toolchain-x86_64-linux |
| 38 | --symlink_prefix=/ |
| 39 | --color=yes |
| 40 | --show_progress_rate_limit=30 |
| 41 | ) |
| 42 | "${bazel}" --bazelrc=/dev/null build "${build_args[@]}" //tests:stdlib_test |
| 43 | file "${binpath}" | tee /dev/stderr | grep -q ELF |
| 44 | check_with_image "frolvlad/alpine-glibc" # Need glibc image for system libraries. |
| 45 | |
| 46 | echo "" |
| 47 | echo "Testing static linked user and system libraries" |
| 48 | build_args+=( |
| 49 | --features=fully_static_link |
| 50 | ) |
| 51 | "${bazel}" --bazelrc=/dev/null build "${build_args[@]}" //tests:stdlib_test |
| 52 | file "${binpath}" | tee /dev/stderr | grep -q ELF |
| 53 | check_with_image "alpine" |