Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 7 pull requests #92465

Merged
merged 41 commits into from
Jan 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
2a7ee21
Use fewer colors in rustdoc UI
jsha Nov 21, 2021
c8e0f97
Change associated type to use link color
jsha Dec 8, 2021
3f517fb
Split CSS classes for "typedef" vs "associatedtype".
jsha Dec 10, 2021
799e067
Merge commit '97e504549371d7640cf011d266e3c17394fdddac' into sync_cg_…
bjorn3 Dec 20, 2021
eb158de
Merge branch 'sync_from_rust'
bjorn3 Dec 20, 2021
7762c7a
Fix schedule time
bjorn3 Dec 26, 2021
d3323fe
Test rustc tests with unstable features disabled
bjorn3 Dec 26, 2021
ad5966e
Run incremental rustc tests and update broken test list
bjorn3 Dec 26, 2021
9089c30
Remove TyCtxt dependency from UnwindContext
bjorn3 Dec 27, 2021
c40ac57
Add try_reserve for OsString
Xuanwo Dec 28, 2021
013fbc6
Fix windows build
Xuanwo Dec 28, 2021
27b92c9
Implement support in wtf8
Xuanwo Dec 28, 2021
0467c6a
Add y.bin.dSYM to .gitignore
bjorn3 Dec 28, 2021
9166428
Update library/std/src/ffi/os_str.rs
Xuanwo Dec 29, 2021
b07ae1c
Address comments
Xuanwo Dec 29, 2021
59bf63b
Add a couple needs-asm-support headers to tests
bjorn3 Dec 29, 2021
0dd3d28
Rename cargo executable to cargo-clif
bjorn3 Dec 30, 2021
7c62357
Deny warnings on CI
bjorn3 Dec 30, 2021
9bcdb53
Rustfmt
bjorn3 Dec 30, 2021
40e8846
Enforce rustfmt on CI
bjorn3 Dec 30, 2021
4b1a243
Allow false positive unreachable code warning
bjorn3 Dec 30, 2021
304a50b
Rustup to rustc 1.59.0-nightly (78fd0f633 2021-12-29)
bjorn3 Dec 30, 2021
6b4e640
Only deny warnings for cg_clif build itself
bjorn3 Dec 30, 2021
f6d0e14
Fix dead code warning on windows
bjorn3 Dec 30, 2021
f97670a
Don't enable optimizations in the dev profile
bjorn3 Dec 30, 2021
c63d8f3
Move incr comp enable to the build system
bjorn3 Dec 30, 2021
40b00f4
Disable incremental compilation on CI
bjorn3 Dec 30, 2021
a8e6d5b
Merge commit '40b00f4200fbdeefd11815398cb46394b8cb0a5e' into sync_cg_…
bjorn3 Dec 30, 2021
b77830d
Update browser-ui-test version to have assert-position command
GuillaumeGomez Dec 30, 2021
7c78ea5
Fix display of toggles on mobile
GuillaumeGomez Dec 29, 2021
1f62c24
Fix some copy/paste hysteresis in OsString try_reserve docs
dtolnay Dec 30, 2021
d29941e
Remove needless allocation from example code of OsString
dtolnay Dec 30, 2021
2eb637a
Extend check for UnsafeCell in consts to cover unions
tmiasko Oct 28, 2021
b1fbafd
rustbuild: Add support for a per-target default-linker option.
Apteryks Nov 29, 2021
ac1060e
Rollup merge of #90383 - tmiasko:union-validity, r=RalfJung
matthiaskrgr Dec 31, 2021
198fca8
Rollup merge of #91375 - Apteryks:per-target-default-linker, r=Mark-S…
matthiaskrgr Dec 31, 2021
72e36d4
Rollup merge of #91480 - jsha:fewer-colors, r=GuillaumeGomez
matthiaskrgr Dec 31, 2021
8322603
Rollup merge of #92338 - Xuanwo:try_reserve, r=dtolnay
matthiaskrgr Dec 31, 2021
81f5dbd
Rollup merge of #92405 - bjorn3:more_needs_inline_asm, r=lqd
matthiaskrgr Dec 31, 2021
4e4d258
Rollup merge of #92435 - bjorn3:sync_cg_clif-2021-12-30, r=bjorn3
matthiaskrgr Dec 31, 2021
2da54c7
Rollup merge of #92440 - GuillaumeGomez:fix-mobile-toggles, r=jsha
matthiaskrgr Dec 31, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions compiler/rustc_codegen_cranelift/.github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,21 @@ on:
- pull_request

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:
runs-on: ${{ matrix.os }}
timeout-minutes: 60
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Test nightly Cranelift
on:
push:
schedule:
- cron: '1 17 * * *' # At 01:17 UTC every day.
- cron: '17 1 * * *' # At 01:17 UTC every day.

jobs:
build:
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_codegen_cranelift/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ perf.data.old
*.events
*.string*
/y.bin
/y.bin.dSYM
/build
/build_sysroot/sysroot_src
/build_sysroot/compiler-builtins
Expand Down
19 changes: 0 additions & 19 deletions compiler/rustc_codegen_cranelift/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,31 +40,12 @@ unstable-features = ["jit", "inline_asm"]
jit = ["cranelift-jit", "libloading"]
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
# 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]
opt-level = 0
debug = false

[profile.dev.package.cranelift-codegen-meta]
opt-level = 0
debug = false

[profile.release.package.cranelift-codegen-meta]
opt-level = 0
debug = false
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_cranelift/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

```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.
Expand Down
31 changes: 19 additions & 12 deletions compiler/rustc_codegen_cranelift/build_system/build_backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,18 @@ pub(crate) fn build_backend(
let mut cmd = Command::new("cargo");
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 {
cmd.arg("--features").arg("unstable-features");
}
Expand All @@ -22,25 +34,20 @@ pub(crate) fn build_backend(
_ => unreachable!(),
}

// Set the rpath to make the cg_clif executable find librustc_codegen_cranelift without changing
// LD_LIBRARY_PATH
if cfg!(unix) {
if cfg!(target_os = "macos") {
cmd.env(
"RUSTFLAGS",
"-Csplit-debuginfo=unpacked \
rustflags += " -Csplit-debuginfo=unpacked \
-Clink-arg=-Wl,-rpath,@loader_path/../lib \
-Zosx-rpath-install-name"
.to_string()
+ env::var("RUSTFLAGS").as_deref().unwrap_or(""),
);
-Zosx-rpath-install-name";
} else {
cmd.env(
"RUSTFLAGS",
"-Clink-arg=-Wl,-rpath=$ORIGIN/../lib ".to_string()
+ env::var("RUSTFLAGS").as_deref().unwrap_or(""),
);
rustflags += " -Clink-arg=-Wl,-rpath=$ORIGIN/../lib ";
}
}

cmd.env("RUSTFLAGS", rustflags);

eprintln!("[BUILD] rustc_codegen_cranelift");
crate::utils::spawn_and_wait(cmd);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ pub(crate) fn build_sysroot(
// Build and copy cargo wrapper
let mut build_cargo_wrapper_cmd = Command::new("rustc");
build_cargo_wrapper_cmd
.arg("scripts/cargo.rs")
.arg("scripts/cargo-clif.rs")
.arg("-o")
.arg(target_dir.join("cargo"))
.arg(target_dir.join("cargo-clif"))
.arg("-g");
spawn_and_wait(build_cargo_wrapper_cmd);

Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_codegen_cranelift/docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

```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.
Expand All @@ -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.

```bash
$ $cg_clif_dir/build/cargo jit
$ $cg_clif_dir/build/cargo-clif jit
```

or
Expand All @@ -45,7 +45,7 @@ There is also an experimental lazy jit mode. In this mode functions are only com
first called.

```bash
$ $cg_clif_dir/build/cargo lazy-jit
$ $cg_clif_dir/build/cargo-clif lazy-jit
```

## Shell
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ fn call_return_u128_pair() {
return_u128_pair();
}

#[allow(unreachable_code)] // FIXME false positive
fn main() {
take_unique(Unique {
pointer: 0 as *const (),
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_cranelift/rust-toolchain
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "nightly-2021-12-20"
channel = "nightly-2021-12-30"
components = ["rust-src", "rustc-dev", "llvm-tools-preview"]
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
set -e

./y.rs build
./y.rs build --no-unstable-features
source scripts/config.sh

echo "[SETUP] Rust fork"
Expand Down
16 changes: 10 additions & 6 deletions compiler/rustc_codegen_cranelift/scripts/test_rustc_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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/issues/issue-33992.rs # unsupported linkages
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/mir/mir_misc_casts.rs # depends on deduplication of constants
rm src/test/ui/mir/mir_raw_fat_ptr.rs # same
Expand All @@ -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/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/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/unstable-flag-required # same
rm -r src/test/run-make/rustdoc-* # same
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 src/test/ui/json-bom-plus-crlf-multifile.rs # differing warning
Expand All @@ -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/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"
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
36 changes: 18 additions & 18 deletions compiler/rustc_codegen_cranelift/scripts/tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,73 +80,73 @@ function base_sysroot_tests() {

function extended_sysroot_tests() {
pushd rand
../build/cargo clean
../build/cargo-clif clean
if [[ "$HOST_TRIPLE" = "$TARGET_TRIPLE" ]]; then
echo "[TEST] rust-random/rand"
../build/cargo test --workspace
../build/cargo-clif test --workspace
else
echo "[AOT] rust-random/rand"
../build/cargo build --workspace --target $TARGET_TRIPLE --tests
../build/cargo-clif build --workspace --target $TARGET_TRIPLE --tests
fi
popd

pushd simple-raytracer
if [[ "$HOST_TRIPLE" = "$TARGET_TRIPLE" ]]; then
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" \
"../build/cargo build"
"../build/cargo-clif build"

echo "[BENCH RUN] ebobby/simple-raytracer"
cp ./target/debug/main ./raytracer_cg_clif
hyperfine --runs "${RUN_RUNS:-10}" ./raytracer_cg_llvm ./raytracer_cg_clif
else
../build/cargo clean
../build/cargo-clif clean
echo "[BENCH COMPILE] ebobby/simple-raytracer (skipped)"
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)"
fi
popd

pushd build_sysroot/sysroot_src/library/core/tests
echo "[TEST] libcore"
../../../../../build/cargo clean
../../../../../build/cargo-clif clean
if [[ "$HOST_TRIPLE" = "$TARGET_TRIPLE" ]]; then
../../../../../build/cargo test
../../../../../build/cargo-clif test
else
../../../../../build/cargo build --target $TARGET_TRIPLE --tests
../../../../../build/cargo-clif build --target $TARGET_TRIPLE --tests
fi
popd

pushd regex
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
# 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
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
diff -u res.txt examples/regexdna-output.txt
fi

if [[ "$HOST_TRIPLE" = "$TARGET_TRIPLE" ]]; then
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
echo "[AOT] rust-lang/regex tests"
../build/cargo build --tests --target $TARGET_TRIPLE
../build/cargo-clif build --tests --target $TARGET_TRIPLE
fi
popd

pushd portable-simd
echo "[TEST] rust-lang/portable-simd"
../build/cargo clean
../build/cargo build --all-targets --target $TARGET_TRIPLE
../build/cargo-clif clean
../build/cargo-clif build --all-targets --target $TARGET_TRIPLE
if [[ "$HOST_TRIPLE" = "$TARGET_TRIPLE" ]]; then
../build/cargo test -q
../build/cargo-clif test -q
fi
popd
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_cranelift/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ pub(crate) struct FunctionCx<'m, 'clif, 'tcx: 'm> {
pub(crate) module: &'m mut dyn Module,
pub(crate) tcx: TyCtxt<'tcx>,
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) instance: Instance<'tcx>,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_cranelift/src/debuginfo/emit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ impl WriterRelocate {
}

/// 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> {
for reloc in self.relocs.drain(..) {
match reloc.name {
Expand Down
18 changes: 7 additions & 11 deletions compiler/rustc_codegen_cranelift/src/debuginfo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::prelude::*;
use rustc_index::vec::IndexVec;

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::ValueLocRange;

Expand All @@ -23,15 +23,6 @@ use gimli::{Encoding, Format, LineEncoding, RunTimeEndian, X86_64};
pub(crate) use emit::{DebugReloc, DebugRelocName};
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> {
tcx: TyCtxt<'tcx>,

Expand Down Expand Up @@ -60,6 +51,11 @@ impl<'tcx> DebugContext<'tcx> {
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 producer = format!(
Expand Down Expand Up @@ -108,7 +104,7 @@ impl<'tcx> DebugContext<'tcx> {
DebugContext {
tcx,

endian: target_endian(tcx),
endian,

dwarf,
unit_range_list: RangeList(Vec::new()),
Expand Down
Loading