Skip to content

Linux: add ${CMAKE_DL_LIBS} to libHttpClient.Linux and WebSocketCompressionTests target_link_libraries#986

Closed
armahnii2000 wants to merge 1 commit into
microsoft:mainfrom
armahnii2000:user/v-garmah/fix-linux-cmakelists-dl-link
Closed

Linux: add ${CMAKE_DL_LIBS} to libHttpClient.Linux and WebSocketCompressionTests target_link_libraries#986
armahnii2000 wants to merge 1 commit into
microsoft:mainfrom
armahnii2000:user/v-garmah/fix-linux-cmakelists-dl-link

Conversation

@armahnii2000
Copy link
Copy Markdown

@armahnii2000 armahnii2000 commented Jun 3, 2026

Both targets transitively call dlfcn functions (via OpenSSL's dso_dlfcn.c) but don't link against libdl. On linkers that don't auto-resolve, the link fails:

/usr/bin/ld: dso_dlfcn.c:(.text+0xda): undefined reference to `dlerror'

Adds ${CMAKE_DL_LIBS} to:

  • libHttpClient.Linux (shared lib) target_link_libraries
  • WebSocketCompressionTests.Linux target_link_libraries

${CMAKE_DL_LIBS} is the idiomatic CMake variable for this — it expands to dl on platforms that need it and is empty elsewhere. Safe no-op on Windows/macOS.

Surfaced via the PlayFab.SDKs.All.TestDrop Linux pipeline.

…nTests

Both targets transitively pull dlfcn symbols (via OpenSSL's dso_dlfcn.c)
but don't link against libdl. On glibc < 2.34 (e.g. Ubuntu 20.04) the
dl* symbols still live in libdl.so, so the link fails:

  /usr/bin/ld: dso_dlfcn.c:(.text+0xda): undefined reference to `dlerror'

Add ${CMAKE_DL_LIBS} to:
 - libHttpClient.Linux (shared lib) target_link_libraries
 - WebSocketCompressionTests.Linux target_link_libraries

CMAKE_DL_LIBS resolves to "dl" on Linux and is empty on platforms that
don't need it (Windows, macOS), so this is a no-op everywhere except
the affected Linux configurations.

No-op on glibc >= 2.34 (where dl symbols are merged into libc).
@armahnii2000
Copy link
Copy Markdown
Author

armahnii2000 commented Jun 3, 2026

Pinging for review — would appreciate eyes from anyone with libHttpClient.Linux context:

Fix is a 2-line CMake change adding ${CMAKE_DL_LIBS} to two target_link_libraries blocks. Currently blocking the PlayFab.SDKs.All.TestDrop Linux pipeline (tracked in PlayFab work items 62492001 and 62492286).

@armahnii2000 armahnii2000 marked this pull request as ready for review June 3, 2026 17:02
@rgomez391
Copy link
Copy Markdown
Contributor

Let's wait for the CI checks to pass before merging

@armahnii2000 armahnii2000 marked this pull request as draft June 4, 2026 18:19
@armahnii2000
Copy link
Copy Markdown
Author

Closing this PR — the consumer side (Microsoft Xbox PlayFab.SDKs.All TestDrop pipeline) that motivated this fix is migrating its Linux build agent from Ubuntu 20.04 (glibc 2.31, clang-10) to Ubuntu 22.04 (glibc 2.35, clang-14). On glibc 2.35 the dl* symbols are merged into libc.so, so the link succeeds without an explicit -ldl (or ${CMAKE_DL_LIBS}).

Verified empirically: lab build 148767526 ran the unpatched Build/libHttpClient.Linux/CMakeLists.txt on Ubuntu 22.04 + clang-14 + glibc 2.35; both libHttpClient.Linux.so and WebSocketCompressionTests.Linux linked cleanly.

The fix is still correct on its merits for anyone building libHttpClient on older glibc — feel free to re-open / cherry-pick if useful — but our specific consumer no longer needs it. Apologies for the noise!

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