Skip to content

Link ALWAYSLINK CMake libraries via WHOLE_ARCHIVE interface targets. - #1297

Draft
copybara-service[bot] wants to merge 1 commit into
masterfrom
test_994040839
Draft

copybara-service[bot] wants to merge 1 commit into
masterfrom
test_994040839

Conversation

@copybara-service

Copy link
Copy Markdown

Link ALWAYSLINK CMake libraries via WHOLE_ARCHIVE interface targets.

In CMake, target_link_libraries between OBJECT libraries does not propagate transitive object files ($<TARGET_OBJECTS:...>) to executables, causing non-variant cc_test and cc_binary targets to fail at link time with undefined references. Additionally, $<LINK_LIBRARY:WHOLE_ARCHIVE,...> is ignored by CMake on OBJECT libraries.

Build tcmalloc_cc_library targets with SRCS as STATIC libraries and expose ALWAYSLINK targets via an INTERFACE library wrapping $<LINK_LIBRARY:WHOLE_ARCHIVE,${TCMALLOC_NAME}>.

In CMake, target_link_libraries between OBJECT libraries does not propagate transitive object files ($<TARGET_OBJECTS:...>) to executables, causing non-variant cc_test and cc_binary targets to fail at link time with undefined references. Additionally, $<LINK_LIBRARY:WHOLE_ARCHIVE,...> is ignored by CMake on OBJECT libraries.

Build tcmalloc_cc_library targets with SRCS as STATIC libraries and expose ALWAYSLINK targets via an INTERFACE library wrapping $<LINK_LIBRARY:WHOLE_ARCHIVE,${TCMALLOC_NAME}>.

PiperOrigin-RevId: 994040839

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant