rubys / nokogumbo

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

Blocker : Nokogumbo gem does not gem install (fail to link with Nokoguri) #165

Closed pvi-github closed 3 years ago

pvi-github commented 3 years ago

Hello,

Tested on various linux distributions.

Here is the symptom on Mageia :

$ gem install nokogumbo -v '2.0.5' --source 'https://rubygems.org/' -- --with-ldflags="-lxml2"                  ERROR:  Could not find a valid gem 'nokogumbo' (= 2.0.5) in any repository
ERROR:  Possible alternatives: nokogumbo
[git@builder gitlab]$ cd
[git@builder ~]$ gem install nokogumbo -v '2.0.5' --source 'https://rubygems.org/' -- --with-ldflags="-lxml2" 
ERROR:  Could not find a valid gem 'nokogumbo' (= 2.0.5) in any repository
ERROR:  Possible alternatives: nokogumbo
[git@builder ~]$ RUBYOPT='--disable-did_you_mean' gem install nokogumbo -v '2.0.5' --source 'https://rubygems.org/' -- --with-ldflags="-lxml2" 
ERROR:  Could not find a valid gem 'nokogumbo' (= 2.0.5) in any repository
^CERROR:  Interrupted
[git@builder ~]$ gem install nokogumbo -v '2.0.4' --source 'https://rubygems.org/' -- --with-ldflags="-lxml2"                       Building native extensions with: '--with-ldflags=-lxml2'
This could take a while...
ERROR:  Error installing nokogumbo:
        ERROR: Failed to build gem native extension.

    current directory: /home/git/.gem/ruby/gems/nokogumbo-2.0.4/ext/nokogumbo
/usr/bin/ruby -I /usr/share/rubygems -r ./siteconf20210225-120197-1niegyi.rb extconf.rb --with-ldflags\=-lxml2
checking for libxml/tree.h in /home/git/.gem/ruby/gems/nokogiri-1.11.1-x86_64-linux/ext/nokogiri/include/libxml2... yes
checking for nokogiri.h in /home/git/.gem/ruby/gems/nokogiri-1.11.1-x86_64-linux/ext/nokogiri... yes
creating Makefile

current directory: /home/git/.gem/ruby/gems/nokogumbo-2.0.4/ext/nokogumbo
make "DESTDIR=" clean
rm -f 
rm -f nokogumbo.so  *.o  *.bak mkmf.log .*.time

current directory: /home/git/.gem/ruby/gems/nokogumbo-2.0.4/ext/nokogumbo
make "DESTDIR="
x86_64-mageia-linux-gnu-gcc -I. -I/usr/include -I/usr/include/ruby/backward -I/usr/include -I. -I/home/git/.gem/ruby/gems/nokogiri-1.11.1-x86_64-linux/ext/nokogiri/include/libxml2 -I/home/git/.gem/ruby/gems/nokogiri-1.11.1-x86_64-linux/ext/nokogiri -I./../../gumbo-parser/src   -fPIC -O2 -g -pipe -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -fasynchronous-unwind-tables -fPIC -std=c99 -DNGLIB=1  -o nokogumbo.o -c nokogumbo.c
x86_64-mageia-linux-gnu-gcc -I. -I/usr/include -I/usr/include/ruby/backward -I/usr/include -I. -I/home/git/.gem/ruby/gems/nokogiri-1.11.1-x86_64-linux/ext/nokogiri/include/libxml2 -I/home/git/.gem/ruby/gems/nokogiri-1.11.1-x86_64-linux/ext/nokogiri -I./../../gumbo-parser/src   -fPIC -O2 -g -pipe -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -fasynchronous-unwind-tables -fPIC -std=c99 -DNGLIB=1  -o char_ref.o -c ./../../gumbo-parser/src/char_ref.c
x86_64-mageia-linux-gnu-gcc -I. -I/usr/include -I/usr/include/ruby/backward -I/usr/include -I. -I/home/git/.gem/ruby/gems/nokogiri-1.11.1-x86_64-linux/ext/nokogiri/include/libxml2 -I/home/git/.gem/ruby/gems/nokogiri-1.11.1-x86_64-linux/ext/nokogiri -I./../../gumbo-parser/src   -fPIC -O2 -g -pipe -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -fasynchronous-unwind-tables -fPIC -std=c99 -DNGLIB=1  -o tag.o -c ./../../gumbo-parser/src/tag.c
x86_64-mageia-linux-gnu-gcc -I. -I/usr/include -I/usr/include/ruby/backward -I/usr/include -I. -I/home/git/.gem/ruby/gems/nokogiri-1.11.1-x86_64-linux/ext/nokogiri/include/libxml2 -I/home/git/.gem/ruby/gems/nokogiri-1.11.1-x86_64-linux/ext/nokogiri -I./../../gumbo-parser/src   -fPIC -O2 -g -pipe -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -fasynchronous-unwind-tables -fPIC -std=c99 -DNGLIB=1  -o tokenizer.o -c ./../../gumbo-parser/src/tokenizer.c
x86_64-mageia-linux-gnu-gcc -I. -I/usr/include -I/usr/include/ruby/backward -I/usr/include -I. -I/home/git/.gem/ruby/gems/nokogiri-1.11.1-x86_64-linux/ext/nokogiri/include/libxml2 -I/home/git/.gem/ruby/gems/nokogiri-1.11.1-x86_64-linux/ext/nokogiri -I./../../gumbo-parser/src   -fPIC -O2 -g -pipe -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -fasynchronous-unwind-tables -fPIC -std=c99 -DNGLIB=1  -o util.o -c ./../../gumbo-parser/src/util.c
x86_64-mageia-linux-gnu-gcc -I. -I/usr/include -I/usr/include/ruby/backward -I/usr/include -I. -I/home/git/.gem/ruby/gems/nokogiri-1.11.1-x86_64-linux/ext/nokogiri/include/libxml2 -I/home/git/.gem/ruby/gems/nokogiri-1.11.1-x86_64-linux/ext/nokogiri -I./../../gumbo-parser/src   -fPIC -O2 -g -pipe -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -fasynchronous-unwind-tables -fPIC -std=c99 -DNGLIB=1  -o string_piece.o -c ./../../gumbo-parser/src/string_piece.c
x86_64-mageia-linux-gnu-gcc -I. -I/usr/include -I/usr/include/ruby/backward -I/usr/include -I. -I/home/git/.gem/ruby/gems/nokogiri-1.11.1-x86_64-linux/ext/nokogiri/include/libxml2 -I/home/git/.gem/ruby/gems/nokogiri-1.11.1-x86_64-linux/ext/nokogiri -I./../../gumbo-parser/src   -fPIC -O2 -g -pipe -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -fasynchronous-unwind-tables -fPIC -std=c99 -DNGLIB=1  -o svg_attrs.o -c ./../../gumbo-parser/src/svg_attrs.c
x86_64-mageia-linux-gnu-gcc -I. -I/usr/include -I/usr/include/ruby/backward -I/usr/include -I. -I/home/git/.gem/ruby/gems/nokogiri-1.11.1-x86_64-linux/ext/nokogiri/include/libxml2 -I/home/git/.gem/ruby/gems/nokogiri-1.11.1-x86_64-linux/ext/nokogiri -I./../../gumbo-parser/src   -fPIC -O2 -g -pipe -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -fasynchronous-unwind-tables -fPIC -std=c99 -DNGLIB=1  -o utf8.o -c ./../../gumbo-parser/src/utf8.c
x86_64-mageia-linux-gnu-gcc -I. -I/usr/include -I/usr/include/ruby/backward -I/usr/include -I. -I/home/git/.gem/ruby/gems/nokogiri-1.11.1-x86_64-linux/ext/nokogiri/include/libxml2 -I/home/git/.gem/ruby/gems/nokogiri-1.11.1-x86_64-linux/ext/nokogiri -I./../../gumbo-parser/src   -fPIC -O2 -g -pipe -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -fasynchronous-unwind-tables -fPIC -std=c99 -DNGLIB=1  -o error.o -c ./../../gumbo-parser/src/error.c
x86_64-mageia-linux-gnu-gcc -I. -I/usr/include -I/usr/include/ruby/backward -I/usr/include -I. -I/home/git/.gem/ruby/gems/nokogiri-1.11.1-x86_64-linux/ext/nokogiri/include/libxml2 -I/home/git/.gem/ruby/gems/nokogiri-1.11.1-x86_64-linux/ext/nokogiri -I./../../gumbo-parser/src   -fPIC -O2 -g -pipe -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -fasynchronous-unwind-tables -fPIC -std=c99 -DNGLIB=1  -o svg_tags.o -c ./../../gumbo-parser/src/svg_tags.c
x86_64-mageia-linux-gnu-gcc -I. -I/usr/include -I/usr/include/ruby/backward -I/usr/include -I. -I/home/git/.gem/ruby/gems/nokogiri-1.11.1-x86_64-linux/ext/nokogiri/include/libxml2 -I/home/git/.gem/ruby/gems/nokogiri-1.11.1-x86_64-linux/ext/nokogiri -I./../../gumbo-parser/src   -fPIC -O2 -g -pipe -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -fasynchronous-unwind-tables -fPIC -std=c99 -DNGLIB=1  -o vector.o -c ./../../gumbo-parser/src/vector.c
x86_64-mageia-linux-gnu-gcc -I. -I/usr/include -I/usr/include/ruby/backward -I/usr/include -I. -I/home/git/.gem/ruby/gems/nokogiri-1.11.1-x86_64-linux/ext/nokogiri/include/libxml2 -I/home/git/.gem/ruby/gems/nokogiri-1.11.1-x86_64-linux/ext/nokogiri -I./../../gumbo-parser/src   -fPIC -O2 -g -pipe -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -fasynchronous-unwind-tables -fPIC -std=c99 -DNGLIB=1  -o ascii.o -c ./../../gumbo-parser/src/ascii.c
x86_64-mageia-linux-gnu-gcc -I. -I/usr/include -I/usr/include/ruby/backward -I/usr/include -I. -I/home/git/.gem/ruby/gems/nokogiri-1.11.1-x86_64-linux/ext/nokogiri/include/libxml2 -I/home/git/.gem/ruby/gems/nokogiri-1.11.1-x86_64-linux/ext/nokogiri -I./../../gumbo-parser/src   -fPIC -O2 -g -pipe -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -fasynchronous-unwind-tables -fPIC -std=c99 -DNGLIB=1  -o attribute.o -c ./../../gumbo-parser/src/attribute.c
x86_64-mageia-linux-gnu-gcc -I. -I/usr/include -I/usr/include/ruby/backward -I/usr/include -I. -I/home/git/.gem/ruby/gems/nokogiri-1.11.1-x86_64-linux/ext/nokogiri/include/libxml2 -I/home/git/.gem/ruby/gems/nokogiri-1.11.1-x86_64-linux/ext/nokogiri -I./../../gumbo-parser/src   -fPIC -O2 -g -pipe -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -fasynchronous-unwind-tables -fPIC -std=c99 -DNGLIB=1  -o parser.o -c ./../../gumbo-parser/src/parser.c
x86_64-mageia-linux-gnu-gcc -I. -I/usr/include -I/usr/include/ruby/backward -I/usr/include -I. -I/home/git/.gem/ruby/gems/nokogiri-1.11.1-x86_64-linux/ext/nokogiri/include/libxml2 -I/home/git/.gem/ruby/gems/nokogiri-1.11.1-x86_64-linux/ext/nokogiri -I./../../gumbo-parser/src   -fPIC -O2 -g -pipe -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -fasynchronous-unwind-tables -fPIC -std=c99 -DNGLIB=1  -o tag_lookup.o -c ./../../gumbo-parser/src/tag_lookup.c
x86_64-mageia-linux-gnu-gcc -I. -I/usr/include -I/usr/include/ruby/backward -I/usr/include -I. -I/home/git/.gem/ruby/gems/nokogiri-1.11.1-x86_64-linux/ext/nokogiri/include/libxml2 -I/home/git/.gem/ruby/gems/nokogiri-1.11.1-x86_64-linux/ext/nokogiri -I./../../gumbo-parser/src   -fPIC -O2 -g -pipe -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -fasynchronous-unwind-tables -fPIC -std=c99 -DNGLIB=1  -o foreign_attrs.o -c ./../../gumbo-parser/src/foreign_attrs.c
x86_64-mageia-linux-gnu-gcc -I. -I/usr/include -I/usr/include/ruby/backward -I/usr/include -I. -I/home/git/.gem/ruby/gems/nokogiri-1.11.1-x86_64-linux/ext/nokogiri/include/libxml2 -I/home/git/.gem/ruby/gems/nokogiri-1.11.1-x86_64-linux/ext/nokogiri -I./../../gumbo-parser/src   -fPIC -O2 -g -pipe -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -fasynchronous-unwind-tables -fPIC -std=c99 -DNGLIB=1  -o string_buffer.o -c ./../../gumbo-parser/src/string_buffer.c
x86_64-mageia-linux-gnu-gcc -I. -I/usr/include -I/usr/include/ruby/backward -I/usr/include -I. -I/home/git/.gem/ruby/gems/nokogiri-1.11.1-x86_64-linux/ext/nokogiri/include/libxml2 -I/home/git/.gem/ruby/gems/nokogiri-1.11.1-x86_64-linux/ext/nokogiri -I./../../gumbo-parser/src   -fPIC -O2 -g -pipe -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -fasynchronous-unwind-tables -fPIC -std=c99 -DNGLIB=1  -o token_buffer.o -c ./../../gumbo-parser/src/token_buffer.c
rm -f nokogumbo.so
x86_64-mageia-linux-gnu-gcc -shared -o nokogumbo.so nokogumbo.o char_ref.o tag.o tokenizer.o util.o string_piece.o svg_attrs.o utf8.o error.o svg_tags.o vector.o ascii.o attribute.o parser.o tag_lookup.o foreign_attrs.o string_buffer.o token_buffer.o -L. -L/usr/lib64 -lxml2 -Wl,--as-needed -Wl,--no-undefined -Wl,-z,relro -Wl,-O1 -Wl,--build-id -Wl,--enable-new-dtags    -lruby  -lm   -lc
/usr/bin/ld: nokogumbo.o: in function `add_errors':
/home/git/.gem/ruby/gems/nokogumbo-2.0.4/ext/nokogumbo/nokogumbo.c:457: undefined reference to `cNokogiriXmlSyntaxError'
/usr/bin/ld: nokogumbo.o: in function `parse_continue':
/home/git/.gem/ruby/gems/nokogumbo-2.0.4/ext/nokogumbo/nokogumbo.c:551: undefined reference to `Nokogiri_wrap_xml_document'
/usr/bin/ld: nokogumbo.o: in function `Init_nokogumbo':
/home/git/.gem/ruby/gems/nokogumbo-2.0.4/ext/nokogumbo/nokogumbo.c:774: undefined reference to `mNokogiri'
collect2: error: ld returned 1 exit status
make: *** [Makefile:263: nokogumbo.so] Error 1

make failed, exit code 2

Gem files will remain installed in /home/git/.gem/ruby/gems/nokogumbo-2.0.4 for inspection.
Results logged to /home/git/.gem/ruby/extensions/x86_64-linux/2.7.0/nokogumbo-2.0.4/gem_make.out

It seems that the link with nokoguri is not made no matter if nokoguriwas installed with the system installer or with gem install

Tested and failed with nokogumbo v 2.0.2, 2.0.3, 2.0.4 on ruby 2.7.2 + gem 3.1.4 and ruby 2.5.8 + gem 2.6.14

All failed

flavorjones commented 3 years ago

Hi @pvi-github, thanks for opening this issue, and I'm sorry you're having issues.

I'm unable to reproduce this on Ubuntu Linux, so this may be something specific to Mageia (which I'm not very familiar with).

I'll keep trying to reproduce, but in the meantime, can you please paste the output from nokogiri -v so we can see how Nokogiri was built?

pvi-github commented 3 years ago

Hello @flavorjones,

thanks for the quick answer.

Here is the output on mageia 7 :

$ nokogiri -v
# Nokogiri (1.11.1)
    ---
    warnings: []
    nokogiri:
      version: 1.11.1
      cppflags:
      - "-I/home/git/.gem/ruby/2.5.0/gems/nokogiri-1.11.1-x86_64-linux/ext/nokogiri"
      - "-I/home/git/.gem/ruby/2.5.0/gems/nokogiri-1.11.1-x86_64-linux/ext/nokogiri/include"
      - "-I/home/git/.gem/ruby/2.5.0/gems/nokogiri-1.11.1-x86_64-linux/ext/nokogiri/include/libxml2"
    ruby:
      version: 2.5.8
      platform: x86_64-linux
      gem_platform: x86_64-linux
      description: ruby 2.5.8p224 (2020-03-31 revision 67882) [x86_64-linux]
      engine: ruby
    libxml:
      source: packaged
      precompiled: true
      patches:
      - 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
      - 0004-libxml2.la-is-in-top_builddir.patch
      - 0005-Fix-infinite-loop-in-xmlStringLenDecodeEntities.patch
      - 0006-htmlParseComment-treat-as-if-it-closed-the-comment.patch
      - 0007-use-new-htmlParseLookupCommentEnd-to-find-comment-en.patch
      - '0008-use-glibc-strlen.patch'
      - '0009-avoid-isnan-isinf.patch'
      libxml2_path: "/home/git/.gem/ruby/2.5.0/gems/nokogiri-1.11.1-x86_64-linux/ext/nokogiri"
      iconv_enabled: true
      compiled: 2.9.10
      loaded: 2.9.10
    libxslt:
      source: packaged
      precompiled: true
      patches: []
      compiled: 1.1.34
      loaded: 1.1.34
    other_libraries:
      zlib: 1.2.11

And on Mageia 8 :

$ ~/bin/nokogiri -v
# Nokogiri (1.11.1)
    ---
    warnings: []
    nokogiri:
      version: 1.11.1
      cppflags:
      - "-I/home/git/.gem/ruby/gems/nokogiri-1.11.1-x86_64-linux/ext/nokogiri"
      - "-I/home/git/.gem/ruby/gems/nokogiri-1.11.1-x86_64-linux/ext/nokogiri/include"
      - "-I/home/git/.gem/ruby/gems/nokogiri-1.11.1-x86_64-linux/ext/nokogiri/include/libxml2"
    ruby:
      version: 2.7.2
      platform: x86_64-linux
      gem_platform: x86_64-linux
      description: ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-linux]
      engine: ruby
    libxml:
      source: packaged
      precompiled: true
      patches:
      - 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
      - 0004-libxml2.la-is-in-top_builddir.patch
      - 0005-Fix-infinite-loop-in-xmlStringLenDecodeEntities.patch
      - 0006-htmlParseComment-treat-as-if-it-closed-the-comment.patch
      - 0007-use-new-htmlParseLookupCommentEnd-to-find-comment-en.patch
      - '0008-use-glibc-strlen.patch'
      - '0009-avoid-isnan-isinf.patch'
      libxml2_path: "/home/git/.gem/ruby/gems/nokogiri-1.11.1-x86_64-linux/ext/nokogiri"
      iconv_enabled: true
      compiled: 2.9.10
      loaded: 2.9.10
    libxslt:
      source: packaged
      precompiled: true
      patches: []
      compiled: 1.1.34
      loaded: 1.1.34
    other_libraries:
      zlib: 1.2.11
flavorjones commented 3 years ago

@pvi-github OK, I'm able to reproduce this -- but ONLY if I have libxml2-devel and libxslt-devel installed. I'm not familiar enough with Mageia to have a theory as to why this would be. Any ideas?

pterjan commented 3 years ago

extconf.rb has $LDFLAGS.gsub!('-Wl,--no-undefined', '') but it also needs $DLDFLAGS.gsub!('-Wl,--no-undefined', '')

stevecheckoway commented 3 years ago

Is one of those causing -Wl,--no-undefined to be added to the link line?

stevecheckoway commented 3 years ago

(I was too slow!)

I'm not familiar with DLDFLAGS, but that certainly seems easy enough to try!

pterjan commented 3 years ago

I am not familiar either but I found it coming from there in the Makefile :)

flavorjones commented 3 years ago

@pterjan Nailed it! That works. I'll create a PR now.

pvi-github commented 3 years ago

You rock guys B-)

pvi-github commented 3 years ago

@flavorjones Can you release a tagged version for this please so that it can be used with gem ?

flavorjones commented 3 years ago

There are a few more fixes I'd like to get into the next release, but my goal is to ship it (potentially with @stevecheckoway's help) in the next few days.

stevecheckoway commented 3 years ago

I’m happy to help however I can.

flavorjones commented 3 years ago

@pvi-github Version 2.0.5 just shipped with this fix. Thanks for your patience!