Jump to page: 1 2
Thread overview
How to build a set of toolchains for cross-compiling for LDC?
Jun 28, 2015
Majestio
Jun 28, 2015
Kai Nacke
Jul 14, 2015
Majestio
Jul 14, 2015
Kai Nacke
Jul 17, 2015
Majestio
Jul 17, 2015
Majestio
Jul 20, 2015
Kai Nacke
May 12, 2016
Majestio
May 12, 2016
Majestio
May 17, 2016
Kai Nacke
May 17, 2016
Jacob Carlborg
June 28, 2015
Hi all!

I apologize in advance for my English, I use Google Translator :-\

I became interested in the D programming language recently. I want build a comfortable environment for cross-compilation. In my Linux Funtoo already has a similar environment for C/C++ based http://mxe.cc:

i686-w64-mingw32.shared
i686-w64-mingw32.static
x86_64-w64-mingw32.shared
x86_64-w64-mingw32.static

... and more libs, including Qt 5.4.2 for each toolchain.

So far I have built native LDC, and native "Hello world" is compiled and linked successfully.

Actually, the question is how to build step by step for the environment LDC for  cross-compile, similar MXE?

Just in case, my directory structure:

/home/majestio/dev/cross/mxe - C/C++ cross-compile env
/home/majestio/dev/cross/llvm - LLVM,Clang,LDC

WBR


June 28, 2015
On Sunday, 28 June 2015 at 14:03:15 UTC, Majestio wrote:
> Hi all!
>
> I apologize in advance for my English, I use Google Translator :-\
>
> I became interested in the D programming language recently. I want build a comfortable environment for cross-compilation. In my Linux Funtoo already has a similar environment for C/C++ based http://mxe.cc:
>
> i686-w64-mingw32.shared
> i686-w64-mingw32.static
> x86_64-w64-mingw32.shared
> x86_64-w64-mingw32.static
>
> ... and more libs, including Qt 5.4.2 for each toolchain.
>
> So far I have built native LDC, and native "Hello world" is compiled and linked successfully.
>
> Actually, the question is how to build step by step for the environment LDC for  cross-compile, similar MXE?
>
> Just in case, my directory structure:
>
> /home/majestio/dev/cross/mxe - C/C++ cross-compile env
> /home/majestio/dev/cross/llvm - LLVM,Clang,LDC
>
> WBR

Hi Majestio!

You need to compile LLVM for the targets you want. With USE flag multitarget, LLVM is build for all available targets. Then rebuild LDC with this LLVM.

I described cross-compiling for AArch64 here: http://forum.dlang.org/post/fhwvxatxezkafnalwhqr@forum.dlang.org

Regards,
Kai
July 14, 2015
Hi,Kai!

On Sunday, 28 June 2015 at 18:14:13 UTC, Kai Nacke wrote:
> I described cross-compiling for AArch64 here: http://forum.dlang.org/post/fhwvxatxezkafnalwhqr@forum.dlang.org

I did as you wrote. But the problem with linking.

I tried to build HelloWorld (with link error):
======================================================================
#!/bin/sh

export MXE="/home/majestio/Dev/cross/mxe/usr"
export TARGET="i686-w64-mingw32.static"
export PATH="$MXE/$TARGET/bin:$MXE/bin:$PATH"

$MXE/$TARGET/bin/ldc2 -v \
-mtriple=i686-w32-mingw32.static \
-gcc=i686-w64-mingw32.static-gcc \
-L=-L$MXE/$TARGET/lib \
hello_d.d
======================================================================

Trying to run the linker separately (with link error):
======================================================================
#!/bin/sh

export MXE="/home/majestio/Dev/cross/mxe/usr"
export TARGET="i686-w64-mingw32.static"
export PATH="$MXE/$TARGET/bin:$MXE/bin:$PATH"

$MXE/bin/$TARGET-ld -v \
hello_d.obj \
-o hello.exe \
-L$MXE/$TARGET/lib \
-lphobos2-ldc \
-lcurl \
-ldruntime-ldc \
-lws2_32 \
-lshell32
======================================================================

Output linker:
======================================================================
GNU ld (GNU Binutils) 2.25
hello_d.obj:(.text[__D3std5stdio16__T7writelnTAyaZ7writelnFAyaZv]+0x1a): undefined reference to `_D3std5stdio6stdoutS3std5stdio4File'
hello_d.obj:(.text[__D3std5stdio16__T7writelnTAyaZ7writelnFAyaZv]+0x3a): undefined reference to `__mingw_fprintf'
hello_d.obj:(.text[__D3std5stdio16__T7writelnTAyaZ7writelnFAyaZv]+0x6c): undefined reference to `_D3std9exception14__T7enforceTbZ7enforceFNaNfbLAxaAyakZb'
hello_d.obj:(.text[__D7hello_d16__moduleinfoCtorZ]+0x8): undefined reference to `_Dmodule_ref'
hello_d.obj:(.text[__D7hello_d16__moduleinfoCtorZ]+0x13): undefined reference to `_Dmodule_ref'
hello_d.obj:(.text[_main]+0x7): undefined reference to `__main'
hello_d.obj:(.text[_main]+0x2f): undefined reference to `_d_run_main'
hello_d.obj:(.rdata[__D12TypeInfo_xAk6__initZ]+0x0): undefined reference to `_D14TypeInfo_Const6__vtblZ'
hello_d.obj:(.rdata[__D12TypeInfo_Axk6__initZ]+0x0): undefined reference to `_D14TypeInfo_Array6__vtblZ'
hello_d.obj:(.rdata[__D11TypeInfo_xk6__initZ]+0x0): undefined reference to `_D14TypeInfo_Const6__vtblZ'
hello_d.obj:(.rdata[__D11TypeInfo_xk6__initZ]+0x8): undefined reference to `_D10TypeInfo_k6__initZ'
hello_d.obj:(.rdata[__D11TypeInfo_ya6__initZ]+0x0): undefined reference to `_D18TypeInfo_Invariant6__vtblZ'
hello_d.obj:(.rdata[__D11TypeInfo_ya6__initZ]+0x8): undefined reference to `_D10TypeInfo_a6__initZ'
hello_d.obj:(.rdata[__D12TypeInfo_xAa6__initZ]+0x0): undefined reference to `_D14TypeInfo_Const6__vtblZ'
hello_d.obj:(.rdata[__D12TypeInfo_xAa6__initZ]+0x8): undefined reference to `_D12TypeInfo_Axa6__initZ'
hello_d.obj:(.rdata[__D11TypeInfo_xb6__initZ]+0x0): undefined reference to `_D14TypeInfo_Const6__vtblZ'
hello_d.obj:(.rdata[__D11TypeInfo_xb6__initZ]+0x8): undefined reference to `_D10TypeInfo_b6__initZ'
hello_d.obj:(.rdata[__D11TypeInfo_xi6__initZ]+0x0): undefined reference to `_D14TypeInfo_Const6__vtblZ'
hello_d.obj:(.rdata[__D11TypeInfo_xi6__initZ]+0x8): undefined reference to `_D10TypeInfo_i6__initZ'
hello_d.obj:(.rdata[__D11TypeInfo_xa6__initZ]+0x0): undefined reference to `_D14TypeInfo_Const6__vtblZ'
hello_d.obj:(.rdata[__D11TypeInfo_xa6__initZ]+0x8): undefined reference to `_D10TypeInfo_a6__initZ'
hello_d.obj:(.rdata[__D11TypeInfo_xh6__initZ]+0x0): undefined reference to `_D14TypeInfo_Const6__vtblZ'
hello_d.obj:(.rdata[__D11TypeInfo_xh6__initZ]+0x8): undefined reference to `_D10TypeInfo_h6__initZ'
hello_d.obj:(.rdata[__D13TypeInfo_xAya6__initZ]+0x0): undefined reference to `_D14TypeInfo_Const6__vtblZ'
hello_d.obj:(.rdata[__D13TypeInfo_xAya6__initZ]+0x8): undefined reference to `_D12TypeInfo_Aya6__initZ'
hello_d.obj:(.data[__D7hello_d12__ModuleInfoZ]+0xc): undefined reference to `_D3std5stdio12__ModuleInfoZ'
======================================================================

Inside .obj (i686-w64-mingw32.static-nm hello_d.obj):
======================================================================
00000000 b .bss
00000000 d .ctors
00000000 d .data
00000000 d .data
00000000 d .data
00000000 i .drectve
00000000 d .eh_frame
00000000 r .rdata
00000000 r .rdata
00000000 r .rdata
00000000 r .rdata
00000000 r .rdata
00000000 r .rdata
00000000 r .rdata
00000000 r .rdata
00000000 r .rdata
00000000 r .rdata
00000000 r .rdata
00000000 t .text
00000000 t .text
00000000 t .text
00000000 t .text
00000000 t .text
00000000 t .text
00000001 a @feat.00
         U __D10TypeInfo_a6__initZ
         U __D10TypeInfo_b6__initZ
         U __D10TypeInfo_h6__initZ
         U __D10TypeInfo_i6__initZ
         U __D10TypeInfo_k6__initZ
00000000 R __D11TypeInfo_xa6__initZ
00000000 R __D11TypeInfo_xb6__initZ
00000000 R __D11TypeInfo_xh6__initZ
00000000 R __D11TypeInfo_xi6__initZ
00000000 R __D11TypeInfo_xk6__initZ
00000000 R __D11TypeInfo_ya6__initZ
         U __D12TypeInfo_Axa6__initZ
00000000 R __D12TypeInfo_Axk6__initZ
         U __D12TypeInfo_Aya6__initZ
00000000 R __D12TypeInfo_xAa6__initZ
00000000 R __D12TypeInfo_xAk6__initZ
00000000 R __D13TypeInfo_xAya6__initZ
         U __D14TypeInfo_Array6__vtblZ
         U __D14TypeInfo_Const6__vtblZ
         U __D18TypeInfo_Invariant6__vtblZ
         U __D3std5stdio12__ModuleInfoZ
00000000 T __D3std5stdio16__T7writelnTAyaZ7writelnFAyaZ12__dgliteral3MFNaNbNiNfZAxa
00000000 T __D3std5stdio16__T7writelnTAyaZ7writelnFAyaZv
         U __D3std5stdio6stdoutS3std5stdio4File
         U __D3std9exception14__T7enforceTbZ7enforceFNaNfbLAxaAyakZb
00000000 d __D7hello_d11__moduleRefZ
00000000 D __D7hello_d12__ModuleInfoZ
00000000 t __D7hello_d16__moduleinfoCtorZ
00000000 T __Dmain
         U __Dmodule_ref
         U ___main
         U ___mingw_fprintf
         U __d_run_main
00000000 T _main




What can be done?






July 14, 2015
On Tuesday, 14 July 2015 at 12:26:53 UTC, Majestio wrote:
> Hi,Kai!
>
> On Sunday, 28 June 2015 at 18:14:13 UTC, Kai Nacke wrote:
>> I described cross-compiling for AArch64 here: http://forum.dlang.org/post/fhwvxatxezkafnalwhqr@forum.dlang.org
>
> I did as you wrote. But the problem with linking.
>

> What can be done?

Hi Majestio!

First, your link command is definitively incomplete.
At least libc and libpthread are missing. You are using ld so I miss the crt*.o files, too. I would recommend to use the cross-gcc for linking.

Symptons for this are:
> hello_d.obj:(.text[_main]+0x7): undefined reference to `__main'
> hello_d.obj:(.text[__D3std5stdio16__T7writelnTAyaZ7writelnFAyaZv]+0x3a): undefined reference to `__mingw_fprintf'

These are symbols from the MingW C library.

BTW: Can you cross-compile a C hello world without problems?

Did you compile druntime and phobos for the mingw target? If yes where did you place the libraries?

The other missing symbols are from druntime and phobos. This indicates that these libraries are not found. Did you also cross-compile the curl library?

You can use the -v command line option with ldc2 to see the call to gcc. This is useful for debugging.

Regards,
Kai

July 17, 2015
Hi, Kai!

I rebuilt the whole system of cross-compile again, and recorded all of his actions step by step. I note, in my opinion, the main points.

First part: make from .c source
========================================================
#!/bin/sh

export TARGET="i686-w64-mingw32.static"
export MXE="/home/majestio/Dev/cross/mxe/usr"
export PATH="$MXE/bin:$PATH"

# Step 1
$MXE/bin/$TARGET-gcc -c hello.c

# Step 2
$MXE/bin/$TARGET-gcc hello.o -o hello.exe
------------------------------------------------------------------------------
Result: ok
hello.exe was successfully launched on the Windows host

then ...

Secont part: make from .d source
------------------------------------------------------------------------------
#!/bin/sh

export TARGET="i686-w64-mingw32.static"
export MXE="/home/majestio/Dev/cross/mxe/usr"
export LLVM="/home/majestio/Dev/cross/llvm"
export DLANG="/home/majestio/Dev/cross/dlang/$TARGET"
export PATH="$MXE/bin:$LLVM/bin:$DLANG/bin:$PATH"

# Step 1
$TARGET-ldc2 -c -gcc=$TARGET-gcc -mtriple=$TARGET hello.d

# Step 2
$TARGET-gcc hello.obj \
-L$LLVM/lib \
-L$DLANG/lib \
-lphobos2-ldc \
-lcurl \
-ldruntime-ldc \
-v \
-o hello.exe

# Step debug
echo "Find libraries ..."
find $DLANG -type f | xargs grep -l "D14TypeInfo_Const6"
echo "For comparison with the specified path ..."
echo "$DLANG/lib"
------------------------------------------------------------------------------
Result: only produced .obj file

Output:
------------------------------------------------------------------------------
majestio@funtoo ~/Dev/projects/hello-d $ ./hello_d-1.sh
Using built-in specs.
COLLECT_GCC=i686-w64-mingw32.static-gcc
COLLECT_LTO_WRAPPER=/home/majestio/Dev/cross/mxe/usr/libexec/gcc/i686-w64-mingw32.static/5.1.0/lto-wrapper
Target: i686-w64-mingw32.static
Configured with: /home/majestio/Dev/cross/mxe/tmp-gcc-i686-w64-mingw32.static/gcc-5.1.0/configure --target=i686-w64-mingw32.static --build=x86_64-pc-linux-gnu --prefix=/home/majestio/Dev/cross/mxe/usr --libdir=/home/majestio/Dev/cross/mxe/usr/lib --enable-shared=libstdc++ --enable-languages=c,c++,objc,fortran --enable-version-specific-runtime-libs --with-gcc --with-gnu-ld --with-gnu-as --disable-nls --disable-shared --disable-multilib --without-x --disable-win32-registry --enable-threads=posix --disable-libgomp --with-gmp=/home/majestio/Dev/cross/mxe/usr --with-isl=/home/majestio/Dev/cross/mxe/usr --with-mpc=/home/majestio/Dev/cross/mxe/usr --with-mpfr=/home/majestio/Dev/cross/mxe/usr --with-as=/home/majestio/Dev/cross/mxe/usr/bin/i686-w64-mingw32.static-as --with-ld=/home/majestio/Dev/cross/mxe/usr/bin/i686-w64-mingw32.static-ld --with-nm=/home/majestio/Dev/cross/mxe/usr/bin/i686-w64-mingw32.static-nm
Thread model: posix
gcc version 5.1.0 (GCC)
COMPILER_PATH=/home/majestio/Dev/cross/mxe/usr/libexec/gcc/i686-w64-mingw32.static/5.1.0/:/home/majestio/Dev/cross/mxe/usr/libexec/gcc/i686-w64-mingw32.static/5.1.0/:/home/majestio/Dev/cross/mxe/usr/libexec/gcc/i686-w64-mingw32.static/:/home/majestio/Dev/cross/mxe/usr/lib/gcc/i686-w64-mingw32.static/5.1.0/:/home/majestio/Dev/cross/mxe/usr/lib/gcc/i686-w64-mingw32.static/:/home/majestio/Dev/cross/mxe/usr/lib/gcc/i686-w64-mingw32.static/5.1.0/../../../../i686-w64-mingw32.static/bin/
LIBRARY_PATH=/home/majestio/Dev/cross/mxe/usr/lib/gcc/i686-w64-mingw32.static/5.1.0/:/home/majestio/Dev/cross/mxe/usr/lib/gcc/i686-w64-mingw32.static/5.1.0/../../../../i686-w64-mingw32.static/lib/../lib/:/home/majestio/Dev/cross/mxe/usr/lib/gcc/i686-w64-mingw32.static/5.1.0/../../../../i686-w64-mingw32.static/lib/
COLLECT_GCC_OPTIONS='-L/home/majestio/Dev/cross/llvm/lib' '-L/home/majestio/Dev/cross/dlang/i686-w64-mingw32.static/lib' '-v' '-o' 'hello.exe' '-mtune=generic' '-march=pentiumpro'
 /home/majestio/Dev/cross/mxe/usr/libexec/gcc/i686-w64-mingw32.static/5.1.0/collect2 -plugin /home/majestio/Dev/cross/mxe/usr/libexec/gcc/i686-w64-mingw32.static/5.1.0/liblto_plugin.so -plugin-opt=/home/majestio/Dev/cross/mxe/usr/libexec/gcc/i686-w64-mingw32.static/5.1.0/lto-wrapper -plugin-opt=-fresolution=/tmp/ccbzqvbz.res -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc -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=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt -m i386pe -Bdynamic -o hello.exe /home/majestio/Dev/cross/mxe/usr/lib/gcc/i686-w64-mingw32.static/5.1.0/../../../../i686-w64-mingw32.static/lib/../lib/crt2.o /home/majestio/Dev/cross/mxe/usr/lib/gcc/i686-w64-mingw32.static/5.1.0/crtbegin.o -L/home/majestio/Dev/cross/llvm/lib -L/home/majestio/Dev/cross/dlang/i686-w64-mingw32.static/lib -L/home/majestio/Dev/cross/mxe/usr/lib/gcc/i686-w64-mingw32.static/5.1.0 -L/home/majestio/Dev/cross/mxe/usr/lib/gcc/i686-w64-mingw32.static/5.1.0/../../../../i686-w64-mingw32.static/lib/../lib -L/home/majestio/Dev/cross/mxe/usr/lib/gcc/i686-w64-mingw32.static/5.1.0/../../../../i686-w64-mingw32.static/lib hello.obj -lphobos2-ldc -lcurl -ldruntime-ldc -lmingw32 -lgcc -lmoldname -lmingwex -lmsvcrt -lpthread -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc -lmoldname -lmingwex -lmsvcrt /home/majestio/Dev/cross/mxe/usr/lib/gcc/i686-w64-mingw32.static/5.1.0/crtend.o
hello.obj:(.text[__D3std5stdio16__T7writelnTAyaZ7writelnFAyaZv]+0x1a): undefined reference to `_D3std5stdio6stdoutS3std5stdio4File'
hello.obj:(.text[__D3std5stdio16__T7writelnTAyaZ7writelnFAyaZv]+0x6c): undefined reference to `_D3std9exception14__T7enforceTbZ7enforceFNaNfbLAxaAyakZb'
hello.obj:(.text[__D5hello16__moduleinfoCtorZ]+0x8): undefined reference to `_Dmodule_ref'
hello.obj:(.text[__D5hello16__moduleinfoCtorZ]+0x13): undefined reference to `_Dmodule_ref'
hello.obj:(.text[_main]+0x2f): undefined reference to `_d_run_main'
hello.obj:(.rdata[__D12TypeInfo_xAk6__initZ]+0x0): undefined reference to `_D14TypeInfo_Const6__vtblZ'
hello.obj:(.rdata[__D12TypeInfo_Axk6__initZ]+0x0): undefined reference to `_D14TypeInfo_Array6__vtblZ'
hello.obj:(.rdata[__D11TypeInfo_xk6__initZ]+0x0): undefined reference to `_D14TypeInfo_Const6__vtblZ'
hello.obj:(.rdata[__D11TypeInfo_xk6__initZ]+0x8): undefined reference to `_D10TypeInfo_k6__initZ'
hello.obj:(.rdata[__D11TypeInfo_ya6__initZ]+0x0): undefined reference to `_D18TypeInfo_Invariant6__vtblZ'
hello.obj:(.rdata[__D11TypeInfo_ya6__initZ]+0x8): undefined reference to `_D10TypeInfo_a6__initZ'
hello.obj:(.rdata[__D12TypeInfo_xAa6__initZ]+0x0): undefined reference to `_D14TypeInfo_Const6__vtblZ'
hello.obj:(.rdata[__D12TypeInfo_xAa6__initZ]+0x8): undefined reference to `_D12TypeInfo_Axa6__initZ'
hello.obj:(.rdata[__D11TypeInfo_xb6__initZ]+0x0): undefined reference to `_D14TypeInfo_Const6__vtblZ'
hello.obj:(.rdata[__D11TypeInfo_xb6__initZ]+0x8): undefined reference to `_D10TypeInfo_b6__initZ'
hello.obj:(.rdata[__D11TypeInfo_xi6__initZ]+0x0): undefined reference to `_D14TypeInfo_Const6__vtblZ'
hello.obj:(.rdata[__D11TypeInfo_xi6__initZ]+0x8): undefined reference to `_D10TypeInfo_i6__initZ'
hello.obj:(.rdata[__D11TypeInfo_xa6__initZ]+0x0): undefined reference to `_D14TypeInfo_Const6__vtblZ'
hello.obj:(.rdata[__D11TypeInfo_xa6__initZ]+0x8): undefined reference to `_D10TypeInfo_a6__initZ'
hello.obj:(.rdata[__D11TypeInfo_xh6__initZ]+0x0): undefined reference to `_D14TypeInfo_Const6__vtblZ'
hello.obj:(.rdata[__D11TypeInfo_xh6__initZ]+0x8): undefined reference to `_D10TypeInfo_h6__initZ'
hello.obj:(.rdata[__D13TypeInfo_xAya6__initZ]+0x0): undefined reference to `_D14TypeInfo_Const6__vtblZ'
hello.obj:(.rdata[__D13TypeInfo_xAya6__initZ]+0x8): undefined reference to `_D12TypeInfo_Aya6__initZ'
hello.obj:(.data[__D5hello12__ModuleInfoZ]+0xc): undefined reference to `_D3std5stdio12__ModuleInfoZ'
collect2: error: ld returned 1 exit status
Find libraries ...
/home/majestio/Dev/cross/dlang/i686-w64-mingw32.static/lib/libphobos2-ldc-debug.a
/home/majestio/Dev/cross/dlang/i686-w64-mingw32.static/lib/libdruntime-ldc.a
/home/majestio/Dev/cross/dlang/i686-w64-mingw32.static/lib/libphobos2-ldc.a
/home/majestio/Dev/cross/dlang/i686-w64-mingw32.static/lib/libdruntime-ldc-debug.a
For comparison with the specified path ...
/home/majestio/Dev/cross/dlang/i686-w64-mingw32.static/lib
------------------------------------------------------------------------------

On Tuesday, 14 July 2015 at 16:38:52 UTC, Kai Nacke wrote:
> BTW: Can you cross-compile a C hello world without problems?
Yes.

> Did you compile druntime and phobos for the mingw target? If yes where did you place the libraries?
Yes. When I built the library, I inserted for your advice in ruttime/CMakeLists.txt:

set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_C_COMPILER i686-w64-mingw32.static-gcc)
set(CMAKE_CXX_COMPILER i686-w64-mingw32.static-g++)

> The other missing symbols are from druntime and phobos. This indicates that these libraries are not found. Did you also cross-compile the curl library?

Curl is present.

> You can use the -v command line option with ldc2 to see the call to gcc. This is useful for debugging.

I used it.

... In general, do not grow coconuts :((

Regards,
Majestio
July 17, 2015
Just in case the attached file: https//yadi.sk/d/bdD44pMYhvEG8

July 20, 2015
On Friday, 17 July 2015 at 07:54:03 UTC, Majestio wrote:
> Just in case the attached file: https//yadi.sk/d/bdD44pMYhvEG8

Hi Majestio!

The files were helpful. You need to add -mtriple=i686-w64-mingw32.static to D_FLAGS variable in runtime/CMakeLists.txt and recompile the libraries.

What happened is that the object files in the library are ELF-64 (compiled for x86-64 Linux) but hello.o is 80386 COFF. Therefore the unresolved references.

What I miss is the error message from the linker, complaining about the architecture mismatch...

Regards,
Kai
May 12, 2016
On Monday, 20 July 2015 at 04:57:14 UTC, Kai Nacke wrote:
> On Friday, 17 July 2015 at 07:54:03 UTC, Majestio wrote:
>> Just in case the attached file: https//yadi.sk/d/bdD44pMYhvEG8
>
> Hi Majestio!
>
> The files were helpful. You need to add -mtriple=i686-w64-mingw32.static to D_FLAGS variable in runtime/CMakeLists.txt and recompile the libraries.
>
> What happened is that the object files in the library are ELF-64 (compiled for x86-64 Linux) but hello.o is 80386 COFF. Therefore the unresolved references.
>
> What I miss is the error message from the linker, complaining about the architecture mismatch...
>
> Regards,
> Kai

Hi Kai!

I'm sorry for what I lift up a very old topic. As I have been busy throughout the year. I tried to fulfill your advice. At the stage of construction of library occur errors.
Maybe I missed some stage of construction? Please help, what to look for?

Details:

1) Build llvm (all ok)
=================================================================
rm -fR ~/llvm

wget -nc  http://llvm.org/releases/3.8.0/llvm-3.8.0.src.tar.xz
wget -nc  http://llvm.org/releases/3.8.0/cfe-3.8.0.src.tar.xz
wget -nc  http://llvm.org/releases/3.8.0/compiler-rt-3.8.0.src.tar.xz
wget -nc  http://llvm.org/releases/3.8.0/clang-tools-extra-3.8.0.src.tar.xz
wget -nc  http://llvm.org/releases/3.8.0/lld-3.8.0.src.tar.xz

tar -xf llvm-3.8.0.src.tar.xz
tar -xf cfe-3.8.0.src.tar.xz
tar -xf compiler-rt-3.8.0.src.tar.xz
tar -xf clang-tools-extra-3.8.0.src.tar.xz
tar -xf lld-3.8.0.src.tar.xz

mv llvm-3.8.0.src llvm
mv cfe-3.8.0.src llvm/tools/clang
mv compiler-rt-3.8.0.src llvm/projects/compiler-rt
mv clang-tools-extra-3.8.0.src llvm/tools/clang/tools/clang-tools-extra
mv lld-3.8.0.src llvm/tools/lld

rm -fR $HOME/Setup/build-llvm-native
mkdir -p $HOME/Setup/build-llvm-native
cd $HOME/Setup/build-llvm-native

cmake ../llvm \
-DCMAKE_INSTALL_PREFIX=$HOME/Dev/cross/llvm \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_ASSERTIONS=OFF
make -j3 && make install


2) Build dmd (all ok)
=================================================================
export PREFIX="$HOME/Dev/cross/dlang"

git clone https://github.com/dlang/dmd
git clone https://github.com/dlang/druntime
git clone https://github.com/dlang/phobos

tar -xJf dmc.tar.xz
tar -xJf druntime.tar.xz
tar -xJf phobos.tar.xz

cd dmd
make -f posix.mak AUTO_BOOTSTRAP=1 INSTALL_DIR=$PREFIX/dmd install
cd ../druntime
make -f posix.mak INSTALL_DIR=$PREFIX/dmd install
cd ../phobos
make -f posix.mak INSTALL_DIR=$PREFIX/dmd install
cd ..


3) Build ldc (all ok)
=================================================================
export LLVM="$HOME/Dev/cross/llvm"
export PREFIX="$HOME/Dev/cross/dlang"
export TARGET="x86_64-pc-linux-gnu"
export DMD="$PREFIX/dmd/linux/bin64/dmd"

git clone --recursive https://github.com/ldc-developers/ldc.git
cd ldc
git submodule update --init
cd ..
rm -fR build_$TARGET && mkdir -p build_$TARGET && cd build_$TARGET

cmake ../ldc \
-DCMAKE_INSTALL_PREFIX=$PREFIX/ldc \
-DLLVM_ROOT_DIR=$LLVM/bin \
-DLLVM_CONFIG=$LLVM/bin/llvm-config
make && make install


4) Build runtime libs for x86_64-w64-mingw32.static (error)
=================================================================
export TARGET="x86_64-w64-mingw32.static"
export LLVM="$HOME/Dev/cross/llvm"
export MXE="$HOME/Dev/cross/mxe/usr"
export PREFIX="$HOME/Dev/cross/dlang"
export DMD="$HOME/Dev/cross/dlang/dmd/linux/bin64/dmd"
export PATH="$MXE/bin:$PATH"

#
# Insert into runtime/CMakeLists.txt
#
# set(CMAKE_SYSTEM_NAME Linux)
# set(CMAKE_C_COMPILER aarch64-pc-linux-gnu-gcc)
# set(CMAKE_CXX_COMPILER aarch64-pc-linux-gnu-c++)
#
# and add to D_FLAGS
#
# set(D_FLAGS -w;-mtriple=x86_64-w64-mingw32.static)
#

rm -fR build_$TARGET && mkdir -p build_$TARGET && cd build_$TARGET

cmake ../ldc \
-DCMAKE_INSTALL_PREFIX=$PREFIX/ldc/$TARGET \
-DLLVM_ROOT_DIR=$LLVM/bin \
-DLLVM_CONFIG=$LLVM/bin/llvm-config
make && make install

Log:
=================================================================
...
Scanning dependencies of target ldc2
[  9%] Generating bin/ldc2
/home/majestio/Setup/ldc/ddmd/builtin.d(288): Warning: switch case fallthrough - use 'goto case;' if intended
/home/majestio/Setup/ldc/ddmd/builtin.d(292): Warning: switch case fallthrough - use 'goto case;' if intended
/home/majestio/Setup/ldc/ddmd/root/rmem.d(190): Deprecation: alias object.TypeInfo.init is deprecated - Please use initializer instead.
/home/majestio/Setup/ldc/ddmd/root/rmem.d(191): Deprecation: alias object.TypeInfo.init is deprecated - Please use initializer instead.
/home/majestio/Setup/ldc/ddmd/root/rmem.d(191): Deprecation: alias object.TypeInfo.init is deprecated - Please use initializer instead.
/home/majestio/Setup/ldc/ddmd/root/rmem.d(198): Deprecation: alias object.TypeInfo.init is deprecated - Please use initializer instead.
/home/majestio/Setup/ldc/ddmd/root/rmem.d(205): Deprecation: alias object.TypeInfo.init is deprecated - Please use initializer instead.
/home/majestio/Setup/ldc/ddmd/root/rmem.d(205): Deprecation: alias object.TypeInfo.init is deprecated - Please use initializer instead.
[  9%] Built target ldc2
Scanning dependencies of target ldmd2
[  9%] Generating bin/ldmd2
[  9%] Built target ldmd2
Scanning dependencies of target not
[  9%] Building CXX object CMakeFiles/not.dir/utils/not.cpp.o
Linking CXX executable bin/not
[  9%] Built target not
[  9%] Generating gccbuiltins_x86.di
[  9%] Generating gccbuiltins_aarch64.di
[  9%] Generating gccbuiltins_arm.di
[  9%] Generating gccbuiltins_mips.di
[  9%] Generating gccbuiltins_ppc.di
[  9%] Generating gccbuiltins_s390.di
[  9%] Generating src/core/atomic.o
[  9%] Generating src/core/attribute.o
[  9%] Generating src/core/demangle.o
/home/majestio/Setup/ldc/runtime/druntime/src/core/stdc/wchar_.d(56): Error: undefined identifier 'FILE'
/home/majestio/Setup/ldc/runtime/druntime/src/core/stdc/wchar_.d(58): Error: undefined identifier 'FILE'
/home/majestio/Setup/ldc/runtime/druntime/src/core/stdc/wchar_.d(64): Error: undefined identifier 'FILE'
/home/majestio/Setup/ldc/runtime/druntime/src/core/stdc/wchar_.d(66): Error: undefined identifier 'FILE'
/home/majestio/Setup/ldc/runtime/druntime/src/core/stdc/wchar_.d(84): Error: undefined identifier 'FILE'
/home/majestio/Setup/ldc/runtime/druntime/src/core/stdc/wchar_.d(86): Error: undefined identifier 'FILE'
/home/majestio/Setup/ldc/runtime/druntime/src/core/stdc/wchar_.d(90): Error: undefined identifier 'FILE'
/home/majestio/Setup/ldc/runtime/druntime/src/core/stdc/wchar_.d(92): Error: undefined identifier 'FILE'
/home/majestio/Setup/ldc/runtime/druntime/src/core/stdc/wchar_.d(102): Error: undefined identifier 'FILE'
/home/majestio/Setup/ldc/runtime/druntime/src/core/stdc/wchar_.d(104): Error: undefined identifier 'FILE'
/home/majestio/Setup/ldc/runtime/druntime/src/core/stdc/wchar_.d(111): Error: undefined identifier 'FILE'
/home/majestio/Setup/ldc/runtime/druntime/src/core/stdc/wchar_.d(120): Error: undefined identifier 'FILE'
/home/majestio/Setup/ldc/runtime/druntime/src/core/stdc/stdio.d(705): Error: undefined identifier 'FILE'
/home/majestio/Setup/ldc/runtime/druntime/src/core/stdc/stdio.d(710): Error: undefined identifier 'FILE'
/home/majestio/Setup/ldc/runtime/druntime/src/core/stdc/stdio.d(716): Error: undefined identifier 'FILE'
/home/majestio/Setup/ldc/runtime/druntime/src/core/stdc/stdio.d(720): Error: undefined identifier 'FILE'
/home/majestio/Setup/ldc/runtime/druntime/src/core/stdc/stdio.d(722): Error: undefined identifier 'FILE'
/home/majestio/Setup/ldc/runtime/druntime/src/core/stdc/stdio.d(722): Error: undefined identifier 'FILE'
/home/majestio/Setup/ldc/runtime/druntime/src/core/stdc/stdio.d(725): Error: undefined identifier 'FILE'
/home/majestio/Setup/ldc/runtime/druntime/src/core/stdc/stdio.d(727): Error: undefined identifier 'FILE'
runtime/CMakeFiles/druntime-ldc.dir/build.make:87: error выполнения рецепта для цели «runtime/src/core/demangle.o»
make[2]: *** [runtime/src/core/demangle.o] Error 1
CMakeFiles/Makefile2:336: error выполнения рецепта для цели «runtime/CMakeFiles/druntime-ldc.dir/all»
make[1]: *** [runtime/CMakeFiles/druntime-ldc.dir/all] Error 2
Makefile:146: error выполнения рецепта для цели «all»
make: *** [all] Error 2
=================================================================
If I use "make -k" many *.obj files created. But restarting the "make -k" still fails.

WBR, Majestio
May 12, 2016
On Thursday, 12 May 2016 at 16:51:54 UTC, Majestio wrote:
> 
> # set(CMAKE_SYSTEM_NAME Linux)
> # set(CMAKE_C_COMPILER aarch64-pc-linux-gnu-gcc)
> # set(CMAKE_CXX_COMPILER aarch64-pc-linux-gnu-c++)
> #

misspelled, it was written:

set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_C_COMPILER x86_64-w64-mingw32.static-gcc)
set(CMAKE_CXX_COMPILER x86_64-w64-mingw32.static-g++)

May 17, 2016
On Thursday, 12 May 2016 at 19:59:15 UTC, Majestio wrote:
> On Thursday, 12 May 2016 at 16:51:54 UTC, Majestio wrote:
>> 
>> # set(CMAKE_SYSTEM_NAME Linux)
>> # set(CMAKE_C_COMPILER aarch64-pc-linux-gnu-gcc)
>> # set(CMAKE_CXX_COMPILER aarch64-pc-linux-gnu-c++)
>> #
>
> misspelled, it was written:
>
> set(CMAKE_SYSTEM_NAME Windows)
> set(CMAKE_C_COMPILER x86_64-w64-mingw32.static-gcc)
> set(CMAKE_CXX_COMPILER x86_64-w64-mingw32.static-g++)

Hi Majestio!

The MinGW target is currently broken. Therefore you get the compile errors in Phobos/druntime (the missing FILE type etc.)

Regards,
Kai
« First   ‹ Prev
1 2