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

Wunused-parameter introduced in #1731 breaks the "make config" phase on Mingw64/Msys64 #1772

Closed
mild123 opened this issue Jun 21, 2018 · 10 comments
Milestone

Comments

@mild123
Copy link

mild123 commented Jun 21, 2018

If you're having trouble installing Nokogiri ...

Have you tried following the installation tutorial?

What is the output of gem install?

What are the contents of the mkmf.log file?

What operating system are you using?

If this isn't an installation issue ...

What problems are you experiencing?

What's the output from nokogiri -v?

Can you provide a self-contained script that reproduces what you're seeing?

@mild123
Copy link
Author

mild123 commented Jun 21, 2018

The merge pull request #1731 introduced the gcc warning flag Wextra, which in the presents of the Wall warning flag, turns on the warning flag Wunused-parameter. The latter warning flag breaks the “make config” phase on a stock native mingw64/msys64 system (with a windows-installer2 ruby 2.5.1) see below.

The compilation completes successfully if the Wextra flag is replaced (leaving out the offending Wunused-parameter warning flag) with the longish warning flag collection

-Wbad-function-cast -Wempty-body -Wignored-qualifiers -Wimplicit-fallthrough=3 -Wmissing-field-initializers -Wmissing-parameter-type -Wold-style-declaration -Woverride-init -Wsign-compare -Wtype-limits -Wuninitialized -Wshift-negative-value -Wunused-but-set-parameter

"pkg-config --exists libxml-2.0"
| pkg-config --libs libxml-2.0
=> "-LC:/Programme/Msys64/mingw64/lib -lxml2\n"
"x86_64-w64-mingw32-gcc -o conftest.exe -IC:/Programme/Msys64/mingw64/include/ruby-2.5.0/x64-mingw32 -IC:/Programme/Msys64/mingw64/include/ruby-2.5.0/ruby/backward -IC:/Programme/Msys64/mingw64/include/ruby-2.5.0 -I. -D_FORTIFY_SOURCE=2 -D__USE_MINGW_ANSI_STDIO=1 -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0501 -D__MINGW_USE_VC2005_COMPAT -D_FILE_OFFSET_BITS=64 "-Idummypath" -march=x86-64 -mtune=generic -O2 -pipe -DXP_WIN -DXP_WIN32 -DUSE_INCLUDED_VASPRINTF -Wall -Wcast-qual -Wwrite-strings -Wextra -Wmissing-noreturn -Winline conftest.c -L. -LC:/Programme/Msys64/mingw64/lib -L. -pipe -lx64-msvcrt-ruby250 -LC:/Programme/Msys64/mingw64/lib -lxml2 -lgmp -lshell32 -lws2_32 -liphlpapi -limagehlp -lshlwapi "
conftest.c: In function 'main':
conftest.c:5:14: warning: unused parameter 'argc' [-Wunused-parameter]
int main(int argc, char **argv)
^~~~
conftest.c:5:27: warning: unused parameter 'argv' [-Wunused-parameter]
int main(int argc, char *argv)
^~~~
checked program was:
/
begin */
1: #include "ruby.h"
2:
3: #include <winsock2.h>
4: #include <windows.h>
5: int main(int argc, char *argv)
6: {
7: return 0;
8: }
/
end */

package configuration for libxml-2.0 is not found
have_package: checking for libxml-2.0... -------------------- no

@mild123 mild123 changed the title -Wunused-parameter introduced in #1731 causes a "make config failure" on a mingw64/msys64 system -Wunused-parameter introduced in #1731 breaks the "make config failure" phase on a mingw64/Msys64 system Jun 21, 2018
@mild123 mild123 changed the title -Wunused-parameter introduced in #1731 breaks the "make config failure" phase on a mingw64/Msys64 system The warning flag Wunused-parameter introduced in #1731 breaks the "make config failure" phase on a mingw64/Msys64 system Jun 21, 2018
@mild123 mild123 changed the title The warning flag Wunused-parameter introduced in #1731 breaks the "make config failure" phase on a mingw64/Msys64 system Wunused-parameter introduced in #1731 breaks the "make config" phase on a Mingw64/Msys64 system Jun 21, 2018
@mild123 mild123 changed the title Wunused-parameter introduced in #1731 breaks the "make config" phase on a Mingw64/Msys64 system Wunused-parameter introduced in #1731 breaks the "make config" phase on Mingw64/Msys64 Jun 21, 2018
@flavorjones
Copy link
Member

Thanks for reporting, will investigate this weekend.

@flavorjones
Copy link
Member

See conversation going on at #1731, I'm having trouble reproducing this.

@voxik
Copy link
Contributor

voxik commented Jul 10, 2018

I can reproduce the same issues on Fedora and I think the difference is the availability of pkg-config gem:

$ diff -u ext/nokogiri/extconf.conversion.rb ext/nokogiri/extconf.extra.rb 
--- ext/nokogiri/extconf.conversion.rb	2018-07-10 09:36:04.283025538 +0200
+++ ext/nokogiri/extconf.extra.rb	2018-07-10 09:36:40.403480909 +0200
@@ -434,7 +434,7 @@
 
 if RbConfig::MAKEFILE_CONFIG['CC'] =~ /gcc/
   $CFLAGS << " -O3" unless $CFLAGS[/-O\d/]
-  $CFLAGS << " -Wall -Wcast-qual -Wwrite-strings -Wconversion -Wmissing-noreturn -Winline"
+  $CFLAGS << " -Wall -Wcast-qual -Wwrite-strings -Wextra -Wmissing-noreturn -Winline"
 end
 
 case

$ gem list | grep pkg-config

$ NOKOGIRI_USE_SYSTEM_LIBRARIES=yes ruby ext/nokogiri/extconf.conversion.rb 
checking if the C compiler accepts ... yes
Building nokogiri using system libraries.
checking for xmlParseDoc() in libxml/parser.h... yes
checking for xsltParseStylesheetDoc() in libxslt/xslt.h... yes
checking for exsltFuncRegister() in libexslt/exslt.h... yes
checking for xmlHasFeature()... yes
checking for xmlFirstElementChild()... yes
checking for xmlRelaxNGSetParserStructuredErrors()... yes
checking for xmlRelaxNGSetParserStructuredErrors()... yes
checking for xmlRelaxNGSetValidStructuredErrors()... yes
checking for xmlSchemaSetValidStructuredErrors()... yes
checking for xmlSchemaSetParserStructuredErrors()... yes
creating Makefile

$ NOKOGIRI_USE_SYSTEM_LIBRARIES=yes ruby ext/nokogiri/extconf.extra.rb 
checking if the C compiler accepts ... yes
Building nokogiri using system libraries.
pkg-config could not be used to find libxml-2.0
Please install either `pkg-config` or the pkg-config gem per

    gem install pkg-config -v "~> 1.1"

pkg-config could not be used to find libxslt
Please install either `pkg-config` or the pkg-config gem per

    gem install pkg-config -v "~> 1.1"

pkg-config could not be used to find libexslt
Please install either `pkg-config` or the pkg-config gem per

    gem install pkg-config -v "~> 1.1"

ERROR: cannot discover where libxml2 is located on your system. please make sure `pkg-config` is installed.

$ gem install pkg-config
Fetching: pkg-config-1.3.1.gem (100%)
WARNING:  You don't have /builddir/bin in your PATH,
	  gem executables will not run.
Successfully installed pkg-config-1.3.1
Parsing documentation for pkg-config-1.3.1
Installing ri documentation for pkg-config-1.3.1
Done installing documentation for pkg-config after 0 seconds
1 gem installed

$ gem list | grep pkg-config
pkg-config (1.3.1)

$ NOKOGIRI_USE_SYSTEM_LIBRARIES=yes ruby ext/nokogiri/extconf.extra.rb 
checking if the C compiler accepts ... yes
Building nokogiri using system libraries.
Using pkg-config gem version 1.3.1
checking for libxml-2.0... yes
checking for libxslt... yes
checking for libexslt... yes
checking for xmlParseDoc() in libxml/parser.h... yes
checking for xsltParseStylesheetDoc() in libxslt/xslt.h... yes
checking for exsltFuncRegister() in libexslt/exslt.h... yes
checking for xmlHasFeature()... yes
checking for xmlFirstElementChild()... yes
checking for xmlRelaxNGSetParserStructuredErrors()... yes
checking for xmlRelaxNGSetParserStructuredErrors()... yes
checking for xmlRelaxNGSetValidStructuredErrors()... yes
checking for xmlSchemaSetValidStructuredErrors()... yes
checking for xmlSchemaSetParserStructuredErrors()... yes
creating Makefile

@voxik
Copy link
Contributor

voxik commented Jul 10, 2018

Just FTR, I'd be glad if system pkg-config is enough and I don't need pkg-config gem ...

@voxik
Copy link
Contributor

voxik commented Jul 10, 2018

Ah, there is a longer discussion in #1731 ... Will continue there ...

@johnl
Copy link

johnl commented Jul 25, 2018

Reproducible on Ubuntu Xenial or Bionic.

This Dockerfile reproduces it, just put it in an empty dir and run docker build .

FROM ubuntu:xenial

RUN apt-get update -q && apt-get install ruby ruby-dev bundler libxslt-dev libxml2-dev pkg-config git -qy
RUN git clone https://github.com/sparklemotion/nokogiri.git
WORKDIR /nokogiri
RUN git checkout v1.8.3
RUN bundler install
ENV NOKOGIRI_USE_SYSTEM_LIBRARIES=true
RUN bundle exec rake compile

@flavorjones
Copy link
Member

@johnl Thanks for the repro, investigating now.

@flavorjones flavorjones added this to the 1.8.5 milestone Aug 15, 2018
@flavorjones
Copy link
Member

@johnl your repro provides the same errors that @knu's repro in #1731 provides, to wit:

package configuration for libxml-2.0 is not found
| pkg-config --libs libxslt
=> "-lxslt -lxml2\n"
"gcc -o conftest -I/usr/include/x86_64-linux-gnu/ruby-2.3.0 -I/usr/include/ruby-2.3.0/ruby/backward -I/usr/include/ruby-2.3.0 
-I../../../../ext/nokogiri -Wdate-time -D_FORTIFY_SOURCE=2   -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -fPIC  -g -DXP_UNIX -Wall -Wcast-qual -Wwrite-strings -Wextra -Wmissing-noreturn -Winline conftest.c  -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -fstack-protector -rdynamic -Wl,-export-dynamic     -lruby-2.3 -lxslt -lxml2 -lpthread -lgmp -ldl -lcrypt -lm   -lc "
conftest.c: In function 'main':
conftest.c:3:14: warning: unused parameter 'argc' [-Wunused-parameter]
 int main(int argc, char **argv)
              ^
conftest.c:3:27: warning: unused parameter 'argv' [-Wunused-parameter]
 int main(int argc, char **argv)
                           ^
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: int main(int argc, char **argv)
4: {
5:   return 0;
6: }
/* end */

which gives me confidence that we only have one problem here, and not multiple. Working on integrating a fix (and regression tests for this scenario).

flavorjones added a commit that referenced this issue Aug 15, 2018
due to conflicting gcc CFLAGS, details in #1772 and #1731.

added to both master and PR pipelines.
@flavorjones
Copy link
Member

This will be fixed in 1.8.5, due out soon.

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

No branches or pull requests

4 participants