Skip to content

Conversation

@jptrainor
Copy link
Contributor

@jptrainor jptrainor commented Dec 15, 2025

This PR fixes static build correctness across CMake and pkg-config.

Static build issues surfaced while implementing static linking using pkg-config for an ffmpeg/MXL integration. MXL supported shared-library builds only, ignored BUILD_SHARED_LIBS, and provided incomplete pkg-config metadata for static linkage.

Key build-related changes:

  • Correct handling of BUILD_SHARED_LIBS=ON|OFF across mxl targets
  • Added MXL_ENABLE_PIC (default ON) to support static builds used in shared contexts
  • Fixed pkg-config metadata for static linking
  • Corrected CMake export-set dependency relationships

This change adds a C consumer link test to prevent regressions.

Tested with:

  • Linux (GCC, Clang)
  • macOS (Clang/x86_64)
  • Shared and static builds (BUILD_SHARED_LIBS=ON|OFF)
  • Debug and release builds
  • Static ffmpeg build as downstream consumer on Linux

The ffmpeg integration lives in a downstream fork and is still being
finalized, but is included here for reference:
https://github.com/cbcrc/FFmpeg/tree/dmf-mxl/master

Copy link
Contributor

@vt-tv vt-tv left a comment

Choose a reason for hiding this comment

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

Looks good to me. Thanks for your contribution!

@vt-tv
Copy link
Contributor

vt-tv commented Dec 16, 2025

You are mising the SPDX headers/comments in these files :

lib/tests/test_pkgconfig_c_link.cpp
lib/tests/test_pkgconfig_c_link.sh

Copy link
Contributor

@vt-tv vt-tv left a comment

Choose a reason for hiding this comment

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

See comments about SPDX

Copy link
Contributor

@jonasohland jonasohland left a comment

Choose a reason for hiding this comment

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

For consistency, the same changes need to be applied to targets in lib/fabrics/ofi

Copy link
Collaborator

@KimonHoffmann KimonHoffmann left a comment

Choose a reason for hiding this comment

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

Thank you very much for this contribution and filling in the missing bits for the static library build. That has been long on my TODO list and I very much appreciate being able to tick this off now.

Regarding the pkg-config compile check I'm a bit conflicted. I think it's a good idea, but having it as part of the tests on the side feels wrong to me. Could you please transform this into a post-build step that is independent of the other tests?

Also regarding the C++ parts of this PR please try to match the style present in other tests with regards to pointer types, right hand types and explicit qualification of entities in the global namespace.

@jptrainor jptrainor force-pushed the main branch 3 times, most recently from 0be1757 to 2d0aa94 Compare December 16, 2025 15:41
@jptrainor
Copy link
Contributor Author

You are mising the SPDX headers/comments in these files :

lib/tests/test_pkgconfig_c_link.cpp lib/tests/test_pkgconfig_c_link.sh

Resolved

@vt-tv vt-tv self-requested a review December 16, 2025 15:46
Copy link
Contributor

@vt-tv vt-tv left a comment

Choose a reason for hiding this comment

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

clang-tidy issues introcued by the spdx changes.

@jptrainor
Copy link
Contributor Author

Thank you very much for this contribution and filling in the missing bits for the static library build. That has been long on my TODO list and I very much appreciate being able to tick this off now.

Regarding the pkg-config compile check I'm a bit conflicted. I think it's a good idea, but having it as part of the tests on the side feels wrong to me. Could you please transform this into a post-build step that is independent of the other tests?

Also regarding the C++ parts of this PR please try to match the style present in other tests with regards to pointer types, right hand types and explicit qualification of entities in the global namespace.

I moved the pkg-config consumer test out of Catch2, removed the cpp wrapper, and added a standalone CTest test (via add_test()) that executes the test shell script directly. It is cleaner this way. Does that address your "independent of other tests" concern?

@jptrainor
Copy link
Contributor Author

clang-tidy issues introcued by the spdx changes.

I removed the cpp wrapper that would have produced that. So it's now a non-issue I believe.

Copy link
Contributor

@jonasohland jonasohland left a comment

Choose a reason for hiding this comment

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

It would be nice if we could have the test script also test linking the fabrics API. But fabrics is not in scope for v1.0.0, so I will just add that later.

@jptrainor
Copy link
Contributor Author

It would be nice if we could have the test script also test linking the fabrics API. But fabrics is not in scope for v1.0.0, so I will just add that later.

I can do it. I looked at the fabric code and noticed that it was not documented yet and not enabled so I was uncertain. It's not a problem for me to add it to the test script so I'll do that. Standby for that update.

@jptrainor
Copy link
Contributor Author

It would be nice if we could have the test script also test linking the fabrics API. But fabrics is not in scope for v1.0.0, so I will just add that later.

Or if this goes in first then I'll do it a followup PR.

Copy link
Contributor

@pedro-alves-ferreira pedro-alves-ferreira left a comment

Choose a reason for hiding this comment

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

LGTM

@KimonHoffmann
Copy link
Collaborator

Thank you for making the changes regarding position independent code. Could you please have a look at my suggestion regarding the linker invocation above?

Copy link
Collaborator

@KimonHoffmann KimonHoffmann left a comment

Choose a reason for hiding this comment

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

Dummy comment to set the status of my review to to "request changes".

@jptrainor jptrainor force-pushed the main branch 2 times, most recently from 11dd246 to 33fe8f0 Compare December 19, 2025 15:19
- Respect BUILD_SHARED_LIBS for mxl, mxl-common, and mxl-fabrics
- Add MXL_ENABLE_PIC option (default ON) for static builds
- Fix CMake export set dependencies involving mxl-internal-headers
- Update libmxl.pc to correctly express static linking requirements
- Add test to validate pkg-config C consumer linking (static and shared)
- Add "CMAKE_LINKER_TYPE": "LLD" to the clang preset to resolve LTO linking
  in the test.

Signed-off-by: jpt <jim.trainor@jptrainor.com>
@vt-tv
Copy link
Contributor

vt-tv commented Dec 22, 2025

@jptrainor Is the request for changes from Kimon adressed?

@jptrainor
Copy link
Contributor Author

@jptrainor Is the request for changes from Kimon adressed?

Yes

@vt-tv
Copy link
Contributor

vt-tv commented Dec 22, 2025

@jptrainor Is the request for changes from Kimon adressed?

Yes

Ready to merge (with rebase)? if so I'll do it now.

@vt-tv vt-tv merged commit 1ccf048 into dmf-mxl:main Dec 22, 2025
9 checks passed
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.

5 participants