Skip to content
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

$LDFLAGS not affecting libraries linked by libmpi #12922

Open
minrk opened this issue Nov 14, 2024 · 0 comments
Open

$LDFLAGS not affecting libraries linked by libmpi #12922

minrk opened this issue Nov 14, 2024 · 0 comments

Comments

@minrk
Copy link
Contributor

minrk commented Nov 14, 2024

Background information

What version of Open MPI are you using? (e.g., v4.1.6, v5.0.1, git branch name and hash, etc.)

v5.0.5

Describe how Open MPI was installed (e.g., from a source/distribution tarball, from a git clone, from an operating system distribution package, etc.)

build from distribution tarball

Please describe the system on which you are running

  • Operating system/version: linux
  • Computer hardware: CI (Azure, x86)
  • Network type: N/A

Details of the problem

When investigating #12921 where libmpi is linked to libcudart despite being unused, we were curious about why libcudart was not being stripped since we have -Wl,--as-needed in $LDFLAGS.

Looking at the link command for libmpi, it looks like:

x86_64-conda-linux-gnu-cc -shared  -fPIC -DPIC  $lots_of.o  -Wl,--whole-archive $lots_of.a \
  -Wl,--no-whole-archive  -Wl,-rpath -Wl,$WORK/opal/.libs -Wl,-rpath -Wl,$WORK/3rd-party/openpmix/src/.libs -Wl,-rpath -Wl,$PREFIX/lib \
  -L$WORK/3rd-party/openpmix/src/.libs -L$PREFIX/lib -lucc -lcudart \
  $WORK/opal/.libs/libopen-pal.so -lucp -lucs -lucm -luct -lpthread -lrt \
  $WORK/3rd-party/openpmix/src/.libs/libpmix.so -lm -lutil -ldl -levent_core -levent_pthreads -lhwloc  \
  # the next line is $LDFLAGS \
  -march=nocona -mtune=haswell -fstack-protector-strong -O2 -Wl,-O2 -Wl,--sort-common -Wl,--as-needed -Wl,-z -Wl,relro -Wl,-z -Wl,now -Wl,--disable-new-dtags -Wl,--gc-sections -Wl,--allow-shlib-undefined -Wl,-rpath -Wl,$PREFIX/lib -Wl,-rpath-link -Wl,$PREFIX/lib  \
  -pthread -Wl,-soname -Wl,libmpi.so.40 -o .libs/libmpi.so.40.40.5

where it seems relevant that $LDFLAGS comes after the libraries being linked, which I think means -Wl,--as-needed does not get applied to libcudart or any of the libraries being linked into libmpi. It is possible that there is a fix as simple as moving $LDFLAGS earlier in the link command, but I am not sure if that would have any undesirable consequences.

@minrk minrk changed the title $LDFLAGS not affecting all links of libmpi $LDFLAGS not affecting libraries linked to libmpi Nov 14, 2024
@minrk minrk changed the title $LDFLAGS not affecting libraries linked to libmpi $LDFLAGS not affecting libraries linked by libmpi Nov 14, 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

No branches or pull requests

1 participant