|
| 1 | +#!/usr/bin/env bash |
| 2 | +# Licensed to the Apache Software Foundation (ASF) under one or more |
| 3 | +# contributor license agreements. See the NOTICE file distributed with this |
| 4 | +# work for additional information regarding copyright ownership. The ASF |
| 5 | +# licenses this file to you under the Apache License, Version 2.0 (the |
| 6 | +# "License"); you may not use this file except in compliance with the |
| 7 | +# License. You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, software |
| 12 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +# See the License for the specific language governing permissions and |
| 15 | +# limitations under the License. |
| 16 | +# |
| 17 | +# Build client-cpp in manylinux2014 and verify max required GLIBC symbol <= 2.17. |
| 18 | +set -euxo pipefail |
| 19 | + |
| 20 | +MACHINE=$(uname -m) |
| 21 | +case "${MACHINE}" in |
| 22 | + x86_64) |
| 23 | + CMAKE_PKG_ARCH=linux-x86_64 |
| 24 | + JDK_API_ARCH=linux/x64 |
| 25 | + DEFAULT_CLASSIFIER=linux-x86_64-glibc217 |
| 26 | + ;; |
| 27 | + aarch64) |
| 28 | + CMAKE_PKG_ARCH=linux-aarch64 |
| 29 | + JDK_API_ARCH=linux/aarch64 |
| 30 | + DEFAULT_CLASSIFIER=linux-aarch64-glibc217 |
| 31 | + ;; |
| 32 | + *) |
| 33 | + echo "Unsupported architecture: ${MACHINE}" >&2 |
| 34 | + exit 1 |
| 35 | + ;; |
| 36 | +esac |
| 37 | + |
| 38 | +PACKAGE_CLASSIFIER="${PACKAGE_CLASSIFIER:-${DEFAULT_CLASSIFIER}}" |
| 39 | + |
| 40 | +CMAKE_VERSION=3.28.4 |
| 41 | +CMAKE_DIR="/opt/cmake-${CMAKE_VERSION}" |
| 42 | +if [[ ! -x "${CMAKE_DIR}/bin/cmake" ]]; then |
| 43 | + wget -q "https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-${CMAKE_PKG_ARCH}.tar.gz" -O /tmp/cmake.tar.gz |
| 44 | + rm -rf "${CMAKE_DIR}" |
| 45 | + mkdir -p /opt |
| 46 | + tar xf /tmp/cmake.tar.gz -C /opt |
| 47 | + mv "/opt/cmake-${CMAKE_VERSION}-${CMAKE_PKG_ARCH}" "${CMAKE_DIR}" |
| 48 | +fi |
| 49 | + |
| 50 | +JAVA_HOME=/opt/jdk-17 |
| 51 | +if [[ ! -x "${JAVA_HOME}/bin/java" ]]; then |
| 52 | + wget -qL -O /tmp/jdk17.tar.gz "https://api.adoptium.net/v3/binary/latest/17/ga/${JDK_API_ARCH}/jdk/hotspot/normal/eclipse?project=jdk" |
| 53 | + rm -rf /opt/jdk-17* |
| 54 | + mkdir -p /opt |
| 55 | + tar xf /tmp/jdk17.tar.gz -C /opt |
| 56 | + JAVA_HOME=$(find /opt -maxdepth 1 -type d -name 'jdk-17*' -print -quit) |
| 57 | + ln -sfn "${JAVA_HOME}" /opt/jdk-17 |
| 58 | + JAVA_HOME=/opt/jdk-17 |
| 59 | +fi |
| 60 | + |
| 61 | +export PATH="${CMAKE_DIR}/bin:${JAVA_HOME}/bin:${PATH}" |
| 62 | +export JAVA_HOME |
| 63 | + |
| 64 | +gcc --version |
| 65 | +cmake --version |
| 66 | +java -version |
| 67 | + |
| 68 | +cd "${GITHUB_WORKSPACE:?GITHUB_WORKSPACE is not set}" |
| 69 | +./mvnw clean package -P with-cpp -pl iotdb-client/client-cpp -am -DskipTests \ |
| 70 | + -Dspotless.skip=true \ |
| 71 | + -Dclient.cpp.package.classifier="${PACKAGE_CLASSIFIER}" |
| 72 | + |
| 73 | +SO="iotdb-client/client-cpp/target/install/lib/libiotdb_session.so" |
| 74 | +test -f "${SO}" |
| 75 | + |
| 76 | +echo "=== Build host glibc ===" |
| 77 | +ldd --version 2>&1 | sed -n '1p' |
| 78 | + |
| 79 | +echo "=== Highest GLIBC_* symbols in libiotdb_session.so ===" |
| 80 | +objdump -T "${SO}" | grep GLIBC_ | sed "s/.*GLIBC_/GLIBC_/" | sort -Vu | tail -10 |
| 81 | + |
| 82 | +max_glibc=$(objdump -T "${SO}" | grep -oE "GLIBC_[0-9.]+" | sed "s/GLIBC_//" | sort -t. -k1,1n -k2,2n -k3,3n | tail -1) |
| 83 | +echo "max_glibc=${max_glibc}" |
| 84 | + |
| 85 | +if awk -v max="${max_glibc}" "BEGIN { exit !(max > 2.17) }"; then |
| 86 | + echo "ERROR: libiotdb_session.so requires glibc > 2.17 (max=${max_glibc})" |
| 87 | + exit 1 |
| 88 | +fi |
| 89 | + |
| 90 | +echo "glibc compatibility check passed (max=${max_glibc} <= 2.17)" |
0 commit comments