Some more fun with cross-compiling...
$ make stage1flex
gcc -DHAVE_CONFIG_H -I. -I../../flex-2.6.4/src -DLOCALEDIR="/usr/share/locale" -isystem/data/poky-tmp/master/work/corei7-64-poky-linux/flex/2.6.4-r0/recipe-sysroot-native/usr/include -isystem/data/poky-tmp/master/work/corei7-64-poky-linux/flex/2.6.4-r0/recipe-sysroot-native/usr/include -O2 -pipe -c -o stage1flex-misc.o test -f 'misc.c' || echo '../../flex-2.6.4/src/'misc.c
../../flex-2.6.4/src/misc.c: In function ‘allocate_array’:
../../flex-2.6.4/src/misc.c:151:14: warning: implicit declaration of function ‘reallocarray’ [-Wimplicit-function-declaration]
new_array = reallocarray(NULL, (size_t) size, element_size);
^~~~~~~~~~~~
...
stage1flex-misc.o: In function allocate_array': misc.c:(.text+0x36f): undefined reference to reallocarray'
It took me a minute to figure this out but the problem is that my target has reallocarray support but my host does not. config.h says the function exists so misc.c tries using the reallocarray() (implicit declaration) and then undefined reference at link time.
My suggestion is to stop trying to cross-build a stage1flex and just expect anyone building a cross-compiled flex to bring their own recent flex binary for the build host.
Some more fun with cross-compiling...
$ make stage1flex
gcc -DHAVE_CONFIG_H -I. -I../../flex-2.6.4/src -DLOCALEDIR="/usr/share/locale" -isystem/data/poky-tmp/master/work/corei7-64-poky-linux/flex/2.6.4-r0/recipe-sysroot-native/usr/include -isystem/data/poky-tmp/master/work/corei7-64-poky-linux/flex/2.6.4-r0/recipe-sysroot-native/usr/include -O2 -pipe -c -o stage1flex-misc.o
test -f 'misc.c' || echo '../../flex-2.6.4/src/'misc.c../../flex-2.6.4/src/misc.c: In function ‘allocate_array’:
../../flex-2.6.4/src/misc.c:151:14: warning: implicit declaration of function ‘reallocarray’ [-Wimplicit-function-declaration]
new_array = reallocarray(NULL, (size_t) size, element_size);
^~~~~~~~~~~~
...
stage1flex-misc.o: In function
allocate_array': misc.c:(.text+0x36f): undefined reference toreallocarray'It took me a minute to figure this out but the problem is that my target has reallocarray support but my host does not. config.h says the function exists so misc.c tries using the reallocarray() (implicit declaration) and then undefined reference at link time.
My suggestion is to stop trying to cross-build a stage1flex and just expect anyone building a cross-compiled flex to bring their own recent flex binary for the build host.