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 9 pull requests #125938

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
c8390cd
Show files produced by --emit foo in json artifact notifications
pacak Apr 6, 2024
fc1e52a
Add tracking issue and unstable book page for `"vectorcall"` ABI
beetrees Apr 28, 2024
a126c11
Reorder the TOC so that targets are put under their meta-group
Lokathor May 28, 2024
f646314
make the fact that arm-none-eabi is a group of targets the first thin…
Lokathor May 28, 2024
144adf6
update armv4t docs
Lokathor May 28, 2024
d8704b9
It's spelled "ARM", in all caps.
Lokathor May 28, 2024
bb1f5c3
delete the offending single space.
Lokathor May 28, 2024
94d4040
The modern styling is apparently to use Title Case for the chip/compa…
Lokathor May 31, 2024
c3de4b3
Handle all GVN binops in a single place.
cjgillot Jun 2, 2024
b320ac7
Add a regression test for a former blanket impl synthesis ICE
fmease Jun 3, 2024
f152e2c
Revert "Cache whether a body has inline consts"
oli-obk Jun 3, 2024
c9e50ae
Revert "Create const block DefIds in typeck instead of ast lowering"
oli-obk Jun 3, 2024
0d88bf2
Add regression test
oli-obk Jun 3, 2024
4576027
Remove stray "this"
tbu- Jun 3, 2024
66a1386
Fix ICE caused by ignoring EffectVars in type inference
ajwock Jun 1, 2024
d392c50
Ignore `vec_deque_alloc_error::test_shrink_to_unwind` test on non-unw…
Veykril Jun 3, 2024
16c670c
Rollup merge of #122597 - pacak:master, r=bjorn3
matthiaskrgr Jun 3, 2024
ce4842c
Rollup merge of #124486 - beetrees:vectorcall-tracking-issue, r=ehuss
matthiaskrgr Jun 3, 2024
e68ab49
Rollup merge of #125690 - Lokathor:arm-maintainer-reorg, r=ehuss
matthiaskrgr Jun 3, 2024
183ad51
Rollup merge of #125865 - ajwock:ice_not_fully_resolved, r=fee1-dead
matthiaskrgr Jun 3, 2024
765f55c
Rollup merge of #125893 - cjgillot:gvn-newops, r=oli-obk
matthiaskrgr Jun 3, 2024
0b0dc46
Rollup merge of #125909 - fmease:rustdoc-add-test-synth-blanket-impls…
matthiaskrgr Jun 3, 2024
8e9737a
Rollup merge of #125918 - oli-obk:const_block_ice, r=compiler-errors
matthiaskrgr Jun 3, 2024
7f15094
Rollup merge of #125919 - tbu-:pr_fix_typo, r=lqd
matthiaskrgr Jun 3, 2024
198b58b
Rollup merge of #125927 - ferrocene:lw-alloc-unwind-test, r=pietroalbini
matthiaskrgr Jun 3, 2024
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
23 changes: 23 additions & 0 deletions compiler/rustc_codegen_cranelift/src/driver/aot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,29 @@ fn produce_final_output_artifacts(
}
}

if sess.opts.json_artifact_notifications {
if codegen_results.modules.len() == 1 {
codegen_results.modules[0].for_each_output(|_path, ty| {
if sess.opts.output_types.contains_key(&ty) {
let descr = ty.shorthand();
// for single cgu file is renamed to drop cgu specific suffix
// so we regenerate it the same way
let path = crate_output.path(ty);
sess.dcx().emit_artifact_notification(path.as_path(), descr);
}
});
} else {
for module in &codegen_results.modules {
module.for_each_output(|path, ty| {
if sess.opts.output_types.contains_key(&ty) {
let descr = ty.shorthand();
sess.dcx().emit_artifact_notification(&path, descr);
}
});
}
}
}

// We leave the following files around by default:
// - #crate#.o
// - #crate#.crate.metadata.o
Expand Down
23 changes: 23 additions & 0 deletions compiler/rustc_codegen_ssa/src/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,29 @@ fn produce_final_output_artifacts(
}
}

if sess.opts.json_artifact_notifications {
if compiled_modules.modules.len() == 1 {
compiled_modules.modules[0].for_each_output(|_path, ty| {
if sess.opts.output_types.contains_key(&ty) {
let descr = ty.shorthand();
// for single cgu file is renamed to drop cgu specific suffix
// so we regenerate it the same way
let path = crate_output.path(ty);
sess.dcx().emit_artifact_notification(path.as_path(), descr);
}
});
} else {
for module in &compiled_modules.modules {
module.for_each_output(|path, ty| {
if sess.opts.output_types.contains_key(&ty) {
let descr = ty.shorthand();
sess.dcx().emit_artifact_notification(&path, descr);
}
});
}
}
}

// We leave the following files around by default:
// - #crate#.o
// - #crate#.crate.metadata.o
Expand Down
18 changes: 18 additions & 0 deletions compiler/rustc_codegen_ssa/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,24 @@ pub struct CompiledModule {
pub llvm_ir: Option<PathBuf>, // --emit=llvm-ir, llvm-bc is in bytecode
}

impl CompiledModule {
/// Call `emit` function with every artifact type currently compiled
pub fn for_each_output(&self, mut emit: impl FnMut(&Path, OutputType)) {
if let Some(path) = self.object.as_deref() {
emit(path, OutputType::Object);
}
if let Some(path) = self.bytecode.as_deref() {
emit(path, OutputType::Bitcode);
}
if let Some(path) = self.llvm_ir.as_deref() {
emit(path, OutputType::LlvmAssembly);
}
if let Some(path) = self.assembly.as_deref() {
emit(path, OutputType::Assembly);
}
}
}

pub struct CachedModuleCodegen {
pub name: String,
pub source: WorkProduct,
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_mir_transform/src/dump_mir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ pub fn emit_mir(tcx: TyCtxt<'_>) -> io::Result<()> {
OutFileName::Real(path) => {
let mut f = io::BufWriter::new(File::create(&path)?);
write_mir_pretty(tcx, None, &mut f)?;
if tcx.sess.opts.json_artifact_notifications {
tcx.dcx().emit_artifact_notification(&path, "mir");
}
}
}
Ok(())
Expand Down
8 changes: 7 additions & 1 deletion src/doc/rustc/src/json.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@ Diagnostics have the following format:
Artifact notifications are emitted when the [`--json=artifacts`
flag][option-json] is used. They indicate that a file artifact has been saved
to disk. More information about emit kinds may be found in the [`--emit`
flag][option-emit] documentation.
flag][option-emit] documentation. Notifications can contain more than one file
for each type, for example when using multiple codegen units.

```javascript
{
Expand All @@ -229,6 +230,11 @@ flag][option-emit] documentation.
- "link": The generated crate as specified by the crate-type.
- "dep-info": The `.d` file with dependency information in a Makefile-like syntax.
- "metadata": The Rust `.rmeta` file containing metadata about the crate.
- "asm": The `.s` file with generated assembly
- "llvm-ir": The `.ll` file with generated textual LLVM IR
- "llvm-bc": The `.bc` file with generated LLVM bitcode
- "mir": The `.mir` file with rustc's mid-level intermediate representation.
- "obj": The `.o` file with generated native object code
*/
"emit": "link"
}
Expand Down
21 changes: 21 additions & 0 deletions tests/run-make/notify-all-emit-artifacts/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
fn one() -> usize {
1
}

pub mod a {
pub fn two() -> usize {
::one() + ::one()
}
}

pub mod b {
pub fn three() -> usize {
::one() + ::a::two()
}
}

#[inline(never)]
pub fn main() {
a::two();
b::three();
}
45 changes: 45 additions & 0 deletions tests/run-make/notify-all-emit-artifacts/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// rust should produce artifact notifications about files it was asked to --emit.
//
// It should work in incremental mode both on the first pass where files are generated as well
// as on subsequent passes where they are taken from the incremental cache
//
// See <https://internals.rust-lang.org/t/easier-access-to-files-generated-by-emit-foo/20477>
extern crate run_make_support;

use run_make_support::{rustc, tmp_dir};

fn main() {
let inc_dir = tmp_dir();

// With single codegen unit files are renamed to match the source file name
for _ in 0..=1 {
let output = rustc()
.input("lib.rs")
.emit("obj,asm,llvm-ir,llvm-bc,mir")
.codegen_units(1)
.json("artifacts")
.error_format("json")
.incremental(&inc_dir)
.run();
let stderr = String::from_utf8_lossy(&output.stderr);
for file in &["lib.o", "lib.ll", "lib.bc", "lib.s"] {
assert!(stderr.contains(file), "No {:?} in {:?}", file, stderr);
}
}

// with multiple codegen units files keep codegen unit id part.
for _ in 0..=1 {
let output = rustc()
.input("lib.rs")
.emit("obj,asm,llvm-ir,llvm-bc,mir")
.codegen_units(2)
.json("artifacts")
.error_format("json")
.incremental(&inc_dir)
.run();
let stderr = String::from_utf8_lossy(&output.stderr);
for file in &["rcgu.o", "rcgu.ll", "rcgu.bc", "rcgu.s"] {
assert!(stderr.contains(file), "No {:?} in {:?}", file, stderr);
}
}
}