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

Handle -Xarch_<arch> <arg> for Clang #2265

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

torarnv
Copy link

@torarnv torarnv commented Oct 1, 2024

A new ArgDisposition is introduces that combines the Concatenated and Separated behaviors, but produces results similar to a plain Separated argument with the full original -Xarch_ argument.

Fixes #2090

ArgInfo::TakeArg(_s, create, ArgDisposition::ConcatenatedAndSeparated(_)) => {
if let Some(a) = get_next_arg() {
Argument::WithValue(
arg.to_string().leak(),
Copy link
Author

@torarnv torarnv Oct 1, 2024

Choose a reason for hiding this comment

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

I'm not a Rust developer, so hopefully there is a better way to pass arg here than to leak it 😅

Copy link
Collaborator

Choose a reason for hiding this comment

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

it would have been nice to investigate this before submitting the PR ;)

Copy link
Author

Choose a reason for hiding this comment

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

Believe me, I did. This is what I came up with in the end, and figured pushing a WIP so someone more knowledgeable in Rust could provide input. Would you rather I had given up on the patch and never submitted a PR instead because I couldn't come up with anything better? 🤷‍♂️

Copy link
Author

Choose a reason for hiding this comment

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

Or did you mean before landing/pushing it into master? If so, yes, we definitely want to solve that first 😅

@@ -176,6 +176,7 @@ counted_array!(pub static ARGS: [ArgInfo<gcc::ArgData>; _] = [
take_arg!("-MF", PathBuf, CanBeSeparated, DepArgumentPath),
take_arg!("-MQ", OsString, CanBeSeparated, DepTarget),
take_arg!("-MT", OsString, CanBeSeparated, DepTarget),
take_arg!("-Xarch", OsString, ConcatenatedAndSeparated('_'), PassThrough),
Copy link
Author

Choose a reason for hiding this comment

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

Is PassThough the right choice here? I only dealt with the mechanism of recognizing and processing the arg, but not the semantics of passing it and how that may affect the cache.

@sylvestre
Copy link
Collaborator

sylvestre commented Oct 1, 2024

thanks
It will need tests to make sure we don't regress

@torarnv
Copy link
Author

torarnv commented Oct 1, 2024

The test suite still passes for me locally, but I assume we want some test coverage for this as well.

@torarnv
Copy link
Author

torarnv commented Oct 1, 2024

I extended test_arginfo_process a bit

A new ArgDisposition is introduces that combines the Concatenated
and Separated behaviors, but produces results similar to a plain
Separated argument with the full original -Xarch_<arch> argument.

Fixes mozilla#2090
@sylvestre
Copy link
Collaborator

I extended test_arginfo_process a bit

i don't see it ?
and we will probably need a test in .github/workflows/integration-tests.yml

@codecov-commenter
Copy link

codecov-commenter commented Oct 2, 2024

Codecov Report

Attention: Patch coverage is 47.36842% with 10 lines in your changes missing coverage. Please review.

Project coverage is 40.65%. Comparing base (0cc0c62) to head (a1e95c2).
Report is 78 commits behind head on main.

Files with missing lines Patch % Lines
src/compiler/args.rs 53.33% 1 Missing and 6 partials ⚠️
src/compiler/diab.rs 0.00% 2 Missing ⚠️
src/compiler/gcc.rs 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2265      +/-   ##
==========================================
+ Coverage   30.91%   40.65%   +9.74%     
==========================================
  Files          53       54       +1     
  Lines       20112    20722     +610     
  Branches     9755     9628     -127     
==========================================
+ Hits         6217     8424    +2207     
- Misses       7922     8142     +220     
+ Partials     5973     4156    -1817     

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

Comment on lines +873 to +881
let info = take_arg!("-foo", OsString, ConcatenatedAndSeparated('_'), Foo);
assert_eq!(
info.clone().process("-foo_bar", || None).unwrap_err(),
ArgParseError::UnexpectedEndOfArgs
);
assert_eq!(
info.process("-foo_bar", || Some("baz".into())).unwrap(),
arg!(WithValue("-foo_bar", Foo("baz"), Separated))
);
Copy link
Author

Choose a reason for hiding this comment

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

@sylvestre Here :)

@torarnv
Copy link
Author

torarnv commented Oct 2, 2024

I extended test_arginfo_process a bit

i don't see it ?

See

and we will probably need a test in .github/workflows/integration-tests.yml

Do you have an example of an existing test I can base it on? Not sure where to start

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.

-Xarch Clang compiler option not supported
3 participants