Skip to content

Instantly share code, notes, and snippets.

@kassane
Last active November 4, 2023 15:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kassane/2a181fa4dfe66dbd283f3ad7a941ca2b to your computer and use it in GitHub Desktop.
Save kassane/2a181fa4dfe66dbd283f3ad7a941ca2b to your computer and use it in GitHub Desktop.
LDC2 cross-compiling using zig toolchain - D language
#!/usr/bin/env bash
# Based on: https://github.com/kassane/xwin-zig-test/
# download and unpack WinSDK and MSCRT libs
# manifest 16 == VS2019
# xwin --manifest-version 16 --accept-license splat --output $PWD/.xwin --include-debug-symbols --preserve-ms-arch-notation --include-debug-libs
# "$HOME/ldc-xcross/lib64" - need prebuilded libs
# curl -LO https://github.com/ldc-developers/ldc/releases/download/v1.35.0/ldc2-1.35.0-windows-multilib.7z
# copy LDC_ROOT/libs only (x86 or x64)
# ldc2 -Oz source/app.d -mtriple=x86_64-windows-msvc -static -c
zig cc -fno-sanitize=all -target x86_64-windows-msvc \
-isystem $HOME/ldc-xcross/hello/.xwin/crt/include \
-isystem $HOME/ldc-xcross/hello/.xwin/sdk/include \
-isystem $HOME/ldc-xcross/hello/.xwin/sdk/include/10.0.22000/cppwinrt \
-isystem $HOME/ldc-xcross/hello/.xwin/sdk/include/10.0.22000/ucrt \
-isystem $HOME/ldc-xcross/hello/.xwin/sdk/include/10.0.22000/um \
-isystem $HOME/ldc-xcross/hello/.xwin/sdk/include/10.0.22000/shared \
-L $HOME/ldc-xcross/hello/.xwin/crt/lib/x64 \
-L $HOME/ldc-xcross/hello/.xwin/sdk/lib/ucrt/x64 \
-L $HOME/ldc-xcross/hello/.xwin/sdk/lib/um/x64 \
-L$HOME/ldc-xcross/lib64 \
-lphobos2-ldc -ldruntime-ldc $@
@kassane
Copy link
Author

kassane commented Nov 2, 2023

dumpbin

Microsoft (R) COFF/PE Dumper Version 14.36.32534.0
Copyright (C) Microsoft Corporation.  All rights reserved.


Dump of file hello_d_zig.exe

File Type: EXECUTABLE IMAGE

  Image has the following dependencies:

    KERNEL32.dll
    SHELL32.dll
    WS2_32.dll
    ADVAPI32.dll

  Summary

        1000 .00cfg
       3D000 .data
        1000 .gfids
        1000 .minfo
       1B000 .pdata
       A6000 .rdata
        6000 .reloc
      231000 .text
        1000 .tls
        1000 .voltbl
        1000 _RDATA

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment