Skip to content

Commit

Permalink
Add a check for gperf function signature.
Browse files Browse the repository at this point in the history
Loosely based on:
systemd/systemd@c9f7b4d

Signed-off-by: Alexey Neyman <[email protected]>
Signed-off-by: Max Filippov <[email protected]>
  • Loading branch information
stilor authored and jcmvbkbc committed Mar 4, 2017
1 parent a194053 commit 37b07f6
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export objdump := @OBJDUMP@
export readelf := @READELF@
export patch := @PATCH@
export gperf := @GPERF@
export gperf_len_type := @GPERF_LEN_TYPE@
export CC := @CC@
export CPP := @CPP@
export CPPFLAGS := @CPPFLAGS@
Expand Down
16 changes: 16 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,22 @@ AC_CACHE_CHECK([for GNU automake >= 1.10], [ac_cv_path_automake],
AC_MSG_ERROR([could not find GNU automake >= 1.10])])])
AC_SUBST([automake], [$ac_cv_path_automake])

#----------------------------------------
# Gperf 3.1 started generating functions with size_t rather than unsigned int
AC_MSG_CHECKING([for the type used in gperf declarations])
echo "#include <string.h>" > conftest.gperf.c
echo "const char * in_word_set(const char *, GPERF_LEN_TYPE);" >> conftest.gperf.c
echo foo,bar | ${GPERF} -L ANSI-C >> conftest.gperf.c
AS_IF([${CC} -c -o /dev/null conftest.gperf.c -DGPERF_LEN_TYPE='size_t' >/dev/null 2>&1],
[AC_MSG_RESULT([size_t])
GPERF_LEN_TYPE='size_t'],
[${CC} -c -o /dev/null conftest.gperf.c -DGPERF_LEN_TYPE='unsigned int' >/dev/null 2>&1],
[AC_MSG_RESULT([unsigned int])
GPERF_LEN_TYPE='unsigned int'],
[AC_MSG_ERROR([unable to determine gperf len type])])
rm -f conftest.gperf.c
AC_SUBST([GPERF_LEN_TYPE])

#--------------------------------------------------------------------
# Boring again... But still a bit of work to do...
#--------------------------------------------------------------------
Expand Down
3 changes: 2 additions & 1 deletion kconfig/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ all: conf mconf nconf
@true # Just be silent, you fscking son of a fscking beach...

# Build flags
CFLAGS = -DCONFIG_=\"CT_\" -DPACKAGE="\"crosstool-NG $(VERSION)\""
CFLAGS = -DCONFIG_=\"CT_\" -DPACKAGE="\"crosstool-NG $(VERSION)\"" \
-DGPERF_LEN_TYPE="$(gperf_len_type)"
LDFLAGS = $(INTL_LIBS)

# Compiler flags to use gettext
Expand Down
2 changes: 1 addition & 1 deletion kconfig/zconf.gperf
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

struct kconf_id;

static const struct kconf_id *kconf_id_lookup(register const char *str, register unsigned int len);
static const struct kconf_id *kconf_id_lookup(register const char *str, register GPERF_LEN_TYPE len);

%%
mainmenu, T_MAINMENU, TF_COMMAND
Expand Down

5 comments on commit 37b07f6

@funnydog
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this commit causes an error when building (arch linux latest here), since the function kconf_id_lookup() has now a different signature than kconf_id_lookup(register const char *str, register size_t len).

@jcmvbkbc
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@funnydog could you please share your config.log, kconfig/zconf.hash.c and the exact error message that you see?

@funnydog
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, sorry for the missing details, I was in a hurry.

config.log:
https://gist.github.com/anonymous/79cf55119baf7e20e0945bf04eaa3c08

zconf.hash.c:
https://gist.github.com/anonymous/1b0255a128249ffc27138f85637eb622

This is the error message:

  ...
  BISON  'zconf.tab.c'
  GPERF  'zconf.hash.c'
  LEX    'zconf.lex.c'
  DEP    'zconf.tab.dep'
  CC     'zconf.tab.o'
In file included from zconf.tab.c:212:0:
zconf.hash.c:167:1: error: conflicting types for ‘kconf_id_lookup’
 kconf_id_lookup (register const char *str, register size_t len)
 ^~~~~~~~~~~~~~~
zconf.hash.c:34:31: note: previous declaration of ‘kconf_id_lookup’ was here
 static const struct kconf_id *kconf_id_lookup(register const char *str, register unsigned int len);
                               ^~~~~~~~~~~~~~~

This is the gcc version I'm using:

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared --enable-threads=posix --enable-libmpx --with-system-zlib --with-isl --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch --disable-libssp --enable-gnu-unique-object --enable-linker-build-id --enable-lto --enable-plugin --enable-install-libiberty --with-linker-hash-style=gnu --enable-gnu-indirect-function --disable-multilib --disable-werror --enable-checking=release
Thread model: posix
gcc version 6.3.1 20170306 (GCC) 

@jcmvbkbc
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, @funnydog , according to the contents of your config.log and especially the following line in it:

It was created by crosstool-NG configure crosstool-ng-1.22.0-55-gecfc19a5, which was

you haven't rebuilt configure script in your crosstool-ng. Please try running bootstrap script followed by configure followed by make.

@funnydog
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now I get it, and I'm a little embarassed since it seems I wasted your time :(

esp-open-sdk which I tried to build, checks out the commit: ecfc19a
of crosstool-NG and the build fails.

But if I checkout the xtensa-1.22.x branch everything is ok.

I'm sorry for the noise, I'll report the bug to esp-open-sdk.

Please sign in to comment.