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

strip -Wlinker-messages wrappers from rust-lld rmake test #138052

Merged
merged 1 commit into from
Mar 12, 2025
Merged
Changes from all commits
Commits
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
5 changes: 3 additions & 2 deletions tests/run-make/rust-lld/rmake.rs
Original file line number Diff line number Diff line change
@@ -60,7 +60,8 @@ fn main() {
}

fn find_lld_version_in_logs(stderr: String) -> bool {
let lld_version_re =
Regex::new(r"^warning: linker std(out|err): LLD [0-9]+\.[0-9]+\.[0-9]+").unwrap();
// Strip the `-Wlinker-messages` wrappers prefixing the linker output.
let stderr = Regex::new(r"warning: linker std(out|err):").unwrap().replace_all(&stderr, "");
let lld_version_re = Regex::new(r"^LLD [0-9]+\.[0-9]+\.[0-9]+").unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it would be enough to use a single regex Regex::new(r"^.*LLD [0-9]+\.[0-9]+\.[0-9]+").unwrap()

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. It's specifically looking for a line version in the output, not a prefix, otherwise it could be searching the entire stderr. I did it this way because I found it likely the message wrapper stripping will be moved in run_make_support once it's solidified, esp if we encounter more searching in linker output in the future. So while I'm not particularly convinced, I'm also not too invested in any approach either.

Copy link
Member

@jieyouxu jieyouxu Mar 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't say I'm a huge fan of this regex (before or after) since it really does feel fragile (we're doing text processing on the human-readable output of lld but with the rustc -Wlinker-messages wrappers on top, which together can totally change between lld versions since there AFAIK reasonably has no stability guarantee on that specific shape). But it does seem like we would want to test -Wlinker-messages so...

stderr.lines().any(|line| lld_version_re.is_match(line.trim()))
}
Loading