Uncommon mk 300 build ext error 2

closed

Build fails on darwin due to libtool being removed

ruby -v:

ruby 3.0.0p0 (2020-12-25 revision ccb58c9f76) [x86_64-darwin18]

[ruby-core:101790]


Description

The following commit is causing builds in master and for the recently released Ruby 3.0.0 to fail on darwin. This was tested on macOS Mojave using the most recent XCode and Mojave patches. The error reported is as follows:

compiling bigdecimal.c
In file included from bigdecimal.c:13:
./bigdecimal.h:122:1: error: redefinition of 'rb_array_const_ptr'
rb_array_const_ptr(VALUE a)
^
../.././include/ruby/internal/core/rarray.h:184:1: note: previous definition is here
rb_array_const_ptr(VALUE a)
^
In file included from bigdecimal.c:13:
./bigdecimal.h:139:1: error: static declaration of 'rb_sym2str' follows non-static declaration
rb_sym2str(VALUE sym)
^
../.././include/ruby/internal/symbol.h:63:7: note: previous declaration is here
VALUE rb_sym2str(VALUE);
      ^
bigdecimal.c:109:1: error: static declaration of 'rb_rational_num' follows non-static declaration
rb_rational_num(VALUE rat)
^
../.././include/ruby/internal/intern/rational.h:39:7: note: previous declaration is here
VALUE rb_rational_num(VALUE rat);
      ^
bigdecimal.c:121:1: error: static declaration of 'rb_rational_den' follows non-static declaration
rb_rational_den(VALUE rat)
^
../.././include/ruby/internal/intern/rational.h:40:7: note: previous declaration is here
VALUE rb_rational_den(VALUE rat);
      ^
bigdecimal.c:133:1: error: static declaration of 'rb_complex_real' follows non-static declaration
rb_complex_real(VALUE cmp)
^
../.././include/ruby/internal/intern/complex.h:38:7: note: previous declaration is here
VALUE rb_complex_real(VALUE z);
      ^
bigdecimal.c:145:1: error: static declaration of 'rb_complex_imag' follows non-static declaration
rb_complex_imag(VALUE cmp)
^
../.././include/ruby/internal/intern/complex.h:39:7: note: previous declaration is here
VALUE rb_complex_imag(VALUE z);
      ^
6 errors generated.
make[2]: *** [bigdecimal.o] Error 1
make[1]: *** [ext/bigdecimal/all] Error 2
make: *** [build-ext] Error 2

Reverting the following commit allows the build to run successfully:

https://github.com/ruby/ruby/commit/ed01cc8fdc845b1db258eb3e35b3ba834463672e

After reverting this commit on either master or the v3_0_0 tag, I was able to successfully build again.

  • History
  • Notes
  • Property changes

I've heard that similar error used to occur in earlier versions too,
and sudo xcode-select -s /Library/Developer/CommandLineTools may fix it.

  • Status changed from Open to Feedback

I tried the following on a Macbook Pro with Catalina and the error was still present.

$ sudo rm -rf /Library/Developer/CommandLineTools
$ xcode-select --install
$ sudo xcode-select -s /Library/Developer/CommandLineTools

Adding a data point to this. I've also tried reinstalling the CLTs on Catalina, but the build only succeeded with the reverted commit. Big Sur doesn't support my iMac, so I'm stuck with Catalina for good.

I'm running into this exact same issue, it fails on both Catalina and Big Sur.

$ ASDF_RUBY_BUILD_VERSION=master RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl) --with-readline-dir=$(brew --prefix readline)" asdf install ruby 3.0.0

Downloading ruby-build...
Cloning into '/Users/cbjohnson/.asdf/plugins/ruby/ruby-build-source'...
remote: Enumerating objects: 18, done.
remote: Counting objects: 100% (18/18), done.
remote: Compressing objects: 100% (13/13), done.
remote: Total 11325 (delta 4), reused 11 (delta 3), pack-reused 11307
Receiving objects: 100% (11325/11325), 2.41 MiB | 7.18 MiB/s, done.
Resolving deltas: 100% (7471/7471), done.
Already on 'master'
Downloading ruby-3.0.0.tar.gz...
-> https://cache.ruby-lang.org/pub/ruby/3.0/ruby-3.0.0.tar.gz
Installing ruby-3.0.0...

BUILD FAILED (macOS 11.2 using ruby-build 20210119)

Inspect or clean up the working tree at /var/folders/4y/t1_w3pf12k31z9tmf4hh79tr0000gn/T/ruby-build.20210207172219.84379.QJCgoQ
Results logged to /var/folders/4y/t1_w3pf12k31z9tmf4hh79tr0000gn/T/ruby-build.20210207172219.84379.log

Last 10 log lines:
linking shared-object digest.bundle
linking shared-object etc.bundle
linking shared-object dbm.bundle
make[2]: Leaving directory `/private/var/folders/4y/t1_w3pf12k31z9tmf4hh79tr0000gn/T/ruby-build.20210207172219.84379.QJCgoQ/ruby-3.0.0/ext/digest'
make[2]: Leaving directory `/private/var/folders/4y/t1_w3pf12k31z9tmf4hh79tr0000gn/T/ruby-build.20210207172219.84379.QJCgoQ/ruby-3.0.0/ext/etc'
make[2]: Leaving directory `/private/var/folders/4y/t1_w3pf12k31z9tmf4hh79tr0000gn/T/ruby-build.20210207172219.84379.QJCgoQ/ruby-3.0.0/ext/dbm'
linking shared-object date_core.bundle
make[2]: Leaving directory `/private/var/folders/4y/t1_w3pf12k31z9tmf4hh79tr0000gn/T/ruby-build.20210207172219.84379.QJCgoQ/ruby-3.0.0/ext/date'
gmake[1]: Leaving directory '/private/var/folders/4y/t1_w3pf12k31z9tmf4hh79tr0000gn/T/ruby-build.20210207172219.84379.QJCgoQ/ruby-3.0.0'
gmake: *** [uncommon.mk:300: build-ext] Error 2

$ xcodebuild -version
Xcode 12.4
Build version 12D4e

$ sw_vers
ProductName:    macOS
ProductVersion: 11.2
BuildVersion:   20D64

Complete build log: https://gist.github.com/charlesbjohnson/bc384e90b985d02854380fb476fd22b0

Could you show mkmf.log file for a failed extension?

charlesbjohnson (Charles Johnson) wrote in #note-8:

nobu (Nobuyoshi Nakada) wrote in #note-7:

Could you show mkmf.log file for a failed extension?

Here's what I have for ext/bigdecimal/mkmf.log: https://gist.github.com/charlesbjohnson/1b280cd5fe041824de68dd04bc6fafe1

Good news is that I was able to build 3.0.0. The culprit appeared to be that I'm using the GNU coreutils and related packages (ie. gmake instead of make) installed from Homebrew instead of the usual binaries that come included with macOS. When I unlinked them and used the macOS binaries I was able to build without issue.

For what it's worth, though, I've never ran into this issue with previous Ruby releases.

  • Status changed from Feedback to Closed

This is still failing for me on Big Sur with 3.0.2. I have made sure to uninstall gmake and coreutils from MacPorts but it is still failing. If I revert commit I mentioned in the original report then it builds fine on Big Sur under all conditions, with or without GNU coreutils.

ld: warning: ignoring file ../../libruby.3.0-static.a, building for macOS-x86_64 but attempting to link with file built for macOS-x86_64

This message appears to be contradictory.
Isn’t ranlib working?

Also available in: Atom PDF

Like0

Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0

How to install Ruby 2.5 1 in Ubuntu?

Install Ruby Using Rbenv.
Step 1: Download Updates and Dependencies. Start by updating the system repositories: sudo apt update. ... .
Step 2: Install Rbenv. Download and run the shell script used to install Rbenv: curl -fsSL https://github.com/rbenv/rbenv-installer/raw/HEAD/bin/rbenv-installer | bash. ... .
Step 3: Install Ruby..

How to install Ruby 2.7 0?

Installing Ruby 2.7 with rbenv.
$ git clone https://github.com/rbenv/rbenv.git ~/.rbenv. ... .
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc $ echo 'eval "$(rbenv init -)"' >> ~/.bashrc $ exec $SHELL. ... .
$ git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build..

How to remove Rbenv from Linux?

Use Purging rbenv If you use with purge options to rbenv package, all the configuration and dependent packages will be removed. If you use purge options along with auto-remove, will be removed everything regarding the package, It's really useful when you want to reinstall it again.

How to install Ruby using asdf?

How to install Ruby on Rails 6.1 with asdf on macOS Big Sur.
Step 1 - Install Homebrew. The Missing Package Manager for macOS (or Linux) ... .
Step 2 - Install asdf. Manage multiple runtime versions with a single CLI tool. ... .
Step 3 - Install Ruby. ... .
Step 4 - Install Node. ... .
Step 5 - Install Postgres. ... .
Step 6 - Create Ruby on Rails app..