WIP: Windows support #925

Draft
mediocregopher wants to merge 11 commits from mediocregopher/garage:windows-v1 into main
First-time contributor

I'll be clear up front that I'm not really expecting to get this merged as it is. But I saw that others are interested in windows support (#536), so I thought I'd contribute my work back. What I did here on the rust side overlaps a bit with #891, but I've gone further and gotten cross-compiling from linux to windows apparently working. I say "apparently" because I haven't fully tested it yet, but it does compile and the binary does work in a VM.

Performing the actual cross-compilation cannot be done via flake.nix or default.nix. The default.nix is broken anyway, and flake.nix wants to build a full release binary, but not all features are currently supported, only the base ones, so this fails. To test this you have to do something like:

  let
  
    pkgsSrc = DIY;

    src = builtins.fetchGit {
      name = "garage-v1.0.1-windows";
      url = "git@git.deuxfleurs.fr:mediocregopher/garage.git";
      rev = "8edf5aab228d93b79e2c6b6a3f2402fffdc4c4ab";
    };

    common = (import "${src}/nix/common.nix") {
        system = builtins.currentSystem;
    };

    compile = (import "${src}/nix/compile.nix") {
      system = builtins.currentSystem;
      target = "x86_64-w64-mingw32";
      pkgsSrc = pkgsSrc;

      cargo2nixOverlay = common.cargo2nixOverlay;

      release = true;
      git_version = "windows-debug";

      features = [
        "garage/bundled-libs"
        "garage/lmdb"
        "garage/sqlite"
        "garage/metrics"
        "garage/k2v"
      ];
    };

  in
    compile.workspace.garage {}

In the next few weeks I'll be working on testing this more thoroughly, but in the meantime any feedback would be great.

I'll be clear up front that I'm not really expecting to get this merged as it is. But I saw that others are interested in windows support (#536), so I thought I'd contribute my work back. What I did here on the rust side overlaps a bit with #891, but I've gone further and gotten cross-compiling from linux to windows apparently working. I say "apparently" because I haven't fully tested it yet, but it does compile and the binary does work in a VM. Performing the actual cross-compilation cannot be done via `flake.nix` or `default.nix`. The `default.nix` is broken anyway, and `flake.nix` wants to build a full release binary, but not all features are currently supported, only the base ones, so this fails. To test this you have to do something like: ```nix let pkgsSrc = DIY; src = builtins.fetchGit { name = "garage-v1.0.1-windows"; url = "git@git.deuxfleurs.fr:mediocregopher/garage.git"; rev = "8edf5aab228d93b79e2c6b6a3f2402fffdc4c4ab"; }; common = (import "${src}/nix/common.nix") { system = builtins.currentSystem; }; compile = (import "${src}/nix/compile.nix") { system = builtins.currentSystem; target = "x86_64-w64-mingw32"; pkgsSrc = pkgsSrc; cargo2nixOverlay = common.cargo2nixOverlay; release = true; git_version = "windows-debug"; features = [ "garage/bundled-libs" "garage/lmdb" "garage/sqlite" "garage/metrics" "garage/k2v" ]; }; in compile.workspace.garage {} ``` In the next few weeks I'll be working on testing this more thoroughly, but in the meantime any feedback would be great.
mediocregopher added 7 commits 2025-01-14 16:43:08 +00:00
mediocregopher added 1 commit 2025-01-15 10:35:38 +00:00
Merge remote-tracking branch 'origin/main' into windows-v1
Some checks failed
ci/woodpecker/pr/debug Pipeline failed
b1c664a8ab
lx added the
kind
improvement
scope
build
labels 2025-02-14 12:58:18 +00:00
mediocregopher added 2 commits 2025-03-20 21:00:30 +00:00
mediocregopher added 1 commit 2025-03-20 21:27:14 +00:00
Ran rustfmt
Some checks are pending
ci/woodpecker/pr/debug Pipeline is pending approval
5eabd64ca7
Author
First-time contributor

I've updated this MR to account for the build system changes in 1.1.0. The move to crane is a great move, btw, really simplifies everything :)

This MR still requires manually calling compile.nix with the correct target. I could easily add accessible release targets for windows to flake.nix and default.nix, but the release naming in those currently only specifies the CPU architecture and assumes the OS is Linux (I guess). I could add the release name as x86_64-windows, but maybe it'd be better add the OS to the other release names as well for consistency?

I've updated this MR to account for the build system changes in `1.1.0`. The move to crane is a great move, btw, really simplifies everything :) This MR still requires manually calling `compile.nix` with the correct `target`. I could easily add accessible release targets for windows to `flake.nix` and `default.nix`, but the release naming in those currently only specifies the CPU architecture and assumes the OS is Linux (I guess). I could add the release name as `x86_64-windows`, but maybe it'd be better add the OS to the other release names as well for consistency?
Some checks are pending
ci/woodpecker/pr/debug Pipeline is pending approval
Required
Details
This pull request is marked as a work in progress.
This branch is out-of-date with the base branch
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u windows-v1:mediocregopher-windows-v1
git checkout mediocregopher-windows-v1
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: Deuxfleurs/garage#925
No description provided.