Follow-up to 3c51348 fixing linker issues with gflags and glog

The temporary solution for binaries/tests that fully statically linked is to
link against `gflags` using `-Wl,--whole-archive`. This will no longer be
necessary, once Abseil ships with logging. Then we can (finally) use Abseil
flags and use a logging library that does not depend on a different flags
library.

PiperOrigin-RevId: 260705702
Change-Id: I8562faaff59f9c3e0e1d331186d2806d387438fb
This commit is contained in:
Christian Blichmann 2019-07-30 06:48:16 -07:00 committed by Copybara-Service
parent 1be24d945c
commit b7cbc36071
7 changed files with 38 additions and 20 deletions

View File

@ -42,6 +42,7 @@ if(SAPI_ENABLE_TESTS)
sandbox2::file_helpers
sandbox2::fileops
sandbox2::testing
sapi::status_matchers
sapi::test_main
)
gtest_discover_tests(filewrapper_test PROPERTIES

View File

@ -33,6 +33,9 @@ add_library(sapi_stringop STATIC
stringop.cc
)
add_library(sapi::stringop ALIAS sapi_stringop)
add_dependencies(sapi_stringop
sapi::stringop_params_proto
)
target_link_libraries(sapi_stringop
PRIVATE $<TARGET_OBJECTS:sapi_stringop_params_proto>
sapi::base

View File

@ -34,6 +34,9 @@ add_library(sapi_sum STATIC
sum_cpp.cc
)
add_library(sapi::sum ALIAS sapi_sum)
add_dependencies(sapi_sum
sapi::sum_params_proto
)
target_link_libraries(sapi_sum
PRIVATE $<TARGET_OBJECTS:sapi_sum_params_proto>
glog::glog

View File

@ -57,7 +57,8 @@ target_link_libraries(sandbox2_syscall
absl::strings
sandbox2::util
sapi::base
PUBLIC glog::glog
PUBLIC glog::glog
gflags::gflags
)
# sandboxed_api/sandbox2:result
@ -637,9 +638,9 @@ if(SAPI_ENABLE_TESTS)
${_sandbox2_comms_test_pb_h}
)
add_library(sandbox2::comms_test_proto ALIAS sandbox2_comms_test_proto)
target_link_libraries(sandbox2_comms_test_proto PRIVATE
protobuf::libprotobuf
sapi::base
target_link_libraries(sandbox2_comms_test_proto
PRIVATE sapi::base
PUBLIC protobuf::libprotobuf
)
# sandboxed_api/sandbox2:comms_test
@ -650,7 +651,7 @@ if(SAPI_ENABLE_TESTS)
absl::fixed_array
absl::strings
glog::glog
protobuf::libprotobuf
gflags::gflags
sandbox2::comms
sandbox2::comms_test_proto
sapi::status_matchers

View File

@ -71,6 +71,9 @@ add_executable(ipc
add_executable(sandbox2::testcase_ipc ALIAS ipc)
target_link_libraries(ipc PRIVATE
absl::strings
-Wl,--whole-archive
gflags::gflags
-Wl,--no-whole-archive
glog::glog
sandbox2::client
sandbox2::comms
@ -135,6 +138,9 @@ set_target_properties(pidcomms PROPERTIES
${_sandbox2_testcase_properties}
)
target_link_libraries(pidcomms PRIVATE
-Wl,--whole-archive
gflags::gflags
-Wl,--no-whole-archive
glog::glog
sandbox2::client
sandbox2::comms
@ -234,10 +240,13 @@ set_target_properties(tsync PROPERTIES
${_sandbox2_testcase_properties}
)
target_link_libraries(tsync PRIVATE
-Wl,--whole-archive
gflags::gflags
-Wl,--no-whole-archive
glog::glog
sapi::base
sandbox2::client
sandbox2::comms
sapi::base
${_sandbox2_fully_static_linkopts}
)

View File

@ -89,13 +89,13 @@ add_library(sandbox2_util_temp_file STATIC
temp_file.h
)
add_library(sandbox2::temp_file ALIAS sandbox2_util_temp_file)
target_link_libraries(sandbox2_util_temp_file PRIVATE
absl::strings
sandbox2::fileops
sandbox2::strerror
sapi::base
sapi::status
sapi::statusor
target_link_libraries(sandbox2_util_temp_file
PRIVATE absl::strings
sandbox2::fileops
sandbox2::strerror
sapi::base
PUBLIC sapi::status
sapi::statusor
)
# sandboxed_api/sandbox2/util:maps_parser
@ -191,6 +191,7 @@ if(SAPI_ENABLE_TESTS)
sandbox2::maps_parser
sandbox2::minielf
sandbox2::testing
sapi::status_matchers
sapi::test_main
)
gtest_discover_tests(minielf_test PROPERTIES

View File

@ -85,13 +85,13 @@ if(SAPI_ENABLE_TESTS)
status_matchers.h
)
add_library(sapi::status_matchers ALIAS sapi_util_status_matchers)
target_link_libraries(sapi_util_status_matchers PRIVATE
absl::optional
gmock
gtest
sapi::base
sapi::status
sapi::statusor
target_link_libraries(sapi_util_status_matchers
PRIVATE absl::optional
gmock
gtest
sapi::base
PUBLIC sapi::status
sapi::statusor
)
# sandboxed_api/util:status_test