From e3180f815b650060321a6743a1d6e9eb2910c177 Mon Sep 17 00:00:00 2001 From: Matt Date: Wed, 12 Aug 2026 23:12:17 +0100 Subject: [PATCH 1/4] feat: build on GLIBC=2.31 for older distro compatibility --- .github/workflows/ci.yml | 4 ++-- CLAUDE.md | 10 ++++++++-- CMakeLists.txt | 2 +- build-generic-linux.sh | 26 +++++++++++++++++++++----- 4 files changed, 32 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 95f47ca80..c59ebfff8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -200,9 +200,9 @@ jobs: run: | docker rmi $MEMGRAPH_IMAGE || true if [[ "${{ matrix.arch }}" == "X64" ]]; then - docker rmi memgraph/mgbuild:v7_centos-9 || true + docker rmi memgraph/mgbuild:v8_ubuntu-24.04 || true elif [[ "${{ matrix.arch }}" == "ARM64" ]]; then - docker rmi memgraph/mgbuild:v7_debian-12-arm || true + docker rmi memgraph/mgbuild:v8_ubuntu-24.04-arm || true fi docker_build_and_test: diff --git a/CLAUDE.md b/CLAUDE.md index fcc674749..17109ea47 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -24,8 +24,14 @@ The binary lands at `build/src/mgconsole`. `compile_commands.json` is emitted in `-Wall -Wextra -pedantic -Werror` is enabled — warnings break the build. **Static / release build** (matches what ships): `./build-generic-linux.sh` builds inside the -`memgraph/mgbuild` Docker image with the Memgraph toolchain and `-DMGCONSOLE_STATIC_SSL=ON`, -producing `build/generic/mgconsole`. +`memgraph/mgbuild:v8_ubuntu-24.04` image with the Memgraph toolchain and +`-DMGCONSOLE_STATIC_SSL=ON`, producing `build/generic/mgconsole`. It exports `CC`/`CXX` pointing +at `/opt/toolchain-v8/bin/{gcc,g++}` (configured `--with-sysroot`) plus +`OPENSSL_ROOT_DIR=/opt/toolchain-v8/sysroot/usr`, so everything — including the +`ExternalProject` deps, which inherit the environment but not CMake toolchain settings — links +against the toolchain's GLIBC 2.31 sysroot instead of the image's GLIBC 2.39. That's what keeps +the generic binary runnable on older distros; the script prints the maximum `GLIBC_*` version +the binary ends up referencing (currently 2.25). ## Test diff --git a/CMakeLists.txt b/CMakeLists.txt index a18d90832..935c52c13 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,7 +15,7 @@ # along with this program. If not, see . cmake_minimum_required(VERSION 3.10) -project(mgconsole VERSION 1.7.0) +project(mgconsole VERSION 1.7.1) include(CTest) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake) diff --git a/build-generic-linux.sh b/build-generic-linux.sh index c12e5502f..896a0fc1c 100755 --- a/build-generic-linux.sh +++ b/build-generic-linux.sh @@ -22,11 +22,15 @@ function cleanup() { exit $status } -ARCH="$(arch)" +TOOLCHAIN_ROOT="/opt/toolchain-v8" +ARCH="$(uname -m)" if [[ $ARCH == "x86_64" ]]; then - DOCKER_IMAGE="memgraph/mgbuild:v7_centos-9" # libc 2.34 + DOCKER_IMAGE="memgraph/mgbuild:v8_ubuntu-24.04" elif [[ $ARCH == "aarch64" ]]; then - DOCKER_IMAGE="memgraph/mgbuild:v7_debian-12-arm" # libc 2.36 + DOCKER_IMAGE="memgraph/mgbuild:v8_ubuntu-24.04-arm" +else + echo -e "${RED}Unsupported architecture: $ARCH${RESET}" + exit 1 fi trap cleanup EXIT ERR @@ -38,13 +42,25 @@ echo -e "${GREEN}Copying mgconsole source code to build container...${RESET}" docker cp "$PROJECT_ROOT/." builder:/home/mg/mgconsole docker exec -u root builder bash -c "chown -R mg:mg /home/mg/mgconsole" +# Build against the toolchain sysroot (glibc 2.31) +# --strip on install: the sysroot gcc build carries debug info (~21MB -> ~8MB). echo -e "${GREEN}Building mgconsole...${RESET}" docker exec -u mg builder bash -c " - source /opt/toolchain-v7/activate && \ + source $TOOLCHAIN_ROOT/activate && \ + export CC=$TOOLCHAIN_ROOT/bin/gcc CXX=$TOOLCHAIN_ROOT/bin/g++ && \ + export OPENSSL_ROOT_DIR=$TOOLCHAIN_ROOT/sysroot/usr && \ cd /home/mg/mgconsole && \ cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DMGCONSOLE_STATIC_SSL=ON -DCMAKE_INSTALL_PREFIX=/home/mg/mgconsole/build/install . && \ cmake --build build && \ - cmake --install build" + cmake --install build --strip" + +echo -e "${GREEN}Checking GLIBC requirement of the binary...${RESET}" +docker exec -u mg builder bash -c ' + source '"$TOOLCHAIN_ROOT"'/activate + versions=$(objdump -T /home/mg/mgconsole/build/install/bin/mgconsole \ + | grep -oE "GLIBC_[0-9]+(\.[0-9]+)+" | sort -uV) + echo "Referenced GLIBC versions: $(echo $versions)" + echo "Maximum GLIBC version required: $(echo "$versions" | tail -n 1)"' echo -e "${GREEN}Saving build...${RESET}" mkdir -p "$PROJECT_ROOT/build/generic" From b3ad5a8441610049330c62996eba3c1ecaa3a890 Mon Sep 17 00:00:00 2001 From: Matt Date: Thu, 13 Aug 2026 09:17:40 +0100 Subject: [PATCH 2/4] use git ref for Docker build --- .github/workflows/ci.yml | 2 +- Dockerfile | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c59ebfff8..37ea7c557 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -215,7 +215,7 @@ jobs: - name: Build and test mgconsole in Docker container run: | - docker build -t mgconsole . + docker build --build-arg GIT_REF=${{ github.sha }} -t mgconsole . - name: Run latest Memgraph Docker container run: | diff --git a/Dockerfile b/Dockerfile index 9e15873a2..3fcd779eb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,14 +12,16 @@ RUN apt-get update && apt-get install -y \ libssl-dev \ && rm -rf /var/lib/apt/lists/* -RUN git clone https://github.com/memgraph/mgconsole.git /mgconsole +ARG GIT_REF=master + +RUN git clone https://github.com/memgraph/mgconsole.git /mgconsole && \ + git -C /mgconsole checkout --detach "$GIT_REF" WORKDIR /mgconsole -RUN mkdir build && cd build && \ - cmake -DCMAKE_BUILD_TYPE=Release .. && \ - make && \ - make install +RUN cmake -B build -DCMAKE_BUILD_TYPE=Release . && \ + cmake --build build && \ + cmake --install build --strip FROM gcr.io/distroless/base-debian13:debug From 7c33b0d8ff5da58787d21db6566b4532dcc9d727 Mon Sep 17 00:00:00 2001 From: Matt Date: Thu, 13 Aug 2026 10:20:37 +0100 Subject: [PATCH 3/4] added -i to the docker test --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 37ea7c557..cd34db2be 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,6 @@ name: CI -on: +on: push: workflow_dispatch: inputs: @@ -43,7 +43,7 @@ jobs: uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 with: name: "mgconsole_ctest.log" - path: build/Testing/Temporary/LastTest.log + path: build/Testing/Temporary/LastTest.log build_windows_mingw: name: Build and test mgconsole on Windows @@ -240,11 +240,11 @@ jobs: - name: Test mgconsole in Docker container run: | # Test pipe directly into docker run - echo "RETURN 1;" | docker run --network host mgconsole:latest + echo "RETURN 1;" | docker run --network host -i mgconsole:latest # Test entrypoint override with echo docker run --network host --rm --entrypoint sh mgconsole:latest -c "echo 'RETURN 1;' | mgconsole" - + - name: Cleanup docker images run: | docker rmi mgconsole || true From 0a3cd6378ab68700e5f41bde3826c2a3d66be6a1 Mon Sep 17 00:00:00 2001 From: Matt Date: Thu, 13 Aug 2026 10:29:38 +0100 Subject: [PATCH 4/4] ship stripped binary --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 3fcd779eb..c9ba38703 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,6 +27,6 @@ FROM gcr.io/distroless/base-debian13:debug WORKDIR /mgconsole -COPY --from=builder /mgconsole/build/src/mgconsole /usr/local/bin/mgconsole +COPY --from=builder /bin/mgconsole /usr/local/bin/mgconsole ENTRYPOINT ["mgconsole"]