Skip to content

fix: LD_BUILD_SHARED_LIBS build flag usage #260

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

Merged
merged 2 commits into from
Oct 19, 2023

Conversation

cwaldren-ld
Copy link
Contributor

@cwaldren-ld cwaldren-ld commented Oct 18, 2023

In my previous PR cleaning up cmake variables, during development I renamed the BUILD_SHARED_LIBS flag to BUILD_STATIC_LIBS, but then reconsidered and stuck with the original naming.

Unfortunately I didn't un-rename some usages of it - so we ended up having some instances of LD_BUILD_STATIC_LIBS in our CMakeLists.txt.

It appears this didn't have an obvious impact on our build/release process because:

  1. Since NOT LD_BUILD_STATIC_LIBS would always be true (variable not defined), then it would have been setting -fvisibility=hidden on both shared and static builds. I'm pretty sure that flag has no affect when building static libs so it was a no-op in that situation.
  2. Using the target_sources trick for pulling in the boost libraries always works whether we're building static libs or dynamic libs, so another no-op.

It'd be nice to test this going forward. Some ideas:

  • Generate a report on the artifact sizes, like the C Server SDK
  • Generate a report corresponding to something like nm -gU artifact.dylib | wc -l to get the number of symbols (e.g. 8k when visibility=hidden, 26k without)
  • Force the SDK to be compiled as a shared lib with unit testing enabled, and assert that the compilation fails due to missing symbols

Manual workflow run:

@cwaldren-ld cwaldren-ld changed the title build: fix LD_BUILD_SHARED_LIBS flag usage fix: LD_BUILD_SHARED_LIBS flag usage Oct 18, 2023
@cwaldren-ld cwaldren-ld marked this pull request as ready for review October 18, 2023 18:03
@cwaldren-ld cwaldren-ld requested a review from a team October 18, 2023 18:04
@cwaldren-ld cwaldren-ld changed the title fix: LD_BUILD_SHARED_LIBS flag usage fix: LD_BUILD_SHARED_LIBS build flag usage Oct 18, 2023

set(BUILD_TESTING "${ORIGINAL_BUILD_TESTING}")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This line is a leftover that should have been removed. Certify is an INTERFACE library (header only.)

@@ -76,7 +76,7 @@ set_property(TARGET ${LIBNAME} PROPERTY
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")

install(TARGETS ${LIBNAME})
if (BUILD_SHARED_LIBS AND MSVC)
if (LD_BUILD_SHARED_LIBS AND MSVC)
install(FILES $<TARGET_PDB_FILE:${LIBNAME}> DESTINATION bin OPTIONAL)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don't have cmake tests that actually try to use the install files, which is why this didn't break CI.

@cwaldren-ld cwaldren-ld merged commit 8dd473f into main Oct 19, 2023
@cwaldren-ld cwaldren-ld deleted the cw/fix-shared-lib-variable branch October 19, 2023 15:59
@github-actions github-actions bot mentioned this pull request Oct 19, 2023
cwaldren-ld pushed a commit that referenced this pull request Oct 19, 2023
🤖 I have created a release *beep* *boop*
---


<details><summary>launchdarkly-cpp-client: 3.1.1</summary>

##
[3.1.1](launchdarkly-cpp-client-v3.1.0...launchdarkly-cpp-client-v3.1.1)
(2023-10-19)


### Bug Fixes

* LD_BUILD_SHARED_LIBS build flag usage
([#260](#260))
([8dd473f](8dd473f))
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@github-actions github-actions bot mentioned this pull request May 13, 2024
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.

2 participants