ruby / ruby.wasm

ruby.wasm is a collection of WebAssembly ports of the CRuby.

Home Page:https://ruby.github.io/ruby.wasm/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

rbwasm build fails due to LDFLAGS misconfiguration

palkan opened this issue · comments

On a system having Ruby installed in a non-canonical location (e.g., via Homebrew), the rbwasm build fails to build Ruby (downloaded) due to LDFLAGS issue. Setting LDFLAGS explicitly helps:

$ bundle exec rbwasm build -o ruby.wasm --ruby-version 3.2   

 % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100  114M  100  114M    0     0  45.6M      0  0:00:02  0:00:02 --:--:-- 69.6M
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 4278k  100 4278k    0     0  3598k      0  0:00:01  0:00:01 --:--:-- 12.8M
==> RubyWasm::BuildSource(3.2) -- Building
  ==> curl -L -o /Users/palkan/dev/ruby-next-web/tmp/wasm-test/build/checkouts/3.2.tar.gz https://cache.ruby-lang.org/pub/ruby/3.2/ruby-3.2.3.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 19.6M  100 19.6M    0     0  27.3M      0 --:--:-- --:--:-- --:--:-- 27.3M
  ==> tar xf /Users/palkan/dev/ruby-next-web/tmp/wasm-test/build/checkouts/3.2.tar.gz -C /Users/palkan/dev/ruby-next-web/tmp/wasm-test/build/checkouts/3.2 --strip-components\=1
==> RubyWasm::BuildSource(3.2) -- done in 1.97s
==> RubyWasm::BaseRubyProduct(baseruby-3.2) -- Building
  ==> /Users/palkan/dev/ruby-next-web/tmp/wasm-test/build/checkouts/3.2/configure --prefix\=/Users/palkan/dev/ruby-next-web/tmp/wasm-test/build/arm64-apple-darwin21/baseruby-3.2/opt --disable-install-doc
configure: error: something wrong with LDFLAGS="-L/usr/local/opt/ruby/lib"
checking for ruby... /opt/homebrew/opt/ruby/bin/ruby
tool/config.guess already exists
tool/config.sub already exists
checking build system type... aarch64-apple-darwin23.3.0
checking host system type... aarch64-apple-darwin23.3.0
checking target system type... aarch64-apple-darwin23.3.0
checking for cl.exe... no
checking for clang... clang
checking for llvm-ar... no
checking for clang++... clang++
checking for llvm-nm... no
checking for llvm-objcopy... no
checking for llvm-objdump... no
checking for llvm-ranlib... no
checking for llvm-strip... no
checking for gcc... (cached) clang
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether the compiler supports GNU C... yes
checking whether clang accepts -g... yes
checking for clang option to enable C11 features... none needed
checking whether the compiler supports GNU C++... yes
checking whether clang++ accepts -g... yes
checking for clang++ option to enable C++11 features... none needed
checking how to run the C preprocessor... clang -E
checking for ranlib... ranlib
checking for gar... (cached) /Library/Developer/CommandLineTools/usr/bin/ar
checking for gas... no
checking for as... as
checking for gnm... (cached) /Library/Developer/CommandLineTools/usr/bin/nm
checking for gobjcopy... no
checking for objcopy... no
checking for gobjdump... no
checking for objdump... objdump
checking for gstrip... no
checking for strip... strip
checking for stdio.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for strings.h... yes
checking for sys/stat.h... yes
checking for sys/types.h... yes
checking for unistd.h... yes
checking for wchar.h... yes
checking for minix/config.h... no
checking for vfork.h... no
checking whether it is safe to define __EXTENSIONS__... yes
checking whether _XOPEN_SOURCE should be defined... no
checking if minimum required OS X version is supported... yes
checking if thread-local storage is supported... yes
checking whether the linker is GNU ld... no
checking whether clang -E accepts -o... yes
checking for clang... /usr/bin/clang
checking for real target cpu... arm64
checking arch option... 
checking for /Library/Developer/CommandLineTools/usr/bin/ar flags... rcu
checking whether ln -s works... yes
checking whether make sets $(MAKE)... yes
checking for a BSD-compatible install... /opt/homebrew/bin/ginstall -c
checking for a race-free mkdir -p... /opt/homebrew/bin/gmkdir -p
checking for dtrace... dtrace
checking for dot... dot
checking for doxygen... no
checking for pkg-config... pkg-config
checking whether it is Android... no
checking for cd using physical directory... cd -P
checking whether CFLAGS is valid... yes
checking whether LDFLAGS is valid... no
configure: error: something wrong with LDFLAGS="-L/usr/local/opt/ruby/lib"
Try running with `rake --verbose` for more complete output.
bundler: failed to load command: rbwasm (/opt/homebrew/lib/ruby/gems/3.2.0/bin/rbwasm)
/opt/homebrew/lib/ruby/gems/3.2.0/gems/ruby_wasm-2.5.0-arm64-darwin/lib/ruby_wasm/build/executor.rb:77:in `system': Command failed with status (1): '/Users/palkan/dev/ruby-next-web/tmp/wasm-test/build/checkouts/3.2/configure' '--prefix=/Users/palkan/dev/ruby-next-web/tmp/wasm-test/build/arm64-apple-darwin21/baseruby-3.2/opt' '--disable-install-doc' (RuntimeError)
        from /opt/homebrew/lib/ruby/gems/3.2.0/gems/ruby_wasm-2.5.0-arm64-darwin/lib/ruby_wasm/build/product/baseruby.rb:27:in `build'
        from /opt/homebrew/lib/ruby/gems/3.2.0/gems/ruby_wasm-2.5.0-arm64-darwin/lib/ruby_wasm/build/product/crossruby.rb:172:in `block in build'
        from /opt/homebrew/lib/ruby/gems/3.2.0/gems/ruby_wasm-2.5.0-arm64-darwin/lib/ruby_wasm/build/product/crossruby.rb:170:in `each'
        from /opt/homebrew/lib/ruby/gems/3.2.0/gems/ruby_wasm-2.5.0-arm64-darwin/lib/ruby_wasm/build/product/crossruby.rb:170:in `build'
        from /opt/homebrew/lib/ruby/gems/3.2.0/gems/ruby_wasm-2.5.0-arm64-darwin/lib/ruby_wasm/packager/core.rb:78:in `block in build'

Ruby: ruby 3.2.2 (2023-03-30 revision e51014f9c0) [arm64-darwin21]
rbwasm: 2.5.0

Thank you for your report :) I guess you have set LDFLAGS in your environment variables and our build script respects the variable as traditional autoconf convention. However, the specified linker flags seem not working.

Would you mind checking if you set LDFLAGS in your env (maybe set by shell rc?), and also checking if /usr/local/opt/ruby/lib is a valid directory?

$ echo $LDFLAGS
$ stat /usr/local/opt/ruby/lib

If no LDFLAGS or valid one is specified, I think the build works well.

Oh, yeah, you're right, I have LDFLAGS set to -L/usr/local/opt/ruby/lib for some reason (and there is no such folder). Looks like some installation script configured my .rc file to include a bunch of Ruby-related /usr/local/opt/ruby paths.

Thanks! Closing this.