Skip to content

Hide some internal functions and 13 variables from public ABI - #14367

Open
hppritcha wants to merge 1 commit into
open-mpi:mainfrom
hppritcha:issue_14336
Open

Hide some internal functions and 13 variables from public ABI#14367
hppritcha wants to merge 1 commit into
open-mpi:mainfrom
hppritcha:issue_14336

Conversation

@hppritcha

Copy link
Copy Markdown
Member

Add OMPI_HIDDEN attribute to internal symbols in libmpi.so and libmpi_abi.so to prevent them from being exported in the public API.

Hidden functions (27):

  • 9 ABI C callback functions (ABI_C_MPI_*_FN)
  • 12 MPI_T functions (ompit_*, including ompi_mpit_lock/unlock)
  • 4 Fortran ABI functions (ompi_abi_get/set_fortran_*)
  • 2 Sendrecv functions (ompi_sendrecv, ompi_isendrecv)

Hidden variables (13):

  • 9 ABI variables (ompi_abi_mpi_*)
  • 2 MPI_T variables (ompi_mpit_big_lock, ompi_mpit_init_failed)
  • 2 Class instances (ompi_isendrecv_context_t_class, ompi_isendrecv_replace_context_t_class)

Files modified:

  • ompi/mpi/c/attr_fn_abi.c
  • ompi/mpi/c/abi.h
  • ompi/mpi/c/bindings.h
  • ompi/mpi/c/ompi_abi_fortran.c
  • ompi/mpi/c/ompi_isendrecv.c
  • ompi/mpi/c/ompi_sendrecv.c
  • ompi/mpi/tool/mpit_common.c
  • ompi/mpi/tool/mpit-internal.h
  • ompi/test/general/abi_fortran.c
  • ompi/mpi/bindings/ompi_bindings/c.py
  • ompi/mpi/c/isendrecv_replace.c.in

Also updated AGENTS.md with a note about changing visibility of internal symbols which tests might be using.

Related to #14336

Add OMPI_HIDDEN attribute to internal symbols in libmpi.so and
libmpi_abi.so to prevent them from being exported in the public API.

Hidden functions (27):
- 9 ABI C callback functions (ABI_C_MPI_*_FN)
- 12 MPI_T functions (ompit_*, including ompi_mpit_lock/unlock)
- 4 Fortran ABI functions (ompi_abi_get/set_fortran_*)
- 2 Sendrecv functions (ompi_sendrecv, ompi_isendrecv)

Hidden variables (13):
- 9 ABI variables (ompi_abi_mpi_*)
- 2 MPI_T variables (ompi_mpit_big_lock, ompi_mpit_init_failed)
- 2 Class instances (ompi_isendrecv_context_t_class,
  ompi_isendrecv_replace_context_t_class)

Files modified:
- ompi/mpi/c/attr_fn_abi.c
- ompi/mpi/c/abi.h
- ompi/mpi/c/bindings.h
- ompi/mpi/c/ompi_abi_fortran.c
- ompi/mpi/c/ompi_isendrecv.c
- ompi/mpi/c/ompi_sendrecv.c
- ompi/mpi/tool/mpit_common.c
- ompi/mpi/tool/mpit-internal.h
- ompi/test/general/abi_fortran.c
- ompi/mpi/bindings/ompi_bindings/c.py
- ompi/mpi/c/isendrecv_replace.c.in

Also updated AGENTS.md with a note about changing visibility of internal
symbols which tests might be using.

Related to open-mpi#14336

Signed-off-by: Howard Pritchard <howardp@lanl.gov>
@hppritcha

Copy link
Copy Markdown
Member Author

This PR doesn't address the mysterious

10 Removed function symbols not referenced by debug info:

  [D] MPI_Attr_delete
  [D] MPI_Attr_get
  [D] MPI_Attr_put
  [D] MPI_Keyval_create
  [D] MPI_Keyval_free
  [D] PMPI_Attr_delete
  [D] PMPI_Attr_get
  [D] PMPI_Attr_put
  [D] PMPI_Keyval_create
  [D] PMPI_Keyval_free

mentioned in the issue. That will be investigated/addressed in a different PR>

@hppritcha
hppritcha requested a review from devreal August 28, 2026 21:06

@devreal devreal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I cannot find another place where we have used OMPI_HIDDEN in the ompi source tree (only in the third-party tree). Why is it necessary for internal ABI and tools functions? Would OMPI_DECLSPEC not achieve the same goal?

@hppritcha

Copy link
Copy Markdown
Member Author

@dalcinl how important do you think it is for there to be abidiff between the stub implementation and ompi libmpi_abi?

@dalcinl

dalcinl commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

how important do you think it is for there to be abidiff between the stub implementation and ompi libmpi_abi?

Well, it depends on what kind of differences we are talking about.

For sure there should be nothing missing, that would be a bug. That's why I pointed out the missing MPI_(Attr|Keyval)_* functions.

However, I would not complain if OMPI exposes additional functions. For example, OMPI may want to expose MPIX_* functions related to the current in-development fault tolerance APis. I think MPICH is currently doing that, that is exposing its MPIX_ symbols.

What I'm not so OK about is carelessly exposing internal functions and variables without a clear purpose. I think that is the case of the 27 functions and 13 variables I reported in #14336.

We could think of adding a CI test using abidiff. A suppression file would be enough to ignore extra symbols not in the MPI standard, e.g. the MPIX_ stuff, if OMPI ever decides to expose these things in libmpi_abi.so.

@dalcinl

dalcinl commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

I cannot find another place where we have used OMPI_HIDDEN in the ompi source tree (only in the third-party tree). Why is it necessary for internal ABI and tools functions? Would OMPI_DECLSPEC not achieve the same goal?

Well, OMPI's ABI mpi.h does not use OMPI_DECLSPEC. Maybe it should, and libmpi_abi sources should then be build with -fvisibility=hidden ? IIRC, MPICH does something like this. The installed, user-facing ABI mpi.h is plain, no visibility attributes on functions, just like OMPI. However, the sources are built with a different, autogenerated header that do have the equivalent of OMPI_DECLSPEC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants