Skip to content

Enable Windows build#1407

Open
8Keep wants to merge 1 commit intodavidlattimore:mainfrom
8Keep:windows-build-ci
Open

Enable Windows build#1407
8Keep wants to merge 1 commit intodavidlattimore:mainfrom
8Keep:windows-build-ci

Conversation

@8Keep
Copy link

@8Keep 8Keep commented Dec 24, 2025

I am maybe/sorta going to try to get wild working on windows. The first (easy step to that is to get it buildable on windows. This PR gets it building on windows, disables some tests that don't yet work, and sets up github actions CI to also build+test on windows.


const PERFETTO_ENV_VAR: &str = "WILD_PERFETTO_OUT";

#[cfg(feature = "perfetto")]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just published version 0.3.0 of perfetto-recorder, which adds support for Windows. At least it builds and the tests pass on Windows.


#[cfg(not(unix))]
fn path_from_bytes(bytes: &[u8]) -> PathBuf {
PathBuf::from(String::from_utf8_lossy(bytes).into_owned())
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a path is supplied that isn't a valid Windows path, then from_utf8_lossy won't do what we want. Most likely we'd end up reporting that the file couldn't be found which would be confusing. Reporting an error or even panicking would likely be better.

inner(path, limit).with_context(|| format!("Failed to process {}", path.display()))
}

#[cfg(unix)]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than using cfg to disable tests, how about using #[cfg_attr(not(unix), ignore)]. That way the test will still be built, it just won't be executed. That will then mean that you won't get dead code warnings for stuff that was only used by that test.


pub(crate) fn make_executable(file: &File) -> Result {
#[cfg(unix)]
use std::os::unix::prelude::PermissionsExt;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this use-statement just be moved inside the cfg block below?

@8Keep 8Keep force-pushed the windows-build-ci branch 4 times, most recently from e0b2a72 to 04bb282 Compare December 29, 2025 16:55
@8Keep
Copy link
Author

8Keep commented Dec 29, 2025

Thanks for the review. I've pushed a new version.

Some notes:

  1. All unit tests now work, none disabled on windows.
  2. I had to disable the integration tests, too much broken. Will need to put together windows specific integration tests in the future.
  3. I have made some changes to args.rs for char escaping for @argfiles, otherwise it clobbers backslashes in windows paths. I am making an assumption there. It is also not wrapped in a platform specific cfg. Maybe this should be redone.

Cargo build+test now pass

@8Keep 8Keep marked this pull request as ready for review December 29, 2025 17:06
@davidlattimore
Copy link
Owner

Thanks. Looks good. A few CI failures. Looks like you need to run cargo +nightly fmt, there's some clippy warnings that need fixing and a test that's failing. Not sure why the test would fail in CI, but not when you run locally, but if you need help to figure it out, let me know.

@8Keep 8Keep force-pushed the windows-build-ci branch 2 times, most recently from 9dc20fc to 9e58271 Compare January 3, 2026 18:43
@8Keep
Copy link
Author

8Keep commented Jan 3, 2026

Ok, I've fixed some lints/errors/format.

I did use cfg a bit more to make the executable bit code only available on unix, let me know if you'd prefer something else there.

The test error was due to clrf endings on windows, and git was thinking that .a file is a text file. I've added a .gitattributes so git doesn't treat it like a text file. I have that config set locally, so I didn't see that error locally. I think this would be right... Let's see what ci says now

@davidlattimore
Copy link
Owner

Looks like there's just one clippy warning left. The clippy command that gets run in CI is cargo clippy --workspace --target x86_64-unknown-linux-gnu. Hopefully if you run that you can see the warning.

#[cfg(unix)]
{
let _ = crate::fs::make_executable(&self.file);
}
Copy link
Contributor

@bjorn3 bjorn3 Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe pull the #[cfg(unix)] into the make_executable body?

Edit: Didn't notice your comment above.

)
})?;
}
#[cfg(not(unix))]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be cleaner to write this as:

if meta.is_dir() {
    // ...
    return Ok(());
}

#[cfg(unix)]
if meta.is_symlink() {
    // ...
    return Ok(());
}

if let Ok(data) = FileData::new(source_path, false) {
    // ...
}

// hardlink or copy

@davidlattimore
Copy link
Owner

@8Keep - it'd be good to get this merged so that we can progress on #1462. Let us know if you don't think you'll get back to this and we can finish it off.

@davidlattimore
Copy link
Owner

Nothing heard. @bjorn3 would you like to pick this up or should I?

@Blazearth
Copy link
Contributor

Blazearth commented Feb 10, 2026

I ran into the tidy::check_sources_format failure locally.

It turns out the failure is purely due to clang-format enforcing brace spacing in
tests/sources/export-dynamic.c:

    void foo(void) {};
→  void foo(void){};

After running clang-format -i tests/sources/*.{c,cc,h}, the tidy test passes.
No functional or linker-related changes, just formatting.

Mentioning this in case anyone else hits the same failure while testing this PR.

@8Keep
Copy link
Author

8Keep commented Feb 10, 2026

So sorry everyone, I've just been very busy and out of town most of the time since. If you need it soon - feel free to take it over

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants