Thread overview
Why ldc-1.20.1 is always building runtime to x86_64 even when I'm running an i686 linux?
Apr 17, 2020
dangbinghoo
Apr 17, 2020
dangbinghoo
Apr 17, 2020
kinke
Apr 20, 2020
dangbinghoo
Apr 20, 2020
dangbinghoo
April 17, 2020
hi there,

I have tried to building LDC 1.20.1 from src for ubuntu 14.04 i686 system. But got trouble in the building step, it seems that it always trying to building runtime for  x86_64 target, no matter what kind of D compiler is using, I have tried with ldc2-1.2.0-linux-x86 or the latest dmd 2.091.0-0_i386.

I also tried to using the cross-compiling style to build runtime adding `mtrip=i686-linux-gnu`, but the final ldc2 failed to link when building a simple empty D source file saying

```
/usr/bin/i686-linux-gnu-ld.gold: error: /usr/lib/gcc/i686-linux-gnu/6/crtbegin.o: incompatible target
/usr/bin/i686-linux-gnu-ld.gold: error: /usr/lib/gcc/i686-linux-gnu/6/crtend.o: incompatible target
/usr/bin/i686-linux-gnu-ld.gold: warning: skipping incompatible /home/chiot/ldctool/ldc2-tmp/bin/../lib/libdruntime-ldc.a while searching for druntime-ldc
/usr/bin/i686-linux-gnu-ld.gold: error: cannot find -ldruntime-ldc
/usr/bin/i686-linux-gnu-ld.gold: warning: skipping incompatible /usr/lib/gcc/i686-linux-gnu/6/libgcc_s.so.1 while searching for libgcc_s.so.1
/usr/bin/i686-linux-gnu-ld.gold: warning: skipping incompatible /usr/lib/gcc/i686-linux-gnu/6/libgcc_s.so.1 while searching for libgcc_s.so.1
/usr/lib/gcc/i686-linux-gnu/6/../../../../lib64/crt1.o(.text+0x20): error: undefined reference to 'main'
xx.o:xx.d:function ldc.register_dso: error: undefined reference to '_d_dso_registry'
collect2: error: ld returned 1 exit status
Error: /usr/bin/cc failed with status: 1

```

so, the ldc2 now is sticking to x86_64 for PC now?

Thanks!

~~~~~
binghoo dang

April 17, 2020
On Friday, 17 April 2020 at 09:32:32 UTC, dangbinghoo wrote:
> hi there,
>
> I have tried to building LDC 1.20.1 from src for ubuntu 14.04 i686 system. But got trouble in the building step, it seems that it always trying to building runtime for  x86_64 target, no matter what kind of D compiler is using, I have tried with ldc2-1.2.0-linux-x86 or the latest dmd 2.091.0-0_i386.

PS:

building ldc 1.20.1 source just error in `ninja` step:

```
e/objects-debug-shared/core/sys/linux/err.o runtime/objects-debug-shared/core/sys/bionic/fcntl.o runtime/objects-debug-shared/core/sys/bionic/string.o runtime/objects-debug-shared/core/sys/bionic/unistd.o runtime/objects-debug-shared/core/sys/bionic/err.o runtime/CMakeFiles/druntime-ldc-debug-shared.dir/druntime/src/core/stdc/errno.c.o runtime/CMakeFiles/druntime-ldc-debug-shared.dir/druntime/src/ldc/arm_unwind.c.o runtime/CMakeFiles/druntime-ldc-debug-shared.dir/druntime/src/ldc/msvc.c.o runtime/CMakeFiles/druntime-ldc-debug-shared.dir/druntime/src/core/threadasm.S.o runtime/CMakeFiles/druntime-ldc-debug-shared.dir/druntime/src/ldc/eh_asm.S.o  -lm -lpthread -lrt -ldl && :
/usr/bin/i686-linux-gnu-ld: i386:x86-64 architecture of input file `runtime/objects-debug-shared/core/volatile.o' is incompatible with i386 output
/usr/bin/i686-linux-gnu-ld: i386:x86-64 architecture of input file `runtime/objects-debug-shared/core/memory.o' is incompatible with i386 output
/usr/bin/i686-linux-gnu-ld: i386:x86-64 architecture of input file `runtime/objects-debug-shared/core/math.o' is incompatible with i386 output
/usr/bin/i686-linux-gnu-ld: i386:x86-64 architecture of input file `runtime/objects-debug-shared/core/simd.o' is incompatible with i386 output
/usr/bin/i686-linux-gnu-ld: i386:x86-64 architecture of input file `runtime/objects-debug-shared/core/atomic.o' is incompatible with i386 output
/usr/bin/i686-linux-gnu-ld: i386:x86-64 architecture of input file `runtime/objects-debug-shared/core/checkedint.o' is incompatible with i386 output
/usr/bin/i686-linux-gnu-ld: i386:x86-64 architecture of input file `runtime/objects-debug-shared/core/gc/gcinterface.o' is incompatible with i386 output
/usr/bin/i686-linux-gnu-ld: i386:x86-64 architecture of input file `runtime/objects-debug-shared/core/gc/config.o' is incompatible with i386 output
/usr/bin/i686-linux-gnu-ld: i386:x86-64 architecture of input file `runtime/objects-debug-shared/core/gc/registry.o' is incompatible with i386 output
/usr/bin/i686-linux-gnu-ld: i386:x86-64 architecture of input file `runtime/objects-debug-shared/core/internal/array/concatenation.o' is incompatible with i386 output
/usr/bin/i686-linux-gnu-ld: i386:x86-64 architecture of input file `runtime/objects-debug-shared/core/internal/array/comparison.o' is incompatible with i386 output
/usr/bin/i686-linux-gnu-ld: i386:x86-64 architecture of input file `runtime/objects-debug-shared/core/internal/array/construction.o' is incompatible with i386 output
/usr/bin/i686-linux-gnu-ld: i386:x86-64 architecture of input file `runtime/objects-debug-shared/core/internal/array/equality.o' is incompatible with i386 output
/usr/bin/i686-linux-gnu-ld: i386:x86-64 architecture of input file `runtime/objects-debug-shared/core/internal/array/utils.o' is incompatible with i386 output
/usr/bin/i686-linux-gnu-ld: i386:x86-64 architecture of input file `runtime/objects-debug-shared/core/internal/array/capacity.o' is incompatible with i386 output

```

thanks!

April 17, 2020
On Friday, 17 April 2020 at 09:32:32 UTC, dangbinghoo wrote:
> so, the ldc2 now is sticking to x86_64 for PC now?

Of course not. With the little information you gave, it looks like the LLVM you use defaults to the x86_64 triple (can be configured via CMake when building LLVM), that's why you need -mtriple to build the libs, and later too when compiling any D file.
April 20, 2020
On Friday, 17 April 2020 at 12:22:07 UTC, kinke wrote:
> On Friday, 17 April 2020 at 09:32:32 UTC, dangbinghoo wrote:
>> so, the ldc2 now is sticking to x86_64 for PC now?
>
> Of course not. With the little information you gave, it looks like the LLVM you use defaults to the x86_64 triple (can be configured via CMake when building LLVM), that's why you need -mtriple to build the libs, and later too when compiling any D file.

thank you. I just tried to set llvm default tripple to `i686-linux-gnu`, and when I trying to build ldc2, again failed with runtime building:

```
Warning: unknown target OS: gnu
Warning: Assuming critical section size = 24 bytes
core/stdc/time.d(151): Error: undefined identifier `time_t`, did you mean function `time`?
core/stdc/time.d(151): Error: undefined identifier `time_t`, did you mean function `time`?
core/stdc/time.d(153): Error: undefined identifier `time_t`, did you mean function `time`?
core/stdc/time.d(153): Error: undefined identifier `tm`
core/stdc/time.d(155): Error: undefined identifier `time_t`, did you mean function `time`?
core/stdc/time.d(155): Error: undefined identifier `time_t`, did you mean function `time`?
core/stdc/time.d(158): Error: undefined identifier `tm`
core/stdc/time.d(160): Error: undefined identifier `time_t`, did you mean function `time`?
core/stdc/time.d(162): Error: undefined identifier `tm`
core/stdc/time.d(162): Error: undefined identifier `time_t`, did you mean function `time`?
core/stdc/time.d(164): Error: undefined identifier `tm`
core/stdc/time.d(164): Error: undefined identifier `time_t`, did you mean function `time`?
core/stdc/time.d(166): Error: undefined identifier `tm`
core/stdc/wchar_.d(125): Error: undefined identifier `wchar_t`, did you mean `dchar`?
core/stdc/wchar_.d(128): Error: undefined identifier `wchar_t`, did you mean `dchar`?
core/stdc/wchar_.d(131): Error: undefined identifier `FILE`
core/stdc/wchar_.d(131): Error: undefined identifier `wchar_t`, did you mean `dchar`?
core/stdc/wchar_.d(133): Error: undefined identifier `FILE`
core/stdc/wchar_.d(133): Error: undefined identifier `wchar_t`, did you mean `dchar`?
core/stdc/wchar_.d(135): Error: undefined identifier `wchar_t`, did you mean `dchar`?
[125/216] Building CXX object runtime/CMakeFiles/ldc-jit-rt-so.dir/__/gen/passes/GarbageCollect2Stack.cpp.o
ninja: build stopped: subcommand failed
```

I don't know what's the real instructions for building an LDC for i686.  I'm using a docker env. with system image ubuntu 14.04 i386 arch and running on x86_64 archlinux host, is this my docker env causes such problems?


thanks!

~~~~
binghoo dang
April 20, 2020
On Monday, 20 April 2020 at 07:20:32 UTC, dangbinghoo wrote:
> On Friday, 17 April 2020 at 12:22:07 UTC, kinke wrote:
>> [...]
>
> thank you. I just tried to set llvm default tripple to `i686-linux-gnu`, and when I trying to build ldc2, again failed with runtime building:
>
> [...]

finally I built my ldc2 1.20.1 by specify LLVM_DEFAULT_TARGET_TRIPLE=i686-pc-linux to LLVM10 rather than `i686-linux-gnu`.

but actually I really have an `i686-linux-gnu` GCC toolchain. I don't know what's reason but thanks very much to you experts!

Thanks!

~~~~
binghoo dang