Skip to content

prov/efa: fix unit test linking to not affect libfabric.so#12001

Draft
sunkuamzn wants to merge 1 commit intoofiwg:mainfrom
sunkuamzn:unit-test-build-fix
Draft

prov/efa: fix unit test linking to not affect libfabric.so#12001
sunkuamzn wants to merge 1 commit intoofiwg:mainfrom
sunkuamzn:unit-test-build-fix

Conversation

@sunkuamzn
Copy link
Copy Markdown
Contributor

The previous implementation added "-static" to efa_LIBS when unit tests were enabled, which caused static linking flags to propagate into the main libfabric.so build. This resulted in a shared library with embedded static dependencies, causing symbol conflicts and breaking compatibility with other tests and applications.

The fix isolates static linking to only the unit test binary by:

  1. Removing "-static" from efa_LIBS in configure.m4 and storing cmocka flags in a separate cmocka_LIBS_STATIC variable

  2. Linking the unit test binary against libfabric.a using --whole-archive to include all internal symbols (like efa_env) needed for mocking

  3. Explicitly adding transitive dependencies (-lrdmacm, -libverbs, etc.) required when statically linking libfabric

  4. Adding a dependency on libfabric.la to ensure proper build ordering

This change requires --enable-static when building with unit tests to generate libfabric.a.

The previous implementation added "-static" to efa_LIBS when unit tests
were enabled, which caused static linking flags to propagate into the
main libfabric.so build. This resulted in a shared library with embedded
static dependencies, causing symbol conflicts and breaking compatibility
with other tests and applications.

The fix isolates static linking to only the unit test binary by:

1. Removing "-static" from efa_LIBS in configure.m4 and storing cmocka
   flags in a separate cmocka_LIBS_STATIC variable

2. Linking the unit test binary against libfabric.a using
   --whole-archive
   to include all internal symbols (like efa_env) needed for mocking

3. Explicitly adding transitive dependencies (-lrdmacm, -libverbs, etc.)
   required when statically linking libfabric

4. Adding a dependency on libfabric.la to ensure proper build ordering

This change requires --enable-static when building with unit tests to
generate libfabric.a.

Signed-off-by: Sai Sunku <sunkusa@amazon.com>
@sunkuamzn sunkuamzn marked this pull request as draft March 13, 2026 23:52
@sunkuamzn sunkuamzn marked this pull request as ready for review March 16, 2026 18:04
@sunkuamzn sunkuamzn marked this pull request as draft March 16, 2026 18:14
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