unbit / uwsgi

uWSGI application server container
http://projects.unbit.it/uwsgi
Other
3.45k stars 691 forks source link

stats_pusher_mongodb can't build in fedora 23 #1140

Closed thekad closed 8 years ago

thekad commented 8 years ago

Hello,

The stats pusher for mongodb stopped compiling in fedora 23. I am the maintainer and was trying to update to latest 2.0.12 but the compilation step fails. This is how I am building it CFLAGS="-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -Wno-unused-but-set-variable" python uwsgiconfig.py --plugin plugins/stats_pusher_mongodb fedora and this is the fedora.ini file used:

[uwsgi]
inherit = core
bin_name = uwsgi
xml = libxml2
yaml = libyaml
json = jansson
pcre = auto
routing = auto
ssl = auto
malloc_implementation = libc
embedded_plugins = corerouter, echo, ping
plugins = alarm_curl, alarm_xmpp, airbrake, cache, carbon, cgi, cplusplus, curl_cron, dumbloop, dummy, fastrouter, forkptyrouter, geoip, gevent, graylog2, http, ldap, logcrypto, logfile, logpipe, logsocket, lua, msgpack, nagios, notfound, pam, php, pty, python, rack, rawrouter, redislog, router_access, router_basicauth, router_cache, router_expires, router_hash, router_http, router_memcached, router_metrics, router_radius, router_redirect, router_redis, router_rewrite, router_spnego, router_static, router_uwsgi, router_xmldir, rpc, rrdtool, rsyslog, ruby19, spooler, sqlite3, ssi, sslrouter, stats_pusher_file, stats_pusher_socket, stats_pusher_statsd, syslog, tornado, transformation_chunked, transformation_gzip, transformation_offload, transformation_template, transformation_tofile, transformation_toupper, ugreen, webdav, xattr, xslt, zabbix, zergpool

Building the plugin yields the following error:

/usr/include/c++/5.3.1/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.

I attempted to pass CXXFLAGS instead but that proved fruitless, until I also overrode the compiler. Now this CXXFLAGS="-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -std=gnu++11" CC="g++" python uwsgiconfig.py --plugin plugins/stats_pusher_mongodb fedora

yields now the next error:

plugins/stats_pusher_mongodb/plugin.c: In function ‘void stats_pusher_mongodb_init()’:
plugins/stats_pusher_mongodb/plugin.c:6:68: error: deprecated conversion from string constant to ‘char*’ [-Werror=write-strings]
         uwsgi_register_stats_pusher("mongodb", stats_pusher_mongodb);
                                                                    ^
plugins/stats_pusher_mongodb/plugin.c: At global scope:
plugins/stats_pusher_mongodb/plugin.c:13:1: sorry, unimplemented: non-trivial designated initializers not supported
 };
 ^
cc1plus: all warnings being treated as errors

I am unsure on how to proceed here. This could very well be GCC version from fedora 22 to 23 (the last time this got compiled, it was on fedora 22. Relevant versions:

gcc (GCC) 5.3.1 20151207 (Red Hat 5.3.1-2) mongo-cxx-driver-devel.x86_64 1.0.7-1.fc23

thekad commented 8 years ago

Forgot to add: the CFLAGS come from an rpm spec macro, not specifying it all manually.

xrmx commented 8 years ago

Thanks for reporting. First warning is not plugin specific all stats_pusher plugins at least have the same issue. More on that we have a blacklist of cflags that we are supposed to remove in uwsgiconfig.py (p_cflags_blacklist) where -Werror=write-strings is included so failure is somewhat expected, said that fixing that error is trivial. The second one is quite interesting because when a C++ compiler is used we may need to define the struct differently. Is there any reason for CC=g++?

thekad commented 8 years ago

No reason for changing the compiler other than trying to make it work. Are you saying I should stick with gcc and this patch will solve it?

xrmx commented 8 years ago

@thekad the patch would silence the -Werror=write-strings error which should be the one you are getting in fedora but am not sure it's the right thing to do as it is an error for g++ but not for gcc. BTW the plugin builds just fine on debian with gcc 5.3.1

thekad commented 8 years ago

@xrmx interesting, this builds just fine in fedora 22 but not in fedora 23 (both using gcc, not g++), like I said I am using the common rpm spec macros on both but there's a real difference between the two. Here are the expanded options in fedora 22:

CFLAGS='-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches  -m64 -mtune=generic -Wno-unused-but-set-variable'

And the expanded flags for fedora 23:

CFLAGS='-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -Wno-unused-but-set-variable'

The difference is the addition of -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 in fedora 23, and here's the contents of this particular file:

*cc1_options:
+ %{!r:%{!fpie:%{!fPIE:%{!fpic:%{!fPIC:%{!fno-pic:-fPIE}}}}}}

Not entirely sure how these extra flags may make the build to fail...

xrmx commented 8 years ago

could you please pastebin all the output when rpm building the plugin?

thekad commented 8 years ago

Sure thing https://kojipkgs.fedoraproject.org//work/tasks/1869/12381869/build.log is my last attempt

thekad commented 8 years ago

This is the main build page, you can check the other logs for versions and etc http://koji.fedoraproject.org/koji/taskinfo?taskID=12381869

xrmx commented 8 years ago

Which version of mongodb are you compiling against? Does something like this works for you?

diff --git a/plugins/stats_pusher_mongodb/uwsgiplugin.py b/plugins/stats_pusher_mongodb/uwsgiplugin.py
index cc4dd0b..4479cc8 100644
--- a/plugins/stats_pusher_mongodb/uwsgiplugin.py
+++ b/plugins/stats_pusher_mongodb/uwsgiplugin.py
@@ -5,6 +5,8 @@ NAME = 'stats_pusher_mongodb'
 CFLAGS = [
     '-I/usr/include/mongo',
     '-I/usr/local/include/mongo',
+    '-std=c++11',
+    '-Wno-error'
 ]
 LDFLAGS = []
xrmx commented 8 years ago

Also _Patch #5 (uwsgi_fixmongodb.patch) would be interesting to see

thekad commented 8 years ago

This is the full list of patches and spec file used to build this, I will try your patch above later today http://pkgs.fedoraproject.org/cgit/rpms/uwsgi.git/tree/

thekad commented 8 years ago

Using the CFLAGS posted does work, fwiw

xrmx commented 8 years ago

@thekad do you have logs for the build with the patch please?

thekad commented 8 years ago

@xrmx sure thing http://koji.fedoraproject.org/koji/taskinfo?taskID=12456410

cicku commented 8 years ago

python uwsgiconfig.py --plugin plugins/stats_pusher_mongodb fedora cc1: warning: command line option '-std=gnu++11' is valid for C++/ObjC++ but not for C using profile: buildconf/fedora.ini detected include path: ['/usr/lib/gcc/x86_64-redhat-linux/5.3.1/include', '/usr/local/include', '/usr/include'] *** uWSGI building and linking plugin plugins/stats_pusher_mongodb *** [gcc -pthread] stats_pusher_mongodb_plugin.so build time: 2 seconds *** stats_pusher_mongodb plugin built and available in stats_pusher_mongodb_plugin.so ***

'-std=gnu++11' is valid for C++/ObjC++ but not for C, that's right. F23 has changed the CXX ABI(Follow https://lwn.net/Articles/632118/)

xrmx commented 8 years ago

@thekad pushed patch in master and uwsgi-2.0. Thanks!

cicku commented 8 years ago

-Wno-error is not a good practice for packagers :joy: But it's fine now. Thanks.

xrmx commented 8 years ago

@cicku -Wno-error is not a good practice for developers too, but all the errors are in mongodb files so that's the only workaround for us.