This is the mail archive of the libffi-discuss@sourceware.org mailing list for the libffi project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

build issue with memcpy/bcopy on Winz with mingw


Hi,

I ran into a problem building libffi on Win32 using mingw/msys.

I was able to work around the problem (in the jna project at least) by commenting out some logic that substitutes bcopy for memcopy:

diff --git a/include/ffi_common.h b/include/ffi_common.h
index c179d68..3697de4 100644
--- a/include/ffi_common.h
+++ b/include/ffi_common.h
@@ -46,10 +46,12 @@ char *alloca ();
 /* Check for the existence of memcpy. */
 #if STDC_HEADERS
 # include <string.h>
-#else
-# ifndef HAVE_MEMCPY
-#  define memcpy(d, s, n) bcopy ((s), (d), (n))
-# endif
+/* This may cause compile failure on Windows with mingw.
+else
+ ifndef HAVE_MEMCPY
+  define memcpy(d, s, n) bcopy ((s), (d), (n))
+ endif
+*/
 #endif

#if defined(FFI_DEBUG)


While this workaround was fine in the jna project's build of libffi on windows, it did not solve the problem when I try to build libffi stand-alone.


Below (sorry for the long post - do attachments survive posting?), is the output of 'configure' and 'make', before I made the change above. I noticed warnings about memcpy and bcopy. Any suggestions on a better way to build libffi on windows using mingw/msys?

Thanks,
Dan Rollo


Failed output (note configure succeeded, but compile fails).


'configure' appears to find memcpy:
...
checking for memcpy... yes
...

However, notice warnings like this near the end of the compile stage:

src/raw_api.c:175:4: warning: incompatible implicit declaration of built-in function 'bcopy' [enable
d by default]




C:\home\dan\c\libffi>bash
bash-3.1$ pwd
/c/home/dan/c/libffi
bash-3.1$ configure
checking build system type... i686-pc-mingw32
checking host system type... i686-pc-mingw32
checking target system type... i686-pc-mingw32
./configure: line 2654: AX_ENABLE_BUILDDIR: command not found
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.exe
checking for suffix of executables... .exe
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking dependency style of gcc... gcc3
checking whether gcc and cc understand -c and -o together... yes
checking how to print strings... printf
checking for a sed that does not truncate output... /usr/bin/sed
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for fgrep... /usr/bin/grep -F
checking for ld used by gcc... c:/mingw/mingw32/bin/ld.exe
checking if the linker (c:/mingw/mingw32/bin/ld.exe) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /mingw/bin/nm
checking the name lister (/mingw/bin/nm) interface... BSD nm
checking whether ln -s works... no, using cp -p
checking the maximum length of command line arguments... 8192
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking how to convert i686-pc-mingw32 file names to i686-pc-mingw32 format... func_convert_file_ms
ys_to_w32
checking how to convert i686-pc-mingw32 file names to toolchain format... func_convert_file_msys_to_
w32
checking for c:/mingw/mingw32/bin/ld.exe option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... file_magic ^x86 archive import|^x86 DLL
checking for dlltool... dlltool
checking how to associate runtime and link libraries... func_cygming_dll_for_implib
checking for ar... ar
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /mingw/bin/nm output from gcc object... ok
checking for sysroot... no
checking for mt... no
checking if : is a manifest tool... no
checking how to run the C preprocessor... gcc -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... no
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -DDLL_EXPORT -DPIC
checking if gcc PIC flag -DDLL_EXPORT -DPIC works... yes
checking if gcc static flag -static works... yes
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (c:/mingw/mingw32/bin/ld.exe) supports shared libraries... yes
checking whether -lc should be explicitly linked in... yes
checking dynamic linker characteristics... Win32 ld.exe
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
./configure: line 11904: AX_CC_MAXOPT: command not found
./configure: line 11905: AX_CFLAGS_WARN_ALL: command not found
checking whether to enable maintainer-specific portions of Makefiles... no
checking sys/mman.h usability... no
checking sys/mman.h presence... no
checking for sys/mman.h... no
checking for mmap... no
checking for sys/mman.h... (cached) no
checking for mmap... (cached) no
checking for ANSI C header files... (cached) yes
checking for memcpy... yes
checking for size_t... yes
checking for working alloca.h... no
checking for alloca... yes
checking size of double... 8
checking size of long double... 12
checking whether byte ordering is bigendian... no
./configure: line 13140: GCC_AS_CFI_PSEUDO_OP: command not found
checking assembler supports pc related relocs... yes
checking assembler .ascii pseudo-op support... yes
checking assembler .string pseudo-op support... yes
checking whether .eh_frame section should be read-only... no
checking for __attribute__((visibility("hidden")))... no
configure: creating ./config.status
config.status: creating include/Makefile
config.status: creating include/ffi.h
config.status: creating Makefile
config.status: creating testsuite/Makefile
config.status: creating man/Makefile
config.status: creating libffi.pc
config.status: creating fficonfig.h
config.status: linking src/x86/ffitarget.h to include/ffitarget.h
config.status: executing depfiles commands
config.status: executing libtool commands
config.status: executing include commands
config.status: executing src commands
bash-3.1$ make
make "AR_FLAGS=" "CC_FOR_BUILD=" "CFLAGS=-fexceptions" "CXXFLAGS=" "CFLAGS_FOR_BUILD=" "CFLAGS_FOR_T
ARGET=" "INSTALL=/usr/bin/install -c" "INSTALL_DATA=/usr/bin/install -c -m 644" "INSTALL_PROGRAM=/us
r/bin/install -c" "INSTALL_SCRIPT=/usr/bin/install -c" "JC1FLAGS=" "LDFLAGS=" "LIBCFLAGS=" "LIBCFLAG
S_FOR_TARGET=" "MAKE=make" "MAKEINFO=/bin/sh /c/home/dan/c/libffi/missing --run makeinfo " "PICFLAG=
" "PICFLAG_FOR_TARGET=" "RUNTESTFLAGS=" "SHELL=/bin/sh" "exec_prefix=/usr/local" "infodir=/usr/local
/share/info" "libdir=/usr/local/lib" "mandir=/usr/local/share/man" "prefix=/usr/local" "AR=ar" "AS=a
s" "CC=gcc" "CXX=g++" "LD=c:/mingw/mingw32/bin/ld.exe" "NM=/mingw/bin/nm" "RANLIB=ranlib" "DESTDIR="
all-recursive
make[1]: Entering directory `/c/home/dan/c/libffi'
Making all in include
make[2]: Entering directory `/c/home/dan/c/libffi/include'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/c/home/dan/c/libffi/include'
Making all in testsuite
make[2]: Entering directory `/c/home/dan/c/libffi/testsuite'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/c/home/dan/c/libffi/testsuite'
Making all in man
make[2]: Entering directory `/c/home/dan/c/libffi/man'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/c/home/dan/c/libffi/man'
make[2]: Entering directory `/c/home/dan/c/libffi'
depbase=`echo src/prep_cif.lo | sed 's|[^/]*$|.deps/&|;s|\.lo$||'`;\
/bin/sh ./libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I. -I./include -Iinclu
de -I./src -DFFI_BUILDING -g -fexceptions -MT src/prep_cif.lo -MD -MP -MF $depbase.Tpo -c -o src/p
rep_cif.lo src/prep_cif.c &&\
mv -f $depbase.Tpo $depbase.Plo
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I. -I./include -Iinclude -I./src -DFFI_BUILDING -g -fexc
eptions -MT src/prep_cif.lo -MD -MP -MF src/.deps/prep_cif.Tpo -c src/prep_cif.c -DDLL_EXPORT -DPIC
-o src/.libs/prep_cif.o
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I. -I./include -Iinclude -I./src -DFFI_BUILDING -g -fexc
eptions -MT src/prep_cif.lo -MD -MP -MF src/.deps/prep_cif.Tpo -c src/prep_cif.c -o src/prep_cif.o >
/dev/null 2>&1
depbase=`echo src/types.lo | sed 's|[^/]*$|.deps/&|;s|\.lo$||'`;\
/bin/sh ./libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I. -I./include -Iinclu
de -I./src -DFFI_BUILDING -g -fexceptions -MT src/types.lo -MD -MP -MF $depbase.Tpo -c -o src/type
s.lo src/types.c &&\
mv -f $depbase.Tpo $depbase.Plo
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I. -I./include -Iinclude -I./src -DFFI_BUILDING -g -fexc
eptions -MT src/types.lo -MD -MP -MF src/.deps/types.Tpo -c src/types.c -DDLL_EXPORT -DPIC -o src/.
libs/types.o
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I. -I./include -Iinclude -I./src -DFFI_BUILDING -g -fexc
eptions -MT src/types.lo -MD -MP -MF src/.deps/types.Tpo -c src/types.c -o src/types.o >/dev/null 2>
&1
depbase=`echo src/raw_api.lo | sed 's|[^/]*$|.deps/&|;s|\.lo$||'`;\
/bin/sh ./libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I. -I./include -Iinclu
de -I./src -DFFI_BUILDING -g -fexceptions -MT src/raw_api.lo -MD -MP -MF $depbase.Tpo -c -o src/ra
w_api.lo src/raw_api.c &&\
mv -f $depbase.Tpo $depbase.Plo
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I. -I./include -Iinclude -I./src -DFFI_BUILDING -g -fexc
eptions -MT src/raw_api.lo -MD -MP -MF src/.deps/raw_api.Tpo -c src/raw_api.c -DDLL_EXPORT -DPIC -o
src/.libs/raw_api.o
src/raw_api.c: In function 'ffi_ptrarray_to_raw':
src/raw_api.c:175:4: warning: incompatible implicit declaration of built-in function 'bcopy' [enable
d by default]
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I. -I./include -Iinclude -I./src -DFFI_BUILDING -g -fexc
eptions -MT src/raw_api.lo -MD -MP -MF src/.deps/raw_api.Tpo -c src/raw_api.c -o src/raw_api.o >/dev
/null 2>&1
depbase=`echo src/java_raw_api.lo | sed 's|[^/]*$|.deps/&|;s|\.lo$||'`;\
/bin/sh ./libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I. -I./include -Iinclu
de -I./src -DFFI_BUILDING -g -fexceptions -MT src/java_raw_api.lo -MD -MP -MF $depbase.Tpo -c -o s
rc/java_raw_api.lo src/java_raw_api.c &&\
mv -f $depbase.Tpo $depbase.Plo
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I. -I./include -Iinclude -I./src -DFFI_BUILDING -g -fexc
eptions -MT src/java_raw_api.lo -MD -MP -MF src/.deps/java_raw_api.Tpo -c src/java_raw_api.c -DDLL_
EXPORT -DPIC -o src/.libs/java_raw_api.o
src/java_raw_api.c: In function 'ffi_java_ptrarray_to_raw':
src/java_raw_api.c:225:4: warning: incompatible implicit declaration of built-in function 'bcopy' [e
nabled by default]
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I. -I./include -Iinclude -I./src -DFFI_BUILDING -g -fexc
eptions -MT src/java_raw_api.lo -MD -MP -MF src/.deps/java_raw_api.Tpo -c src/java_raw_api.c -o src/
java_raw_api.o >/dev/null 2>&1
depbase=`echo src/closures.lo | sed 's|[^/]*$|.deps/&|;s|\.lo$||'`;\
/bin/sh ./libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I. -I./include -Iinclu
de -I./src -DFFI_BUILDING -g -fexceptions -MT src/closures.lo -MD -MP -MF $depbase.Tpo -c -o src/c
losures.lo src/closures.c &&\
mv -f $depbase.Tpo $depbase.Plo
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I. -I./include -Iinclude -I./src -DFFI_BUILDING -g -fexc
eptions -MT src/closures.lo -MD -MP -MF src/.deps/closures.Tpo -c src/closures.c -DDLL_EXPORT -DPIC
-o src/.libs/closures.o
In file included from src/closures.c:112:0:
c:\mingw\bin\../lib/gcc/mingw32/4.6.2/../../../../include/string.h:38:40: error: expected declaratio
n specifiers or '...' before '(' token
c:\mingw\bin\../lib/gcc/mingw32/4.6.2/../../../../include/string.h:38:40: error: expected declaratio
n specifiers or '...' before '(' token
c:\mingw\bin\../lib/gcc/mingw32/4.6.2/../../../../include/string.h:38:40: error: expected declaratio
n specifiers or '...' before '(' token
In file included from src/closures.c:210:0:
src/dlmalloc.c: In function 'internal_realloc':
src/dlmalloc.c:3894:9: warning: incompatible implicit declaration of built-in function 'bcopy' [enab
led by default]
make[2]: *** [src/closures.lo] Error 1
make[2]: Leaving directory `/c/home/dan/c/libffi'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/c/home/dan/c/libffi'
make: *** [all] Error 2
bash-3.1$





Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]