tl;dr
- crubyのconfigure時のオプション知りたかったら
RbConfig::CONFIG["configure_args"]
をみる。
環境
$ uname -mrv
4.15.0-124-generic #127-Ubuntu SMP Fri Nov 6 10:54:43 UTC 2020 x86_64
$ cat /etc/issue
Ubuntu 18.04.5 LTS \n \l
$ rbenv --version
rbenv 1.1.2-34-g0843745
$ ruby -v
ruby 2.5.8p224 (2020-03-31 revision 67882) [x86_64-linux]
本題
rbenvで入れたバイナリでdpkg-shlibdepsかけたらなんか言われた。
$ pwd
/home/kubo39/.anyenv/envs/rbenv/versions/2.5.8/bin
$ mkdir debian;touch debian/control
$ dpkg-shlibdeps -v -v ruby
dpkg-shlibdeps: debug: >> Scanning ruby (for Depends field)
dpkg-shlibdeps: debug: Library libruby.so.2.5 found in /home/kubo39/.anyenv/envs/rbenv/versions/2.5.8/lib/libruby.so.2.5
dpkg-shlibdeps: debug: Skipping lib /lib/i386-linux-gnu/libc.so.6, libabi=0x0101000300000000 != objabi=0x0201003e00000000
dpkg-shlibdeps: debug: Skipping lib /lib32/libc.so.6, libabi=0x0101000300000000 != objabi=0x0201003e00000000
dpkg-shlibdeps: debug: Skipping lib /libx32/libc.so.6, libabi=0x0101003e00000000 != objabi=0x0201003e00000000
dpkg-shlibdeps: debug: Skipping lib /lib32/libc.so.6, libabi=0x0101000300000000 != objabi=0x0201003e00000000
dpkg-shlibdeps: debug: Library libc.so.6 found in /lib/x86_64-linux-gnu/libc.so.6
dpkg-shlibdeps: debug: No associated package found for /home/kubo39/.anyenv/envs/rbenv/versions/2.5.8/lib/libruby.so.2.5
dpkg-shlibdeps: debug: Using shlibs+objdump for libruby.so.2.5 (file /home/kubo39/.anyenv/envs/rbenv/versions/2.5.8/lib/libruby.so.2.5)
dpkg-shlibdeps: debug: Looking up shlibs dependency of libruby.so.2.5 provided by ''
dpkg-shlibdeps: debug: Found nothing
dpkg-shlibdeps: debug: No shlibs+objdump info available, trying next package for /home/kubo39/.anyenv/envs/rbenv/versions/2.5.8/lib/libruby.so.2.5
dpkg-shlibdeps: error: no dependency information found for /home/kubo39/.anyenv/envs/rbenv/versions/2.5.8/lib/libruby.so.2.5 (used by ruby)
Hint: check if the library actually comes from a package.
ん?と思ってlddみるとlibruby.soとかいうのリンクしてる。これは自前ビルドしたやつにはなかったような。
$ ldd ruby
linux-vdso.so.1 (0x00007fff7c5be000)
libgtk3-nocsd.so.0 => /usr/lib/x86_64-linux-gnu/libgtk3-nocsd.so.0 (0x00007f27f31ad000)
libruby.so.2.5 => /home/kubo39/.anyenv/envs/rbenv/versions/2.5.8/lib/libruby.so.2.5 (0x00007f27f2c79000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f27f2888000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f27f2684000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f27f2465000)
libgmp.so.10 => /usr/lib/x86_64-linux-gnu/libgmp.so.10 (0x00007f27f21e4000)
libcrypt.so.1 => /lib/x86_64-linux-gnu/libcrypt.so.1 (0x00007f27f1fac000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f27f1c0e000)
/lib64/ld-linux-x86-64.so.2 (0x00007f27f35b6000)
とりあえずconfigureの引数知りたいな、ってときは RbConfig::CONFIG
が使える。
$ irb
irb(main):001:0> RbConfig::CONFIG["configure_args"]
=> " '--prefix=/home/kubo39/.anyenv/envs/rbenv/versions/2.5.8' '--enable-shared' 'LDFLAGS=-L/home/kubo39/.anyenv/envs/rbenv/versions/2.5.8/lib ' 'CPPFLAGS=-I/home/kubo39/.anyenv/envs/rbenv/versions/2.5.8/include '"
--enable-shared
ってオプションがそれっぽい。
- Build ruby with shared library - rbenv/ruby-build
- Turn on
--enable-shared
by default for all supported MRI Rubies - rbenv/ruby-build
なるほどね。
追記
ビルド時っていうとこういうのあるので言葉がよくない。
irb(main):002:0> RbConfig::CONFIG["CXXFLAGS"]
=> "-O3 -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wmisleading-indentation -Wno-packed-bitfield-compat -Wsuggest-attribute=noreturn -Wsuggest-attribute=format -Wimplicit-fallthrough=0 -Wduplicated-cond -Wrestrict"
irb(main):003:0> RbConfig::CONFIG["CFLAGS"]
=> "-O3 -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wmisleading-indentation -Wno-packed-bitfield-compat -Wsuggest-attribute=noreturn -Wsuggest-attribute=format -Wimplicit-fallthrough=0 -Wduplicated-cond -Wrestrict -fPIC"
irb(main):004:0> RbConfig::CONFIG["LDFLAGS"]
=> "-L. -L/home/kubo39/.anyenv/envs/rbenv/versions/2.5.8/lib -fstack-protector -rdynamic -Wl,-export-dynamic"
おまけ
なぜかはわからないけど、rbenvで入れたやつはソースコードはおろかMakefileもconfigure残ってない(ソースからビルドしてるはずなので、わざわざ消しているのだろう。容量削減?)
かわりに自前ビルドしたやつのほうをみてみる。
$ ./configure --help| grep enable-shared
--enable-shared build a shared library for Ruby
うーん、まあそうなんだろうけど、rubyバイナリ自身が依存してるのはなんでだろ。
C拡張ライブラリ用とかそういう感じな気がするけどよくわからなかった。