Re: Cross Compile to Linux from Windows using LDC?

2022-02-14 Thread Kagamin via Digitalmars-d-learn
Isn't cross-linker enough? My regular mingw build of ld says it 
supports elf64-x86-64 traget, so I assume something like this 
should be enough:
ld -b elf64-x86-64 -L lib --dynamic-linker 
/lib64/ld-linux-x86-64.so.2 --as-needed --gc-sections -s 
lib/crt1.o lib/crti.o my.o -lc lib/crtn.o


Re: Cross Compile to Linux from Windows using LDC?

2022-02-10 Thread kinke via Digitalmars-d-learn

On Thursday, 10 February 2022 at 16:52:32 UTC, H. S. Teoh wrote:
If I understand it right, you ought to be able to do the same 
thing on Windows [...]


Not quite; cross-compiling to Windows has been made especially 
simple and is a special case. When cross-compiling from Windows 
to Linux, this applies: 
https://wiki.dlang.org/Cross-compiling_with_LDC#Non-Apple_POSIX_targets - a working C cross-compiler setup is required for linking, incl. glibc.


Re: Cross Compile to Linux from Windows using LDC?

2022-02-10 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Feb 10, 2022 at 04:43:12PM +, Fry via Digitalmars-d-learn wrote:
> Is it possible to compile for Linux from Windows using the LDC
> compiler? It seems like it is possible to compile for different
> architectures Linux x86 -> Linux Arm but what about for Windows x86 ->
> Linux x86?

I'm not familiar with using LDC on Windows, but I imagine it should be
analogous to what I do for cross-compilation from Linux to Windows:

1) Download and unpack the Linux tarball for LDC.
2) Download and unpack the Windows zip file for LDC.
3) Edit ldc2.conf (for the Linux version of LDC) and add the following:

"(i686|x86_64)-.*-windows.msvc":
{
switches = [
"-defaultlib=phobos2-ldc,druntime-ldc",
"-link-defaultlib-shared=false",
];
lib-dirs = [
"/path/to/ldc2-1.28.1-windows-x64/lib",
];
};

4) Compile with `ldc -mtriple=x86_64-windows-msvc`.

If I understand it right, you ought to be able to do the same thing on
Windows by editing ldc2.conf for the Windows version of LDC and adding a
block for "i686-.*-linux-gnu" with the library paths set to point to the
Linux version of LDC, and compile with the appropriate -mtriple flag.


T

-- 
Spaghetti code may be tangly, but lasagna code is just cheesy.


Cross Compile to Linux from Windows using LDC?

2022-02-10 Thread Fry via Digitalmars-d-learn
Is it possible to compile for Linux from Windows using the LDC 
compiler? It seems like it is possible to compile for different 
architectures Linux x86 -> Linux Arm but what about for Windows 
x86 -> Linux x86?