Skip to content

Commit

Permalink
Document potential problem with target triples in the "compiling Rust…
Browse files Browse the repository at this point in the history
…" example.
  • Loading branch information
rschatz committed Apr 20, 2021
1 parent 15f16a6 commit 8095e0c
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions sulong/docs/user/Compiling.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,26 @@ standard libraries:
lli --lib $(rustc --print sysroot)/lib/libstd-* hello-rust.bc
Hello Rust!
```

Since the Rust compiler is not using the LLVM toolchain shipped with GraalVM, depending on the
local Rust installation, an error similar to one of the following might happen:
```
Mismatching target triple (expected x86_64-unknown-linux-gnu, got x86_64-pc-linux-gnu)
Mismatching target triple (expected x86_64-apple-macosx10.11.0, got x86_64-apple-darwin)
```

This indicates that the Rust compiler used a different target triple than the LLVM toolchain
shipped with GraalVM. In this particular case, the differences are just different naming
conventions across Linux distributions or MacOS versions, there is no real difference.
In that case, the error can be safely ignored:

```shell
lli --experimental-options --llvm.verifyBitcode=false --lib $(rustc --print sysroot)/lib/libstd-* hello-rust.bc
```

This option should only be used after manually verifying that the target triples are
really compatible, i.e., the architecture, operating system, and C library all match.
For example, `x86_64-unknown-linux-musl` and `x86_64-unknown-linux-gnu` are really different,
the bitcode is compiled for a different C library. The `--llvm.verifyBitcode=false` option
disables all checks, GraalVM will then try to run the bitcode regardless, which might randomly
fail in unexpected ways.

0 comments on commit 8095e0c

Please sign in to comment.