Skip to content

Commit 23e3d10

Browse files
guzman109claude
andcommitted
fix(build): statically link libc++ on Linux to remove runtime LLVM dependency
- Add -static-libstdc++ linker flag on Linux/Clang builds so libc++ is embedded in the binary rather than required as a runtime .so - Simplify Dockerfile back to just libssl3 + libpq5; no LLVM apt repo needed Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent f0e28b2 commit 23e3d10

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ target_link_libraries(${PROJECT_NAME}
7272
OpenSSL::Crypto
7373
)
7474

75+
# Statically link libc++ on Linux/Clang so the runtime container needs no LLVM packages.
76+
if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
77+
target_link_options(${PROJECT_NAME} PRIVATE -static-libstdc++ -lc++abi)
78+
endif()
79+
7580
target_compile_definitions(${PROJECT_NAME}
7681
PRIVATE
7782
GLZ_ENABLE_SSL

Dockerfile

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,10 @@
55
# =============================================================================
66
FROM debian:bookworm-slim
77

8-
RUN apt-get update && apt-get install -y wget ca-certificates \
9-
&& wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc \
10-
&& echo "deb http://apt.llvm.org/bookworm/ llvm-toolchain-bookworm-21 main" >> /etc/apt/sources.list.d/llvm-21.list \
11-
&& apt-get update && apt-get install -y \
8+
RUN apt-get update && apt-get install -y \
129
libssl3 \
1310
libpq5 \
14-
libc++1-21 \
15-
libc++abi1-21 \
11+
ca-certificates \
1612
&& rm -rf /var/lib/apt/lists/*
1713

1814
WORKDIR /app

0 commit comments

Comments
 (0)