Project

General

Profile

Actions

Bug #8443

closed

-Lprefix/lib

Added by akr (Akira Tanaka) almost 11 years ago. Updated about 10 years ago.

Status:
Closed
Target version:
-
ruby -v:
2.1.0
[ruby-dev:47363]

Description

最近試しているクロスコンパイルな CI で、
思い立って DESTDIR を使って気がついたんですが、
configure に --prefix=/usr と指定すると、
/usr にあるライブラリを使ってしまうことがあるようです。

クロスコンパイルなので、ビルド環境の /usr は使ってほしくないんですが、
どうでしょうか。

実際に問題が出た環境は buildroot で作った i386 環境と、
Android (x86) の環境です。
ビルド環境 (x86_64) と中途半端に似ていると問題が起きやすいようです。

まず i386 は
http://www.rubyist.net/~akr/chkbuild/debian/crossruby-trunk-i386/log/20130522T080000Z.diff.html.gz
というように、curses のところで -ltermcap が見つからないというエラーになっています。

compiling curses.c
linking shared-object curses.so
/extdisk/chkbuild/buildroot/i386/buildroot-2013.02/output/host/usr/lib/gcc/i586-buildroot-linux-uclibc/4.6.3/../../../../i586-buildroot-linux-uclibc/bin/ld:
cannot find -ltermcap

ext/curses/mkmf.log をみると以下のように -ltermcap は見つかっています。
(改行を入れてあります)

have_library: checking for tgetent() in -ltermcap... -------------------- yes

"i586-buildroot-linux-uclibc-gcc -o conftest
-I../../.ext/include/i586-linux-uclibc -I../.././include
-I../.././ext/curses
-O3 -fno-fast-math
-ggdb3
-Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long
-Wno-missing-field-initializers -Wunused-variable -Wpointer-arith
-Wwrite-strings -Wdeclaration-after-statement
-Wimplicit-function-declaration
conftest.c
-L. -L../.. -L.
-rdynamic -Wl,-export-dynamic -Wl,-R -Wl,/usr/lib -L/usr/lib
-lruby-static -ltermcap -lpthread -ldl -lcrypt -lm -lc"
conftest.c: In function 't':
conftest.c:13:57: error: 'tgetent' undeclared (first use in this function)
conftest.c:13:57: note: each undeclared identifier is reported only
once for each function it appears in
conftest.c:13:32: warning: variable 'p' set but not used
[-Wunused-but-set-variable]
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: /top/
4: extern int t(void);
5: int main(int argc, char *argv)
6: {
7: if (argc > 1000000) {
8: printf("%p", &t);
9: }
10:
11: return 0;
12: }
13: int t(void) { void ((volatile p)()); p = (void (()()))tgetent; return 0; }
/
end */

それに対し、make -n で実際のコマンドを調べて実行すると、リンクできません。

% i586-buildroot-linux-uclibc-gcc -shared
-o ../../.ext/i586-linux-uclibc/curses.so curses.o
-L. -L../.. -L. -rdynamic -Wl,-export-dynamic
-lncurses -ltermcap -lpthread -ldl -lcrypt -lm -lc
/extdisk/chkbuild/buildroot/i386/buildroot-2013.02/output/host/usr/lib/gcc/i586-buildroot-linux-uclibc/4.6.3/../../../../i586-buildroot-linux-uclibc/bin/ld:
cannot find -ltermcap
collect2: ld returned 1 exit status

比較すると、mkmf.log には -L/usr/lib があるので
試しに足してみるとリンクできますが、それはおそらく間違いでしょう。

また、Android (x86) では、
http://www.rubyist.net/~akr/chkbuild/debian/crossruby-trunk-x86android/log/20130522T093235Z.diff.html.gz
というように ruby のリンクのところで失敗しています。

linking ruby
/extdisk/chkbuild/android/x86/bin/../sysroot/usr/lib/crtbegin_dynamic.o(.text+0x19):
error: undefined reference to '__libc_init'
eval_error.c:8: error: undefined reference to '__stack_chk_guard'
file.c:1023: error: undefined reference to '__stack_chk_guard'
file.c:1066: error: undefined reference to '__stack_chk_guard'
以下略

make -n で調べると失敗するコマンドラインは以下のようになっています。

i686-linux-android-gcc -O3 -fno-fast-math -ggdb3
-Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long
-Wno-missing-field-initializers -Wunused-variable -Werror=pointer-arith
-Werror=write-strings -Werror=declaration-after-statement
-Werror=implicit-function-declaration
-ansi -std=iso9899:199409
-L. -fstack-protector -rdynamic -Wl,-export-dynamic
-fstack-protector -pie
main.o
-Wl,-R -Wl,/usr/lib -L/usr/lib
-lruby-static -ldl -lm
-o ruby

この場合、-L/usr/lib を削るとリンクに成功します。

-Lprefix/lib というのは、少なくともクロスコンパイルでは間違いだと思うんですが、
どうですかねぇ。

[田中 哲][たなか あきら][Tanaka Akira]

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0