-
Notifications
You must be signed in to change notification settings - Fork 552
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
Support both -arg and /arg with msvc/clang-cl without altering paths #674
Conversation
34c6f9a added support for /arg flags by replacing the initial slash with a -, and falling back to normal argument parsing. Unfortunately, when running clang-cl on a non-Windows system, that means absolute paths get garbled, and that can lead to bad argument parsing with separate arguments (e.g. -I /absolute/path). We change the arguments definition for MSVC to include both styles, by hacking up a macro that generates two lists, one with - arguments, and one with / arguments. Merging the two lists at build time doesn't seem possible without going full procedural macro. Fixes mozilla#669
Doesn't this achieve what you want? diff --git a/src/compiler/msvc.rs b/src/compiler/msvc.rs
index 3302856..7197b8c 100644
--- a/src/compiler/msvc.rs
+++ b/src/compiler/msvc.rs
@@ -229,8 +229,10 @@ use self::ArgData::*;
macro_rules! msvc_args {
(static ARGS: [$t:ty; _] = [$($macro:ident ! ($($v:tt)*),)*]) => {
- counted_array!(static ARGS: [$t; _] = [$(msvc_args!(@one "-", $macro!($($v)*)),)*]);
- counted_array!(static SLASH_ARGS: [$t; _] = [$(msvc_args!(@one "/", $macro!($($v)*)),)*]);
+ counted_array!(static ARGS: [$t; _] = [
+ $(msvc_args!(@one "-", $macro!($($v)*)),)*
+ $(msvc_args!(@one "/", $macro!($($v)*)),)*
+ ]);
};
(@one $prefix:expr, msvc_take_arg!($s:expr, $($t:tt)*)) => {
take_arg!(concat!($prefix, $s), $($t)+)
@@ -284,7 +286,7 @@ pub fn parse_arguments(
let mut show_includes = false;
let mut xclangs: Vec<OsString> = vec![];
- for arg in ArgsIter::new(arguments.iter().cloned(), (&ARGS[..], &SLASH_ARGS[..])) {
+ for arg in ArgsIter::new(arguments.iter().cloned(), &ARGS[..]) {
let arg = try_or_cannot_cache!(arg, "argument parse");
match arg.get_data() {
Some(TooHardFlag) | Some(TooHard(_)) | Some(TooHardPath(_)) => { |
This doesn't work because of the requirement of |
We're using a binary search in |
Caching is broken for commands like
But if I change to
|
Please open a new issue. |
@glandium No problem. |
mozilla#674 broke caching for msvc /foo style arguments that weren't handled in our arg list. So let's expand that list. Fixes mozilla#725.
mozilla#674 broke caching for msvc /foo style arguments that weren't handled in our arg list. So let's expand that list. Fixes mozilla#725.
34c6f9a added support for /arg flags by replacing the initial slash with
a -, and falling back to normal argument parsing. Unfortunately, when
running clang-cl on a non-Windows system, that means absolute paths get
garbled, and that can lead to bad argument parsing with separate
arguments (e.g. -I /absolute/path).
We change the arguments definition for MSVC to include both styles, by
hacking up a macro that generates two lists, one with - arguments, and
one with / arguments. Merging the two lists at build time doesn't seem
possible without going full procedural macro.
Fixes #669