On Thursday, 21 July 2022 at 05:44:41 UTC, Alexander Zhirov wrote:
I will report on the successes a little later.

Result:

I downloaded and unpacked the binary version of the `dmd` compiler version [2.097.2](http://downloads.dlang.org/releases/2021/dmd.2.097.2.linux.tar.xz), which runs without problems with my `glibc` set.

Then I compiled the `GCC` compiler version 9.5.0 from the source code:
```sh
wget https://ftp.mpi-inf.mpg.de/mirrors/gnu/mirror/gcc.gnu.org/pub/gcc/releases/gcc-9.5.0/gcc-9.5.0.tar.gz
mkdir build-gcc && cd build-gcc
../gcc-9.5.0/configure --prefix=$PWD/../install-gcc --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --enable-languages=c,c++
make -j16
make install
```

Then I built `LLVM` using this compiler, according to the instructions on the [LDC website](https://wiki.dlang.org/Building_LDC_from_source#Building_LLVM_from_source):
```sh
export CC=/root/source/gcc/gcc-install/bin/gcc
export CXX=/root/source/gcc/gcc-install/bin/g++
mkdir build-llvm && cd build-llvm
cmake ../llvm-10.0.1.src -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PWD/../install-llvm -DLLVM_BINUTILS_INCDIR=/usr/include -DLLVM_TARGETS_TO_BUILD='X86' -DCOMPILER_RT_INCLUDE_TESTS=OFF -DLLVM_INCLUDE_TESTS=OFF
make -j16
make install
```

And then I built the `ldc` compiler myself, also according to the instructions on the [website](https://wiki.dlang.org/Building_LDC_from_source#Building_LDC_from_source):
```sh
git clone --recursive https://github.com/ldc-developers/ldc.git
mkdir build-ldc && cd build-ldc
cmake ../ldc -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PWD/../install-ldc -DLLVM_ROOT_DIR=<PATH_TO_LLVM_INSTALL> -DD_COMPILER=<PATH_TO_DMD_COMPILER_X32>
make -j16
make install
```

As a result, I built the `ldc` compiler for my `x32` machine:

```sh
# ldc2 --version
LDC - the LLVM D compiler (1.30.0):
  based on DMD v2.100.1 and LLVM 10.0.1
  built with DMD32 D Compiler v2.097.2
  Default target: i686-pc-linux-gnu
  Host CPU: broadwell
  http://dlang.org - http://wiki.dlang.org/LDC

  Registered Targets:
    x86    - 32-bit X86: Pentium-Pro and above
    x86-64 - 64-bit X86: EM64T and AMD64
```

I hope my guide will be useful to someone who will face the same task. Thank you for your help!

Reply via email to