Skip to content

Commit 702bdbb

Browse files
authored
readme: update section on cross-transpilation to explain how to cross-arch transpile (#1456)
2 parents 3b2788c + 30afcbb commit 702bdbb

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

README.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,8 +348,21 @@ or email us at [[email protected]](mailto:[email protected]).
348348
> I translated code on platform X, but it didn't work correctly on platform Y.
349349
350350
We run the C preprocessor before translation to Rust.
351-
This specializes the code to the host platform.
352-
For this reason, we do not support cross compiling translated code at the moment.
351+
This specializes the code to the target platform (usually the host platform).
352+
We do, however, support cross-architecture transpilation with a different sysroot
353+
(cross-OS transpilation is more difficult because
354+
it can be difficult to get a sysroot for the target OS).
355+
For example, on an `aarch64-linux-gnu` host, to cross-transpile to `x86_64-linux-gnu`,
356+
you can run
357+
358+
```sh
359+
sudo apt install gcc-x86-64-linux-gnu # install cross-compiler, which comes with a sysroot
360+
c2rust transpile ${existing_args[@]} -- --target=x86_64-linux-gnu --sysroot=/usr/x86_64-linux-gnu
361+
```
362+
363+
These extra args are passed to the `libclangTooling` that `c2rust-transpile` uses.
364+
You sometimes also need to pass extra headers, as occasionally headers are installed globally
365+
in the default sysroot and won't be found in the cross-compiling sysroot.
353366

354367
> What platforms can C2Rust be run on?
355368

0 commit comments

Comments
 (0)