From f12ce9d1ae949a7dcb815c11db531b06b7c136b0 Mon Sep 17 00:00:00 2001 From: Craig Edwards Date: Thu, 17 Oct 2024 17:52:07 +0000 Subject: [PATCH 1/6] fix: fix broken static builds --- library/CMakeLists.txt | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt index 840807669d..cf92d6e4f1 100644 --- a/library/CMakeLists.txt +++ b/library/CMakeLists.txt @@ -111,10 +111,11 @@ endif() if(NOT BUILD_SHARED_LIBS) if(UNIX) - message("-- Building static library.") + message("-- Building ${Green}static${ColourReset} library.") if(UNIX AND NOT APPLE) set(CMAKE_FIND_LIBRARY_SUFFIXES ".a") + message("-- INFO: Changed lib suffix to .a") endif() set(OPENSSL_USE_STATIC_LIBS ON) @@ -122,6 +123,8 @@ if(NOT BUILD_SHARED_LIBS) else() message(WARNING "-- Building of static library not supported on non UNIX systems.") endif() +else() + message("-- Building ${Green}dynamic${ColourReset} library.") endif() if (BUILD_VOICE_SUPPORT) @@ -276,13 +279,22 @@ foreach (fullmodname ${subdirlist}) if (HAVE_VOICE) # Private statically linked dependencies - target_link_libraries(${modname} PRIVATE - mlspp - mls_vectors - bytes - tls_syntax - hpke - ) + if(NOT BUILD_SHARED_LIBS AND NOT APPLE) + target_link_libraries(${modname} PRIVATE mlspp.a + mls_vectors.a + bytes.a + tls_syntax.a + hpke.a + ) + else() + target_link_libraries(${modname} PRIVATE + mlspp + mls_vectors + bytes + tls_syntax + hpke + ) + endif() endif() if (HAVE_VOICE) From b63c817fad750ef870ed12f8e975bd82e9fed41c Mon Sep 17 00:00:00 2001 From: Craig Edwards Date: Fri, 18 Oct 2024 01:08:20 +0000 Subject: [PATCH 2/6] fix static linking - generates huge static blob --- cmake/FindOpus.cmake | 3 +- library/CMakeLists.txt | 96 ++++++++++++++++++++++++++---------------- 2 files changed, 62 insertions(+), 37 deletions(-) diff --git a/cmake/FindOpus.cmake b/cmake/FindOpus.cmake index ba23166985..a34553f73a 100644 --- a/cmake/FindOpus.cmake +++ b/cmake/FindOpus.cmake @@ -18,7 +18,8 @@ endif() if(OPUS_LIBRARIES) if(OPUS_USE_STATIC_LIBS) - find_library(LIBM NAMES "libm.a" "libm.tbd") + # on linux with glibc you CANT statically link libm without statically linking all of glibc. DONT DO IT. + #find_library(LIBM NAMES "libm.a" "libm.tbd") else() find_library(LIBM NAMES m) endif() diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt index cf92d6e4f1..36dac3829c 100644 --- a/library/CMakeLists.txt +++ b/library/CMakeLists.txt @@ -48,6 +48,27 @@ STRING(REPLACE "AVX" "" AVX_TYPE ${AVX_TYPE}) add_compile_definitions(AVX_TYPE=${AVX_TYPE}) add_compile_options(${AVX_FLAG}) +if(NOT BUILD_SHARED_LIBS) + if(UNIX) + message("-- Building ${Green}static${ColourReset} library.") + + if(UNIX AND NOT APPLE) + set(CMAKE_FIND_LIBRARY_SUFFIXES ".a") + message("-- INFO: Changed lib suffix to ${CMAKE_FIND_LIBRARY_SUFFIXES}") + endif() + + set(OPENSSL_USE_STATIC_LIBS TRUE) + set(OPUS_USE_STATIC_LIBS TRUE) + + else() + message(WARNING "-- Building of static library not supported on non UNIX systems.") + endif() +else() + message("-- Building ${Green}dynamic${ColourReset} library.") +endif() + + + if(WIN32 AND NOT MINGW) # Fake an ssl version number to satisfy MLSPP set(OPENSSL_VERSION "1.1.1f") @@ -109,24 +130,6 @@ if (UNIX) endif() endif() -if(NOT BUILD_SHARED_LIBS) - if(UNIX) - message("-- Building ${Green}static${ColourReset} library.") - - if(UNIX AND NOT APPLE) - set(CMAKE_FIND_LIBRARY_SUFFIXES ".a") - message("-- INFO: Changed lib suffix to .a") - endif() - - set(OPENSSL_USE_STATIC_LIBS ON) - set(OPUS_USE_STATIC_LIBS TRUE) - else() - message(WARNING "-- Building of static library not supported on non UNIX systems.") - endif() -else() - message("-- Building ${Green}dynamic${ColourReset} library.") -endif() - if (BUILD_VOICE_SUPPORT) if (MINGW OR NOT WIN32) include("${CMAKE_CURRENT_SOURCE_DIR}/../cmake/FindOpus.cmake") @@ -154,6 +157,7 @@ set(THREADS_PREFER_PTHREAD_FLAG ON) find_package(Threads REQUIRED) if(MINGW OR NOT WIN32) find_package(ZLIB REQUIRED) + message("-- ZLIB: ${Green}${ZLIB_LIBRARIES}${ColourReset}") endif(MINGW OR NOT WIN32) if(APPLE) @@ -165,6 +169,7 @@ if(APPLE) find_package(OpenSSL REQUIRED) else() if(MINGW OR NOT WIN32) + set(OPENSSL_USE_STATIC_LIBS TRUE) find_package(OpenSSL REQUIRED) endif() endif() @@ -278,30 +283,33 @@ foreach (fullmodname ${subdirlist}) endif() if (HAVE_VOICE) - # Private statically linked dependencies - if(NOT BUILD_SHARED_LIBS AND NOT APPLE) - target_link_libraries(${modname} PRIVATE mlspp.a + target_link_libraries(${modname} PUBLIC ${OPUS_LIBRARIES}) + include_directories(${OPUS_INCLUDE_DIRS}) + endif() +endforeach() + +if (HAVE_VOICE) + # Private statically linked dependencies + if(NOT BUILD_SHARED_LIBS AND NOT APPLE) + target_link_libraries(dpp PRIVATE + mlspp.a mls_vectors.a bytes.a tls_syntax.a hpke.a - ) - else() - target_link_libraries(${modname} PRIVATE + ) + message("-- INFO: Linking static dependencies") + else() + target_link_libraries(dpp PRIVATE mlspp mls_vectors bytes tls_syntax hpke - ) - endif() - endif() - - if (HAVE_VOICE) - target_link_libraries(${modname} PUBLIC ${OPUS_LIBRARIES}) - include_directories(${OPUS_INCLUDE_DIRS}) + ) + message("-- INFO: Linking dynamic dependencies") endif() -endforeach() +endif() target_compile_features(dpp PUBLIC cxx_std_17) target_compile_features(dpp PRIVATE cxx_constexpr) @@ -379,6 +387,22 @@ if(DPP_FORMATTERS) target_compile_definitions(dpp PUBLIC DPP_FORMATTERS) endif() +if (NOT BUILD_SHARED_LIBS) + add_library(dppstatic STATIC + $ + $ + $ + $ + $ + $ + ) + if (HAVE_VOICE) + target_link_libraries(dppstatic ${ZLIB_LIBRARIES} ${OPENSSL_LIBRARIES} ${OPUS_LIBRARIES} -static-libgcc -static-libstdc++) + else() + target_link_libraries(dppstatic ${ZLIB_LIBRARIES} ${OPENSSL_LIBRARIES}) + endif() +endif() + if (DPP_BUILD_TEST) enable_testing(${CMAKE_CURRENT_SOURCE_DIR}/..) file(GLOB testnamelist "${CMAKE_CURRENT_SOURCE_DIR}/../src/*") @@ -397,11 +421,11 @@ if (DPP_BUILD_TEST) if (MSVC) target_compile_options(${testname} PRIVATE /utf-8) endif() - set (static_if_needed "") - if(NOT BUILD_SHARED_LIBS) - set (static_if_needed "-static") + if(BUILD_SHARED_LIBS) + target_link_libraries(${testname} PUBLIC ${modname}) + else() + target_link_libraries(${testname} PUBLIC dppstatic) endif() - target_link_libraries(${testname} PUBLIC ${modname} ${static_if_needed}) endif() endforeach() add_test( From 76d0cd0cfed59064c6427904c29982a274f3b368 Mon Sep 17 00:00:00 2001 From: Craig Edwards Date: Fri, 18 Oct 2024 01:30:19 +0000 Subject: [PATCH 3/6] get rid of circleci --- .circleci/config.yml | 20 -------------------- 1 file changed, 20 deletions(-) delete mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index ae375b935b..0000000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,20 +0,0 @@ -version: 2 - -jobs: - build: - docker: - - image: "debian:bullseye" - steps: - - checkout - - run: - name: Installing build dependencies - command: 'apt-get update && apt-get install -y sudo gcc g++ build-essential git cmake libssl-dev zlib1g-dev' - - run: - name: Creating Build Files - command: 'cmake -H. -Bbuild' - - run: - name: Creating Binary Files - command: 'cmake --build build' - - run: - name: Testing installation - command: 'cmake --build build --target install' From bab4c1c99f374b550674f0c448cf9dfa91c3f9a9 Mon Sep 17 00:00:00 2001 From: Craig Edwards Date: Fri, 18 Oct 2024 01:58:22 +0000 Subject: [PATCH 4/6] oops, dont force linking openssl static when we arent doing static build --- library/CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt index 36dac3829c..d631d61f31 100644 --- a/library/CMakeLists.txt +++ b/library/CMakeLists.txt @@ -169,7 +169,9 @@ if(APPLE) find_package(OpenSSL REQUIRED) else() if(MINGW OR NOT WIN32) - set(OPENSSL_USE_STATIC_LIBS TRUE) + if(NOT BUILD_SHARED_LIBS) + set(OPENSSL_USE_STATIC_LIBS TRUE) + endif() find_package(OpenSSL REQUIRED) endif() endif() From ea3ca970185fe392f4304c3778df5a0cbbee1bcb Mon Sep 17 00:00:00 2001 From: Craig Edwards Date: Fri, 18 Oct 2024 12:56:34 +0000 Subject: [PATCH 5/6] fix minmax import on fallback.h --- include/dpp/isa/fallback.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/dpp/isa/fallback.h b/include/dpp/isa/fallback.h index 87a219f053..68af9a1232 100644 --- a/include/dpp/isa/fallback.h +++ b/include/dpp/isa/fallback.h @@ -20,6 +20,7 @@ ************************************************************************************/ #pragma once +#include #include #include #include From 261eded8dad9b6f4a1090053921167ed7b349d9b Mon Sep 17 00:00:00 2001 From: Craig Edwards Date: Fri, 18 Oct 2024 13:08:30 +0000 Subject: [PATCH 6/6] helps to get the include name right (rushed commit) --- include/dpp/isa/fallback.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/dpp/isa/fallback.h b/include/dpp/isa/fallback.h index 68af9a1232..a7154233b2 100644 --- a/include/dpp/isa/fallback.h +++ b/include/dpp/isa/fallback.h @@ -20,7 +20,7 @@ ************************************************************************************/ #pragma once -#include +#include #include #include #include