Bug 214009 - devel/git: build fails with DEVELOPER=yes
Summary: devel/git: build fails with DEVELOPER=yes
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Renato Botelho
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-11-02 12:38 UTC by John Hein
Modified: 2016-12-01 16:00 UTC (History)
1 user (show)

See Also:
garga: maintainer-feedback+


Attachments
[patch] avoid building with DEVELOPER_CFLAGS when ports tree DEVELOPER var is set (663 bytes, patch)
2016-12-01 14:04 UTC, John Hein
jcfyecrayz: maintainer-approval? (garga)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description John Hein 2016-11-02 12:38:52 UTC
If you build devel/git with DEVELOPER=yes, you will get a failure due to -Werror (added in work/git-2.10.1/Makefile when DEVELOPER=yes).  Here's a snippet from a build on 10-stable/amd64:

cc -o t/helper/test-path-utils.o -c -MF t/helper/.depend/test-path-utils.o.d -MQ t/helper/test-path-utils.o -MMD -MP -isystem/usr/local/include -DLIBICONV_PLUG -O2 -pipe  -DLIBICONV_PLUG -fstack-protector -fno-strict-aliasing -Werror -Wdeclaration-after-statement -Wno-format-zero-length -Wold-style-definition -Woverflow -Wpointer-arith -Wstrict-prototypes -Wunused -Wvla -I. -I/usr/local/include -DUSE_LIBPCRE -I/usr/local/include -DUSE_CURL_FOR_IMAP_SEND -I/usr/local/include -DUSE_ST_TIMESPEC -pthread -DHAVE_PATHS_H -DHAVE_STRINGS_H -DGMTIME_UNRELIABLE_ERRORS -DHAVE_CLOCK_GETTIME -DHAVE_CLOCK_MONOTONIC -DHAVE_BSD_SYSCTL -DHAVE_GETDELIM -DSHA1_HEADER='<openssl/sha.h>'  -DFREAD_READS_DIRECTORIES -DDIR_HAS_BSD_GROUP_SEMANTICS -DSHELL_PATH='"/bin/sh"' -DPAGER_ENV='"LESS=FRX LV=-c MORE=FRX"'  t/helper/test-path-utils.c
t/helper/test-path-utils.c:254:39: error: incompatible pointer types passing 'char *(const char *)' to
      parameter of type 'char *(*)(char *)' [-Werror,-Wincompatible-pointer-types]
                return test_function(basename_data, basename, argv[1]);
                                                    ^~~~~~~~
t/helper/test-path-utils.c:41:58: note: passing argument to parameter 'func' here
static int test_function(struct test_data *data, char *(*func)(char *input),
                                                         ^
t/helper/test-path-utils.c:257:38: error: incompatible pointer types passing 'char *(const char *)' to
      parameter of type 'char *(*)(char *)' [-Werror,-Wincompatible-pointer-types]
                return test_function(dirname_data, dirname, argv[1]);
                                                   ^~~~~~~
t/helper/test-path-utils.c:41:58: note: passing argument to parameter 'func' here
static int test_function(struct test_data *data, char *(*func)(char *input),
                                                         ^
2 errors generated.
gmake[2]: *** [Makefile:1982: t/helper/test-path-utils.o] Error 1


Similar results on 9-stable (using default base gcc).

git-2.10.1/Makefile has:

ifdef DEVELOPER
CFLAGS += $(DEVELOPER_CFLAGS)
endif


The problem with test-path-utils.c is real - it expects basename(3) to be take a 'char *' argument rather than 'const char *'.  That's an upstream issue, although they would have to deal with linux having two different prototypes for basename(3) (one with const, one without) depending on which prototype in system header files is pulled in (string.h vs libgen.h).

This fixes it for the freebsd port:

--- work/git-2.10.1/t/helper/test-path-utils.c.orig     2016-11-02 12:23:15.000000000 +0000
+++ work/git-2.10.1/t/helper/test-path-utils.c  2016-11-02 12:23:15.000000000 +0000
@@ -38,7 +38,7 @@
        const char *alternative; /* output: ... or this.      */
 };

-static int test_function(struct test_data *data, char *(*func)(char *input),
+static int test_function(struct test_data *data, char *(*func)(const char *input),
        const char *funcname)
 {
        int failed = 0, i;


Alternately you could comment out the DEVELOPER_CFLAGS definition in the git-2.10.1/Makefile or something similar:

@@ -968,7 +969,7 @@
 -include config.mak

 ifdef DEVELOPER
-CFLAGS += $(XXX_DONT_USE_DEVELOPER_CFLAGS)
+CFLAGS += $(DEVELOPER_CFLAGS)
 endif

 ifndef sysconfdir



Or try to avoid passing DEVELOPER down into the port build (e.g., undefine it).
Comment 1 Jan Beich freebsd_committer 2016-11-03 07:11:28 UTC
(In reply to John Hein from comment #0)
> linux having two different prototypes for basename(3)

FreeBSD is in a similar boat since base r303451, so your patch would break 12.0-CURRENT instead.

  t/helper/test-path-utils.c:254:39: error: incompatible pointer types passing 'char *(char *)' to
	parameter of type 'char *(*)(const char *)' [-Werror,-Wincompatible-pointer-types]
		  return test_function(basename_data, basename, argv[1]);
						      ^~~~~~~~
  t/helper/test-path-utils.c:41:58: note: passing argument to parameter 'func' here
  static int test_function(struct test_data *data, char *(*func)(const char *input),
							   ^
  t/helper/test-path-utils.c:257:38: error: incompatible pointer types passing 'char *(char *)' to
	parameter of type 'char *(*)(const char *)' [-Werror,-Wincompatible-pointer-types]
		  return test_function(dirname_data, dirname, argv[1]);
						     ^~~~~~~
  t/helper/test-path-utils.c:41:58: note: passing argument to parameter 'func' here
  static int test_function(struct test_data *data, char *(*func)(const char *input),
							   ^
  2 errors generated.

Rather than patching ${WRKSRC}/Makefile maybe override values via MAKE_ARGS e.g.,

  MAKE_ARGS+=	DEVELOPER_CFLAGS=
Comment 2 John Hein 2016-11-04 00:45:14 UTC
Thanks for that info.  It sounds like the const version of dirname/basename is going away.

The MAKE_ARGS way sounds okay to me.  Or making DEVELOPER undefined when gmake is invoked in do-build.  But I don't see a clean way to do that.
Comment 3 John Hein 2016-12-01 14:04:53 UTC
Created attachment 177575 [details]
[patch] avoid building with DEVELOPER_CFLAGS when ports tree DEVELOPER var is set

The problem still exists with git 2.11.0

The attached patch uses the suggestion offered by jbeich@ and clears DEVELOPER_CFLAGS in MAKE_ARGS.  So in case DEVELOPER is set to use the ports tree testing infrastructure (stage-qa), the port will not be built with the extra CFLAGS intended for use by git developers.
Comment 4 Renato Botelho freebsd_committer 2016-12-01 16:00:48 UTC
A commit references this bug:

Author: garga
Date: Thu Dec  1 15:24:06 UTC 2016
New revision: 427505
URL: https://svnweb.freebsd.org/changeset/ports/427505

Log:
  - Fix build with PERL and non-default LOCALBASE [1]
  - Fix build with DEVELOPER=yes [2]
  - Do not install ZSH completion [3]
  	- ZSH installs a better version itself
  - Fix PLIST
  - Bump PORTREVISION

  PR:		213494 [1]
  		214009 [2]
  		214870 [3] (based on)
  Submitted by:	John Hein <z7dr6ut7gs@snkmail.com> [1] [3]
  		Michael Zuo <muh.muhten@gmail.com>
  Sponsored by:	Rubicon Communications (Netgate)

Changes:
  head/devel/git/Makefile
  head/devel/git/pkg-plist