|
| 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 inside CentOS 7 + devtoolset-8 for glibc 2.17-compatible .so. |
| 18 | +set -euxo pipefail |
| 19 | + |
| 20 | +# CentOS 7 EOL: use vault mirrors when default mirrors are unavailable. |
| 21 | +if grep -q mirrorlist /etc/yum.repos.d/CentOS-*.repo 2>/dev/null; then |
| 22 | + sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*.repo |
| 23 | + sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*.repo |
| 24 | +fi |
| 25 | + |
| 26 | +yum install -y centos-release-scl epel-release |
| 27 | +yum install -y devtoolset-8-gcc devtoolset-8-gcc-c++ devtoolset-8-binutils \ |
| 28 | + make wget tar which git patch unzip |
| 29 | + |
| 30 | +CMAKE_VERSION=3.28.4 |
| 31 | +CMAKE_DIR=/opt/cmake-${CMAKE_VERSION} |
| 32 | +if [[ ! -x "${CMAKE_DIR}/bin/cmake" ]]; then |
| 33 | + wget -q "https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-linux-x86_64.tar.gz" \ |
| 34 | + -O /tmp/cmake.tar.gz |
| 35 | + rm -rf "${CMAKE_DIR}" |
| 36 | + mkdir -p /opt |
| 37 | + tar xf /tmp/cmake.tar.gz -C /opt |
| 38 | + mv "/opt/cmake-${CMAKE_VERSION}-linux-x86_64" "${CMAKE_DIR}" |
| 39 | +fi |
| 40 | + |
| 41 | +JAVA_HOME=/opt/jdk-17 |
| 42 | +if [[ ! -x "${JAVA_HOME}/bin/java" ]]; then |
| 43 | + wget -q "https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.13%2B11/OpenJDK17U-jdk_x64_linux_hotspot_17.0.13_11.tar.gz" \ |
| 44 | + -O /tmp/jdk17.tar.gz |
| 45 | + rm -rf "${JAVA_HOME}" |
| 46 | + mkdir -p /opt |
| 47 | + tar xf /tmp/jdk17.tar.gz -C /opt |
| 48 | + mv /opt/jdk-17.0.13+11 "${JAVA_HOME}" |
| 49 | +fi |
| 50 | + |
| 51 | +export PATH="${CMAKE_DIR}/bin:${JAVA_HOME}/bin:${PATH}" |
| 52 | +export JAVA_HOME |
| 53 | + |
| 54 | +scl enable devtoolset-8 -- bash -c ' |
| 55 | + set -euxo pipefail |
| 56 | + gcc --version |
| 57 | + cmake --version |
| 58 | + java -version |
| 59 | + cd "${GITHUB_WORKSPACE:?GITHUB_WORKSPACE is not set}" |
| 60 | + ./mvnw clean package -P with-cpp -pl iotdb-client/client-cpp -am -DskipTests \ |
| 61 | + -Dspotless.skip=true \ |
| 62 | + -Dclient.cpp.package.classifier=linux-x86_64-glibc217 |
| 63 | +' |
| 64 | + |
| 65 | +SO="iotdb-client/client-cpp/target/install/lib/libiotdb_session.so" |
| 66 | +test -f "${SO}" |
| 67 | + |
| 68 | +echo "=== Build host glibc ===" |
| 69 | +ldd --version | head -1 |
| 70 | + |
| 71 | +echo "=== Highest GLIBC_* symbols in libiotdb_session.so ===" |
| 72 | +objdump -T "${SO}" | grep GLIBC_ | sed "s/.*GLIBC_/GLIBC_/" | sort -Vu | tail -10 |
| 73 | + |
| 74 | +max_glibc=$(objdump -T "${SO}" | grep -oE "GLIBC_[0-9.]+" | sed "s/GLIBC_//" | sort -t. -k1,1n -k2,2n -k3,3n | tail -1) |
| 75 | +echo "max_glibc=${max_glibc}" |
| 76 | + |
| 77 | +# Fail if any symbol requires glibc newer than 2.17 |
| 78 | +if awk -v max="${max_glibc}" "BEGIN { exit !(max > 2.17) }"; then |
| 79 | + echo "ERROR: libiotdb_session.so requires glibc > 2.17 (max=${max_glibc})" |
| 80 | + exit 1 |
| 81 | +fi |
| 82 | + |
| 83 | +echo "glibc compatibility check passed (max=${max_glibc} <= 2.17)" |
0 commit comments