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
<dd>Dump a C-like representation to /tmp/gccjit_dumps and enable debug info in order to debug this C-like representation.</dd>
140
140
</dl>
141
141
142
-
## Licensing
143
-
144
-
While this crate is licensed under a dual Apache/MIT license, it links to `libgccjit` which is under the GPLv3+ and thus, the resulting toolchain (rustc + GCC codegen) will need to be released under the GPL license.
145
-
146
-
However, programs compiled with `rustc_codegen_gcc` do not need to be released under a GPL license.
147
-
148
-
## Debugging
149
-
150
-
Sometimes, libgccjit will crash and output an error like this:
151
-
152
-
```
153
-
during RTL pass: expand
154
-
libgccjit.so: error: in expmed_mode_index, at expmed.h:249
# Take the command from the output and add --emit=llvm-ir
268
-
```
269
-
270
-
### To prevent the linker from unmangling symbols
271
-
272
-
Run with:
273
-
274
-
```
275
-
COLLECT_NO_DEMANGLE=1
276
-
```
277
-
278
-
### How to use a custom-build rustc
279
-
280
-
* Build the stage2 compiler (`rustup toolchain link debug-current build/x86_64-unknown-linux-gnu/stage2`).
281
-
* Clean and rebuild the codegen with `debug-current` in the file `rust-toolchain`.
282
-
283
-
### How to use [mem-trace](https://github.com/antoyo/mem-trace)
284
-
285
-
`rustc` needs to be built without `jemalloc` so that `mem-trace` can overload `malloc` since `jemalloc` is linked statically, so a `LD_PRELOAD`-ed library won't a chance to intercept the calls to `malloc`.
286
-
287
-
### How to generate GIMPLE
288
-
289
-
If you need to check what gccjit is generating (GIMPLE), then take a look at how to
290
-
generate it in [gimple.md](./doc/gimple.md).
291
-
292
-
### How to build a cross-compiling libgccjit
293
-
294
-
#### Building libgccjit
295
-
296
-
* Follow the instructions on [this repo](https://github.com/cross-cg-gcc-tools/cross-gcc).
297
-
298
-
#### Configuring rustc_codegen_gcc
299
-
300
-
* Run `./y.sh prepare --cross` so that the sysroot is patched for the cross-compiling case.
301
-
* Set the path to the cross-compiling libgccjit in `gcc-path` (in `config.toml`).
302
-
* Make sure you have the linker for your target (for instance `m68k-unknown-linux-gnu-gcc`) in your `$PATH`. Currently, the linker name is hardcoded as being `$TARGET-gcc`. Specify the target when building the sysroot: `./y.sh build --target-triple m68k-unknown-linux-gnu`.
303
-
* Build your project by specifying the target: `OVERWRITE_TARGET_TRIPLE=m68k-unknown-linux-gnu ../y.sh cargo build --target m68k-unknown-linux-gnu`.
304
-
305
-
If the target is not yet supported by the Rust compiler, create a [target specification file](https://docs.rust-embedded.org/embedonomicon/custom-target.html) (note that the `arch` specified in this file must be supported by the rust compiler).
306
-
Then, you can use it the following way:
307
-
308
-
* Add the target specification file using `--target` as an **absolute** path to build the sysroot: `./y.sh build --target-triple m68k-unknown-linux-gnu --target $(pwd)/m68k-unknown-linux-gnu.json`
309
-
* Build your project by specifying the target specification file: `OVERWRITE_TARGET_TRIPLE=m68k-unknown-linux-gnu ../y.sh cargo build --target path/to/m68k-unknown-linux-gnu.json`.
310
-
311
-
If you get the following error:
153
+
## Licensing
312
154
313
-
```
314
-
/usr/bin/ld: unrecognised emulation mode: m68kelf
315
-
```
155
+
While this crate is licensed under a dual Apache/MIT license, it links to `libgccjit` which is under the GPLv3+ and thus, the resulting toolchain (rustc + GCC codegen) will need to be released under the GPL license.
316
156
317
-
Make sure you set `gcc-path` (in `config.toml`) to the install directory.
157
+
However, programs compiled with `rustc_codegen_gcc` do not need to be released under a GPL license.
# Take the command from the output and add --emit=llvm-ir
23
+
```
24
+
25
+
### To prevent the linker from unmangling symbols
26
+
27
+
Run with:
28
+
29
+
```
30
+
COLLECT_NO_DEMANGLE=1
31
+
```
32
+
33
+
### How to use a custom-build rustc
34
+
35
+
* Build the stage2 compiler (`rustup toolchain link debug-current build/x86_64-unknown-linux-gnu/stage2`).
36
+
* Clean and rebuild the codegen with `debug-current` in the file `rust-toolchain`.
37
+
38
+
### How to use [mem-trace](https://github.com/antoyo/mem-trace)
39
+
40
+
`rustc` needs to be built without `jemalloc` so that `mem-trace` can overload `malloc` since `jemalloc` is linked statically, so a `LD_PRELOAD`-ed library won't a chance to intercept the calls to `malloc`.
41
+
42
+
### How to generate GIMPLE
43
+
44
+
If you need to check what gccjit is generating (GIMPLE), then take a look at how to
45
+
generate it in [gimple.md](./doc/gimple.md).
46
+
47
+
### How to build a cross-compiling libgccjit
48
+
49
+
#### Building libgccjit
50
+
51
+
* Follow the instructions on [this repo](https://github.com/cross-cg-gcc-tools/cross-gcc).
52
+
53
+
#### Configuring rustc_codegen_gcc
54
+
55
+
* Run `./y.sh prepare --cross` so that the sysroot is patched for the cross-compiling case.
56
+
* Set the path to the cross-compiling libgccjit in `gcc-path` (in `config.toml`).
57
+
* Make sure you have the linker for your target (for instance `m68k-unknown-linux-gnu-gcc`) in your `$PATH`. Currently, the linker name is hardcoded as being `$TARGET-gcc`. Specify the target when building the sysroot: `./y.sh build --target-triple m68k-unknown-linux-gnu`.
58
+
* Build your project by specifying the target: `OVERWRITE_TARGET_TRIPLE=m68k-unknown-linux-gnu ../y.sh cargo build --target m68k-unknown-linux-gnu`.
59
+
60
+
If the target is not yet supported by the Rust compiler, create a [target specification file](https://docs.rust-embedded.org/embedonomicon/custom-target.html) (note that the `arch` specified in this file must be supported by the rust compiler).
61
+
Then, you can use it the following way:
62
+
63
+
* Add the target specification file using `--target` as an **absolute** path to build the sysroot: `./y.sh build --target-triple m68k-unknown-linux-gnu --target $(pwd)/m68k-unknown-linux-gnu.json`
64
+
* Build your project by specifying the target specification file: `OVERWRITE_TARGET_TRIPLE=m68k-unknown-linux-gnu ../y.sh cargo build --target path/to/m68k-unknown-linux-gnu.json`.
65
+
66
+
If you get the following error:
67
+
68
+
```
69
+
/usr/bin/ld: unrecognised emulation mode: m68kelf
70
+
```
71
+
72
+
Make sure you set `gcc-path` (in `config.toml`) to the install directory.
0 commit comments