static Windows build
Using this program:
import stdio = std.stdio;
void main() {
stdio.writeln("hello world");
}
and this command:
ldc2 app.d
I do not get a static build. Namely, the file vcruntime140.dll is required. So I tried this:
ldc2 -static app.d
same result. It seems LDC includes the static library:
Directory: D:\ldc2\lib\mingw
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 2022-07-20 1:10 PM 32542 vcruntime140.lib
so it would appear it should be possible to do what I am trying to do.
You need a Visual C++ installation, then the MSVC runtime can be linked statically (and is by default for non-DLLs). See the 2nd-last paragraph in README.txt.
have you guys considered using another Windows DLL, thats already pre installed? this would solve the issue of having to download a redistributable, or even having to install the full Visual Studio or whatever.
this is whats done by the Go programming language, as well as Rust. this is the one thing keeping me from getting into D development, because this detail makes distributing D programs harder than other languages.
Oh, it's you again.
have you guys considered using another Windows DLL, thats already pre installed? this would solve the issue of having to download a redistributable, or even having to install the full Visual Studio or whatever.
this is whats done by the Go programming language, as well as Rust. this is the one thing keeping me from getting into D development, because this detail makes distributing D programs harder than other languages.
I think it's a license issue iirc. Do you know how Go and Rust solves it?
But the easiest fix is to just have a Visual C++ installation on your system.
I carried out some tests using ldc2 + zig cc (replacing clang-cl) [target msvc] and got this result:
https://gist.github.com/kassane/2a181fa4dfe66dbd283f3ad7a941ca2b
Iirc the licensing is tricky. That's why you need the vc redist.
someone finds something similar to Xwin that ALSO downloads the Microsoft compiler.
https://github.com/mstorsjo/msvc-wine?tab=readme-ov-file#use-with-clanglld-in-msvc-mode
https://github.com/mstorsjo/msvc-wine?tab=readme-ov-file#use-with-clanglld-in-msvc-mode
this doesn't seem to be any better than the option presented in the Gist. it just seems to use Clang to compile instead of Zig, which I would guess is actually a larger download. so unless I am misunderstanding, the Gist option while not great, seems to be the best option currently.
I agree. Currently, the Zig toolchain has become convenient due to its small size and facilitation.
If LDC chose MinGW, Zig also offers native integration (currently, default target), although it does not have winpthreads included.
However the dependencies below are statically binary linked. This occurs with zig c++, but not functional for msvc.
What was presented in the gist would be something nostdlib++.
C ABI src: https://github.com/ziglang/zig/tree/master/lib/libc/mingw
C++ ABI/C++EH ABI src: https://github.com/ziglang/zig/tree/master/lib/libcxx src: https://github.com/ziglang/zig/tree/master/lib/libunwind
I don't know how BetterC supports disabling d_runtime. But Zig also has a custom compiler runtime (ziglang does not have an lib ABI).
LLVM-libcompiler-rt rewritten in zig. src: https://github.com/ziglang/zig/tree/master/lib/compiler_rt
OK after talking with Martin Storsjö, it seems vsdownload.py does download the Microsoft compiler as well, so that might actually be a better option than the Gist