You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: QUICKSTART.md
+32-6Lines changed: 32 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -19,13 +19,13 @@ rustup update
19
19
20
20
If this does not solve the problem, open an issue. The project is only compatible with a narrow set of `rustc` versions, and tries to always use the newest nigthly build.
21
21
## Install the .NET runtime
22
-
22
+
**Note: This is only relevant if you want to use this project in its .NET mode**
23
23
This project requires the .NET runtime to be used. You can find [instalation instructions here](https://dotnet.microsoft.com/en-us/download).
24
24
25
25
After installing .NET, run ` dotnet --info` to confoirm it is installed propely.
26
26
27
27
## Install `ilasm`
28
-
28
+
**Note: This is only relevant if you want to use this project in its .NET mode**
29
29
### Windows
30
30
31
31
`ilasm` comes [installed with Visual Studio](https://learn.microsoft.com/en-us/dotnet/framework/tools/ilasm-exe-il-assembler). So, you propably already have it. If not, install visual stuido.
@@ -36,7 +36,11 @@ This tool supports both the "Core" and "Mono" flavours of ILASM. While you *can*
36
36
37
37
### Checking the dependencies
38
38
39
-
After you installed `dotnet` and `ilasm`, run `./bin/rustflags.rs` to check if you installed `ilasm` and `dotnet` correctly.
39
+
After you installed `dotnet` and `ilasm`(, run `./bin/rustflags.rs` to check if you installed `ilasm` and `dotnet` correctly.
40
+
If you want to use the project to generate C code, set `C_MODE` to `1`.
41
+
```
42
+
export C_MODE=1
43
+
```
40
44
41
45
This script uses the experimental `cargo-script` feaure to will check your enviroment, build the project, and print the flags you need to use it.
42
46
@@ -57,9 +61,9 @@ target = "x86_64-unknown-linux-gnu" # Change to the host target.
57
61
build-std = ["core","alloc","std","panic_abort"]
58
62
```
59
63
60
-
Then, run the codegen utility `rustflags` again, by running `cargo --binrustflags --release`**in the directory `rustc_codegen_clr`**.
64
+
Then, run the codegen utility `rustflags` again, by running `./bin/rustflags.rs`**in the directory `rustc_codegen_clr`**.
61
65
62
-
It should provide you with the commands necesary for enabling the codegen. They should look something like this:
66
+
It should provide you with the commands necesarry for enabling the codegen. They should look something like this:
63
67
64
68
On Linux:
65
69
```bash
@@ -75,4 +79,26 @@ The project makes **no pernament changes** to your instaltation, and simply clos
75
79
76
80
After this, simply run `cargo run` to compile & run your app inside the .NET runtime. Other cargo commands should work to. There may be quite a few error / warning messages dispalyed, but they will not stop compilation.
77
81
78
-
NOTE: the project currently does not support any `proc-macros`, due to techincal liminations. Supporting them is possible, but it is currently more effort than it is worth.
82
+
NOTE: the project currently does not properly support `proc-macros`, due to technical liminations. Fully supporting them is possible, but it is currently more effort than it is worth.
83
+
# Additional information on C support
84
+
85
+
## Required features
86
+
Currently, the generated code will, by default, depend on some features of C that may not always be present.
87
+
88
+
Those features are:
89
+
1. malloc and aligned allocators - certain static/constant variables require alignments higher than the ones guaranteed by the C standard. As a workaround, `cg_clr` will use malloc & aligned allocators
90
+
to ensure sufficient alignment of static variables. This is something I am actively working on resolving, and this should not be an issue in the near future.
91
+
2. POSIX threading APIs. The header files generated by `cg_clr` will override certain POSIX APIs in order to track new threads. This is needed to ensure proper initialization of thread-local data.
92
+
93
+
## Odd function names
94
+
Additionally, you might notice that the generated code sometimes calls "wierd" functions, like `System_Numerics_BitOperations_LeadingZeroCountu64i32`.
95
+
This is a limitation of the current abstractions over .NET and C. Most of the time, those functions simply call / emulate a C builtin. This is also something that will not be an issue in the future:
96
+
I am actively working on better abstractions.
97
+
98
+
## Non-alphabetic identifiers.
99
+
100
+
By default, `cg_clr` will keep symbol(function) names more-or-less intact. However, those names may contain characters accepted by *most*, but not *all* compilers.
0 commit comments