Live data from Hacker News

Cross-compiling binaries for Windows is easier than building natively

gist.github.com

271–280 of 349 posts

Re: Cross-compiling binaries for Windows is easier than building natively

#271
Good post (I couldn't quite follow the open source angle tbh), but for the "why doesn't Developer Mode make Windows behave more like Linux" part: this would probably disgruntle a lot of 'native' Windows developers.

Windows was always its separate island, and at least in the past it had a lot of developer mindshare (so more like a whole continent than an island), and from the point of view of those Windows devs, Linux is the odd one out ;)

One common solution is to use scripting languages for build automation that try to hide most of the differences (e.g. Python or Node.js instead of Powershell vs Batch vs Bash), and most importantly there's simply no way around testing on at least Windows, macOS and Linux.

Re: Cross-compiling binaries for Windows is easier than building natively

#272
post #225

Earlier quoted context omitted.

I've looked before, and have never found a definitive answer from Microsoft. I've heard some speculation that it the nebulous security issues would be from a program that checks the permissions of a symlink's target, then opens the symlink. An attacker could then modify the symlink after the permission check but before the file is opened, escalating access by pointing to a restricted file.

It's a kind of attack called a symlink race, which is also possible on other operating systems. There are kernel parameters for hardening against symlink races on Linux, and they just disable symlinking into world-writable locations. I'm not sure why Windows can't use a less invasive mitigation like that, but I guess there must be one.

A lot more tends to be world-writable in Windows, for starters.

Re: Cross-compiling binaries for Windows is easier than building natively

#273

Seriously, i use Windows because i could play video games after coding. Coding in linux machine is 10000x easier than Windows.

The only time I have trouble in Windows is when people coding on a Linux machine don’t use cross platform tools.

Re: Cross-compiling binaries for Windows is easier than building natively

#274
post #94
post #51

Earlier quoted context omitted.

> The only current headache is that there's no pure Rust bundler, to make ".msi" or ".msix" installer files. I have set up a toolchain based on Wix, running via Mono and Wine on Linux, for the purpose of packaging some rather complex .msi files in a commercial software project. Has been running on the Linux-based CI servers of that project for 10 years straight now, with the only change having been that the entire ch…

WiX is great. I have been using it for over a decade to package an internal application. It's all driven by a simple text file which I liked over Microsoft's packaging offerings.

Which offerings? Are there any?

I only know about other proprietary non-MS solutions like InstallShield, which also generate .msi files but use their own proprietary way to define the installation process, with the benefit/disadvantage (depending on what you want to do specifically) of being on a higher abstraction level than WiX, which is more or less a direct resemblance of the internal Windows Installer data structures.

Re: Cross-compiling binaries for Windows is easier than building natively

#275

Earlier quoted context omitted.

I tried that with Rust, actually. My Manjaro was running a much newer version of Glibc than my server so I had to deal with that. First I tried to get it to link to a different system library but no package manager is happy with multiple major versions of glibc. Then I tried MUSL but it turns out the moment you enable MUSL several OpenSSL packages used in very common dependencies don't compile anymore. There was some…

"Statically link or bundle everything" is how most Windows apps deal with this tho. So if we're comparing Windows and Linux, and saying that Linux packaging is worse, this method can't just be dismissed on security grounds.

Windows developers tend to stuff directories full of DLLs if they need to ship dependencies, they're not statically linked per se.

Regardless, it's incredibly complicated to compare linking behaviour between Windows and Linux. Windows has tons of components built into the API (and which is maintained by Microsoft) which you'd need an external dependency for in Linux. Microsoft provides interfaces for things like XML processing, TLS connections, file system management, sound libraries, video libraries, rendering engines, scripting engines and more. If there's a vulnerability in WinHTTP, Microsoft will patch it; if you statically link curl, you'll have to fix it yourself.

Of course many open source developers will statically link binaries because that way they don't have to write platform specific code themselves, but they only need all those dependencies because your average distro is pretty bare bones if you strip it to its core components. If you write cod Linux, you're not even getting a GUI by your base platform, you'll have to provide your own bindings for either X11 or Wayland!

Most third party Windows software I run is some application code and maybe a few proprietary DLLs that the software authors bought. Sometimes those DLLs are even just reusable components from the vendor themselves. Only when I install cross compiled Linux software do I really see crazy stuff like a full copy of a Linux file system hidden somewhere in a Program Files folder (GTK+ really likes to do that) or a copy of a modified dotnet runtime (some Unity games).

The big exception to the rule, of course, is video games, but even those seem to include fewer and fewer external components.

Development becomes a lot easier when you can just assume that Microsoft will maintain and fix giant frameworks like the .NET Framework and the Visual C++ runtime (basically libc for Windows) for you. Microsoft even solved the problem of running multiple versions of their C runtime on the same machine through some tricky hard linking to get the right dependencies in the right place. As a result, most Windows executables I find in the wild are actually linked dynamically despite the lack of a library management system.

Re: Cross-compiling binaries for Windows is easier than building natively

#276
post #252

Earlier quoted context omitted.

Interesting. So 50% Unix and 48% Windows (and 3% are targeting Unix anyway). That's quite a swing over the past 20 years - there was a time where aside the occasional web developer with a Mac, everyone was on Windows. Leaving out Linux, the interesting part has been how much market that Apple has chiseled away.

Cloud workloads mean UNIX has effectively won the server room for classical deployments, however UNIX !== Developer. There are plenty of other workloads and platforms to target. Desktop, mobile devices, IoT, medical, game consoles, infotainment, unikernel, serverless....

Mobile is almost all IOS and Android... and mostly but not all devs use Macs due to xcode.

The only places that Windows seems to persist are developer markets where tooling choices are limited to Windows (games, medical, embedded) or corporate standards dictate tooling.

Re: Cross-compiling binaries for Windows is easier than building natively

#277

Only if you want to be trendchasing rather than letting backwards compatibility take care of itself... I'm a native Win32 developer, have been one for a few decades, and know quite a few others still using MSVC6 because it's fast and enough for what they do. Takes Long file paths: Azure, OpenSearch, and ~90 other open source projects have to document how to enable long file paths on Windows because the default is a ~…

Dang I don't want to even imagine the amount of bugs and how bad the codegen is compared to newer compilers.

Re: Cross-compiling binaries for Windows is easier than building natively

#278
I used to use MXE [1] to compile fully static Windows binaries on Linux VMs hosted with Travis. It needed to crane in everything though, so it was a source of bottlenecks from time to time. I was also uncertain about the provenance of a lot of the dependencies in that toolchain. So when Travis died I took the opportunity to move Windows builds back to gnu with msys2, all over GH Actions. These are actually comparatively snappy and I’m reasonably satisfied with it.

[1] https://mxe.cc/

Re: Cross-compiling binaries for Windows is easier than building natively

#279

Only if you want to be trendchasing rather than letting backwards compatibility take care of itself... I'm a native Win32 developer, have been one for a few decades, and know quite a few others still using MSVC6 because it's fast and enough for what they do. Takes Long file paths: Azure, OpenSearch, and ~90 other open source projects have to document how to enable long file paths on Windows because the default is a ~…

Not enough. Between path limits and "this file is in use by another program" nonsense I regularly ran into while developing on Windows, I switched away and never looked back.

The path separator, drive letter and text file line endings get me. But back when I switched to Linux for development it was the very slow file searches on Windows. I am fine with either macOS or Linux. Not windows.

Re: Cross-compiling binaries for Windows is easier than building natively

#280

Earlier quoted context omitted.

Not enough. Between path limits and "this file is in use by another program" nonsense I regularly ran into while developing on Windows, I switched away and never looked back.

That cuts both days, a Windows developer trying to port a project to Linux would be justified in concluding the filesystem locking semantics are horribly broken and non-existent.

I came from windows and found fewer problems when working on Linux. The problem with deleting files is something everybody will run into at some point. I don’t think what you describe is as common. I have never had it or heard it described as a problem when working in an organization which made software running on Linux and Windows.
Post reply on HN