[HN Gopher] Because cross-compiling binaries for Windows is easi...
___________________________________________________________________
Because cross-compiling binaries for Windows is easier than
building natively
Author : slimsag
Score : 122 points
Date : 2022-06-18 19:09 UTC (3 hours ago)
(HTM) web link (gist.github.com)
(TXT) w3m dump (gist.github.com)
| pjmlp wrote:
| Typical UNIX FOSS rant, not taking into account all the
| development workflows on Windows.
| Dylan16807 wrote:
| Configure autocrlf in what way? I don't want git to change my
| files, and I don't know what problems they're talking about.
| slimsag wrote:
| Configure it to respect your preference ('don't change my
| files') and not pester you with hundreds of warnings any time
| you interact with Git if your preference differs:
| warning: LF will be replaced by CRLF in
| src/au/policy/dao/EmailQueue.java
| ntauthority wrote:
| Counterpoint for this rant (showing it's again not very
| objective, and just what your or your environment's expectations
| are): it's easier to cross-compile binaries for Linux (using
| Clang and a sysroot on Windows) than it is to natively compile on
| Linux (not using a sysroot, as that is the 'default' flow there)
| if your environment is mostly Windows already. We do this for one
| of our products, in fact.
|
| The post meanwhile seems to be part about open source policy
| (nasty, but not a technical issue - also including a new-to-me
| and hard to find on a Google or DDG search fact about the VS
| gallery endpoints having led to legal threats), part issues
| induced by 'weird' modern languages not caring to support Windows
| (as expected?), part Git for Windows not bothering to handle
| symbolic links cleanly (and the weird admin-only default thing
| that remained from Vista), and part... concerns where if people
| would spread the proper way of doing stuff (curl.exe bundled by
| default for downloads, or long file names being 'weird' - albeit
| less broken than claimed here) instead of just ranting this'd be
| fine too... but not really a coherent whole.
| thrdbndndn wrote:
| My counterpoint is simpler: I use some of these tools (like VS
| Code) because they're better, not because they're open source.
|
| Also I don't think Pylance or whatever core extensions being
| closed source contradicts with the fact majority of VS Code (or
| vscodium) is open-source. And I don't see anything morally
| wrong that they want to close source some of their competitive
| products.
| labrador wrote:
| This what is called in Cognitive Behavioral Therapy "All or
| Nothing Thinking." Microsoft is a for-profit company. It is pro
| open-source when it helps them and closed source also when it
| helps them. I like the new Microsoft which has open sourced a lot
| of stuff. It's way better than the old closed source regime.
| unnouinceput wrote:
| Oh, you and the article's author are either forgiven or seeing
| the best in people. Me, on the other hand, who lived the
| Microsoft with their shady dealings in Bill's / Ballmer's era,
| I remember their crushing on OEM's to not allow even a shred of
| openness in their systems. Only because of shifting in
| developer's in favor of Apple's / Google's Microsoft changed
| the tune with "Microsoft loves Linux". Bleah! I have no love
| for Microsoft despite my work involving their products 90% of
| my time. I am just realistic, they just love money, nothing
| else. And if money means open source, guess what?! They bought
| GitHub and they own everything that is published there. That's
| why plenty left GitHub and either started their own venture or
| went to GitLab.
|
| Sorry for my rant, I had to get it off my chest.
| eknkc wrote:
| Microsoft always had great developer tech. And having access
| to that tech more freely (as in on other platforms, partially
| open source etc) is a significant plus for me.
|
| I loved .net back in 2003 or whatever. Then I never got to
| use it for years because I was on unix land. It is now open
| source and multi platform.
|
| They attacked open anything with all their might (and they
| were fucking mighty) and the enemy still flourished.
|
| Let them come again. If the new strategy is to pump high
| quality software out in the open, I hope it becomes a long
| and bloody war.
| labrador wrote:
| Gates and Balmer are long gone and it's no longer the same
| company. If they only loved money, they wouldn't be amenable
| to their workers unionizing.
|
| "CWA, Microsoft Announce Labor Neutrality Agreement"
|
| https://cwa-union.org/news/releases/cwa-microsoft-
| announce-l...
|
| Sorry to be this way, but I'm refreshing my memory about CBT
| today:
|
| Over-generalization: Make a comprehensive, negative
| conclusion that is beyond the current situation.
|
| Labeling and Mis-labeling: The extreme form of
| overgeneralization. Use fixed, comprehensive, and emotional
| language to label yourself or others.
|
| Disqualifying the Positive: Unreasonably believe that
| positive experiences, behaviors or qualities do not count.
|
| Jumping to Conclusions: Making a conclusion before having all
| the evidence.
|
| Emotional Reasoning: Draw conclusions from your own feelings,
| because what I think is what the facts are.
| jrm4 wrote:
| Microsoft's days as a 'primary' desktop operating system are
| numbered. The OP doesn't seem to understand this, but even
| Microsoft itself does, which is why most of its major moves the
| past few years haven't been improving its own desktop, but
| positioning itself to control "open source" the best it can.
|
| More people within the MS ecosystem should understand this.
| munchler wrote:
| One can argue that desktops are no longer the primary computing
| environment, but I don't think there's any evidence that
| Windows is about to displaced within the desktop world.
|
| What are you proposing will become the primary desktop OS? Some
| Linux flavor of the month? MacOS? Neither seems at all likely
| in the foreseeable future.
| pjmlp wrote:
| Better check those desktop market share numbers.
| blibble wrote:
| I suspect if you restrict it to developers the numbers would
| look very, very different
|
| on the stackoverflow survey windows is 41.2%:
| https://insights.stackoverflow.com/survey/2021#most-
| popular-...
| _gabe_ wrote:
| If you toggle that response to "All Respondents" instead of
| "Professional Developers" Windows goes up to 45%. Plus, 3%
| of users are using windows subsystem for Linux. So 48%.
| Whereas Mac and Linux are both at 25%. Even for developers,
| Windows is still the clear majority.
| [deleted]
| e4m2 wrote:
| > Are derived community works, like say the D-language, Dart, or
| Zig bindings to the win32 API which are generated from those
| files open source - if Microsoft did not release them as such?
|
| Certainly. The source for these bindings is the WinMD file, which
| is MIT licensed. While it is true that its contents are generated
| wholly from non-FOSS sources, it doesn't impact end users of the
| metadata. Microsoft owns the original IDL/headers and can choose
| to license any related work however they like.
| [deleted]
| nshm wrote:
| For me SDK sizes are showstopper. Mingw packages are probably
| 100-200 Mb total. To build anything native one has to install
| Windows (20+Gb in modern version and then Visual Studio 40+Gb).
| Not so easy to fit it all on an SSD drive.
|
| Xcode also have this problem now. 8Gb for Xcode 7 is manageable.
| But why 70Gb for Xcode 11?
| swarnie wrote:
| A 1tb M.2 drive is what... PS70?
|
| If that's out of reach im not sure how you're powering your dev
| machine.
| coder543 wrote:
| > > Xcode also have this problem now. 8Gb for Xcode 7 is
| manageable. But why 70Gb for Xcode 11?
|
| > A 1tb M.2 drive is what... PS70?
|
| To be contextually fair, Apple charges $400, and the storage
| isn't replaceable. Who runs their editor off of an external
| drive? I imagine the number is very small.
|
| Although, on my machine, Xcode only seems to be taking up
| 17GB, not 70GB.
| [deleted]
| dotopotoro wrote:
| It's not bleeding edge raytracing stuff. "Get better
| hardware" is far from appropriate response.
| pjmlp wrote:
| Mingw doesn't support anything other than basic UNIX on top of
| Win32, naturally they take so little.
| maccard wrote:
| The visual studio build tools are substantially smaller than
| 40GB. My IDE install is about 25GB, and visual studio has
| distributed the build tools separately since vs2015 - my
| toolchains directory is about 4GB including whatever dotnet
| runtimes, windows GDK.
|
| > Not so easy to fit it all on an SSD drive.
|
| Professionally, no excuse. As an open source or otherwise
| unpaid pursuit, a 250GB SSD is about $45 on Amazon right now.
| That more than comfortably fits your 60GB estimate, with plenty
| of room to spare.
| slimsag wrote:
| I'm cross-compiling Mach engine[0] with Zig, it ends up being a
| quite small toolchain to cross-compile a game engine (using
| DirectX, Vulkan, OpenGL, and Metal on respective platforms)
| from any OS. The Zig toolchain is: * Windows:
| 61 MiB * Linux (x86): 49 MiB * macOS (x86): 42
| MiB * macOS (arm): 38 MiB
|
| Zig provides almost everything that is needed to cross compile
| to those same targets out of the box, including libc and some
| system libraries. Except macOS frameworks and some updated
| DirectX headers/libraries (provides MinGW ones), which we
| bundle and ship separately: * Windows: 7 MiB
| (updated D3D12 headers & libs) * MacOS: 112 MiB (almost
| all frameworks provided by XCode, for x86+arm+iOS) *
| Linux (x86): 22 MiB (x11/wayland headers & libs) *
| Linux (arm): 15 MiB
|
| That's full cross compilation of WebGPU GUI applications to all
| desktop platforms in under ~217 MiB for most platforms.
|
| [0] https://machengine.org
| TazeTSchnitzel wrote:
| You can accomplish similar things by targeting, say, SDL2
| with a C compiler. It's a nice solution when you don't need
| platform-specific stuff, but it's not a general substitute
| for having the platform SDK, alas. With that said, targeting
| SDL2 is what I do... but the apps I like to write are games.
| schemescape wrote:
| I ran into this when trying to test out Rust. On Windows, they
| recommend using native tools that require a multi-gigabyte
| download via the Visual Studio installer (and this is just for
| tools--not Visual Studio, the IDE).
|
| It was annoying for me because part of the reason I wanted to
| try Rust on Windows was specifically to avoid multi-gigabyte
| C/C++ toolchain downloads. I bet the actual compiler and linker
| aren't that big, so I kind of wonder where all those bytes are
| going...
|
| Aside: I see a sibling comment mentions Zig. While I haven't
| really explored Zig, the tiny single-binary download was a
| breath of fresh air. Go also had a quick and easy download, but
| I wanted a language without a garbage collector.
| seanp2k2 wrote:
| Try cross-compiling Go apps that use GTK3 if you'd like to
| spend a few days in intense pain. It's not there yet.
| Electron apps are probably the closest thing we have today
| that actually works correctly on Win / Linux / Mac.
| seanp2k2 wrote:
| The other problem with Xcode is that it won't run on anything
| except a Mac, and MacOS licensing prevents one from running it
| on non-Mac hardware or virtualizing it. That's why services
| like https://www.macstadium.com/ and AWS mac instances exist,
| but it's very annoying to have to work around this just because
| of dinosaur business models and licensing.
| recursive wrote:
| There are very few things that actually require Visual Studio
| just to build.
| steeleduncan wrote:
| Interesting, how can I install just the cmake + msvc to do
| command line builds with windows? I'm also installing wsl2 +
| mingw because it is so much lighter for compilation than
| many, many gigabytes of vis studio.
| aaron-stackbit wrote:
| `msbuild` is what I used back in the day. It seems to still
| exist, but I have no idea if this is still preferred
| solution. I just use WSL 2 these days, and live with the
| extra io latency.
| e4m2 wrote:
| Download the build tools[0] and choose the appropriate
| options. I'd personally consider the following a good
| baseline: MSVC v143, CMake tools, Windows 11 SDK, Clang
| tools (if you don't want/need these you can shave off 3.5
| GB). `zig cc` is another interesting alternative, it's just
| a single ~62 MB download.
|
| [0] https://visualstudio.microsoft.com/downloads/#build-
| tools-fo...
| steeleduncan wrote:
| Thanks, I'll give that a try!
| cptskippy wrote:
| Visual Studio's install size is highly dependent on what you
| install. The minimum size is only 800mb, everything is 120gb.
|
| Many of the high level categories, like Web Development,contain
| features you'll probably never use. If you're concerned about
| file size you can do a custom install to get a very lean
| install.
|
| That being said, I would still recommend a Windows VM be
| allocated a 120Gb drive.
| xboxnolifes wrote:
| > To build anything native one has to install Windows (20+Gb in
| modern version and then Visual Studio 40+Gb). Not so easy to
| fit it all on an SSD drive.
|
| Maybe a decade ago, but SSDs are so much cheaper per GB
| nowadays. Around $0.11/GB. Pretty sure that's cheaper than the
| first 1TB HDD I've owned.
| nshm wrote:
| Not when you are on Macbook. Don't suggest external drives
| please ;)
| nicoburns wrote:
| True historically, but this has actually been solved on the
| latest macs. Base spec for the MacBook Pro is 1TB disk.
| landryraccoon wrote:
| But you don't _have_ to develop on Macbook. So you
| intentionally chose a platform known for being really
| expensive and now your main complaint is that it 's too
| expensive?
|
| I don't really think that the toolchain is to blame for
| that one.
| throwawaymaths wrote:
| > But you don't have to develop on Macbook
|
| Can you please tell that to my IT department which
| refused to issue me a Linux laptop for 1 month, then took
| two months to put the order in... I had to get an
| executive (President of R&D) at the company to harangue
| IT... I still haven't seen it, apparently they are trying
| to install the standard "employee spyware" package on it.
| LeoNatan25 wrote:
| If your IT department is an overt detriment to your
| development effort, send a letter to your company's upper
| management and leave. This is the only way to push for
| change in these moronic companies, and you keep your
| sanity.
| sumy23 wrote:
| I do need to develop on a Macbook. The hardware is just
| so much better than anything else out there. This is my
| personal opinion of course, but I would rather stop being
| a software developer than to develop software using a
| different laptop available on the market today.
| forrestthewoods wrote:
| Meanwhile I'd rather serve coffee than be a software
| developer on any laptop! I can't fathom developing on
| anything other than a high-end desktop.
|
| M1 is very impressive. But I hate macOS as much, if not
| more than, you hate Windows. My Threadripper makes me
| very happy.
| downut wrote:
| Yeah, given the sheer cpu/ram/m.2 power of what even a
| tiny NUC provides, with modular, replaceable
| monitor(s)/keyboard/mouse/USB(3/C/Thunderbolt)/HDMI etc,
| for less than a Mac, I am unable to understand the appeal
| of a laptop. And I use a i7/64GB/1TB NUC for traveling! I
| use a twice as powerful Ryzen rack server for my office
| dev box. 5m extension cables so the noise is in a closet.
|
| I have no problems with external drives. Is this a Mac
| thing too?
|
| 32 years ago as a fresh out I got a government job with
| an SGI box with an enormous monitor. I stare in wonder at
| the future, right now. It sure doesn't look like
| happiness.
| coder543 wrote:
| > But you don't have to develop on Macbook.
|
| The context of this thread literally mentions Xcode. You
| need a Mac to use Xcode.
|
| > I don't really think that the toolchain is to blame for
| that one.
|
| How is the toolchain not even partially to blame?
|
| Some people develop for Mac and iOS. They're not allowed
| to complain if Apple bloats the toolchain?
| cowtools wrote:
| I thought apple computers usually had thunderbolt ports.
| You can't just connect a thunderbolt/M.2 drive enclosure
| and mount it as root?
| colejohnson66 wrote:
| That's still an external drive
| forrestthewoods wrote:
| It's funny because I find compiling and deploying for Windows
| far, far, far easier than Linux. That said, the complaints are
| all good and fair.
| dataflow wrote:
| Now try building a "portable" binary that runs on a version of
| Linux older than yours.
| hacker_homie wrote:
| Easy static link everything.
|
| I think you meant a GUI application that runs on a version of
| Linux older than yours.
| dataflow wrote:
| Statically link _everything_? Including glibc?
| rocqua wrote:
| Isn't that simply a matter of targeting an older glibc? I am
| probably missing something though.
| dataflow wrote:
| Yes, "simply". It's a very fun process. Around 100x more fun
| than the onerous git config --global
| core.symlinks true
| userbinator wrote:
| 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 <250MB of disk space, and
| the self-contained binaries it generates will work on any version
| of Windows starting at Win95.
|
| _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 ~255 character limit._
|
| Personally, I think 260 is long enough and plenty to work with,
| while at the same time discouraging the ridiculous verboseness
| that seems to have crept into "modern" software. Then again, I
| stay away from .NET, VSCode, and the like. I am reminded of this
| post by Raymond Chen:
|
| https://devblogs.microsoft.com/oldnewthing/20070301-00/?p=27...
| akelly wrote:
| It's incredibly fitting that all the links on that post are 403
| Forbidden
| userbinator wrote:
| That's Microsoft being (the new, not the old) Microsoft...
| they seriously fucked up the MSDN documentation when it was
| migrated to docs.microsoft.com, so I'm not surprised that a
| similar thing happened to the blogs:
|
| https://news.ycombinator.com/item?id=20351358
| colejohnson66 wrote:
| Are symlinks on Windows really such a big issue? I've never heard
| of projects using symlinks in their tree. If Windows developers
| are complaining about you doing something unusual, why is it
| their fault?
| pjmlp wrote:
| Nope, since XP that you can use mklink, and before there were
| Technet utilities for the same purpose.
|
| However using symlinks just isn't a thing in the Windows
| culture, people use at most Shell shortcuts.
| slimsag wrote:
| Certainly better to avoid it if at all possible, and I'll be
| eliminating them specifically to improve Windows compatibility.
|
| It's not that unusual, though, a quick search turns up 1.1k
| GitHub repositories with `git config core.symlinks true` in
| their documentation or CI pipelines - including quite popular
| projects like Ava, Apache Arrow, Solana, Chrome Devtools,
| adobe-fonts, IBM/houdinID, travis-ci, RabbitMQ, various Google
| projects & more.
| colejohnson66 wrote:
| I agree that Windows could do more to support the developers
| on other platforms. Symlinks just seem like a petty thing to
| complain about IMHO. Didn't realize how common they were
| though.
|
| NTFS does support them, however. Is Git just not supporting
| them properly?
| Pathogen-David wrote:
| NTFS has supported them for ages. The main issue is that
| they're locked behind elevated permissions or having
| developer mode enabled (as of Windows 10.)
|
| My understanding is Microsoft's concern is that
| applications and OS components not expecting them could
| lead to security issues. Not sure how real that concern is,
| but that's the excuse I've heard.
| pjmlp wrote:
| It does support them, mklink.
|
| https://docs.microsoft.com/en-us/windows-
| server/administrati...
| colejohnson66 wrote:
| Yes, Windows does, but this post is complaining about
| support. Which led me to ask if Git is the problem. Cause
| Git also supports symlinks, but is clearly having issues
| on Windows.
| bogwog wrote:
| I would assume the issue is that they need to disable
| symlink support by default on Windows because symlink
| support is disabled by default on Windows.
| fortran77 wrote:
| That's exactly it. Windows developers know NTFS has
| Symbolic Links https://docs.microsoft.com/en-
| us/windows/win32/fileio/creati...
| bilekas wrote:
| Maybe I missed something on this discussion but symlinks
| and NTFS are not really related.. They have them yes, how
| they're handled is different.
| fragmede wrote:
| How are they not related? If NTFS didn't have symlinks we
| wouldn't be having this discussion. Critically, the
| modern standard for removable drives, exFAT does not
| support symlinks, so you can't count on Windows' support
| for symlinks if the user is git cloning on a drive that's
| using exFAT.
| pjmlp wrote:
| https://docs.microsoft.com/en-us/windows-
| server/administrati...
| CoastalCoder wrote:
| What's the standard for being an "actual Windows user"?
|
| Asking because I doubt e.g. my mom knows that NTFS has
| symlinks.
| Dylan16807 wrote:
| > What's the standard for being an "actual Windows user"?
|
| I think you misread that line.
| slimsag wrote:
| Their message originally read "Actual Windows developers
| know NTFS has Symbolic Links"
| pjmlp wrote:
| Is she a Windows developer?
|
| https://docs.microsoft.com/en-us/windows-
| server/administrati...
| slimsag wrote:
| The developers who complained to me about this are
| Windows developers regularly.
|
| One is even a professional AAA DirectX gamedev.
| slimsag wrote:
| Well, it feels 'petty' and simple until:
|
| 1. You run into it, go "AH, wow, okay, I'll enable
| Developer Mode"
|
| 2. It still doesn't work, you're confused, you Google
| around a bit more and find out actually you also need to
| use a Git config option
|
| 3. You retry, now the symlinks work, but your compiler
| fails because "Destination Path Too Long", huh, that's
| weird
|
| 4. You google a bit more, and discover you need to set a
| registry option. So you do it, but you still get that
| error..
|
| 5. You discover there's another Git option you need to set
|
| And then you're like, hey, what was I doing again? Where
| did the last hour of my time go? It's death by a thousand
| paper cuts.
| [deleted]
| [deleted]
| gizmo686 wrote:
| The higher level thing to notice is that Windows is a second
| class platform for much of the software world. As such, it is
| in a position where it needs to bend the knee for compatibility
| with the dominant platform if they want it to be an active
| player in the larger ecosystem. In the case of symlinks, the
| hard part is already done, to the point where it is a toggle
| that has already been implemented, the UX of enabling it is
| just bad.
| pjmlp wrote:
| For game developers and GUI applications it is first class.
|
| Apparently being the best in symlinks hasn't made a
| difference in the Year of Desktop Linux.
| binarycrusader wrote:
| You don't have to enable Developer Mode to enable symlink
| creation. Administrators have the right to by default and non-
| administrator users can get this by enabling the documented
| policy:
|
| https://docs.microsoft.com/en-us/windows/security/threat-pro...
|
| Developer Mode is just a bundle of useful developer-related
| settings and components that get applied to the device when
| enabled.
|
| There's a post here about this from the Developer Mode angle
| with a bit more background:
|
| https://blogs.windows.com/windowsdeveloper/2016/12/02/symlin...
| nicoburns wrote:
| Projects don't use symlinks _because_ they aren't supported on
| windows.
| pjmlp wrote:
| https://docs.microsoft.com/en-us/windows-
| server/administrati...
| Dylan16807 wrote:
| The command won't help when you don't have the permissions.
|
| Or do you just want it to be phrased "not supported for
| users on normally configured systems"? There, then.
| Animats wrote:
| It is. I generate the Windows executables for a program by cross-
| compiling Rust on Linux. Then test with Wine. The Rust crates are
| cross-platform enough that I don't have to special case
| platforms. This is easier than having a Windows machine.
|
| The only current headache is that there's no pure Rust bundler,
| to make ".msi" or ".msix" installer files.
|
| If you dump the legacy OS stuff, it gets easier.
| encryptluks2 wrote:
| Good news is winget will soon support single binaries so that
| is one option.
| anothernewdude wrote:
| I did a similar thing, but I only ever compiled windows
| versions using Github actions.
| ratww wrote:
| Doesn't cargo-bundle do that? I haven't tried to use it to
| generate .msi files, only for iOS/macOS, but it has the
| feature!
| Animats wrote:
| Cargo-bundle was _supposed_ to do that, but only the Mac part
| was completed. Nobody ever did the .msi output. I 've been
| trying to get someone interested in doing that. That task
| needs someone very familiar with the Microsoft ecosystem,
| which I am not. Discussion in Rust tools forum here.[1]
|
| [1] https://internals.rust-lang.org/t/cross-platform-
| bundling/16...
| Slartie wrote:
| > 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
| chain has been packaged into a Docker container a few years ago
| when that became fashionable.
___________________________________________________________________
(page generated 2022-06-18 23:00 UTC)