-
Notifications
You must be signed in to change notification settings - Fork 248
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
fix(cmake): make sure link flags are propagated to module library builds #1308
Conversation
`CMAKE_SHARED_LINKER_FLAGS_INIT` alone does not populate the link flags for module library targets, i.e.: add_library(foo MODULE) This sets the variable in the crosstool script.
All that's failing is the buildifier step but no logs indicating an issue with the code. |
…#1129) Fixes bazel's linker flags not being passed to CMake module library targets - e.g.: ```cmake add_library(foo MODULE) ``` This can lead to surprising behavior - see: https://github.com/enfabrica/internal/blob/5ac4068d3afad4a662962740981dde0764972c98/bazel/dependencies/rdma-core.BUILD.bazel#L47 Further we can remove the hardcoded linker flags in the above target. We should merge this if upstream takes the fix: bazel-contrib/rules_foreign_cc#1308. Once we upgrade it can be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks reasonable to me - the buildifier errors are lexocographical orderings - We just need to reorder some of the dictionary key entries.
Thanks for your help getting this merged @jsharpe ! |
The PR bazel-contrib#1308, added `CMAKE_MODULE_LINKER_FLAGS_INIT` with the value of cxx_linker_shared to the generated toolchain file in CMAKE. This works for most use cases, however, it broke some macos builds that build bundles. This is because the toolchain usually sets "-shared" or "-dynamiclib" while CMAKE sets "-bundle" for Apple platforms. "-bundle" cannot co-exist with the previous two flags.
The PR bazel-contrib#1308, added `CMAKE_MODULE_LINKER_FLAGS_INIT` with the value of cxx_linker_shared to the generated toolchain file in CMAKE. This works for most use cases, however, it broke some macos builds that build bundles. This is because the toolchain usually sets "-shared" or "-dynamiclib" while CMAKE sets "-bundle" for Apple platforms. "-bundle" cannot co-exist with the previous two flags.
The PR bazel-contrib#1308, added `CMAKE_MODULE_LINKER_FLAGS_INIT` with the value of cxx_linker_shared to the generated toolchain file in CMAKE. This works for most use cases, however, it broke some macos builds that build bundles. This is because the toolchain usually sets "-shared" or "-dynamiclib" while CMAKE sets "-bundle" for Apple platforms. "-bundle" cannot co-exist with the previous two flags.
The PR bazel-contrib#1308, added `CMAKE_MODULE_LINKER_FLAGS_INIT` with the value of cxx_linker_shared to the generated toolchain file in CMAKE. This works for most use cases, however, it broke some macos builds that build bundles. This is because the toolchain usually sets "-shared" or "-dynamiclib" while CMAKE sets "-bundle" for Apple platforms. "-bundle" cannot co-exist with the previous two flags.
CMAKE_SHARED_LINKER_FLAGS_INIT
alone does not populate the link flags for module library targets, i.e.:add_library(foo MODULE)
This sets the variable in the crosstool script.