Skip to content

Commit e493017

Browse files
authored
Add support for Windows #![no_main] (#62)
1 parent 66a1fd9 commit e493017

File tree

12 files changed

+65
-8
lines changed

12 files changed

+65
-8
lines changed

.github/workflows/build.yml

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
toolchain: [ stable, nightly ]
1212
runs-on: ${{ matrix.platform }}
1313
steps:
14-
- uses: actions/checkout@v3
14+
- uses: actions/checkout@v4
1515
- uses: dtolnay/rust-toolchain@master
1616
with:
1717
toolchain: ${{ matrix.toolchain }}
@@ -25,21 +25,35 @@ jobs:
2525
toolchain: [ stable, nightly ]
2626
runs-on: ${{ matrix.platform }}
2727
steps:
28-
- uses: actions/checkout@v3
28+
- uses: actions/checkout@v4
2929
- uses: dtolnay/rust-toolchain@master
3030
with:
3131
toolchain: ${{ matrix.toolchain }}
3232
- name: Build
3333
working-directory: no_std
3434
run: cargo build --release --all-features
35+
no_main_win:
36+
name: no_main-win
37+
strategy:
38+
matrix:
39+
toolchain: [ stable, nightly ]
40+
runs-on: windows-latest
41+
steps:
42+
- uses: actions/checkout@v4
43+
- uses: dtolnay/rust-toolchain@master
44+
with:
45+
toolchain: ${{ matrix.toolchain }}
46+
- name: Build
47+
working-directory: no_main/win
48+
run: cargo build --release --all-features
3549
build_std:
3650
name: build-std
3751
strategy:
3852
matrix:
39-
project_dir: [ build_std, no_main ]
53+
project_dir: [ build_std, no_main/nix ]
4054
runs-on: ubuntu-latest
4155
steps:
42-
- uses: actions/checkout@v3
56+
- uses: actions/checkout@v4
4357
- uses: dtolnay/rust-toolchain@master
4458
with:
4559
toolchain: nightly

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
[package]
22
name = "min-sized-rust"
33
version = "0.1.0"
4-
authors = ["johnthagen <johnthagen@gmail.com>"]
54
edition = "2021"
65
license-file = "LICENSE.txt"
76

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ On macOS, the final stripped binary size is reduced to 30KB.
233233

234234
![Minimum Rust: Nightly](https://img.shields.io/badge/Minimum%20Rust%20Version-nightly-orange.svg)
235235

236-
> Example project is located in the [`no_main`](no_main) folder.
236+
> Example projects are located in the [`no_main`](no_main) folder.
237237
238238
Up until this point, we haven't restricted what utilities we used from `libstd`. In this section
239239
we will restrict our usage of `libstd` in order to reduce binary size further.
File renamed without changes.
File renamed without changes.

no_main/Cargo.toml renamed to no_main/nix/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
[package]
22
name = "no_main"
33
version = "0.1.0"
4-
authors = ["johnthagen <johnthagen@gmail.com>", "Vitaly '_Vi' Shukela <vi0oss@gmail.com>"]
54
edition = "2021"
65
license = "MIT"
76

File renamed without changes.

no_main/win/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/target

no_main/win/Cargo.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

no_main/win/Cargo.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[package]
2+
name = "no_main"
3+
version = "0.1.0"
4+
edition = "2021"
5+
license = "MIT"
6+
7+
[dependencies]
8+
9+
[profile.release]
10+
opt-level = "z"
11+
lto = true
12+
codegen-units = 1
13+
panic = "abort"
14+
strip = true

0 commit comments

Comments
 (0)