libdispatch
libdispatch copied to clipboard
mingw64 / cross-compilation (linux/win32) problem
With some scons hacking I managed to build the necessary libraries for mingw64. For example blocksRuntime:
[yousry@Blasphemy blocks-runtime]$ wine blockrt-test.exe
increment test... ok
[yousry@Blasphemy blocks-runtime]$
But the libdispatch configure script fails to identify it:
...
checking for C Blocks support... -fblocks
checking whether additional libraries are required for the Blocks runtime... configure: error: can't find Blocks runtime
...
This is because i686-clang uses the gcc toolchain.
[yousry@Blasphemy helloMinGW]$ cat iHaveBlocks.c
int
main ()
{
^{ int j; j=0; }();
;
return 0;
}
[yousry@Blasphemy helloMinGW]$ i686-w64-mingw32-clang iHaveBlocks.c -fblocks -lBlocksRuntime
i686-w64-mingw32-gcc: Fehler: nicht erkannte Kommandozeilenoption »-fblocks«
clang-3.6: error: linker (via gcc) command failed with exit code 1 (use -v to see invocation)
As a workaround it is possible to compile the test program like this:
[yousry@Blasphemy helloMinGW]$ i686-w64-mingw32-clang -c iHaveBlocks.c -fblocks
[yousry@Blasphemy helloMinGW]$ i686-w64-mingw32-clang iHaveBlocks.o -o iHaveBlocks -lBlocksRuntime
[yousry@Blasphemy helloMinGW]$ wine ./iHaveBlocks
[yousry@Blasphemy helloMinGW]$
What's clang invoking in response to i686-w64-mingw32-clang iHaveBlocks.c -fblocks -lBlocksRuntime
? i.e. can you retry that command with the -v
flag?
Does it work if instead of -fblocks
you pass -Xclang -fblocks
? I think that should prevent clang passing -fblocks
to the linker, which seems to be what's going wrong.
You are correct. With the -Xclang option the test would probably pass. (Please note the missing library error, I'm currently working on a different vm )
clang --target=i686-w64-mingw32 iHaveBlocks.c -fblocks -lBlocksRuntime -v
clang version 3.6.0 (217569)
Target: i686-w64-windows-gnu
Thread model: posix
"/usr/local/bin/clang-3.5" -cc1 -triple i686-w64-windows-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name iHaveBlocks.c -mrelocation-model static -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -target-cpu pentium4 -v -dwarf-column-info -resource-dir /usr/local/bin/../lib/clang/3.6.0 -fdebug-compilation-dir /home/yousry/Dokumente/source/hello -ferror-limit 19 -fmessage-length 208 -mstackrealign -fblocks -fno-use-cxa-atexit -fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/iHaveBlocks-16f28b.o -x c iHaveBlocks.c
clang -cc1 version 3.6.0 based upon LLVM 3.6.0svn default target x86_64-unknown-linux-gnu
ignoring nonexistent directory "/usr/local/bin/../lib/clang/3.6.0/../../../i686-w64-mingw32/include"
ignoring nonexistent directory "/usr/local/bin/../lib/clang/3.6.0/../../../x86_64-w64-mingw32/include"
ignoring nonexistent directory "/mingw/include"
ignoring duplicate directory "/usr/local/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/usr/local/bin/../lib/clang/3.6.0/include
/usr/include
End of search list.
"/usr/bin/i686-w64-mingw32-gcc" -fblocks -v -m32 -o a.out /tmp/iHaveBlocks-16f28b.o -lBlocksRuntime
Using built-in specs.
COLLECT_GCC=/usr/bin/i686-w64-mingw32-gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-w64-mingw32/4.9.1/lto-wrapper
i686-w64-mingw32-gcc: error: unrecognized command line option '-fblocks'
Target: i686-w64-mingw32
Configured with: /build/mingw-w64-gcc/src/gcc-4.9.1/configure --prefix=/usr --libexecdir=/usr/lib --target=i686-w64-mingw32 --enable-languages=c,lto,c++,objc,obj-c++,fortran,ada --enable-shared --enable-static --enable-threads=posix --enable-fully-dynamic-string --enable-libstdcxx-time=yes --with-system-zlib --enable-cloog-backend=isl --disable-cloog-version-check --disable-isl-version-check --enable-lto --disable-dw2-exceptions --enable-libgomp --disable-multilib --enable-checking=release
Thread model: posix
gcc version 4.9.1 (GCC)
clang-3.5: error: linker (via gcc) command failed with exit code 1 (use -v to see invocation)
The problem in question: i686-w64-mingw32-gcc: error: unrecognized command line option '-fblocks'
With -Xclang the problem is avoided:
clang --target=i686-w64-mingw32 iHaveBlocks.c -Xclang -fblocks -lBlocksRuntime -v
clang version 3.6.0 (217569)
Target: i686-w64-windows-gnu
Thread model: posix
"/usr/local/bin/clang-3.5" -cc1 -triple i686-w64-windows-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name iHaveBlocks.c -mrelocation-model static -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -target-cpu pentium4 -v -dwarf-column-info -resource-dir /usr/local/bin/../lib/clang/3.6.0 -fdebug-compilation-dir /home/yousry/Dokumente/source/hello -ferror-limit 19 -fmessage-length 208 -mstackrealign -fno-use-cxa-atexit -fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics -fblocks -o /tmp/iHaveBlocks-f69543.o -x c iHaveBlocks.c
clang -cc1 version 3.6.0 based upon LLVM 3.6.0svn default target x86_64-unknown-linux-gnu
ignoring nonexistent directory "/usr/local/bin/../lib/clang/3.6.0/../../../i686-w64-mingw32/include"
ignoring nonexistent directory "/usr/local/bin/../lib/clang/3.6.0/../../../x86_64-w64-mingw32/include"
ignoring nonexistent directory "/mingw/include"
ignoring duplicate directory "/usr/local/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/usr/local/bin/../lib/clang/3.6.0/include
/usr/include
End of search list.
"/usr/bin/i686-w64-mingw32-gcc" -v -m32 -o a.out /tmp/iHaveBlocks-f69543.o -lBlocksRuntime
Using built-in specs.
COLLECT_GCC=/usr/bin/i686-w64-mingw32-gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-w64-mingw32/4.9.1/lto-wrapper
Target: i686-w64-mingw32
Configured with: /build/mingw-w64-gcc/src/gcc-4.9.1/configure --prefix=/usr --libexecdir=/usr/lib --target=i686-w64-mingw32 --enable-languages=c,lto,c++,objc,obj-c++,fortran,ada --enable-shared --enable-static --enable-threads=posix --enable-fully-dynamic-string --enable-libstdcxx-time=yes --with-system-zlib --enable-cloog-backend=isl --disable-cloog-version-check --disable-isl-version-check --enable-lto --disable-dw2-exceptions --enable-libgomp --disable-multilib --enable-checking=release
Thread model: posix
gcc version 4.9.1 (GCC)
COMPILER_PATH=/usr/lib/gcc/i686-w64-mingw32/4.9.1/:/usr/lib/gcc/i686-w64-mingw32/4.9.1/:/usr/lib/gcc/i686-w64-mingw32/:/usr/lib/gcc/i686-w64-mingw32/4.9.1/:/usr/lib/gcc/i686-w64-mingw32/:/usr/lib/gcc/i686-w64-mingw32/4.9.1/../../../../i686-w64-mingw32/bin/
LIBRARY_PATH=/usr/lib/gcc/i686-w64-mingw32/4.9.1/:/usr/lib/gcc/i686-w64-mingw32/4.9.1/../../../../i686-w64-mingw32/lib/../lib/:/usr/lib/gcc/i686-w64-mingw32/4.9.1/../../../../i686-w64-mingw32/lib/
COLLECT_GCC_OPTIONS='-v' '-m32' '-o' 'a.out' '-mtune=generic' '-march=pentiumpro'
/usr/lib/gcc/i686-w64-mingw32/4.9.1/collect2 -plugin /usr/lib/gcc/i686-w64-mingw32/4.9.1/liblto_plugin.so -plugin-opt=/usr/lib/gcc/i686-w64-mingw32/4.9.1/lto-wrapper -plugin-opt=-fresolution=/tmp/ccMN48W0.res -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_eh -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt -plugin-opt=-pass-through=-lpthread -plugin-opt=-pass-through=-ladvapi32 -plugin-opt=-pass-through=-lshell32 -plugin-opt=-pass-through=-luser32 -plugin-opt=-pass-through=-lkernel32 -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_eh -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt -m i386pe -Bdynamic -o a.out /usr/lib/gcc/i686-w64-mingw32/4.9.1/../../../../i686-w64-mingw32/lib/../lib/crt2.o /usr/lib/gcc/i686-w64-mingw32/4.9.1/crtbegin.o -L/usr/lib/gcc/i686-w64-mingw32/4.9.1 -L/usr/lib/gcc/i686-w64-mingw32/4.9.1/../../../../i686-w64-mingw32/lib/../lib -L/usr/lib/gcc/i686-w64-mingw32/4.9.1/../../../../i686-w64-mingw32/lib /tmp/iHaveBlocks-f69543.o -lBlocksRuntime -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt -lpthread -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt /usr/lib/gcc/i686-w64-mingw32/4.9.1/crtend.o
/usr/lib/gcc/i686-w64-mingw32/4.9.1/../../../../i686-w64-mingw32/bin/ld: cannot find -lBlocksRuntime
collect2: error: ld returned 1 exit status
clang-3.5: error: linker (via gcc) command failed with exit code 1 (use -v to see invocation)
Is this still a problem with the new CMake build system?