[前][次][番号順一覧][スレッド一覧]

ruby-changes:66719

From: =E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3 <ko1@a...>
Date: Wed, 7 Jul 2021 20:31:40 +0900 (JST)
Subject: [ruby-changes:66719] 737e4432b9 (master): configuRe: add -Wl, --no-as-needed

https://git.ruby-lang.org/ruby.git/commit/?id=737e4432b9

From 737e4432b978eb4b9f5b10fb6cc6d9c883a5d17a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?=
 <shyouhei@r...>
Date: Wed, 7 Jul 2021 10:16:48 +0900
Subject: 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@g...> for their contributions.
---
 configure.ac | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/configure.ac b/configure.ac
index 0acadac..9ce7538 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3383,6 +3383,11 @@ AS_CASE("$enable_shared", [yes], [ https://github.com/ruby/ruby/blob/trunk/configure.ac#L3383
   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*], [],
     [
-- 
cgit v1.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]