How to build a set of toolchains for cross-compiling for LDC?

Majestio via digitalmars-d-ldc digitalmars-d-ldc at puremagic.com
Thu May 12 09:51:54 PDT 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


More information about the digitalmars-d-ldc mailing list