Skip to content

Conversation

@naoNao89
Copy link
Contributor

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

@naoNao89 naoNao89 force-pushed the fix-issue-359-is-flag-supported-assembly branch 3 times, most recently from 5265c16 to da402eb Compare December 16, 2025 13:01
Copy link
Contributor

@NobodyXu NobodyXu left a 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> {
Copy link
Contributor

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

Copy link
Contributor Author

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)

Copy link
Contributor

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

Copy link
Member

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
@naoNao89 naoNao89 force-pushed the fix-issue-359-is-flag-supported-assembly branch from da402eb to bbc61bd Compare December 17, 2025 12:09
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.

is_flag_supported only works for C sources

3 participants