-
Notifications
You must be signed in to change notification settings - Fork 559
Fix is_flag_supported for assembly-specific flags #1632
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
base: main
Are you sure you want to change the base?
Fix is_flag_supported for assembly-specific flags #1632
Conversation
5265c16 to
da402eb
Compare
NobodyXu
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this PR!
just have some small nits, and I'd like feedback from others to ensure that this work on all compilers we need to support
| ) | ||
| } | ||
|
|
||
| fn ensure_check_file(&self) -> Result<PathBuf, Error> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that msvc/cl.exe may not support compiling file from stdin? cc @ChrisDenton
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i have updated, to use a hybrid approach:
For MSVC: Keep the filebased compilati on (creates flag_check.c/cpp/cu files)
For GCC/Clang: Use stdin compilation with -x <lang> ( like -xassembler-with-cpp)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks that'd absolutely work for major use cases, though it'd be great if it's more like a dynamic fallback.
From the top of my head, the nvcc/sccache/ccache maybe a problem.
For nvcc, it seems that
nvcc -x cu -Is needed.
And sccache does not support it at all, it's possible to use sccache with this crate
- by specifying an env, or
- configuring cargo to use it
- symlink/hardlink sccache to cc/gcc/clang etc in /usr/local/bin
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that msvc/cl.exe may not support compiling file from stdin? cc @ChrisDenton
That is correct. I don't if there's some clever way to trick it into doing so but I doubt it.
…ted() Changed flag validation from file-based to stdin-based compilation to support language-selection flags like -xassembler-with-cpp. This also improves flag validation by ensuring invalid flags are properly rejected. - Use stdin compilation with explicit language for most flags - For -x flags, let the flag determine the language - Add -Werror=unknown-warning-option for clang to reject invalid -W flags - Remove unused ensure_check_file() method - Add regression test for assembly flags
da402eb to
bbc61bd
Compare
Fixed a 7-year-old bug where
is_flag_supported()failed with assembly flags like-xassembler-with-cpp.The issue? It was testing flags against C files. Now it uses stdin compilation for GNU/Clang, avoiding file extension problems entirely.
Added regression test to prevent this from breaking again.
Fixes #359