Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat build: prefere static libs when possible #821

Closed
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
f9577de
First try
fdr400 Jan 6, 2025
974d97e
Statis mongo and mysql
fdr400 Jan 6, 2025
476a639
Try fix openssl alpine
fdr400 Jan 6, 2025
5c31308
Fix alpine zlib
fdr400 Jan 6, 2025
ffebb90
Fix static boost
fdr400 Jan 6, 2025
3a3272c
Remove common name from module helpers
fdr400 Jan 6, 2025
ce2ef8a
Fix alpine
fdr400 Jan 6, 2025
c921d2e
Try fix MacOS
fdr400 Jan 6, 2025
d0c6d7a
Merge branch 'develop' into fdr400-more-static-linkage
fdr400 Jan 6, 2025
008adcf
Try fix macos static boost linkage
fdr400 Jan 6, 2025
33bf3f6
Fix MacOS cannot find -lzstd
fdr400 Jan 6, 2025
a89d8c0
Fix boost static linkage
fdr400 Jan 6, 2025
749b7ba
Try fix docker mysql
fdr400 Jan 6, 2025
305e1f9
Fix MacOS again
fdr400 Jan 6, 2025
26b30d0
Do not link statically with mongoc on old Ubuntus
fdr400 Jan 6, 2025
454c627
Again
fdr400 Jan 6, 2025
b5dde1d
Do not use bandled libs for gRPC
fdr400 Jan 6, 2025
1659a73
Fix libcares
fdr400 Jan 6, 2025
e5bfae9
Install c-ares
fdr400 Jan 6, 2025
18d2ea5
Link static clickhouse
fdr400 Jan 6, 2025
d5f77d4
Use brew curl
fdr400 Jan 7, 2025
fecf18d
Try fix clickhouse
fdr400 Jan 7, 2025
1a8f802
Try fix clickhouse again
fdr400 Jan 7, 2025
8c10e48
Try fix clickhouse
fdr400 Jan 7, 2025
3c53c19
try fix abseil
fdr400 Jan 7, 2025
5a234ec
fix abseil
fdr400 Jan 7, 2025
74ffb0f
Fix clickhouse
fdr400 Jan 7, 2025
7104b98
Try temporary fix mac
fdr400 Jan 7, 2025
1956aea
Consistent Kafka build
fdr400 Jan 7, 2025
31866ca
Try use sasl2 from brew
fdr400 Jan 7, 2025
a3b6815
Add kafka service to conan samples
fdr400 Jan 7, 2025
7f2f087
Try fiz link with zstd
fdr400 Jan 7, 2025
ed16f85
Fix kafka version
fdr400 Jan 7, 2025
134acba
Maybe linker problem
fdr400 Jan 7, 2025
32df506
Add options to to use static libs
fdr400 Jan 8, 2025
58cdb80
Use static libs in alpine and in MacOS
fdr400 Jan 8, 2025
46c3121
correct cache keys
fdr400 Jan 8, 2025
3fd84ee
Some fixes
fdr400 Jan 8, 2025
c7d44bc
Try try try
fdr400 Jan 8, 2025
cdfbeb4
Debug
fdr400 Jan 8, 2025
61aba8c
More linker flags
fdr400 Jan 8, 2025
01d0eec
Maybe order makes sense?
fdr400 Jan 8, 2025
4735302
Use framework for all libs
fdr400 Jan 8, 2025
42faf9b
Use dynamic ldap
fdr400 Jan 8, 2025
b907c8a
Install openldap
fdr400 Jan 8, 2025
04c07ea
Fix for old boost
fdr400 Jan 8, 2025
fd29288
Fix libname
fdr400 Jan 8, 2025
dd787f9
Link openldap
fdr400 Jan 8, 2025
6981253
Use ICU data
fdr400 Jan 8, 2025
2256f75
Find dynamic grpc
fdr400 Jan 8, 2025
d1e00f7
Fix not pq patch
fdr400 Jan 8, 2025
e8a9e06
Fix conan
fdr400 Jan 8, 2025
7e79c0f
Try without gold
fdr400 Jan 8, 2025
e62d01b
No static for gcc
fdr400 Jan 8, 2025
3d467dd
Remove strange alias
fdr400 Jan 9, 2025
c02b43e
Add if
fdr400 Jan 9, 2025
8c0dabf
Build static rocksdb
fdr400 Jan 9, 2025
4c4fe3b
do not build shared
fdr400 Jan 9, 2025
067163f
Remove rocks package stub
fdr400 Jan 9, 2025
ea1dca1
More deps for alpine + disable GDB for MacOS
fdr400 Jan 9, 2025
7ece471
Try rabbitmq for alpine
fdr400 Jan 9, 2025
8b304a2
Install rocksdb for alpine
fdr400 Jan 9, 2025
09638db
More consistent names
fdr400 Jan 9, 2025
35b42ac
Do not find libcityhash for Linux clickhouse
fdr400 Jan 9, 2025
6934d7e
Fix clickhouse
fdr400 Jan 9, 2025
8a3056b
Do not try to find static clickhouse Linux
fdr400 Jan 9, 2025
dbd6a21
Fix mongo install
fdr400 Jan 9, 2025
645bf31
Do not link to Iconv if it is bultin
fdr400 Jan 9, 2025
8affca6
Rollback
fdr400 Jan 9, 2025
555af6b
Fix install
fdr400 Jan 9, 2025
4627238
Better for Conan
fdr400 Jan 9, 2025
86b2006
Update
fdr400 Jan 9, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ option(USERVER_FEATURE_OTLP "Provide asynchronous OTLP exporters" "${USERVER_LIB

set(CMAKE_DEBUG_POSTFIX d)

set(OPENSSL_USE_STATIC_LIBS ON)
Copy link
Member Author

@fdr400 fdr400 Jan 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Это стоит в опцию какой-нибудь обернуть, потому что у нас явно не везде всё для статических либ готово

set(ZLIB_USE_STATIC_LIBS ON)
set(Protobuf_USE_STATIC_LIBS ON)
set(Boost_USE_STATIC_LIBS ON)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
include(UserverSetupEnvironment)
userver_setup_environment()
Expand Down
13 changes: 13 additions & 0 deletions cmake/SetupMongoDeps.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
include_guard(GLOBAL)

find_package(bson-1.0 QUIET CONFIG)
find_package(mongoc-1.0 QUIET CONFIG)
if(bson-1.0_FOUND AND mongoc-1.0_FOUND)
message(STATUS "Using config version for bson + mongoc")
add_library(bson ALIAS mongo::bson_static)
add_library(mongoc ALIAS mongo::mongoc_static)
else()
find_package(bson REQUIRED)
find_package(mongoc REQUIRED)
endif()

13 changes: 8 additions & 5 deletions cmake/SetupPostgresqlDeps.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,16 @@ target_link_libraries(PostgreSQLInternal
${USERVER_LIB_MATH}
)

if(${CMAKE_SYSTEM_NAME} MATCHES "BSD")
find_package(libintl REQUIRED)
target_link_libraries(PostgreSQLInternal INTERFACE libintl)
if(${CMAKE_SYSTEM_NAME} MATCHES "BSD" OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
find_package(Intl REQUIRED)
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.20)
target_link_libraries(PostgreSQLInternal INTERFACE Intl::Intl)
else()
target_link_libraries(PostgreSQLInternal INTERFACE ${Intl_LIBRARIES})
endif()
endif()

if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
find_package(libintl REQUIRED)
find_package(Iconv REQUIRED)
target_link_libraries(PostgreSQLInternal INTERFACE libintl Iconv::Iconv "-framework Foundation")
target_link_libraries(PostgreSQLInternal INTERFACE Iconv::Iconv)
endif()
3 changes: 1 addition & 2 deletions cmake/SetupProtobuf.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,14 @@ function(_userver_set_protobuf_version_category)
endfunction()

if(USERVER_CONAN)
find_package(Protobuf REQUIRED)
find_package(Protobuf REQUIRED CONFIG)
_userver_set_protobuf_version_category()
set(PROTOBUF_PROTOC "${Protobuf_PROTOC_EXECUTABLE}")
return()
endif()

if(NOT USERVER_FORCE_DOWNLOAD_PROTOBUF)
# Use the builtin CMake FindProtobuf
set(Protobuf_USE_STATIC_LIBS ON)
if(USERVER_DOWNLOAD_PACKAGE_PROTOBUF)
find_package(Protobuf QUIET)
else()
Expand Down
2 changes: 1 addition & 1 deletion cmake/SetupRdKafka.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ option(USERVER_DOWNLOAD_PACKAGE_KAFKA "Download and setup librdkafka if no librd

set(USERVER_KAFKA_VERSION "2.3.0")

find_package(OpenSSL COMPONENTS SSL Crypto REQUIRED)
find_package(OpenSSL REQUIRED)
find_package(CURL REQUIRED)
find_package(ZLIB REQUIRED)
find_package(libzstd REQUIRED)
Expand Down
4 changes: 0 additions & 4 deletions cmake/UserverSetupEnvironment.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,6 @@ function(_userver_setup_environment_impl)
message(STATUS "ccache: disabled")
endif()

if(CMAKE_SYSTEM_NAME MATCHES "Darwin" AND NOT USERVER_CONAN)
set(Boost_NO_BOOST_CMAKE ON PARENT_SCOPE)
endif()

# Build type specific
if (CMAKE_BUILD_TYPE MATCHES "Debug" OR CMAKE_BUILD_TYPE MATCHES "Test")
add_compile_definitions(_GLIBCXX_ASSERTIONS)
Expand Down
12 changes: 0 additions & 12 deletions cmake/modules/FindCrypto.cmake

This file was deleted.

2 changes: 1 addition & 1 deletion cmake/modules/FindCryptoPP.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ _userver_module_find_include(
)

_userver_module_find_library(
NAMES cryptlib cryptopp
NAMES libcryptopp.a cryptlib cryptopp
PATH_SUFFIXES lib
)

Expand Down
2 changes: 1 addition & 1 deletion cmake/modules/FindHiredis.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ _userver_module_find_include(
)

_userver_module_find_library(
NAMES hiredis
NAMES libhiredis.a hiredis
)

_userver_module_end()
2 changes: 1 addition & 1 deletion cmake/modules/FindJemalloc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ _userver_module_find_include(
)

_userver_module_find_library(
NAMES jemalloc
NAMES libjemalloc.a jemalloc
)

_userver_module_end()
2 changes: 1 addition & 1 deletion cmake/modules/FindLibEv.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ _userver_module_find_include(
)

_userver_module_find_library(
NAMES ev
NAMES libev.a ev
)

_userver_module_end()
2 changes: 1 addition & 1 deletion cmake/modules/FindNghttp2.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ _userver_module_find_include(
)

_userver_module_find_library(
NAMES nghttp2
NAMES libnghttp2.a nghttp2
)

_userver_module_end()
2 changes: 1 addition & 1 deletion cmake/modules/FindPugixml.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ _userver_module_find_include(
)

_userver_module_find_library(
NAMES pugixml libpugixml
NAMES libpugixml.a pugixml libpugixml
)

_userver_module_end()
2 changes: 1 addition & 1 deletion cmake/modules/FindRdKafka.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ _userver_module_find_include(
)

_userver_module_find_library(
NAMES librdkafka.a
NAMES librdkafka.a rdkafka
)

_userver_module_end()
2 changes: 1 addition & 1 deletion cmake/modules/FindRocksDB.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ _userver_module_find_include(
)

_userver_module_find_library(
NAMES librocksdb.a
NAMES librocksdb.a rocksdb
)

_userver_module_end()
12 changes: 0 additions & 12 deletions cmake/modules/FindSSL.cmake

This file was deleted.

2 changes: 1 addition & 1 deletion cmake/modules/Findbson.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ _userver_module_find_include(
)

_userver_module_find_library(
NAMES bson bson-1.0
NAMES libbson-static-1.0.a bson bson-1.0
)

_userver_module_end()
2 changes: 1 addition & 1 deletion cmake/modules/Findc-ares.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ _userver_module_find_include(
)

_userver_module_find_library(
NAMES libcares.a libcares_static.a libcares.so
NAMES libcares.a libcares_static.a cares
)

_userver_module_end()
6 changes: 4 additions & 2 deletions cmake/modules/Findcctz.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ _userver_module_find_include(
)

_userver_module_find_library(
NAMES cctz
PATHS /usr/lib/x86_64-linux-gnu
NAMES libcctz.a cctz
PATHS
/usr/lib/x86_64-linux-gnu
/opt/homebrew/opt/cctz/lib
)

_userver_module_end()
2 changes: 1 addition & 1 deletion cmake/modules/Findfmt.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ _userver_module_find_include(
)

_userver_module_find_library(
NAMES fmt
NAMES libfmt.a fmt
)

_userver_module_end()
2 changes: 1 addition & 1 deletion cmake/modules/Findlibgflags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ _userver_module_find_include(
)

_userver_module_find_library(
NAMES gflags
NAMES libgflags.a gflags
PATH_SUFFIXES lib
)

Expand Down
14 changes: 0 additions & 14 deletions cmake/modules/Findlibintl.cmake

This file was deleted.

2 changes: 1 addition & 1 deletion cmake/modules/Findlibmariadb.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ _userver_module_find_include(
)

_userver_module_find_library(
NAMES mariadb
NAMES libmariadb.a mariadb
PATH_SUFFIXES lib
)

Expand Down
2 changes: 1 addition & 1 deletion cmake/modules/Findlibsnappy.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ _userver_module_find_include(
)

_userver_module_find_library(
NAMES snappy
NAMES libsnappy.a snappy
PATH_SUFFIXES lib
)

Expand Down
2 changes: 1 addition & 1 deletion cmake/modules/Findlibyamlcpp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ _userver_module_find_include(
)

_userver_module_find_library(
NAMES yaml-cpp
NAMES libyaml-cpp.a yaml-cpp
PATH_SUFFIXES lib
)

Expand Down
2 changes: 1 addition & 1 deletion cmake/modules/Findlibzip.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
_userver_module_begin(
NAME libzip
DEBIAN_NAMES libbz2-dev
FORMULA_NAMES libbz2
FORMULA_NAMES bzip2
RPM_NAMES libbz2-dev
PACMAN_NAMES bzip2
)
Expand Down
2 changes: 1 addition & 1 deletion cmake/modules/Findlibzstd.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ _userver_module_find_include(
)

_userver_module_find_library(
NAMES zstd
NAMES libzstd.a zstd
PATH_SUFFIXES lib
)

Expand Down
6 changes: 4 additions & 2 deletions cmake/modules/Findlz4.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ _userver_module_find_include(
)

_userver_module_find_library(
NAMES liblz4.a
NAMES liblz4.a lz4
)

_userver_module_end()

add_library(lz4::lz4 ALIAS lz4)
if(NOT TARGET lz4::lz4)
add_library(lz4::lz4 ALIAS lz4)
endif()
2 changes: 1 addition & 1 deletion cmake/modules/Findmongoc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ _userver_module_find_include(
)

_userver_module_find_library(
NAMES mongoc mongoc-1.0
NAMES libmongoc-static-1.0.a mongoc mongoc-1.0
)

_userver_module_end()
3 changes: 1 addition & 2 deletions mongo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ if (USERVER_CONAN)
add_library(mongoc ALIAS mongo::mongoc_static)
find_package(cyrus-sasl REQUIRED CONFIG)
else()
find_package(bson REQUIRED)
find_package(mongoc REQUIRED)
include(SetupMongoDeps)
endif()

userver_module(mongo
Expand Down
3 changes: 2 additions & 1 deletion mysql/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
project(userver-mysql CXX)

find_package(ZLIB REQUIRED)
find_package(libmariadb REQUIRED)

userver_module(mysql
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}"
LINK_LIBRARIES_PRIVATE libmariadb
LINK_LIBRARIES_PRIVATE libmariadb ZLIB::ZLIB

DBTEST_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/tests"
UTEST_LINK_LIBRARIES libmariadb
Expand Down
4 changes: 4 additions & 0 deletions scripts/docs/en/deps/alpine.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ mariadb-static
mongo-c-driver-dev
nghttp2-dev
openldap-dev
openssl-dev
openssl-libs-static
postgresql16-dev
protobuf-c-compiler
protobuf-c-dev
Expand All @@ -32,3 +34,5 @@ python3-dev
snappy-dev
snappy-static
yaml-cpp-dev
zlib-dev
zlib-static
27 changes: 13 additions & 14 deletions scripts/docs/en/deps/macos.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
ares
boost
c-ares
ccache
cctz
cmake
coreutils
cyrus-sasl
fmt
git
google-benchmark
boost
ares
cctz
libev
fmt
googletest
hiredis
jemalloc
krb5
libev
librdkafka
mariadb
mongo-c-driver
nghttp2
ninja
pugixml
openssl
yaml-cpp
librdkafka
rocksdb
postgresql@16
redis
pugixml
rocksdb
yaml-cpp
zlib
c-ares
coreutils
mongo-c-driver
mariadb
Loading
Loading