Build for i586

Alexander Zhirov azhirov1991 at gmail.com
Thu Jul 28 06:01:17 UTC 2022


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.

The [official 
documentation](https://www.amd.com/system/files/TechDocs/33234H_LX_databook.pdf) says that "*... the core is a combination of Intel Pentium ® processor, AMD Athlon™ processor, and AMD Geode LX processor specific instructions.*" - this means that the processor architecture is **<** `i686`. And judging by the fact that Linux gives a description when calling `uname`:

```sh
# uname -m
i586
```

This suggests that the processor is CLEARLY `i586`.
The problem is that I can't assemble the software I need for this 
processor, since it is automatically assembled for `i686`.
What have I done?
I built an `ldc` compiler on this machine:

```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
```

And when I try to compile the program through it, I create a 
binary file, but when I start it outputs **Illegal instruction**:

```sh
# ldc2 app.d
# ./app
Illegal instruction
```

Here's using the `mcpu` flag:

```sh
# ldc2 --mcpu=i586 app.d -v
binary    /mnt/disc/sdb/part1/program/ldc/1.30/install/bin/ldc2
version   1.30.0-git-32f5a35 (DMD v2.100.1, LLVM 10.0.1)
config    
/mnt/disc/sdb/part1/program/ldc/1.30/install/etc/ldc2.conf 
(i686-pc-linux-gnu)
predefs   LDC all D_Version2 assert D_PreConditions 
D_PostConditions D_Invariants D_ModuleInfo D_Exceptions 
D_TypeInfo X86 D_InlineAsm_X86 D_HardFloat LittleEndian D_PIC 
linux Posix CRuntime_Glibc CppRuntime_Gcc LDC_LLVM_1000
parse     app
importall app
import    object    
(/root/usr/program/ldc/1.30/install/include/d/object.d)
import    core.attribute    
(/root/usr/program/ldc/1.30/install/include/d/core/attribute.d)
import    ldc.attributes    
(/root/usr/program/ldc/1.30/install/include/d/ldc/attributes.d)
import    core.internal.hash    
(/root/usr/program/ldc/1.30/install/include/d/core/internal/hash.d)
import    core.internal.traits  
(/root/usr/program/ldc/1.30/install/include/d/core/internal/traits.d)
import    core.internal.entrypoint  
(/root/usr/program/ldc/1.30/install/include/d/core/internal/entrypoint.d)
import    core.internal.array.appending 
(/root/usr/program/ldc/1.30/install/include/d/core/internal/array/appending.d)
import    core.internal.array.comparison    
(/root/usr/program/ldc/1.30/install/include/d/core/internal/array/comparison.d)
import    core.internal.array.equality  
(/root/usr/program/ldc/1.30/install/include/d/core/internal/array/equality.d)
import    core.internal.array.casting   
(/root/usr/program/ldc/1.30/install/include/d/core/internal/array/casting.d)
import    core.internal.array.concatenation 
(/root/usr/program/ldc/1.30/install/include/d/core/internal/array/concatenation.d)
import    core.internal.array.construction  
(/root/usr/program/ldc/1.30/install/include/d/core/internal/array/construction.d)
import    core.internal.array.capacity  
(/root/usr/program/ldc/1.30/install/include/d/core/internal/array/capacity.d)
import    core.internal.dassert 
(/root/usr/program/ldc/1.30/install/include/d/core/internal/dassert.d)
import    core.atomic   
(/root/usr/program/ldc/1.30/install/include/d/core/atomic.d)
import    core.internal.attributes  
(/root/usr/program/ldc/1.30/install/include/d/core/internal/attributes.d)
import    core.internal.atomic  
(/root/usr/program/ldc/1.30/install/include/d/core/internal/atomic.d)
import    ldc.intrinsics    
(/root/usr/program/ldc/1.30/install/include/d/ldc/intrinsics.di)
import    core.internal.destruction 
(/root/usr/program/ldc/1.30/install/include/d/core/internal/destruction.d)
import    core.internal.moving  
(/root/usr/program/ldc/1.30/install/include/d/core/internal/moving.d)
import    core.internal.postblit    
(/root/usr/program/ldc/1.30/install/include/d/core/internal/postblit.d)
import    core.internal.switch_ 
(/root/usr/program/ldc/1.30/install/include/d/core/internal/switch_.d)
import    core.lifetime 
(/root/usr/program/ldc/1.30/install/include/d/core/lifetime.d)
import    core.builtins 
(/root/usr/program/ldc/1.30/install/include/d/core/builtins.d)
semantic  app
entry     main          app.d
semantic2 app
semantic3 app
import    std.stdio 
(/root/usr/program/ldc/1.30/install/include/d/std/stdio.d)
import    core.stdc.stddef  
(/root/usr/program/ldc/1.30/install/include/d/core/stdc/stddef.d)
import    std.algorithm.mutation    
(/root/usr/program/ldc/1.30/install/include/d/std/algorithm/mutation.d)
import    std.traits    
(/root/usr/program/ldc/1.30/install/include/d/std/traits.d)
import    std.meta  
(/root/usr/program/ldc/1.30/install/include/d/std/meta.d)
import    std.range.primitives  
(/root/usr/program/ldc/1.30/install/include/d/std/range/primitives.d)
import    std.typecons  
(/root/usr/program/ldc/1.30/install/include/d/std/typecons.d)
import    std.format.spec   
(/root/usr/program/ldc/1.30/install/include/d/std/format/spec.d)
import    std.format.write  
(/root/usr/program/ldc/1.30/install/include/d/std/format/write.d)
import    std.format.internal.write 
(/root/usr/program/ldc/1.30/install/include/d/std/format/internal/write.d)
import    std.internal.attributes   
(/root/usr/program/ldc/1.30/install/include/d/std/internal/attributes.d)
import    std.range 
(/root/usr/program/ldc/1.30/install/include/d/std/range/package.d)
import    std.array 
(/root/usr/program/ldc/1.30/install/include/d/std/array.d)
import    std.functional    
(/root/usr/program/ldc/1.30/install/include/d/std/functional.d)
import    std.conv  
(/root/usr/program/ldc/1.30/install/include/d/std/conv.d)
import    std.ascii 
(/root/usr/program/ldc/1.30/install/include/d/std/ascii.d)
import    std.range.interfaces  
(/root/usr/program/ldc/1.30/install/include/d/std/range/interfaces.d)
import    core.stdc.stdio   
(/root/usr/program/ldc/1.30/install/include/d/core/stdc/stdio.d)
import    core.stdc.stdint  
(/root/usr/program/ldc/1.30/install/include/d/core/stdc/stdint.d)
import    core.stdc.config  
(/root/usr/program/ldc/1.30/install/include/d/core/stdc/config.d)
import    core.stdc.signal  
(/root/usr/program/ldc/1.30/install/include/d/core/stdc/signal.d)
import    core.stdc.wchar_  
(/root/usr/program/ldc/1.30/install/include/d/core/stdc/wchar_.d)
import    core.stdc.stdarg  
(/root/usr/program/ldc/1.30/install/include/d/core/stdc/stdarg.d)
import    core.stdc.time    
(/root/usr/program/ldc/1.30/install/include/d/core/stdc/time.d)
import    core.sys.posix.stdc.time  
(/root/usr/program/ldc/1.30/install/include/d/core/sys/posix/stdc/time.d)
import    core.sys.posix.sys.types  
(/root/usr/program/ldc/1.30/install/include/d/core/sys/posix/sys/types.d)
import    core.sys.posix.config 
(/root/usr/program/ldc/1.30/install/include/d/core/sys/posix/config.d)
import    core.sys.posix.stdio  
(/root/usr/program/ldc/1.30/install/include/d/core/sys/posix/stdio.d)
import    std.exception 
(/root/usr/program/ldc/1.30/install/include/d/std/exception.d)
import    core.stdc.errno   
(/root/usr/program/ldc/1.30/install/include/d/core/stdc/errno.d)
import    std.utf   
(/root/usr/program/ldc/1.30/install/include/d/std/utf.d)
import    core.exception    
(/root/usr/program/ldc/1.30/install/include/d/core/exception.d)
import    core.internal.string  
(/root/usr/program/ldc/1.30/install/include/d/core/internal/string.d)
import    std.algorithm.comparison  
(/root/usr/program/ldc/1.30/install/include/d/std/algorithm/comparison.d)
import    core.stdc.string  
(/root/usr/program/ldc/1.30/install/include/d/core/stdc/string.d)
import    std.format    
(/root/usr/program/ldc/1.30/install/include/d/std/format/package.d)
import    std.format.read   
(/root/usr/program/ldc/1.30/install/include/d/std/format/read.d)
import    std.format.internal.read  
(/root/usr/program/ldc/1.30/install/include/d/std/format/internal/read.d)
import    std.algorithm.searching   
(/root/usr/program/ldc/1.30/install/include/d/std/algorithm/searching.d)
import    std.bitmanip  
(/root/usr/program/ldc/1.30/install/include/d/std/bitmanip.d)
import    std.system    
(/root/usr/program/ldc/1.30/install/include/d/std/system.d)
import    core.bitop    
(/root/usr/program/ldc/1.30/install/include/d/core/bitop.d)
import    core.memory   
(/root/usr/program/ldc/1.30/install/include/d/core/memory.d)
import    core.time 
(/root/usr/program/ldc/1.30/install/include/d/core/time.d)
import    core.sys.posix.time   
(/root/usr/program/ldc/1.30/install/include/d/core/sys/posix/time.d)
import    core.sys.posix.signal 
(/root/usr/program/ldc/1.30/install/include/d/core/sys/posix/signal.d)
import    core.sys.posix.sys.time   
(/root/usr/program/ldc/1.30/install/include/d/core/sys/posix/sys/time.d)
import    core.sys.posix.sys.select 
(/root/usr/program/ldc/1.30/install/include/d/core/sys/posix/sys/select.d)
import    core.sys.linux.sys.time   
(/root/usr/program/ldc/1.30/install/include/d/core/sys/linux/sys/time.d)
import    core.sys.linux.config 
(/root/usr/program/ldc/1.30/install/include/d/core/sys/linux/config.d)
import    core.internal.array.utils 
(/root/usr/program/ldc/1.30/install/include/d/core/internal/array/utils.d)
import    core.checkedint   
(/root/usr/program/ldc/1.30/install/include/d/core/checkedint.d)
import    std.string    
(/root/usr/program/ldc/1.30/install/include/d/std/string.d)
import    std.uni   
(/root/usr/program/ldc/1.30/install/include/d/std/uni/package.d)
import    std.internal.unicode_tables   
(/root/usr/program/ldc/1.30/install/include/d/std/internal/unicode_tables.d)
import    core.internal.lifetime    
(/root/usr/program/ldc/1.30/install/include/d/core/internal/lifetime.d)
import    std.format.internal.floats    
(/root/usr/program/ldc/1.30/install/include/d/std/format/internal/floats.d)
import    std.math.operations   
(/root/usr/program/ldc/1.30/install/include/d/std/math/operations.d)
import    std.math  
(/root/usr/program/ldc/1.30/install/include/d/std/math/package.d)
import    std.math.algebraic    
(/root/usr/program/ldc/1.30/install/include/d/std/math/algebraic.d)
import    core.math 
(/root/usr/program/ldc/1.30/install/include/d/core/math.d)
import    core.stdc.math    
(/root/usr/program/ldc/1.30/install/include/d/core/stdc/math.d)
import    std.math.constants    
(/root/usr/program/ldc/1.30/install/include/d/std/math/constants.d)
import    std.math.exponential  
(/root/usr/program/ldc/1.30/install/include/d/std/math/exponential.d)
import    std.math.hardware 
(/root/usr/program/ldc/1.30/install/include/d/std/math/hardware.d)
import    core.stdc.fenv    
(/root/usr/program/ldc/1.30/install/include/d/core/stdc/fenv.d)
import    core.cpuid    
(/root/usr/program/ldc/1.30/install/include/d/core/cpuid.d)
import    std.math.remainder    
(/root/usr/program/ldc/1.30/install/include/d/std/math/remainder.d)
import    std.math.rounding 
(/root/usr/program/ldc/1.30/install/include/d/std/math/rounding.d)
import    std.math.traits   
(/root/usr/program/ldc/1.30/install/include/d/std/math/traits.d)
import    std.math.trigonometry 
(/root/usr/program/ldc/1.30/install/include/d/std/math/trigonometry.d)
import    std.internal.unicode_grapheme 
(/root/usr/program/ldc/1.30/install/include/d/std/internal/unicode_grapheme.d)
GC stats  0M used, 5M free, 5M total
code      app
/root/usr/program/gcc/9.5.0/install/bin/cc app.o -o app 
-L/root/usr/program/ldc/1.30/install/lib -lphobos2-ldc 
-ldruntime-ldc -Wl,--gc-sections -lrt -ldl -lpthread -lm -m32
```

The GCC compiler is built on `i686`:

```sh
# cc --version
cc (GCC) 9.5.0
```

At first I thought that I needed to rebuild the `GCC` compiler 
for the `i586` architecture. I downloaded GCC 9.5.0 and started 
the installation:

```sh
# cd source
# ./contrib/download_prerequisites
gmp-6.1.0.tar.bz2: OK
mpfr-3.1.4.tar.bz2: OK
mpc-1.0.3.tar.gz: OK
isl-0.18.tar.bz2: OK
All prerequisites downloaded successfully.
# cd ..
# mkdir build && cd build
# ../source/config.sub i586-linux
i586-pc-linux-gnu
# ../source/configure --prefix=$PWD/../install_i586 
--enable-shared --enable-threads=posix --enable-__cxa_atexit 
--enable-clocale=gnu --enable-languages=c,c++,d 
--target=i586-pc-linux-gnu --disable-multilib 
--with-multilib-list=m32
...
# make -j8
...
```

But during the installation process I got an error:

```sh
...
checking for suffix of object files... mv -f .deps/findcomp.Tpo 
.deps/findcomp.Plo
configure: error: in 
`/root/source/gcc/9.5.0/build/i586-pc-linux-gnu/libgcc':
configure: error: cannot compute suffix of object files: cannot 
compile
See `config.log' for more details
Makefile:14150: recipe for target 'configure-target-libgcc' failed
make[1]: *** [configure-target-libgcc] Error 1
make[1]: *** Waiting for unfinished jobs....
...
```

If I do it without a flag `--target=i586-pc-linux-gnu`, then 
everything is assembled without errors.

I'm at a dead end, please help, guys.



More information about the Digitalmars-d-learn mailing list