grok icon indicating copy to clipboard operation
grok copied to clipboard

Failes to compile with gperf 3.1 (conflicting types for ‘patname2macro’)

Open ercpe opened this issue 8 years ago • 4 comments

After removing the lines 217-219 from the Makefile (https://github.com/jordansissel/grok/issues/28), the compilation failes with gperf 3.1:

>>> Compiling source in /var/tmp/portage/dev-libs/grok-0.9.2-r1/work/grok-0.9.2 ...
make -j1 
sh ./version.sh --header > grok_version.h
[ -f grok_capture_xdr.h ] && rm grok_capture_xdr.h || true
rpcgen -h grok_capture.x -o grok_capture_xdr.h
x86_64-pc-linux-gnu-gcc -c -O2 -pipe -march=core-avx2 -mssse3 -msse4 -fPIC -I. -DPLATFORM_GNULinux  grok.c -o grok.o
x86_64-pc-linux-gnu-gcc -c -O2 -pipe -march=core-avx2 -mssse3 -msse4 -fPIC -I. -DPLATFORM_GNULinux  grokre.c -o grokre.o
grokre.c: In function ‘grok_pattern_expand’:
grokre.c:312:12: warning: passing argument 1 of ‘free’ discards ‘const’ qualifier from pointer target type
    free(pattern_regex);
            ^
In file included from /usr/include/pcre.h:90:0,
                from grokre.c:1:
/usr/include/stdlib.h:483:13: note: expected ‘void *’ but argument is of type ‘const char *’
extern void free (void *__ptr) __THROW;
            ^
x86_64-pc-linux-gnu-gcc -c -O2 -pipe -march=core-avx2 -mssse3 -msse4 -fPIC -I. -DPLATFORM_GNULinux  grok_capture.c -o grok_capture.o
x86_64-pc-linux-gnu-gcc -c -O2 -pipe -march=core-avx2 -mssse3 -msse4 -fPIC -I. -DPLATFORM_GNULinux  grok_pattern.c -o grok_pattern.o
x86_64-pc-linux-gnu-gcc -c -O2 -pipe -march=core-avx2 -mssse3 -msse4 -fPIC -I. -DPLATFORM_GNULinux  stringhelper.c -o stringhelper.o
x86_64-pc-linux-gnu-gcc -c -O2 -pipe -march=core-avx2 -mssse3 -msse4 -fPIC -I. -DPLATFORM_GNULinux  predicates.c -o predicates.o
[ -f grok_capture_xdr.c ] && rm grok_capture_xdr.c || true
rpcgen -c grok_capture.x -o grok_capture_xdr.c
x86_64-pc-linux-gnu-gcc -c -O2 -pipe -march=core-avx2 -mssse3 -msse4 -fPIC -I. -DPLATFORM_GNULinux  grok_capture_xdr.c -o grok_capture_xdr.o
x86_64-pc-linux-gnu-gcc -c -O2 -pipe -march=core-avx2 -mssse3 -msse4 -fPIC -I. -DPLATFORM_GNULinux  grok_match.c -o grok_match.o
x86_64-pc-linux-gnu-gcc -c -O2 -pipe -march=core-avx2 -mssse3 -msse4 -fPIC -I. -DPLATFORM_GNULinux  grok_logging.c -o grok_logging.o
x86_64-pc-linux-gnu-gcc -c -O2 -pipe -march=core-avx2 -mssse3 -msse4 -fPIC -I. -DPLATFORM_GNULinux  grok_program.c -o grok_program.o
x86_64-pc-linux-gnu-gcc -c -O2 -pipe -march=core-avx2 -mssse3 -msse4 -fPIC -I. -DPLATFORM_GNULinux  grok_input.c -o grok_input.o
x86_64-pc-linux-gnu-gcc -c -O2 -pipe -march=core-avx2 -mssse3 -msse4 -fPIC -I. -DPLATFORM_GNULinux  grok_matchconf.c -o grok_matchconf.o
x86_64-pc-linux-gnu-gcc -c -O2 -pipe -march=core-avx2 -mssse3 -msse4 -fPIC -I. -DPLATFORM_GNULinux  libc_helper.c -o libc_helper.o
/usr/bin/gperf grok_matchconf_macro.gperf > grok_matchconf_macro.c
x86_64-pc-linux-gnu-gcc -c -O2 -pipe -march=core-avx2 -mssse3 -msse4 -fPIC -I. -DPLATFORM_GNULinux  grok_matchconf_macro.c -o grok_matchconf_macro.o
grok_matchconf_macro.gperf:69:1: error: conflicting types for ‘patname2macro’
In file included from grok_matchconf_macro.gperf:4:0:
grok_matchconf_macro.h:22:24: note: previous declaration of ‘patname2macro’ was here
const struct strmacro *patname2macro(const char *str, unsigned int len);
                        ^
Makefile:238: recipe for target 'grok_matchconf_macro.o' failed
make: *** [grok_matchconf_macro.o] Error 1
rm grok_matchconf_macro.c

Works fine with gperf 3.0.4.

ercpe avatar Jan 15 '17 14:01 ercpe

Anything on this one?

ercpe avatar Mar 24 '17 04:03 ercpe

I haven't looked into this. If an older version of gperf is working then that is my recommendation.

On Thu, Mar 23, 2017 at 9:58 PM Johann Schmitz [email protected] wrote:

Anything on this one?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/jordansissel/grok/issues/29#issuecomment-288933707, or mute the thread https://github.com/notifications/unsubscribe-auth/AAIC6qm3nnvFDtp9ATimDSzPjBjFzLcfks5ro013gaJpZM4Lj7IQ .

jordansissel avatar Mar 24 '17 05:03 jordansissel

From gperf 3.1 NEWS file:

* The 'len' parameter of the hash function and of the lookup function is now
  of type 'size_t' instead of 'unsigned int'. This makes it safe to call these
  functions with strings of length > 4 GB, on 64-bit machines.

So we need to change patname2macro's definition from

const struct strmacro *patname2macro(const char *str, unsigned int len);

to

const struct strmacro *patname2macro(const char *str, size_t len);

However, that would break backward compatibility with older gperf. But I am not sure how we should patch this project because it only has a Makefile. I.e. other projects will check for size_t support in their configure script, see https://github.com/systemd/systemd-stable/commit/79a5d862a7abe903f456a75d6d1ca3c11adfa379 for example.

Whissi avatar May 22 '17 13:05 Whissi

While packaging grok fro alpine; I just used

--- a/Makefile
+++ b/Makefile
@@ -213,8 +213,8 @@
 	rpcgen -h $< -o $@
 
 %.c: %.gperf
-	@if $(GPERF) --version | head -1 | egrep -v '3\.[0-9]+\.[0-9]+' ; then \
-		echo "We require gperf version >= 3.0.3" ; \
+	@if $(GPERF) --version | head -1 | egrep -v '3\.[1-9]+' ; then \
+		echo "We require gperf version >= 3.1" ; \
 		exit 1; \
 	fi
 	$(GPERF) $< > $@
--- a/grok_matchconf_macro.h
+++ b/grok_matchconf_macro.h
@@ -19,6 +19,6 @@
 #endif
 
 /* this function is generated by gperf */
-const struct strmacro *patname2macro(const char *str, unsigned int len);
+const struct strmacro *patname2macro(const char *str, size_t len);
 
 #endif /* _GROK_MATCHCONF_MACRO_ */

as grok 3.0 wasn't really available anymore :)

oliv3r avatar Mar 09 '22 11:03 oliv3r