Skip to content

Commit

Permalink
Fix assembly $RUSTC replacing
Browse files Browse the repository at this point in the history
  • Loading branch information
madsmtm committed Jul 31, 2023
1 parent a9b4418 commit 413929d
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,7 @@ l_anon.[ID].2:
.ascii "called `Option::unwrap()` on a `None` value"

l_anon.[ID].3:
.ascii "/Users/madsmarquart/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/std/src/sync/once.rs"
.ascii "$RUSTC/library/std/src/sync/once.rs"

.section __DATA,__const
.p2align 3, 0x0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ l_anon.[ID].2:
.ascii "called `Option::unwrap()` on a `None` value"

l_anon.[ID].3:
.ascii "/Users/madsmarquart/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/std/src/sync/once.rs"
.ascii "$RUSTC/library/std/src/sync/once.rs"

.section __DATA,__const
.p2align 2, 0x0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ l_anon.[ID].2:
.ascii "called `Option::unwrap()` on a `None` value"

l_anon.[ID].3:
.ascii "/Users/madsmarquart/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/std/src/sync/once.rs"
.ascii "$RUSTC/library/std/src/sync/once.rs"

.section __DATA,__const
.p2align 2, 0x0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ l_anon.[ID].2:
.ascii "called `Option::unwrap()` on a `None` value"

l_anon.[ID].3:
.ascii "/Users/madsmarquart/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/std/src/sync/once.rs"
.ascii "$RUSTC/library/std/src/sync/once.rs"

.section __DATA,__const
.p2align 2, 0x0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ l_anon.[ID].2:
.ascii "called `Option::unwrap()` on a `None` value"

l_anon.[ID].3:
.ascii "/Users/madsmarquart/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/std/src/sync/once.rs"
.ascii "$RUSTC/library/std/src/sync/once.rs"

.section __DATA,__const
.p2align 2, 0x0
Expand Down
10 changes: 10 additions & 0 deletions crates/test-assembly/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ pub fn read_assembly<P: AsRef<Path>>(path: P, package_path: &Path) -> io::Result
.as_os_str()
.to_str()
.unwrap();

// Replace paths
let s = s.replace(workspace_dir, "$WORKSPACE");
let s = s.replace(
package_path
Expand All @@ -79,6 +81,14 @@ pub fn read_assembly<P: AsRef<Path>>(path: P, package_path: &Path) -> io::Result
let s = regex::Regex::new(r"/rustc/[0-9a-f]*/")
.unwrap()
.replace_all(&s, |_: &regex::Captures| "$RUSTC/");
let s = regex::Regex::new(r"/.*/rustlib/src/rust/")
.unwrap()
.replace_all(&s, |_: &regex::Captures| "$RUSTC/");

// HACK: Make location data the same no matter which platform generated
// the data.
let s = s.replace(".asciz\t\"}", ".asciz\t\"t");

// HACK: Replace Objective-C image info for simulator targets
let s = s.replace(
".asciz\t\"\\000\\000\\000\\000`\\000\\000\"",
Expand Down

0 comments on commit 413929d

Please sign in to comment.