Cross-compiling a static binary from GitHub Actions

Paolo Invernizzi paolo.invernizzi at gmail.com
Mon Sep 27 08:38:25 UTC 2021


On Monday, 27 September 2021 at 06:59:32 UTC, Vladimir Panteleev 
wrote:
> On Sunday, 26 September 2021 at 16:30:04 UTC, Jacob Carlborg 
> wrote:
>> I'm using an approach were I'm cross-compiling on the host and 
>> then link and run the tests in a Docker container with the 
>> help of QEMU:
>
> Very interesting, thanks! Though I guess linking elsewhere 
> would preclude any kind of LTO :)

I was cross compiling and cross linking on my iMac for ARM with 
ld.lld, after having scraped only the necessary ubuntu libs and 
the ARM distribution of ldc.
For linking, it was something like that (copy/pasted from the D 
build script):


     "/usr/local/opt/llvm/bin/ld.lld ",
     "-o %o ",

     "--sysroot=/ ",
     "--build-id ",
     "--eh-frame-hdr ",
     "-m aarch64linux ",
     "--hash-style=gnu ",
     "-z now ",
     "-z relro ",

     "--lto-O2 ",
     "--gc-sections ",

     "-dynamic-linker /lib/ld-linux-aarch64.so.1 ",

     
"-L/Users/pinver/Projects/Workspace/Prefix/ubuntu_a64/18.10/usr/lib/gcc/aarch64-linux-gnu/7 ",
     
"-L/Users/pinver/Projects/Workspace/Prefix/ubuntu_a64/18.10/usr/lib/aarch64-linux-gnu ",
     
"-L/Users/pinver/Projects/Workspace/Prefix/ubuntu_a64/18.10/usr/lib ",
     
"-L/Users/pinver/Projects/Workspace/Prefix/ubuntu_a64/18.10/lib/aarch64-linux-gnu ",
     
"-L/Users/pinver/Projects/Workspace/Prefix/ubuntu_a64/18.10/lib ",

     
"/Users/pinver/Projects/Workspace/Prefix/ubuntu_a64/18.10/usr/lib/aarch64-linux-gnu/Scrt1.o ",
     
"/Users/pinver/Projects/Workspace/Prefix/ubuntu_a64/18.10/usr/lib/aarch64-linux-gnu/crti.o ",
     
"/Users/pinver/Projects/Workspace/Prefix/ubuntu_a64/18.10/usr/lib/gcc/aarch64-linux-gnu/7/crtbeginS.o ",

     "%f ",

     
"/Users/pinver/Projects/Workspace/Prefix/ubuntu_a64/18.10/ldc-1.27.1/lib/libphobos2-ldc.a  ",
     
"/Users/pinver/Projects/Workspace/Prefix/ubuntu_a64/18.10/ldc-1.27.1/lib/libdruntime-ldc.a ",

     
"/Users/pinver/Projects/Workspace/Prefix/ubuntu_a64/18.10/lib/aarch64-linux-gnu/librt-2.27.so ",
     
"/Users/pinver/Projects/Workspace/Prefix/ubuntu_a64/18.10/lib/aarch64-linux-gnu/libdl-2.27.so ",
     
"/Users/pinver/Projects/Workspace/Prefix/ubuntu_a64/18.10/lib/aarch64-linux-gnu/libpthread.so.0 ",
     
"/Users/pinver/Projects/Workspace/Prefix/ubuntu_a64/18.10/usr/lib/aarch64-linux-gnu/libpthread_nonshared.a ",
     
"/Users/pinver/Projects/Workspace/Prefix/ubuntu_a64/18.10/lib/aarch64-linux-gnu/libm.so.6 ",

     
"/Users/pinver/Projects/Workspace/Prefix/ubuntu_a64/18.10/lib/aarch64-linux-gnu/libc.so.6 ",
     
"/Users/pinver/Projects/Workspace/Prefix/ubuntu_a64/18.10/usr/lib/aarch64-linux-gnu/libc_nonshared.a ",
     
"/Users/pinver/Projects/Workspace/Prefix/ubuntu_a64/18.10/lib/aarch64-linux-gnu/ld-linux-aarch64.so.1 ",
     
"/Users/pinver/Projects/Workspace/Prefix/ubuntu_a64/18.10/usr/lib/gcc/aarch64-linux-gnu/7/libgcc.a ",
     
"/Users/pinver/Projects/Workspace/Prefix/ubuntu_a64/18.10/usr/lib/gcc/aarch64-linux-gnu/7/libgcc_s.so ",

     
"/Users/pinver/Projects/Workspace/Prefix/ubuntu_a64/18.10/usr/lib/gcc/aarch64-linux-gnu/7/crtendS.o ",
     
"/Users/pinver/Projects/Workspace/Prefix/ubuntu_a64/18.10/usr/lib/aarch64-linux-gnu/crtn.o"
```


More information about the digitalmars-d-ldc mailing list