Bug 214639 - devel/kore: fails to build with clang 3.9
Summary: devel/kore: fails to build with clang 3.9
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Jan Beich
URL:
Keywords: needs-patch
Depends on:
Blocks: 212343
  Show dependency treegraph
 
Reported: 2016-11-18 20:29 UTC by Jan Beich
Modified: 2017-02-05 19:13 UTC (History)
2 users (show)

See Also:
tobik: maintainer-feedback+


Attachments
kore.diff (451 bytes, patch)
2016-12-13 02:35 UTC, Tobias Kortkamp
tobik: maintainer-approval+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Beich freebsd_committer freebsd_triage 2016-11-18 20:29:53 UTC
src/pgsql.c:222:17: error: passing an object that undergoes default argument promotion to 'va_start'
      has undefined behavior [-Werror,-Wvarargs]
        va_start(args, count);
                       ^
src/pgsql.c:217:45: note: parameter of type 'u_int8_t' (aka 'unsigned char') is declared here
    const char *query, int result, u_int8_t count, ...)
                                            ^

http://package18.nyi.freebsd.org/data/headi386PR212343-default/2016-09-11_07h04m19s/logs/errors/kore-2.0.0.log

To reproduce without upgrading to /projects/clang390-import try

  $ pkg install -y llvm39
  $ CC=clang39 CXX=clang++39 CPP=clang-cpp39 make clean all
Comment 1 Tobias Kortkamp freebsd_committer freebsd_triage 2016-11-19 07:17:32 UTC
I've opened an upstream issue: https://github.com/jorisvink/kore/issues/153
Comment 2 Tobias Kortkamp freebsd_committer freebsd_triage 2016-11-19 12:23:05 UTC
The issue has been fixed upstream: https://github.com/jorisvink/kore/commit/7eced6f035c83c02680d9b58371851f8662a0e8a

I've included a backport of the fix in the patch attached to bug #214638.
Comment 3 commit-hook freebsd_committer freebsd_triage 2016-11-20 20:59:01 UTC
A commit references this bug:

Author: jbeich
Date: Sun Nov 20 20:58:38 UTC 2016
New revision: 426630
URL: https://svnweb.freebsd.org/changeset/ports/426630

Log:
  devel/kore: unbreak build with clang 3.9

  src/pgsql.c:222:17: error: passing an object that undergoes default argument promotion to 'va_start'
        has undefined behavior [-Werror,-Wvarargs]
          va_start(args, count);
                         ^
  src/pgsql.c:217:45: note: parameter of type 'u_int8_t' (aka 'unsigned char') is declared here
      const char *query, int result, u_int8_t count, ...)
                                              ^

  PR:		214639
  Reported by:	antoine (via exp-run)
  Submitted by:	Tobias Kortkamp <t@tobik.me> (maintainer)
  Obtained from:	upstream

Changes:
  head/devel/kore/Makefile
  head/devel/kore/files/patch-includes_pgsql.h
  head/devel/kore/files/patch-src_pgsql.c
Comment 4 John Marino freebsd_committer freebsd_triage 2016-12-13 00:24:00 UTC
well, unfortunately one man's fix is another man's breakage.

This fix breaks gcc compilers.
Can this fix be reworked to avoid the gcc regression?

--------------------------------------------------------------------------------
--  Phase: build
--------------------------------------------------------------------------------
===>  Building for kore-2.0.0_1
gmake[1]: Entering directory '/construction/devel/kore/kore-2.0.0-release'
cc -pipe -O2 -fno-strict-aliasing -Wall -Werror -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wshadow -Wpointer-arith -Wcast-qual -Wsign-compare -Iincludes -std=c99 -pedantic -Wno-error=c11-extensions -DPREFIX='"/usr/local"' -I/usr/local/include -DKORE_USE_PGSQL -DPGSQL_INCLUDE_PATH="\"/usr/local/include\"" -DKORE_USE_TASKS -DKORE_USE_JSONRPC -I/usr/local/include -c src/kore.c -o obj/kore.o
cc -pipe -O2 -fno-strict-aliasing -Wall -Werror -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wshadow -Wpointer-arith -Wcast-qual -Wsign-compare -Iincludes -std=c99 -pedantic -Wno-error=c11-extensions -DPREFIX='"/usr/local"' -I/usr/local/include -DKORE_USE_PGSQL -DPGSQL_INCLUDE_PATH="\"/usr/local/include\"" -DKORE_USE_TASKS -DKORE_USE_JSONRPC -I/usr/local/include -c src/buf.c -o obj/buf.o
cc1: error: -Werror=c11-extensions: no option -Wc11-extensions
cc1: error: -Werror=c11-extensions: no option -Wc11-extensions
gmake[1]: *** [Makefile:106: obj/kore.o] Error 1
gmake[1]: *** Waiting for unfinished jobs....
gmake[1]: *** [Makefile:106: obj/buf.o] Error 1
Comment 5 Tobias Kortkamp freebsd_committer freebsd_triage 2016-12-13 02:35:09 UTC
Created attachment 177921 [details]
kore.diff

(In reply to John Marino from comment #4)

Ah...  I added -Wno-error=c11-extensions because of bug 214638.
In hindsight knowingly adding a clang only option is pretty bad.
Using -Wno-c11-extensions instead should fix the build with gcc.
Comment 6 Jan Beich freebsd_committer freebsd_triage 2017-02-05 19:10:42 UTC
Comment on attachment 177921 [details]
kore.diff

The patch failed to fix build with GCC, so I've landed my own in ports r433446. Besides, having -Werror downstream is a recipe for churn:

  $ pkg install gcc7-devel
  $ make clean all CC=gcc7 CXX=g++7 CPP=cpp7 CHOSEN_COMPILER_TYPE=gcc
  [...]
  src/http.c: In function 'http_header_recv':
  src/http.c:597:50: error: comparison between pointer and zero character constant [-Werror=pointer-compare]
	 strncasecmp(host[0], "host", 4) || host[1] == '\0') {
						    ^~
  src/http.c:597:42: note: did you mean to dereference the pointer?
	 strncasecmp(host[0], "host", 4) || host[1] == '\0') {
					    ^