Skip to content

Windows no std shim #46

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions website/docs/windows.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ of this documentation.

### DotSlash Windows Shim

**This is the preferred method.** The _DotSlash Windows Shim_ is a tiny `.exe`
executable that is placed next to the DotSlash file that performs the same
function as the [batch script](#sibling-batch-script) above, but is a native
executable rather than a batch script. This is the _ideal_ method that allows
for easy execution without any of the drawbacks of batch scripts. But this
**This is the preferred method.** The _DotSlash Windows Shim_ is a tiny 4KB
`.exe` executable that is placed next to the DotSlash file that performs the
same function as the [batch script](#sibling-batch-script) above, but is a
native executable rather than a batch script. This is the _ideal_ method that
allows for easy execution without any of the drawbacks of batch scripts. But this
method requires compiling a small executable and keeping it next to the DotSlash
file.

Expand All @@ -82,6 +82,9 @@ The _DotSlash Windows Shim_ is available under the
folder in the
[DotSlash GitHub repository](https://github.com/facebook/dotslash).

A pre-built version can also be downloaded from there:
[`dotslash_windows_shim-x86_64.exe`](https://github.com/facebook/dotslash/raw/main/windows_shim/dotslash_windows_shim-x86_64.exe)

## `MAX_PATH` limits

DotSlash stores fetched artifacts in a cache directory and they're executed from
Expand Down
92 changes: 91 additions & 1 deletion windows_shim/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions windows_shim/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,27 @@ name = "dotslash_windows_shim"
path = "dotslash_windows_shim.rs"
test = false

[dependencies]
cfg-if = "0.1.10"
compiler_builtins = { version = "0.1.146", features = ["mem"], optional = true }
windows-sys = { version = "0.59.0", features = [
"Win32_Foundation",
"Win32_Globalization",
"Win32_Security",
"Win32_Storage_FileSystem",
"Win32_System_Console",
"Win32_System_Environment",
"Win32_System_IO",
"Win32_System_LibraryLoader",
"Win32_System_Memory",
"Win32_System_Threading",
"Win32_UI_Shell",
] }

[features]
default = ["no_std"]
no_std = ["compiler_builtins"]

[profile.release]
opt-level = "z"
lto = true
Expand Down
28 changes: 26 additions & 2 deletions windows_shim/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,29 @@ The _DotSlash Windows Shim_ does this:

## Binary size

The current "reference implementation" is rather large. A no_std version that
uses only Windows APIs will be added soon. Stay tuned!
_DotSlash Windows Shim_ builds without a standard library and only uses Windows
APIs. Release binaries are around ~5KB.

## Release

A nightly toolchain is required:

```shell
cargo +nightly build --release
```

Alternatively, though not recommended:

```shell
RUSTC_BOOTSTRAP=1 cargo build --release
```

## Debugging

It may be useful to have the standard library (e.g. `dbg!`) when debugging.
Build with `--no-default-features` (avoids the default `no_std` feature) to have
access to the standard library.

```shell
cargo build --no-default-features
```
Binary file added windows_shim/dotslash_windows_shim-x86_64.exe
Binary file not shown.
Loading