Skip to content

Commit

Permalink
Make it optional to link statically to libgcc and libstdc++ (#474)
Browse files Browse the repository at this point in the history
  • Loading branch information
BewareMyPower authored Feb 8, 2025
1 parent afeac78 commit d3fd6b2
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ target_include_directories(PULSAR_OBJECT_LIB PUBLIC
"${CMAKE_SOURCE_DIR}/include"
"${CMAKE_BINARY_DIR}/include")

option(LINK_STATIC_GCC_CXX "Link statically to libgcc and libstdc++" OFF)
include(CheckCXXSymbolExists)
if (BUILD_DYNAMIC_LIB)
add_library(pulsarShared SHARED $<TARGET_OBJECTS:PULSAR_OBJECT_LIB>)
Expand All @@ -94,7 +95,7 @@ if (BUILD_DYNAMIC_LIB)
target_link_options(pulsarShared PRIVATE -Wl,-Bsymbolic)
endif ()
check_cxx_symbol_exists(__GLIBCXX__ iostream GLIBCXX)
if (GLIBCXX)
if (GLIBCXX AND LINK_STATIC_GCC_CXX)
target_link_libraries(pulsarShared PUBLIC -static-libgcc -static-libstdc++)
endif ()
endif()
Expand Down
2 changes: 1 addition & 1 deletion pkg/deb/build-deb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pushd $CPP_DIR
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH

chmod +x $(find . -name "*.sh")
cmake . -DBUILD_TESTS=OFF -DBUILD_PERF_TOOLS=OFF -DLINK_STATIC=ON
cmake . -DBUILD_TESTS=OFF -DBUILD_PERF_TOOLS=OFF -DLINK_STATIC=ON -DLINK_STATIC_GCC_CXX=ON
make -j 3
popd

Expand Down
1 change: 1 addition & 0 deletions pkg/rpm/SPECS/pulsar-client.spec
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ static library.
%build
git clone https://github.com/microsoft/vcpkg.git
cmake -B build -DINTEGRATE_VCPKG=ON -DCMAKE_BUILD_TYPE=Release \
-DLINK_STATIC_GCC_CXX=ON \
-DBUILD_TESTS=OFF -DBUILD_DYNAMIC_LIB=ON -DBUILD_STATIC_LIB=ON
cmake --build build -j8
./build-support/merge_archives_vcpkg.sh $PWD/build
Expand Down

0 comments on commit d3fd6b2

Please sign in to comment.