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

Detect rustc(drivers) more precisely #1897

Closed
wants to merge 2 commits into from

Conversation

sagudev
Copy link
Contributor

@sagudev sagudev commented Oct 7, 2023

If we are not sure it's rustc like and we check -vV output to accept valid rustc drivers.

Fixes #861

@sagudev sagudev marked this pull request as ready for review October 7, 2023 06:42
@codecov-commenter
Copy link

codecov-commenter commented Oct 7, 2023

Codecov Report

Attention: 125 lines in your changes are missing coverage. Please review.

Comparison is base (abbd88e) 31.00% compared to head (0bf8ee2) 30.55%.

❗ Current head 0bf8ee2 differs from pull request most recent head 1a58db1. Consider uploading reports for the commit 1a58db1 to get more accurate results

Files Patch % Lines
src/compiler/compiler.rs 28.07% 17 Missing and 106 partials ⚠️
src/test/tests.rs 33.33% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1897      +/-   ##
==========================================
- Coverage   31.00%   30.55%   -0.46%     
==========================================
  Files          52       51       -1     
  Lines       19753    19254     -499     
  Branches     9506     9238     -268     
==========================================
- Hits         6125     5883     -242     
+ Misses       7925     7731     -194     
+ Partials     5703     5640      -63     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sagudev
Copy link
Contributor Author

sagudev commented Oct 7, 2023

Aarch fails on unrelated error (installation of musl).

@Xuanwo
Copy link
Collaborator

Xuanwo commented Oct 7, 2023

Aarch fails on unrelated error (installation of musl).

Yep. It's unrelated. I'm working on the fix. Please ignore it for now. Thanks for the patience.

src/compiler/compiler.rs Outdated Show resolved Hide resolved
src/compiler/compiler.rs Outdated Show resolved Hide resolved
src/compiler/compiler.rs Outdated Show resolved Hide resolved
src/compiler/compiler.rs Outdated Show resolved Hide resolved
@drahnr
Copy link
Collaborator

drahnr commented Oct 17, 2023

I have yet to do a full review.

@sagudev
Copy link
Contributor Author

sagudev commented Oct 18, 2023

I squashed all commits as they were not meant to be reviewed separately. I also updated verify_rust_compiler to not depend on must_be_rust and moved this logic back to detect_compiler

src/compiler/compiler.rs Outdated Show resolved Hide resolved
@sagudev
Copy link
Contributor Author

sagudev commented Nov 27, 2023

rebased

@drahnr
Copy link
Collaborator

drahnr commented Jan 23, 2024

I'll do a full review as soon as all CI steps went green

@sagudev
Copy link
Contributor Author

sagudev commented Jan 25, 2024

src/compiler/compiler.rs Outdated Show resolved Hide resolved
if stdout.starts_with("rustc ") {
return Ok(stdout);
}
if !must_be_rust && is_like_c_compiler(&rustc_executable) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't see the need for the must_be_rust. I do not understand why we go back to mutable state if we can use scoped Option<PathBuf> if there is a rustc-like or None, and use that to determine the full compiler path or fallback to c_compiler.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is to be compatible with current behavior. If name of compiler is rustc and we cannot detect it we fast fail (we do not try it for c compiler).

Copy link
Collaborator

Choose a reason for hiding this comment

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

That may be, but it can be expressed more concisely.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So, should I just change behavior and simply code or express it differently (currently have no idea how)?

"",
"gcc: error: unrecognized command-line option '-vV'; did you mean '-v'?",
)),
);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Iirc, the result will be cached, so the impact of another resolution call is very small, even for small projects. Correct me if I am wrong.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this comment to #1897 (comment)?

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is a principled question, if we incur much overhead for the compiler resolution with this changeset.

Copy link
Contributor Author

@sagudev sagudev Jan 25, 2024

Choose a reason for hiding this comment

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

I am not sure, to be honest. But if the results are cached then it should be ok.

Copy link
Collaborator

@drahnr drahnr left a comment

Choose a reason for hiding this comment

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

I don't particularly like the use mutable bool variables in deciding the compiler. There is an outstanding question on the efficiency of test runs and ifwe can assume -vV is unique to rust.

@sagudev
Copy link
Contributor Author

sagudev commented Jan 25, 2024

if we can assume -vV is unique to rust.

Even if it is not we try to parse the result and if it does not contain rustc(-drivers) specific output we know it is not rusty.

@sylvestre
Copy link
Collaborator

sylvestre commented Feb 20, 2024

moved into a different PR #1897

@sylvestre sylvestre closed this Feb 20, 2024
sylvestre pushed a commit that referenced this pull request Feb 23, 2024
* compiler: Add an additional fallback attempt if no vanilla rustc or known cc was found

Fixes #861


Co-authored-by: sagudev <16504129+sagudev@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support arbitrary rustc drivers
5 participants