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::file_helpers
sandbox2::fileops sandbox2::fileops
sandbox2::testing sandbox2::testing
sapi::status_matchers
sapi::test_main sapi::test_main
) )
gtest_discover_tests(filewrapper_test PROPERTIES gtest_discover_tests(filewrapper_test PROPERTIES

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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