blob: b0a7cfb8c4559f5a14cdccb721985a3a27a60909 [file] [log] [blame]
Brian Silverman7d89e282021-11-17 17:36:54 -08001#!/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
16set -euo pipefail
17
18source "$(dirname "${BASH_SOURCE[0]}")/bazel.sh"
19"${bazel}" version
20
21binpath="$("${bazel}" info bazel-bin)/tests/stdlib_test"
22
23check_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
32echo ""
33echo "Testing static linked user libraries and dynamic linked system libraries"
34build_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
43file "${binpath}" | tee /dev/stderr | grep -q ELF
44check_with_image "frolvlad/alpine-glibc" # Need glibc image for system libraries.
45
46echo ""
47echo "Testing static linked user and system libraries"
48build_args+=(
49 --features=fully_static_link
50)
51"${bazel}" --bazelrc=/dev/null build "${build_args[@]}" //tests:stdlib_test
52file "${binpath}" | tee /dev/stderr | grep -q ELF
53check_with_image "alpine"