rubys / nokogumbo

A Nokogiri interface to the Gumbo HTML5 parser.
Apache License 2.0
186 stars 114 forks source link

compilation failing on engine yard cloud (gentoo) #4

Closed AlexandreBernard closed 10 years ago

AlexandreBernard commented 10 years ago

currently no idea what could be missing.

note that i tried also with libxml2 installed on the server

 ~ $ gem install nokogumbo
Fetching: mini_portile-0.6.0.gem (100%)
Successfully installed mini_portile-0.6.0
Fetching: nokogiri-1.6.2.1.gem (100%)
Building native extensions.  This could take a while...
Building nokogiri using packaged libraries.
Building libxml2-2.8.0 for nokogiri with the following patches applied:
    - 0001-Fix-parser-local-buffers-size-problems.patch
    - 0002-Fix-entities-local-buffers-size-problems.patch
    - 0003-Fix-an-error-in-previous-commit.patch
    - 0004-Fix-potential-out-of-bound-access.patch
    - 0005-Detect-excessive-entities-expansion-upon-replacement.patch
    - 0006-Do-not-fetch-external-parsed-entities.patch
    - 0007-Enforce-XML_PARSER_EOF-state-handling-through-the-pa.patch
    - 0008-Improve-handling-of-xmlStopParser.patch
    - 0009-Fix-a-couple-of-return-without-value.patch
    - 0010-Keep-non-significant-blanks-node-in-HTML-parser.patch
    - 0011-Do-not-fetch-external-parameter-entities.patch
************************************************************************
IMPORTANT!  Nokogiri builds and uses a packaged version of libxml2.

If this is a concern for you and you want to use the system library
instead, abort this installation process and reinstall nokogiri as
follows:

    gem install nokogiri -- --use-system-libraries

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

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

However, note that nokogiri does not necessarily support all versions
of libxml2.

For example, libxml2-2.9.0 and higher are currently known to be broken
and thus unsupported by nokogiri, due to compatibility problems and
XPath optimization bugs.
************************************************************************
Building libxslt-1.1.28 for nokogiri with the following patches applied:
    - 0001-Adding-doc-update-related-to-1.1.28.patch
    - 0002-Fix-a-couple-of-places-where-f-printf-parameters-wer.patch
    - 0003-Initialize-pseudo-random-number-generator-with-curre.patch
    - 0004-EXSLT-function-str-replace-is-broken-as-is.patch
    - 0006-Fix-str-padding-to-work-with-UTF-8-strings.patch
    - 0007-Separate-function-for-predicate-matching-in-patterns.patch
    - 0008-Fix-direct-pattern-matching.patch
    - 0009-Fix-certain-patterns-with-predicates.patch
    - 0010-Fix-handling-of-UTF-8-strings-in-EXSLT-crypto-module.patch
    - 0013-Memory-leak-in-xsltCompileIdKeyPattern-error-path.patch
    - 0014-Fix-for-bug-436589.patch
    - 0015-Fix-mkdir-for-mingw.patch
************************************************************************
IMPORTANT!  Nokogiri builds and uses a packaged version of libxslt.

If this is a concern for you and you want to use the system library
instead, abort this installation process and reinstall nokogiri as
follows:

    gem install nokogiri -- --use-system-libraries

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

    bundle config build.nokogiri --use-system-libraries
    bundle install
************************************************************************
Successfully installed nokogiri-1.6.2.1
Fetching: nokogumbo-1.1.5.gem (100%)
Building native extensions.  This could take a while...
ERROR:  Error installing nokogumbo:
    ERROR: Failed to build gem native extension.

    /usr/bin/ruby21 extconf.rb
checking for xmlNewDoc() in -lxml2... yes
checking for nokogiri.h in /home/deploy/.gem/ruby/2.1.0/gems/nokogiri-1.6.2.1/ext/nokogiri... yes
checking for nokogiri.h in /home/deploy/.gem/ruby/2.1.0/gems/nokogiri-1.6.2.1/ext/nokogiri... yes
checking for gumbo_parse() in -lgumbo... no
creating Makefile

make "DESTDIR="
compiling vector.c
compiling tokenizer.c
compiling utf8.c
compiling nokogumbo.c
In file included from nokogumbo.c:28:0:
/home/deploy/.gem/ruby/2.1.0/gems/nokogiri-1.6.2.1/ext/nokogiri/nokogiri.h:13:0: warning: "_GNU_SOURCE" redefined
/usr/include/ruby-2.1.0/x86_64-linux/ruby/config.h:17:0: note: this is the location of the previous definition
compiling error.c
compiling parser.c
compiling tag.c
compiling attribute.c
compiling util.c
compiling string_piece.c
compiling string_buffer.c
compiling char_ref.c
linking shared-object nokogumboc.so
nokogumbo.o: In function `parse':
nokogumbo.c:(.text+0x26a): undefined reference to `Nokogiri_wrap_xml_document'
collect2: ld returned 1 exit status
make: *** [nokogumboc.so] Error 1

Gem files will remain installed in /home/deploy/.gem/ruby/2.1.0/gems/nokogumbo-1.1.5 for inspection.
Results logged to /home/deploy/.gem/ruby/2.1.0/gems/nokogumbo-1.1.5/ext/nokogumboc/gem_make.out
AlexandreBernard commented 10 years ago

still investigating.. i've tried installing gumbo on the system first. the error changes but remains the same:

$ gem install nokogumbo
Building native extensions.  This could take a while...
ERROR:  Error installing nokogumbo:
    ERROR: Failed to build gem native extension.

    /usr/bin/ruby21 extconf.rb
checking for xmlNewDoc() in -lxml2... yes
checking for nokogiri.h in /home/deploy/.gem/ruby/2.1.0/gems/nokogiri-1.6.1/ext/nokogiri... yes
checking for nokogiri.h in /home/deploy/.gem/ruby/2.1.0/gems/nokogiri-1.6.1/ext/nokogiri... yes
checking for gumbo_parse() in -lgumbo... yes
creating Makefile

make "DESTDIR="
compiling nokogumbo.c
In file included from nokogumbo.c:28:0:
/home/deploy/.gem/ruby/2.1.0/gems/nokogiri-1.6.1/ext/nokogiri/nokogiri.h:13:0: warning: "_GNU_SOURCE" redefined
/usr/include/ruby-2.1.0/x86_64-linux/ruby/config.h:17:0: note: this is the location of the previous definition
linking shared-object nokogumboc.so
nokogumbo.o: In function `parse':
nokogumbo.c:(.text+0x26a): undefined reference to `Nokogiri_wrap_xml_document'
collect2: ld returned 1 exit status
make: *** [nokogumboc.so] Error 1

Gem files will remain installed in /home/deploy/.gem/ruby/2.1.0/gems/nokogumbo-1.1.5 for inspection.
Results logged to /home/deploy/.gem/ruby/2.1.0/gems/nokogumbo-1.1.5/ext/nokogumboc/gem_make.out
rbankston commented 10 years ago

able to get it installed by passing

gem install nokogumbo -- --with-ldflags=-no-undefined

Also fails on some centos boxes

rubys commented 10 years ago

@rbankston care to create a patch?

krutten commented 10 years ago

Couldn't find a way to get that into the Gem. Anywhere in the extconf.rb I added it I got

compiling nokogumbo.c
In file included from nokogumbo.c:28:0:
/usr/local/lib64/ruby/gems/2.0.0/gems/nokogiri-1.6.2.1/ext/nokogiri/nokogiri.h:13:0: warning: "_GNU_SOURCE" redefined
/usr/include/ruby-2.0.0/x86_64-linux/ruby/config.h:17:0: note: this is the location of the previous definition
compiling string_piece.c
linking shared-object nokogumboc.so
x86_64-pc-linux-gnu-gcc: unrecognized option '-no-undefined'
nokogumbo.o: In function `parse':
nokogumbo.c:(.text+0x26a): undefined reference to `Nokogiri_wrap_xml_document'
collect2: ld returned 1 exit status
make: *** [nokogumboc.so] Error 1
ERROR:  Error installing pkg/nokogumbo-1.1.5.gem:

Explicitly adding the library worked for me.

https://github.com/rubys/nokogumbo/pull/5

rubys commented 10 years ago

@AlexandreBernard does gem version 1.1.6 solve this for you?

AlexandreBernard commented 10 years ago

on the server yes it does compile

however now it fails on my mac but let me ask for a confirmation to somebody else at the office tomorrow morning: i played a bit forking the gem on my machine and i suspect there's something i should clean. keeping you informed.

AlexandreBernard commented 10 years ago

unfortunately others can confirm, that doesn't compile anymore on a mac

we're using ruby 2.1.2 on mavericks with everything up to date i guess

https://gist.github.com/Veejay/a80fda133f351fe4400c

rubys commented 10 years ago

OK, so the current state is that nokogumbo builds on mac osx and ubuntu and fails on gentoo and centos. With the patch @krutten it builds on ubuntu, gentoo, and centos, but fails on mac osx.

Is it worth trying adding the following line to the patch @krutten provided?

if RUBY_PLATFORM !~ /linux/

If necessary, we can more finely select/exclude the linux variant using code from https://github.com/goodtouch/rbenv-ruby-install/blob/master/platform_info.rb#L49

AlexandreBernard commented 10 years ago

I guess this would work. I definitely don't have any C skills but isn't there a fix that could be done on the code (nokogumbo.c rather than extconf.rb) that would make it run everywhere?

rubys commented 10 years ago

With compiled languages, there are two steps. First you compile each source into an object file; then you link the object files together to build either an executable or a shared library. The Gentoo failure is in the link step:

linking shared-object nokogumboc.so
nokogumbo.o: In function `parse':
nokogumbo.c:(.text+0x26a): undefined reference to `Nokogiri_wrap_xml_document'
collect2: ld returned 1 exit status

Adding the library needed to resolve this, causes a Mac OSX failure is in the link step:

ld: library not found for -l:nokogiri.so
AlexandreBernard commented 10 years ago

thanks, can you release it please?

rubys commented 10 years ago

done

AlexandreBernard commented 10 years ago

and.... it works! thanks a lot for the help