configure: add -Wl,--no-as-needed

It is reported that combination of `--enable-shared --with-jemalloc`
breaks on Debian bullseye (testig).  Deeper investigation revealed that
this system's `ld(1)` is patched, to turn `ld --as-needed` on by
default.

This linker flag strips "unnecessary" library dependencies from an
executable.  In case of `ruby(1)` (of `--enable-shared`), because
everything is in `libruby.so`, the binary itself doesn't include any
calls to `malloc(3)` at all.  So in spite of our explicit `-ljemalloc`
flag, it is ignored.  Libc's one is chosen instead.

This is not what we want.  Let's force our `ruby(1)` link what we want.

Fixes https://github.com/ruby/ruby/pull/4627

The author would like to acknowledge
Akihiko Odaki <akihiko.odaki@gmail.com> for their contributions.
This commit is contained in:
卜部昌平 2021-07-07 10:16:48 +09:00
Родитель 1293042307
Коммит 737e4432b9
1 изменённых файлов: 5 добавлений и 0 удалений

Просмотреть файл

@ -3383,6 +3383,11 @@ AS_CASE("$enable_shared", [yes], [
AC_DEFINE_UNQUOTED(LIBDIR_BASENAME, ["${libdir_basename}"])
libdir_basename="${libdir_basename}"${multiarch+'/${arch}'}
RUBY_TRY_LDFLAGS([${linker_flag}--no-as-needed], [no_as_needed=yes], [no_as_needed=no])
AS_IF([test "$no_as_needed" = yes], [
RUBY_APPEND_OPTIONS(LDFLAGS, [${linker_flag}--no-as-needed])
])
AS_CASE(["$target_os"],
[freebsd*|dragonfly*], [],
[