Closed kramermt closed 3 years ago
No idea why this hasn't shown up before; thanks a ton for the detective work! I'd gladly take another PR to deal with this as you propose (since the -ldl
thing is probably not enough).
(Appears to be solved now; thanks!)
Issue: Even after adding
-ldl
to thekmeans
Makefile, the resulting profile.coz contained only samples, with no progress points.The executable still isn't linking/requiring libdl.so:
Cause: Turns out
gcc
, at least on Ubuntu 14.04 and 20.04, is configured to callld
with--as-needed
by default, and does so before all command-line-specified specified libraries. So-ldl
is effectively--as-needed
, and the weak symbol does count as a "need".clang
, on the same system, does not suffer from this, as it excludes the command-line-specified libraries from--as-needed
.Fix: I resolved this locally by changing the Makefile to:
Which adds not only
libdl.so
, but several other unneeded libraries to the load list, since the setting then applies to all other libraries gcc adds to the LIBS list.Ultimately, the following seems to fix it for
gcc
, without any adverse side-effects forclang
(i.e., clang-linked executables still have the same number of libs in the load list as before this change):And my profiles now contain progress points. Woot.
Questions:
clang
? Or distros that don't buildgcc
with--as-needed
in its default link script?--no-as-needed
requirement to the README?-Wl,--push-state,--no-as-needed -ldl -Wl,--pop-state
be added to the benchmark Makefiles?-ldl
specified in the benchmark Makefiles as it is?Happy to make a Pull Request with any updates you'd find worthwhile, @emeryberger or @ccurtsinger .