Merge commit '40b00f4200fbdeefd11815398cb46394b8cb0a5e' into sync_cg_clif-2021-12-30
This commit is contained in:
parent
799e067912
commit
a5a14258e5
20 changed files with 90 additions and 81 deletions
15
.github/workflows/main.yml
vendored
15
.github/workflows/main.yml
vendored
|
@ -5,6 +5,21 @@ on:
|
||||||
- pull_request
|
- pull_request
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
rustfmt:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 10
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Install rustfmt
|
||||||
|
run: |
|
||||||
|
rustup component add rustfmt
|
||||||
|
|
||||||
|
- name: Rustfmt
|
||||||
|
run: |
|
||||||
|
cargo fmt --check
|
||||||
|
|
||||||
build:
|
build:
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
timeout-minutes: 60
|
timeout-minutes: 60
|
||||||
|
|
2
.github/workflows/nightly-cranelift.yml
vendored
2
.github/workflows/nightly-cranelift.yml
vendored
|
@ -3,7 +3,7 @@ name: Test nightly Cranelift
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
schedule:
|
schedule:
|
||||||
- cron: '1 17 * * *' # At 01:17 UTC every day.
|
- cron: '17 1 * * *' # At 01:17 UTC every day.
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -7,6 +7,7 @@ perf.data.old
|
||||||
*.events
|
*.events
|
||||||
*.string*
|
*.string*
|
||||||
/y.bin
|
/y.bin
|
||||||
|
/y.bin.dSYM
|
||||||
/build
|
/build
|
||||||
/build_sysroot/sysroot_src
|
/build_sysroot/sysroot_src
|
||||||
/build_sysroot/compiler-builtins
|
/build_sysroot/compiler-builtins
|
||||||
|
|
19
Cargo.toml
19
Cargo.toml
|
@ -40,31 +40,12 @@ unstable-features = ["jit", "inline_asm"]
|
||||||
jit = ["cranelift-jit", "libloading"]
|
jit = ["cranelift-jit", "libloading"]
|
||||||
inline_asm = []
|
inline_asm = []
|
||||||
|
|
||||||
[profile.dev]
|
|
||||||
# By compiling dependencies with optimizations, performing tests gets much faster.
|
|
||||||
opt-level = 3
|
|
||||||
|
|
||||||
[profile.dev.package.rustc_codegen_cranelift]
|
|
||||||
# Disabling optimizations for cg_clif itself makes compilation after a change faster.
|
|
||||||
opt-level = 0
|
|
||||||
|
|
||||||
[profile.release.package.rustc_codegen_cranelift]
|
|
||||||
incremental = true
|
|
||||||
|
|
||||||
# Disable optimizations and debuginfo of build scripts and some of the heavy build deps, as the
|
# Disable optimizations and debuginfo of build scripts and some of the heavy build deps, as the
|
||||||
# execution time of build scripts is so fast that optimizing them slows down the total build time.
|
# execution time of build scripts is so fast that optimizing them slows down the total build time.
|
||||||
[profile.dev.build-override]
|
|
||||||
opt-level = 0
|
|
||||||
debug = false
|
|
||||||
|
|
||||||
[profile.release.build-override]
|
[profile.release.build-override]
|
||||||
opt-level = 0
|
opt-level = 0
|
||||||
debug = false
|
debug = false
|
||||||
|
|
||||||
[profile.dev.package.cranelift-codegen-meta]
|
|
||||||
opt-level = 0
|
|
||||||
debug = false
|
|
||||||
|
|
||||||
[profile.release.package.cranelift-codegen-meta]
|
[profile.release.package.cranelift-codegen-meta]
|
||||||
opt-level = 0
|
opt-level = 0
|
||||||
debug = false
|
debug = false
|
||||||
|
|
|
@ -37,7 +37,7 @@ Assuming `$cg_clif_dir` is the directory you cloned this repo into and you follo
|
||||||
In the directory with your project (where you can do the usual `cargo build`), run:
|
In the directory with your project (where you can do the usual `cargo build`), run:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ $cg_clif_dir/build/cargo build
|
$ $cg_clif_dir/build/cargo-clif build
|
||||||
```
|
```
|
||||||
|
|
||||||
This will build your project with rustc_codegen_cranelift instead of the usual LLVM backend.
|
This will build your project with rustc_codegen_cranelift instead of the usual LLVM backend.
|
||||||
|
|
|
@ -10,6 +10,18 @@ pub(crate) fn build_backend(
|
||||||
let mut cmd = Command::new("cargo");
|
let mut cmd = Command::new("cargo");
|
||||||
cmd.arg("build").arg("--target").arg(host_triple);
|
cmd.arg("build").arg("--target").arg(host_triple);
|
||||||
|
|
||||||
|
cmd.env("CARGO_BUILD_INCREMENTAL", "true"); // Force incr comp even in release mode
|
||||||
|
|
||||||
|
let mut rustflags = env::var("RUSTFLAGS").unwrap_or_default();
|
||||||
|
|
||||||
|
if env::var("CI").as_ref().map(|val| &**val) == Ok("true") {
|
||||||
|
// Deny warnings on CI
|
||||||
|
rustflags += " -Dwarnings";
|
||||||
|
|
||||||
|
// Disabling incr comp reduces cache size and incr comp doesn't save as much on CI anyway
|
||||||
|
cmd.env("CARGO_BUILD_INCREMENTAL", "false");
|
||||||
|
}
|
||||||
|
|
||||||
if use_unstable_features {
|
if use_unstable_features {
|
||||||
cmd.arg("--features").arg("unstable-features");
|
cmd.arg("--features").arg("unstable-features");
|
||||||
}
|
}
|
||||||
|
@ -22,25 +34,20 @@ pub(crate) fn build_backend(
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set the rpath to make the cg_clif executable find librustc_codegen_cranelift without changing
|
||||||
|
// LD_LIBRARY_PATH
|
||||||
if cfg!(unix) {
|
if cfg!(unix) {
|
||||||
if cfg!(target_os = "macos") {
|
if cfg!(target_os = "macos") {
|
||||||
cmd.env(
|
rustflags += " -Csplit-debuginfo=unpacked \
|
||||||
"RUSTFLAGS",
|
|
||||||
"-Csplit-debuginfo=unpacked \
|
|
||||||
-Clink-arg=-Wl,-rpath,@loader_path/../lib \
|
-Clink-arg=-Wl,-rpath,@loader_path/../lib \
|
||||||
-Zosx-rpath-install-name"
|
-Zosx-rpath-install-name";
|
||||||
.to_string()
|
|
||||||
+ env::var("RUSTFLAGS").as_deref().unwrap_or(""),
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
cmd.env(
|
rustflags += " -Clink-arg=-Wl,-rpath=$ORIGIN/../lib ";
|
||||||
"RUSTFLAGS",
|
|
||||||
"-Clink-arg=-Wl,-rpath=$ORIGIN/../lib ".to_string()
|
|
||||||
+ env::var("RUSTFLAGS").as_deref().unwrap_or(""),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cmd.env("RUSTFLAGS", rustflags);
|
||||||
|
|
||||||
eprintln!("[BUILD] rustc_codegen_cranelift");
|
eprintln!("[BUILD] rustc_codegen_cranelift");
|
||||||
crate::utils::spawn_and_wait(cmd);
|
crate::utils::spawn_and_wait(cmd);
|
||||||
|
|
||||||
|
|
|
@ -46,9 +46,9 @@ pub(crate) fn build_sysroot(
|
||||||
// Build and copy cargo wrapper
|
// Build and copy cargo wrapper
|
||||||
let mut build_cargo_wrapper_cmd = Command::new("rustc");
|
let mut build_cargo_wrapper_cmd = Command::new("rustc");
|
||||||
build_cargo_wrapper_cmd
|
build_cargo_wrapper_cmd
|
||||||
.arg("scripts/cargo.rs")
|
.arg("scripts/cargo-clif.rs")
|
||||||
.arg("-o")
|
.arg("-o")
|
||||||
.arg(target_dir.join("cargo"))
|
.arg(target_dir.join("cargo-clif"))
|
||||||
.arg("-g");
|
.arg("-g");
|
||||||
spawn_and_wait(build_cargo_wrapper_cmd);
|
spawn_and_wait(build_cargo_wrapper_cmd);
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ Assuming `$cg_clif_dir` is the directory you cloned this repo into and you follo
|
||||||
In the directory with your project (where you can do the usual `cargo build`), run:
|
In the directory with your project (where you can do the usual `cargo build`), run:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ $cg_clif_dir/build/cargo build
|
$ $cg_clif_dir/build/cargo-clif build
|
||||||
```
|
```
|
||||||
|
|
||||||
This will build your project with rustc_codegen_cranelift instead of the usual LLVM backend.
|
This will build your project with rustc_codegen_cranelift instead of the usual LLVM backend.
|
||||||
|
@ -32,7 +32,7 @@ In jit mode cg_clif will immediately execute your code without creating an execu
|
||||||
> The jit mode will probably need cargo integration to make this possible.
|
> The jit mode will probably need cargo integration to make this possible.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ $cg_clif_dir/build/cargo jit
|
$ $cg_clif_dir/build/cargo-clif jit
|
||||||
```
|
```
|
||||||
|
|
||||||
or
|
or
|
||||||
|
@ -45,7 +45,7 @@ There is also an experimental lazy jit mode. In this mode functions are only com
|
||||||
first called.
|
first called.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ $cg_clif_dir/build/cargo lazy-jit
|
$ $cg_clif_dir/build/cargo-clif lazy-jit
|
||||||
```
|
```
|
||||||
|
|
||||||
## Shell
|
## Shell
|
||||||
|
|
|
@ -129,6 +129,7 @@ fn call_return_u128_pair() {
|
||||||
return_u128_pair();
|
return_u128_pair();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(unreachable_code)] // FIXME false positive
|
||||||
fn main() {
|
fn main() {
|
||||||
take_unique(Unique {
|
take_unique(Unique {
|
||||||
pointer: 0 as *const (),
|
pointer: 0 as *const (),
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
[toolchain]
|
[toolchain]
|
||||||
channel = "nightly-2021-12-20"
|
channel = "nightly-2021-12-30"
|
||||||
components = ["rust-src", "rustc-dev", "llvm-tools-preview"]
|
components = ["rust-src", "rustc-dev", "llvm-tools-preview"]
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
./y.rs build
|
./y.rs build --no-unstable-features
|
||||||
source scripts/config.sh
|
source scripts/config.sh
|
||||||
|
|
||||||
echo "[SETUP] Rust fork"
|
echo "[SETUP] Rust fork"
|
||||||
|
|
|
@ -47,6 +47,8 @@ rm src/test/ui/codegen/init-large-type.rs # same
|
||||||
rm src/test/ui/sse2.rs # cpuid not supported, so sse2 not detected
|
rm src/test/ui/sse2.rs # cpuid not supported, so sse2 not detected
|
||||||
rm src/test/ui/issues/issue-33992.rs # unsupported linkages
|
rm src/test/ui/issues/issue-33992.rs # unsupported linkages
|
||||||
rm src/test/ui/issues/issue-51947.rs # same
|
rm src/test/ui/issues/issue-51947.rs # same
|
||||||
|
rm src/test/incremental/hashes/function_interfaces.rs # same
|
||||||
|
rm src/test/incremental/hashes/statics.rs # same
|
||||||
rm src/test/ui/numbers-arithmetic/saturating-float-casts.rs # intrinsic gives different but valid result
|
rm src/test/ui/numbers-arithmetic/saturating-float-casts.rs # intrinsic gives different but valid result
|
||||||
rm src/test/ui/mir/mir_misc_casts.rs # depends on deduplication of constants
|
rm src/test/ui/mir/mir_misc_casts.rs # depends on deduplication of constants
|
||||||
rm src/test/ui/mir/mir_raw_fat_ptr.rs # same
|
rm src/test/ui/mir/mir_raw_fat_ptr.rs # same
|
||||||
|
@ -60,18 +62,14 @@ rm src/test/ui/intrinsics/intrinsic-nearby.rs # unimplemented nearbyintf32 and n
|
||||||
|
|
||||||
rm src/test/incremental/hashes/inline_asm.rs # inline asm
|
rm src/test/incremental/hashes/inline_asm.rs # inline asm
|
||||||
rm src/test/incremental/issue-72386.rs # same
|
rm src/test/incremental/issue-72386.rs # same
|
||||||
rm src/test/incremental/issue-49482.rs # same
|
|
||||||
rm src/test/incremental/issue-54059.rs # same
|
|
||||||
rm src/test/incremental/lto.rs # requires lto
|
rm src/test/incremental/lto.rs # requires lto
|
||||||
|
rm src/test/incremental/dirty_clean.rs # TODO
|
||||||
|
|
||||||
rm -r src/test/run-make/emit-shared-files # requires the rustdoc executable in build/bin/
|
rm -r src/test/run-make/emit-shared-files # requires the rustdoc executable in build/bin/
|
||||||
rm -r src/test/run-make/unstable-flag-required # same
|
rm -r src/test/run-make/unstable-flag-required # same
|
||||||
rm -r src/test/run-make/rustdoc-* # same
|
rm -r src/test/run-make/rustdoc-* # same
|
||||||
rm -r src/test/run-make/emit-named-files # requires full --emit support
|
rm -r src/test/run-make/emit-named-files # requires full --emit support
|
||||||
|
|
||||||
rm src/test/pretty/asm.rs # inline asm
|
|
||||||
rm src/test/pretty/raw-str-nonexpr.rs # same
|
|
||||||
|
|
||||||
rm -r src/test/run-pass-valgrind/unsized-locals
|
rm -r src/test/run-pass-valgrind/unsized-locals
|
||||||
|
|
||||||
rm src/test/ui/json-bom-plus-crlf-multifile.rs # differing warning
|
rm src/test/ui/json-bom-plus-crlf-multifile.rs # differing warning
|
||||||
|
@ -97,6 +95,12 @@ rm src/test/ui/command/command-current-dir.rs # can't find libstd.so
|
||||||
|
|
||||||
rm src/test/ui/abi/stack-protector.rs # requires stack protector support
|
rm src/test/ui/abi/stack-protector.rs # requires stack protector support
|
||||||
|
|
||||||
|
rm src/test/incremental/issue-80691-bad-eval-cache.rs # wrong exit code
|
||||||
|
rm src/test/incremental/spike-neg1.rs # errors out for some reason
|
||||||
|
rm src/test/incremental/spike-neg2.rs # same
|
||||||
|
|
||||||
|
rm src/test/incremental/thinlto/cgu_invalidated_when_import_{added,removed}.rs # requires LLVM
|
||||||
|
|
||||||
echo "[TEST] rustc test suite"
|
echo "[TEST] rustc test suite"
|
||||||
RUST_TEST_NOCAPTURE=1 COMPILETEST_FORCE_STAGE0=1 ./x.py test --stage 0 src/test/{codegen-units,run-make,run-pass-valgrind,ui}
|
RUST_TEST_NOCAPTURE=1 COMPILETEST_FORCE_STAGE0=1 ./x.py test --stage 0 src/test/{codegen-units,run-make,run-pass-valgrind,ui,incremental}
|
||||||
popd
|
popd
|
||||||
|
|
|
@ -80,73 +80,73 @@ function base_sysroot_tests() {
|
||||||
|
|
||||||
function extended_sysroot_tests() {
|
function extended_sysroot_tests() {
|
||||||
pushd rand
|
pushd rand
|
||||||
../build/cargo clean
|
../build/cargo-clif clean
|
||||||
if [[ "$HOST_TRIPLE" = "$TARGET_TRIPLE" ]]; then
|
if [[ "$HOST_TRIPLE" = "$TARGET_TRIPLE" ]]; then
|
||||||
echo "[TEST] rust-random/rand"
|
echo "[TEST] rust-random/rand"
|
||||||
../build/cargo test --workspace
|
../build/cargo-clif test --workspace
|
||||||
else
|
else
|
||||||
echo "[AOT] rust-random/rand"
|
echo "[AOT] rust-random/rand"
|
||||||
../build/cargo build --workspace --target $TARGET_TRIPLE --tests
|
../build/cargo-clif build --workspace --target $TARGET_TRIPLE --tests
|
||||||
fi
|
fi
|
||||||
popd
|
popd
|
||||||
|
|
||||||
pushd simple-raytracer
|
pushd simple-raytracer
|
||||||
if [[ "$HOST_TRIPLE" = "$TARGET_TRIPLE" ]]; then
|
if [[ "$HOST_TRIPLE" = "$TARGET_TRIPLE" ]]; then
|
||||||
echo "[BENCH COMPILE] ebobby/simple-raytracer"
|
echo "[BENCH COMPILE] ebobby/simple-raytracer"
|
||||||
hyperfine --runs "${RUN_RUNS:-10}" --warmup 1 --prepare "../build/cargo clean" \
|
hyperfine --runs "${RUN_RUNS:-10}" --warmup 1 --prepare "../build/cargo-clif clean" \
|
||||||
"RUSTC=rustc RUSTFLAGS='' cargo build" \
|
"RUSTC=rustc RUSTFLAGS='' cargo build" \
|
||||||
"../build/cargo build"
|
"../build/cargo-clif build"
|
||||||
|
|
||||||
echo "[BENCH RUN] ebobby/simple-raytracer"
|
echo "[BENCH RUN] ebobby/simple-raytracer"
|
||||||
cp ./target/debug/main ./raytracer_cg_clif
|
cp ./target/debug/main ./raytracer_cg_clif
|
||||||
hyperfine --runs "${RUN_RUNS:-10}" ./raytracer_cg_llvm ./raytracer_cg_clif
|
hyperfine --runs "${RUN_RUNS:-10}" ./raytracer_cg_llvm ./raytracer_cg_clif
|
||||||
else
|
else
|
||||||
../build/cargo clean
|
../build/cargo-clif clean
|
||||||
echo "[BENCH COMPILE] ebobby/simple-raytracer (skipped)"
|
echo "[BENCH COMPILE] ebobby/simple-raytracer (skipped)"
|
||||||
echo "[COMPILE] ebobby/simple-raytracer"
|
echo "[COMPILE] ebobby/simple-raytracer"
|
||||||
../build/cargo build --target $TARGET_TRIPLE
|
../build/cargo-clif build --target $TARGET_TRIPLE
|
||||||
echo "[BENCH RUN] ebobby/simple-raytracer (skipped)"
|
echo "[BENCH RUN] ebobby/simple-raytracer (skipped)"
|
||||||
fi
|
fi
|
||||||
popd
|
popd
|
||||||
|
|
||||||
pushd build_sysroot/sysroot_src/library/core/tests
|
pushd build_sysroot/sysroot_src/library/core/tests
|
||||||
echo "[TEST] libcore"
|
echo "[TEST] libcore"
|
||||||
../../../../../build/cargo clean
|
../../../../../build/cargo-clif clean
|
||||||
if [[ "$HOST_TRIPLE" = "$TARGET_TRIPLE" ]]; then
|
if [[ "$HOST_TRIPLE" = "$TARGET_TRIPLE" ]]; then
|
||||||
../../../../../build/cargo test
|
../../../../../build/cargo-clif test
|
||||||
else
|
else
|
||||||
../../../../../build/cargo build --target $TARGET_TRIPLE --tests
|
../../../../../build/cargo-clif build --target $TARGET_TRIPLE --tests
|
||||||
fi
|
fi
|
||||||
popd
|
popd
|
||||||
|
|
||||||
pushd regex
|
pushd regex
|
||||||
echo "[TEST] rust-lang/regex example shootout-regex-dna"
|
echo "[TEST] rust-lang/regex example shootout-regex-dna"
|
||||||
../build/cargo clean
|
../build/cargo-clif clean
|
||||||
export RUSTFLAGS="$RUSTFLAGS --cap-lints warn" # newer aho_corasick versions throw a deprecation warning
|
export RUSTFLAGS="$RUSTFLAGS --cap-lints warn" # newer aho_corasick versions throw a deprecation warning
|
||||||
# Make sure `[codegen mono items] start` doesn't poison the diff
|
# Make sure `[codegen mono items] start` doesn't poison the diff
|
||||||
../build/cargo build --example shootout-regex-dna --target $TARGET_TRIPLE
|
../build/cargo-clif build --example shootout-regex-dna --target $TARGET_TRIPLE
|
||||||
if [[ "$HOST_TRIPLE" = "$TARGET_TRIPLE" ]]; then
|
if [[ "$HOST_TRIPLE" = "$TARGET_TRIPLE" ]]; then
|
||||||
cat examples/regexdna-input.txt \
|
cat examples/regexdna-input.txt \
|
||||||
| ../build/cargo run --example shootout-regex-dna --target $TARGET_TRIPLE \
|
| ../build/cargo-clif run --example shootout-regex-dna --target $TARGET_TRIPLE \
|
||||||
| grep -v "Spawned thread" > res.txt
|
| grep -v "Spawned thread" > res.txt
|
||||||
diff -u res.txt examples/regexdna-output.txt
|
diff -u res.txt examples/regexdna-output.txt
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$HOST_TRIPLE" = "$TARGET_TRIPLE" ]]; then
|
if [[ "$HOST_TRIPLE" = "$TARGET_TRIPLE" ]]; then
|
||||||
echo "[TEST] rust-lang/regex tests"
|
echo "[TEST] rust-lang/regex tests"
|
||||||
../build/cargo test --tests -- --exclude-should-panic --test-threads 1 -Zunstable-options -q
|
../build/cargo-clif test --tests -- --exclude-should-panic --test-threads 1 -Zunstable-options -q
|
||||||
else
|
else
|
||||||
echo "[AOT] rust-lang/regex tests"
|
echo "[AOT] rust-lang/regex tests"
|
||||||
../build/cargo build --tests --target $TARGET_TRIPLE
|
../build/cargo-clif build --tests --target $TARGET_TRIPLE
|
||||||
fi
|
fi
|
||||||
popd
|
popd
|
||||||
|
|
||||||
pushd portable-simd
|
pushd portable-simd
|
||||||
echo "[TEST] rust-lang/portable-simd"
|
echo "[TEST] rust-lang/portable-simd"
|
||||||
../build/cargo clean
|
../build/cargo-clif clean
|
||||||
../build/cargo build --all-targets --target $TARGET_TRIPLE
|
../build/cargo-clif build --all-targets --target $TARGET_TRIPLE
|
||||||
if [[ "$HOST_TRIPLE" = "$TARGET_TRIPLE" ]]; then
|
if [[ "$HOST_TRIPLE" = "$TARGET_TRIPLE" ]]; then
|
||||||
../build/cargo test -q
|
../build/cargo-clif test -q
|
||||||
fi
|
fi
|
||||||
popd
|
popd
|
||||||
}
|
}
|
||||||
|
|
|
@ -237,7 +237,7 @@ pub(crate) struct FunctionCx<'m, 'clif, 'tcx: 'm> {
|
||||||
pub(crate) module: &'m mut dyn Module,
|
pub(crate) module: &'m mut dyn Module,
|
||||||
pub(crate) tcx: TyCtxt<'tcx>,
|
pub(crate) tcx: TyCtxt<'tcx>,
|
||||||
pub(crate) target_config: TargetFrontendConfig, // Cached from module
|
pub(crate) target_config: TargetFrontendConfig, // Cached from module
|
||||||
pub(crate) pointer_type: Type, // Cached from module
|
pub(crate) pointer_type: Type, // Cached from module
|
||||||
pub(crate) constants_cx: ConstantCx,
|
pub(crate) constants_cx: ConstantCx,
|
||||||
|
|
||||||
pub(crate) instance: Instance<'tcx>,
|
pub(crate) instance: Instance<'tcx>,
|
||||||
|
|
|
@ -67,7 +67,7 @@ impl WriterRelocate {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Perform the collected relocations to be usable for JIT usage.
|
/// Perform the collected relocations to be usable for JIT usage.
|
||||||
#[cfg(feature = "jit")]
|
#[cfg(all(feature = "jit", not(windows)))]
|
||||||
pub(super) fn relocate_for_jit(mut self, jit_module: &cranelift_jit::JITModule) -> Vec<u8> {
|
pub(super) fn relocate_for_jit(mut self, jit_module: &cranelift_jit::JITModule) -> Vec<u8> {
|
||||||
for reloc in self.relocs.drain(..) {
|
for reloc in self.relocs.drain(..) {
|
||||||
match reloc.name {
|
match reloc.name {
|
||||||
|
|
|
@ -10,7 +10,7 @@ use crate::prelude::*;
|
||||||
use rustc_index::vec::IndexVec;
|
use rustc_index::vec::IndexVec;
|
||||||
|
|
||||||
use cranelift_codegen::entity::EntityRef;
|
use cranelift_codegen::entity::EntityRef;
|
||||||
use cranelift_codegen::ir::{LabelValueLoc, ValueLabel};
|
use cranelift_codegen::ir::{Endianness, LabelValueLoc, ValueLabel};
|
||||||
use cranelift_codegen::isa::TargetIsa;
|
use cranelift_codegen::isa::TargetIsa;
|
||||||
use cranelift_codegen::ValueLocRange;
|
use cranelift_codegen::ValueLocRange;
|
||||||
|
|
||||||
|
@ -23,15 +23,6 @@ use gimli::{Encoding, Format, LineEncoding, RunTimeEndian, X86_64};
|
||||||
pub(crate) use emit::{DebugReloc, DebugRelocName};
|
pub(crate) use emit::{DebugReloc, DebugRelocName};
|
||||||
pub(crate) use unwind::UnwindContext;
|
pub(crate) use unwind::UnwindContext;
|
||||||
|
|
||||||
fn target_endian(tcx: TyCtxt<'_>) -> RunTimeEndian {
|
|
||||||
use rustc_target::abi::Endian;
|
|
||||||
|
|
||||||
match tcx.data_layout.endian {
|
|
||||||
Endian::Big => RunTimeEndian::Big,
|
|
||||||
Endian::Little => RunTimeEndian::Little,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) struct DebugContext<'tcx> {
|
pub(crate) struct DebugContext<'tcx> {
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
|
|
||||||
|
@ -60,6 +51,11 @@ impl<'tcx> DebugContext<'tcx> {
|
||||||
address_size: isa.frontend_config().pointer_bytes(),
|
address_size: isa.frontend_config().pointer_bytes(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let endian = match isa.endianness() {
|
||||||
|
Endianness::Little => RunTimeEndian::Little,
|
||||||
|
Endianness::Big => RunTimeEndian::Big,
|
||||||
|
};
|
||||||
|
|
||||||
let mut dwarf = DwarfUnit::new(encoding);
|
let mut dwarf = DwarfUnit::new(encoding);
|
||||||
|
|
||||||
let producer = format!(
|
let producer = format!(
|
||||||
|
@ -108,7 +104,7 @@ impl<'tcx> DebugContext<'tcx> {
|
||||||
DebugContext {
|
DebugContext {
|
||||||
tcx,
|
tcx,
|
||||||
|
|
||||||
endian: target_endian(tcx),
|
endian,
|
||||||
|
|
||||||
dwarf,
|
dwarf,
|
||||||
unit_range_list: RangeList(Vec::new()),
|
unit_range_list: RangeList(Vec::new()),
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
|
use cranelift_codegen::ir::Endianness;
|
||||||
use cranelift_codegen::isa::{unwind::UnwindInfo, TargetIsa};
|
use cranelift_codegen::isa::{unwind::UnwindInfo, TargetIsa};
|
||||||
|
|
||||||
use cranelift_object::ObjectProduct;
|
use cranelift_object::ObjectProduct;
|
||||||
|
@ -17,8 +18,11 @@ pub(crate) struct UnwindContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl UnwindContext {
|
impl UnwindContext {
|
||||||
pub(crate) fn new(tcx: TyCtxt<'_>, isa: &dyn TargetIsa, pic_eh_frame: bool) -> Self {
|
pub(crate) fn new(isa: &dyn TargetIsa, pic_eh_frame: bool) -> Self {
|
||||||
let endian = super::target_endian(tcx);
|
let endian = match isa.endianness() {
|
||||||
|
Endianness::Little => RunTimeEndian::Little,
|
||||||
|
Endianness::Big => RunTimeEndian::Big,
|
||||||
|
};
|
||||||
let mut frame_table = FrameTable::default();
|
let mut frame_table = FrameTable::default();
|
||||||
|
|
||||||
let cie_id = if let Some(mut cie) = isa.create_systemv_cie() {
|
let cie_id = if let Some(mut cie) = isa.create_systemv_cie() {
|
||||||
|
|
|
@ -243,7 +243,7 @@ pub(crate) fn run_aot(
|
||||||
let isa = crate::build_isa(tcx.sess, &backend_config);
|
let isa = crate::build_isa(tcx.sess, &backend_config);
|
||||||
let mut allocator_module = make_module(tcx.sess, isa, "allocator_shim".to_string());
|
let mut allocator_module = make_module(tcx.sess, isa, "allocator_shim".to_string());
|
||||||
assert_eq!(pointer_ty(tcx), allocator_module.target_config().pointer_type());
|
assert_eq!(pointer_ty(tcx), allocator_module.target_config().pointer_type());
|
||||||
let mut allocator_unwind_context = UnwindContext::new(tcx, allocator_module.isa(), true);
|
let mut allocator_unwind_context = UnwindContext::new(allocator_module.isa(), true);
|
||||||
let created_alloc_shim =
|
let created_alloc_shim =
|
||||||
crate::allocator::codegen(tcx, &mut allocator_module, &mut allocator_unwind_context);
|
crate::allocator::codegen(tcx, &mut allocator_module, &mut allocator_unwind_context);
|
||||||
|
|
||||||
|
|
|
@ -141,7 +141,7 @@ impl<'tcx> CodegenCx<'tcx> {
|
||||||
assert_eq!(pointer_ty(tcx), isa.pointer_type());
|
assert_eq!(pointer_ty(tcx), isa.pointer_type());
|
||||||
|
|
||||||
let unwind_context =
|
let unwind_context =
|
||||||
UnwindContext::new(tcx, isa, matches!(backend_config.codegen_mode, CodegenMode::Aot));
|
UnwindContext::new(isa, matches!(backend_config.codegen_mode, CodegenMode::Aot));
|
||||||
let debug_context = if debug_info { Some(DebugContext::new(tcx, isa)) } else { None };
|
let debug_context = if debug_info { Some(DebugContext::new(tcx, isa)) } else { None };
|
||||||
CodegenCx {
|
CodegenCx {
|
||||||
tcx,
|
tcx,
|
||||||
|
|
Loading…
Add table
Reference in a new issue