Build for i586

Alexander Zhirov azhirov1991 at gmail.com
Fri Jul 29 10:46:20 UTC 2022


On Thursday, 28 July 2022 at 06:01:17 UTC, Alexander Zhirov wrote:
> I did a topic a [little 
> earlier](https://forum.dlang.org/thread/hfzsnagofrnlmynyzymp@forum.dlang.org) about compiling a compiler for processor Geode LX800.
> The bottom line is that I have a processor on which I want to 
> compile the program, is an i586 architecture.

Yes, I did it!

I have an `i686` host with a `GCC 5.3.0` compiler. The build path 
is `/root/source`.

1. Using `GCC 5.3.0`, I built `GCC 9.5.0` in an `i686` environment
```sh
mkdir /root/source/gcc && cd /root/source/gcc
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
tar xf gcc-9.5.0.tar.gz -C source
cd source
./contrib/download_prerequisites
mkdir /root/source/gcc/build && cd /root/source/gcc/build
../source/configure --prefix=$PWD/../install --enable-shared 
--enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu 
--enable-languages=c,c++
make -j16
make install
```
2. Using `GCC 9.5.0`, I built `LLVM 10.0.1` in an `i686` 
environment
```sh
mkdir /root/source/llvm && cd /root/source/llvm
wget 
https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.1/llvm-project-10.0.1.tar.xz
tar xf llvm-project-10.0.1.tar.xz -C source
mkdir /root/source/llvm/build && cd /root/source/llvm/build
export CC=/root/source/gcc/install/bin/gcc
export CXX=/root/source/gcc/gcc-install/bin/g++
cmake ../source -DCMAKE_BUILD_TYPE=Release 
-DCMAKE_INSTALL_PREFIX=$PWD/../install 
-DLLVM_TARGETS_TO_BUILD='X86' -DCOMPILER_RT_INCLUDE_TESTS=OFF 
-DLLVM_INCLUDE_TESTS=OFF
make -j16
make install
```
3. Downloaded the `DMD 2.086.1` compiler (since this version runs 
on the `Geode LX800` processor without any problems)
4. Copied all this to an external HDD and connected it to my 
`Geode LX800 i586`
5. Using `GCC 9.5.0`, `LLVM 10.0.1` and `DMD 2.086.1`, I built 
`LDC 2.100.1` on `Geode LX800 i586`
```sh
mkdir -p ~/ldc/build && cd ~/ldc
git clone --recursive https://github.com/ldc-developers/ldc.git 
source
cd build
export PATH=<PATH_TO_GCC_BIN>:$PATH
cmake ../source -DCMAKE_BUILD_TYPE=Release 
-DCMAKE_INSTALL_PREFIX=$PWD/../install 
-DLLVM_ROOT_DIR=<PATH_TO_LLVM_INSTALL> 
-DD_COMPILER=<PATH_TO_DMD_COMPILER_X32>
make
make install
```
6. Then, through `ldc-build-runtime`, I rebuilt the libraries for 
`i586`
```sh
ldc-build-runtime --dFlags="-mcpu=i586" --cFlags="-march=i586"
```

When performing the actions, I may have connected the necessary 
paths to `LD_LIBRARY_PATH` (I don't remember 😁).

Now `LDC` with the flag `-mcpu=i586` compiles the binaries I need 
at the output and the architecture fully supports them!

```sh
~ # ldc2 --version
LDC - the LLVM D compiler (1.30.0-git-32f5a35):
   based on DMD v2.100.1 and LLVM 10.0.1
   built with DMD32 D Compiler v2.086.1
   Default target: i686-pc-linux-gnu
   Host CPU: geode
   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
```

Thank you so much for your help!

**As a result, the reassembly of the `runtime` and `phobos` 
libraries helped. Would it be cool to figure out how to rebuild 
the `DMD` library for `i586`?**


More information about the Digitalmars-d-learn mailing list