Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot build on FreeBSD 12 #1941

Closed
theirix opened this issue Nov 10, 2019 · 11 comments · Fixed by #1953
Closed

Cannot build on FreeBSD 12 #1941

theirix opened this issue Nov 10, 2019 · 11 comments · Fixed by #1953

Comments

@theirix
Copy link

theirix commented Nov 10, 2019

Have you read and followed the installation tutorial at http://www.nokogiri.org/tutorials/installing_nokogiri.html?

Yes.

What is the complete output of gem install?

% gem install nokogiri -v '=1.10.5'
Building native extensions. This could take a while...
ERROR:  Error installing nokogiri:
	ERROR: Failed to build gem native extension.

    current directory: /usr/local/lib/ruby/gems/2.5/gems/nokogiri-1.10.5/ext/nokogiri
/usr/local/bin/ruby25 -I /usr/local/lib/ruby/site_ruby/2.5 -r ./siteconf20191110-25375-1hxb03q.rb extconf.rb
checking if the C compiler accepts ... yes
Building nokogiri using packaged libraries.
Using mini_portile version 2.4.0
checking for gzdopen() in -lz... yes
checking for iconv... yes
************************************************************************
IMPORTANT NOTICE:

Building Nokogiri with a packaged version of libxml2-2.9.10
with the following patches applied:
	- 0001-Revert-Do-not-URI-escape-in-server-side-includes.patch
	- 0002-Remove-script-macro-support.patch
	- 0003-Update-entities-to-remove-handling-of-ssi.patch

Team Nokogiri will keep on doing their best to provide security
updates in a timely manner, but if this is a concern for you and want
to use the system library instead; abort this installation process and
reinstall nokogiri as follows:

    gem install nokogiri -- --use-system-libraries
        [--with-xml2-config=/path/to/xml2-config]
        [--with-xslt-config=/path/to/xslt-config]

If you are using Bundler, tell it to use the option:

    bundle config build.nokogiri --use-system-libraries
    bundle install

Note, however, that nokogiri is not fully compatible with arbitrary
versions of libxml2 provided by OS/package vendors.
************************************************************************
Extracting libxml2-2.9.10.tar.gz into tmp/amd64-portbld-freebsd12/ports/libxml2/2.9.10... OK
Running git apply with /usr/local/lib/ruby/gems/2.5/gems/nokogiri-1.10.5/patches/libxml2/0001-Revert-Do-not-URI-escape-in-server-side-includes.patch... OK
Running git apply with /usr/local/lib/ruby/gems/2.5/gems/nokogiri-1.10.5/patches/libxml2/0002-Remove-script-macro-support.patch... OK
Running git apply with /usr/local/lib/ruby/gems/2.5/gems/nokogiri-1.10.5/patches/libxml2/0003-Update-entities-to-remove-handling-of-ssi.patch... OK
Running 'configure' for libxml2 2.9.10... OK
Running 'compile' for libxml2 2.9.10... ERROR, review '/usr/local/lib/ruby/gems/2.5/gems/nokogiri-1.10.5/ext/nokogiri/tmp/amd64-portbld-freebsd12/ports/libxml2/2.9.10/compile.log' to see what happened. Last lines are:
========================================================================
Making all in include
Making all in libxml
Making all in .
  CC       xmllint.o
In file included from xmllint.c:23:
/usr/include/sys/timeb.h:44:2: warning: "this file includes <sys/timeb.h> which is deprecated" [-W#warnings]
#warning "this file includes <sys/timeb.h> which is deprecated"
 ^
1 warning generated.
make[2]: don't know how to make ./libxml2.la. Stop

make[2]: stopped in /usr/local/lib/ruby/gems/2.5/gems/nokogiri-1.10.5/ext/nokogiri/tmp/amd64-portbld-freebsd12/ports/libxml2/2.9.10/libxml2-2.9.10
*** Error code 1

Stop.
make[1]: stopped in /usr/local/lib/ruby/gems/2.5/gems/nokogiri-1.10.5/ext/nokogiri/tmp/amd64-portbld-freebsd12/ports/libxml2/2.9.10/libxml2-2.9.10
*** Error code 1

Stop.
make: stopped in /usr/local/lib/ruby/gems/2.5/gems/nokogiri-1.10.5/ext/nokogiri/tmp/amd64-portbld-freebsd12/ports/libxml2/2.9.10/libxml2-2.9.10
========================================================================
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
	--with-opt-dir
	--without-opt-dir
	--with-opt-include
	--without-opt-include=${opt-dir}/include
	--with-opt-lib
	--without-opt-lib=${opt-dir}/lib
	--with-make-prog
	--without-make-prog
	--srcdir=.
	--curdir
	--ruby=/usr/local/bin/$(RUBY_BASE_NAME)25
	--help
	--clean
	--use-system-libraries
	--enable-static
	--disable-static
	--with-zlib-dir
	--without-zlib-dir
	--with-zlib-include
	--without-zlib-include=${zlib-dir}/include
	--with-zlib-lib
	--without-zlib-lib=${zlib-dir}/lib
	--enable-cross-build
	--disable-cross-build
/usr/local/lib/ruby/gems/2.5/gems/mini_portile2-2.4.0/lib/mini_portile2/mini_portile.rb:402:in `block in execute': Failed to complete compile task (RuntimeError)
	from /usr/local/lib/ruby/gems/2.5/gems/mini_portile2-2.4.0/lib/mini_portile2/mini_portile.rb:373:in `chdir'
	from /usr/local/lib/ruby/gems/2.5/gems/mini_portile2-2.4.0/lib/mini_portile2/mini_portile.rb:373:in `execute'
	from /usr/local/lib/ruby/gems/2.5/gems/mini_portile2-2.4.0/lib/mini_portile2/mini_portile.rb:115:in `compile'
	from /usr/local/lib/ruby/gems/2.5/gems/mini_portile2-2.4.0/lib/mini_portile2/mini_portile.rb:154:in `cook'
	from extconf.rb:365:in `block (2 levels) in process_recipe'
	from extconf.rb:257:in `block in chdir_for_build'
	from extconf.rb:256:in `chdir'
	from extconf.rb:256:in `chdir_for_build'
	from extconf.rb:364:in `block in process_recipe'
	from extconf.rb:262:in `tap'
	from extconf.rb:262:in `process_recipe'
	from extconf.rb:557:in `<main>'

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /usr/local/lib/ruby/gems/2.5/extensions/amd64-freebsd-12/2.5/nokogiri-1.10.5/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /usr/local/lib/ruby/gems/2.5/gems/nokogiri-1.10.5 for inspection.
Results logged to /usr/local/lib/ruby/gems/2.5/extensions/amd64-freebsd-12/2.5/nokogiri-1.10.5/gem_make.out

What are the complete contents of the mkmf.log file generated during the failed installation?

"cc -o conftest -I/usr/local/include/ruby-2.5//amd64-freebsd12 -I/usr/local/include/ruby-2.5//ruby/backward -I/usr/local/include/ruby-2.5/ -I. -I/usr/local/include -isystem /usr/local/include   -O2 -pipe  -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing  -fPIC  conftest.c  -L. -L/usr/local/lib -L.   -fstack-protector-strong  -fstack-protector -rdynamic     -lruby25  -lelf -lunwind -lexecinfo -lprocstat -lthr -ldl -lcrypt -lm -lpthread -L/usr/local/lib -L/usr/local/lib  -lc "
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5:   return 0;
6: }
/* end */

"cc -I/usr/local/include/ruby-2.5//amd64-freebsd12 -I/usr/local/include/ruby-2.5//ruby/backward -I/usr/local/include/ruby-2.5/ -I. -I/usr/local/include -isystem /usr/local/include   -O2 -pipe  -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing  -fPIC    -Werror -c conftest.c"
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main() {return 0;}
/* end */

have_library: checking for gzdopen() in -lz... -------------------- yes

"cc -o conftest -I/usr/local/include/ruby-2.5//amd64-freebsd12 -I/usr/local/include/ruby-2.5//ruby/backward -I/usr/local/include/ruby-2.5/ -I. -I/usr/local/include -isystem /usr/local/include   -O2 -pipe  -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing  -fPIC  -g -DXP_UNIX conftest.c  -L. -L/usr/local/lib -L.   -fstack-protector-strong  -fstack-protector -rdynamic     -lruby25 -lz  -lelf -lunwind -lexecinfo -lprocstat -lthr -ldl -lcrypt -lm -lpthread -L/usr/local/lib -L/usr/local/lib  -lc "
checked program was:
/* begin */
 1: #include "ruby.h"
 2:
 3: #include <zlib.h>
 4:
 5: /*top*/
 6: extern int t(void);
 7: int main(int argc, char **argv)
 8: {
 9:   if (argc > 1000000) {
10:     printf("%p", &t);
11:   }
12:
13:   return 0;
14: }
15: int t(void) { void ((*volatile p)()); p = (void ((*)()))gzdopen; return !p; }
/* end */

--------------------

have_iconv?: checking for iconv... -------------------- yes

"cc -o conftest -I/usr/local/include/ruby-2.5//amd64-freebsd12 -I/usr/local/include/ruby-2.5//ruby/backward -I/usr/local/include/ruby-2.5/ -I. -I/usr/local/include -isystem /usr/local/include   -O2 -pipe  -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing  -fPIC  -g -DXP_UNIX conftest.c  -L. -L/usr/local/lib -L.   -fstack-protector-strong  -fstack-protector -rdynamic     -lruby25  -lelf -lunwind -lexecinfo -lprocstat -lthr -ldl -lcrypt -lm -lpthread -L/usr/local/lib -L/usr/local/lib  -lc "
/usr/bin/ld: error: undefined symbol: libiconv_open
>>> referenced by conftest.c:8
>>>               /tmp/conftest-d25d46.o:(main)

/usr/bin/ld: error: undefined symbol: libiconv
>>> referenced by conftest.c:9
>>>               /tmp/conftest-d25d46.o:(main)
cc: error: linker command failed with exit code 1 (use -v to see invocation)
checked program was:
/* begin */
 1: #include "ruby.h"
 2:
 3: #include <stdlib.h>
 4: #include <iconv.h>
 5:
 6: int main(void)
 7: {
 8:     iconv_t cd = iconv_open("", "");
 9:     iconv(cd, NULL, NULL, NULL, NULL);
10:     return EXIT_SUCCESS;
11: }
/* end */

"cc -o conftest -I/usr/local/include/ruby-2.5//amd64-freebsd12 -I/usr/local/include/ruby-2.5//ruby/backward -I/usr/local/include/ruby-2.5/ -I. -I/usr/local/include -isystem /usr/local/include   -O2 -pipe  -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing  -fPIC  -g -DXP_UNIX conftest.c  -L. -L/usr/local/lib -L.   -fstack-protector-strong  -fstack-protector -rdynamic     -lruby25 -liconv -lelf -lunwind -lexecinfo -lprocstat -lthr -ldl -lcrypt -lm -lpthread -L/usr/local/lib -L/usr/local/lib  -lc "
checked program was:
/* begin */
 1: #include "ruby.h"
 2:
 3: #include <stdlib.h>
 4: #include <iconv.h>
 5:
 6: int main(void)
 7: {
 8:     iconv_t cd = iconv_open("", "");
 9:     iconv(cd, NULL, NULL, NULL, NULL);
10:     return EXIT_SUCCESS;
11: }
/* end */

--------------------

What operating system are you using?

FreeBSD 12

uname -a:

FreeBSD ximc.ru 12.0-RELEASE-p7 FreeBSD 12.0-RELEASE-p7 GENERIC  amd64

gem env:

RubyGems Environment:
  - RUBYGEMS VERSION: 3.0.4
  - RUBY VERSION: 2.5.5 (2019-03-15 patchlevel 157) [amd64-freebsd12]
  - INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/2.5
  - USER INSTALLATION DIRECTORY: /home/irix/.gem/ruby/2.5
  - RUBY EXECUTABLE: /usr/local/bin/ruby25
  - GIT EXECUTABLE: /usr/local/bin/git
  - EXECUTABLE DIRECTORY: /usr/local/bin
  - SPEC CACHE DIRECTORY: /home/irix/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /usr/local/etc
  - RUBYGEMS PLATFORMS:
    - ruby
    - amd64-freebsd-12
  - GEM PATHS:
     - /usr/local/lib/ruby/gems/2.5
     - /home/irix/.gem/ruby/2.5
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /sbin
     - /bin
     - /usr/sbin
     - /usr/bin
     - /usr/games
     - /usr/local/sbin
     - /usr/local/bin
     - /home/irix/bin
     - /home/irix/.rvm/bin
     - /home/irix/.rvm/bin

cc -v

FreeBSD clang version 6.0.1 (tags/RELEASE_601/final 335540) (based on LLVM 6.0.1)
Target: x86_64-unknown-freebsd12.0
Thread model: posix
InstalledDir: /usr/bin
@flavorjones
Copy link
Member

@theirix Hi! Thanks for posting this, and sorry to hear you're having trouble.

I'd like to try to isolate whether this is an issue with libxml2.9.10-on-freebsd-12 or if it's a more general problem of libxml2-on-freebsd-12 or nokogiri-on-freebsd-12. Can you try to do one or both of these things, please:

  1. install nokogiri v1.10.4 (which vendors libxml 2.9.9). if you're successful, this indicates the issue is with libxml 2.9.10 on freebsd 12.
  2. install nokogiri v1.10.5 as above, but compile and link against the system libraries as explained in this section of the installation tutorial. if you're successful, that indicates the problem is with compiling libxml2 and not an issue with nokogiri per se.

Thanks in advance for your help diagnosing what's going on.

@theirix
Copy link
Author

theirix commented Nov 11, 2019

@flavorjones , thanks for the instructions! I'll return with results from a fresh FreeBSD installation.

@theirix
Copy link
Author

theirix commented Nov 12, 2019

Tried with a clean FreeBSD 12, seems strange.

Reproduce steps:

vagrant up generic/freebsd12
vagrant ssh
sudo pkg update
sudo pkg install ruby26-gems libxslt libxml2 pkgconf

freebsd: FreeBSD bazinga.localdomain 12.0-RELEASE FreeBSD 12.0-RELEASE r341666 GENERIC amd64

  • RUBYGEMS VERSION: 3.0.6
  • RUBY VERSION: 2.6.5 (2019-10-01 patchlevel 114) [amd64-freebsd12]
    libxml2: 2.9.9
    cc: FreeBSD clang version 6.0.1 (tags/RELEASE_601/final 335540) (based on LLVM 6.0.1)
  1. Succeeded
sudo gem install nokogiri -v '=1.10.4'
  1. Succededed
sudo gem install nokogiri -v '=1.10.5' -- --use-system-libraries
  1. Fails
sudo gem install nokogiri -v '=1.10.5'

@flavorjones
Copy link
Member

Sorry for the delay in replying here, will take a look.

@flavorjones
Copy link
Member

OK, I've totally reproduced this now, thanks for your help. Unfortunately I don't know how to fix this!

The same issue comes up if I check out (upstream) libxml2 and try to compile it. I'm wondering if someone who understands freebsd better than me can try to get it working? I've spent about an hour on this and haven't made any progress. Maybe @nurse has some time to take a look?

nurse added a commit to nurse/nokogiri that referenced this issue Dec 3, 2019
@nurse
Copy link
Contributor

nurse commented Dec 3, 2019

I also reproduced on FreeBSD 11 and it looks because of the difference of GNU make and BSD make ...?
I reproduced this with plain nokogiri repository master with rake compile, and env MAKE=gmake rake compile works fine.

And #1953 also fix this

@flavorjones
Copy link
Member

@nurse Thank you so much for taking a look and for the PR!

jonathan-shamazing

@theirix I'll merge and cut a patch release in the next day or so.

@flavorjones
Copy link
Member

Shipped in v1.10.6 just now. @theirix please let us know how you get on?

@theirix
Copy link
Author

theirix commented Dec 4, 2019

Works perfectly now, thanks for the quick fix! GNU/BSD differences can be unexpected and very annoying.

@flavorjones
Copy link
Member

I've finally gotten around to proposing a fix upstream in libxml2: Makefile.am: omit $(top_builddir) from DEPS and LDADDS (!232) · Merge requests · GNOME / libxml2 · GitLab

@flavorjones
Copy link
Member

Woo! Patch has been accepted upstream. The next minor release of libxml will allow us to delete the patch from Nokogiri.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants