Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions src/compiler/msvc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ ArgData! {
ClangModuleFile(OsString),
ClangModuleOutput(OsString),
ClangLanguage(OsString),
ClangProfileUse(PathBuf),
}

use self::ArgData::*;
Expand Down Expand Up @@ -546,6 +547,8 @@ msvc_args!(static ARGS: [ArgInfo<ArgData>; _] = [
msvc_flag!("forceInterlockedFunctions-", PassThrough),
msvc_take_arg!("fp:", OsString, Concatenated, PassThroughWithSuffix),
msvc_take_arg!("fpcvt:", OsString, Concatenated, PassThroughWithSuffix),
msvc_take_arg!("fprofile-instr-use", PathBuf, Concatenated(b'='), ClangProfileUse),
msvc_take_arg!("fprofile-use", PathBuf, Concatenated(b'='), ClangProfileUse),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

what about -fprofile-instr-generate passed directly? it still won't set profile_generate like the -clang: path does.
could be a follow-up

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

see new PR #3074

msvc_flag!("fsanitize-address-asan-compat-lib", PassThrough),
msvc_flag!("fsanitize-address-use-after-return", PassThrough),
msvc_take_arg!("fsanitize-blacklist", PathBuf, Concatenated(b'='), ExtraHashFile),
Expand Down Expand Up @@ -752,6 +755,12 @@ pub fn parse_arguments(
}
Some(ClangModuleOutput(p)) if !p.is_empty() => module_output = Some(PathBuf::from(p)),
Some(ClangLanguage(lang)) if is_clang && lang == "c++-module" => cxx_module = true,
Some(ClangProfileUse(path)) if is_clang => {
extra_hash_files.push(clang::resolve_profile_use_path(path, cwd));
}
Some(ClangProfileUse(_)) => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

could be merged with the ClangModuleFile(_) | ClangModuleOutput(_) | ClangLanguage(_) arm below, no?

follow up is fine too

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

same, see PR #3074

cannot_cache!(arg.flag_str().expect("Profile-use flag expected"))
}
Some(ClangModuleFile(_)) | Some(ClangModuleOutput(_)) | Some(ClangLanguage(_)) => {
cannot_cache!(arg.flag_str().expect("Can't be Argument::Raw/UnknownFlag"))
}
Expand Down Expand Up @@ -782,6 +791,7 @@ pub fn parse_arguments(
.iter_os_strings(),
),
Some(ProgramDatabase(_))
| Some(ClangProfileUse(_))
| Some(ClangModuleFile(_))
| Some(ClangModuleOutput(_))
| Some(ClangLanguage(_))
Expand Down Expand Up @@ -2182,6 +2192,25 @@ mod test {
}
}

#[test]
fn test_parse_arguments_clang_profile_use() {
let cwd = std::env::current_dir().unwrap();
for flag in ["-fprofile-instr-use", "-fprofile-use"] {
let option = format!("{flag}=profile.profdata");
let args = ovec!["-c", "foo.c", option.clone()];
let parsed = match parse_arguments_clang(args.clone()) {
CompilerArguments::Ok(parsed) => parsed,
other => panic!("Unexpected parse result: {other:?}"),
};
assert_eq!(parsed.common_args, ovec![option]);
assert_eq!(parsed.extra_hash_files, vec![cwd.join("profile.profdata")]);
assert!(matches!(
parse_arguments(args),
CompilerArguments::CannotCache(..)
));
}
}

#[test]
fn test_parse_arguments_clang_passthrough() {
let args = ovec![
Expand Down
Loading