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: Readme.md
+29-223
Original file line number
Diff line number
Diff line change
@@ -17,6 +17,18 @@ A secondary goal is to check if using the gcc backend will provide any run-time
17
17
**This requires a patched libgccjit in order to work.
18
18
You need to use my [fork of gcc](https://github.com/antoyo/gcc) which already includes these patches.**
19
19
20
+
```bash
21
+
$ cp config.example.toml config.toml
22
+
```
23
+
24
+
If don't need to test GCC patches you wrote in our GCC fork, then the default configuration should
25
+
be all you need. You can update the `rustc_codegen_gcc` without worrying about GCC.
26
+
27
+
### Building with your own GCC version
28
+
29
+
If you wrote a patch for GCC and want to test it without this backend, you will need
30
+
to do a few more things.
31
+
20
32
To build it (most of these instructions come from [here](https://gcc.gnu.org/onlinedocs/jit/internals/index.html), so don't hesitate to take a look there if you encounter an issue):
<dd>Dump a C-like representation to /tmp/gccjit_dumps and enable debug info in order to debug this C-like representation.</dd>
129
140
</dl>
130
141
131
-
## Licensing
132
-
133
-
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.
134
-
135
-
However, programs compiled with `rustc_codegen_gcc` do not need to be released under a GPL license.
136
-
137
-
## Debugging
138
-
139
-
Sometimes, libgccjit will crash and output an error like this:
140
-
141
-
```
142
-
during RTL pass: expand
143
-
libgccjit.so: error: in expmed_mode_index, at expmed.h:249
### How to use [mem-trace](https://github.com/antoyo/mem-trace)
318
-
319
-
`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`.
144
+
More specific documentation is available in the [`doc`](./doc) folder:
*[Send a patch to GCC](./doc/sending-gcc-patch.md)
322
152
323
-
If you need to check what gccjit is generating (GIMPLE), then take a look at how to
324
-
generate it in [gimple.md](./doc/gimple.md).
325
-
326
-
### How to build a cross-compiling libgccjit
327
-
328
-
#### Building libgccjit
329
-
330
-
* Follow the instructions on [this repo](https://github.com/cross-cg-gcc-tools/cross-gcc).
331
-
332
-
#### Configuring rustc_codegen_gcc
333
-
334
-
* Run `./y.sh prepare --cross` so that the sysroot is patched for the cross-compiling case.
335
-
* Set the path to the cross-compiling libgccjit in `gcc-path` (in `config.toml`).
336
-
* 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`.
337
-
* Build your project by specifying the target: `OVERWRITE_TARGET_TRIPLE=m68k-unknown-linux-gnu ../y.sh cargo build --target m68k-unknown-linux-gnu`.
338
-
339
-
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).
340
-
Then, you can use it the following way:
341
-
342
-
* 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`
343
-
* 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`.
344
-
345
-
If you get the following error:
153
+
## Licensing
346
154
347
-
```
348
-
/usr/bin/ld: unrecognised emulation mode: m68kelf
349
-
```
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.
350
156
351
-
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.
0 commit comments