Skip to content

Commit

Permalink
Order flags correctly
Browse files Browse the repository at this point in the history
Signed-off-by: Gavin Zhao <git@gzgz.dev>
  • Loading branch information
GZGavinZhao committed Feb 6, 2024
1 parent 8bf5652 commit 68b2b45
Showing 1 changed file with 66 additions and 4 deletions.
70 changes: 66 additions & 4 deletions src/compiler/clang.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ impl CCompilerImpl for Clang {

counted_array!(pub static ARGS: [ArgInfo<gcc::ArgData>; _] = [
take_arg!("--dependent-lib", OsString, Concatenated('='), PassThrough),
take_arg!("--hip-device-lib-path", PathBuf, Concatenated('='), PassThroughPath),
take_arg!("--hip-path", PathBuf, Concatenated('='), PassThroughPath),
take_arg!("--rocm-path", PathBuf, Concatenated('='), PassThroughPath),
take_arg!("--serialize-diagnostics", OsString, Separated, PassThrough),
take_arg!("--target", OsString, Separated, PassThrough),
// Note: for clang we must override the dep options from gcc.rs with `CanBeSeparated`.
Expand All @@ -181,7 +184,7 @@ counted_array!(pub static ARGS: [ArgInfo<gcc::ArgData>; _] = [
flag!("-fcolor-diagnostics", DiagnosticsColorFlag),
flag!("-fcxx-modules", TooHardFlag),
take_arg!("-fdebug-compilation-dir", OsString, Separated, PassThrough),
take_arg!("-fembed-offload-object", PathBuf, Concatenated, ExtraHashFile),
take_arg!("-fembed-offload-object", PathBuf, Concatenated('='), ExtraHashFile),
flag!("-fmodules", TooHardFlag),
flag!("-fno-color-diagnostics", NoDiagnosticsColorFlag),
flag!("-fno-pch-timestamp", PassThroughFlag),
Expand All @@ -197,14 +200,11 @@ counted_array!(pub static ARGS: [ArgInfo<gcc::ArgData>; _] = [
flag!("-fuse-ctor-homing", PassThroughFlag),
take_arg!("-gcc-toolchain", OsString, Separated, PassThrough),
flag!("-gcodeview", PassThroughFlag),
take_arg!("--hip-path", PathBuf, Concatenated, PassThroughPath),
take_arg!("--hip-device-lib-path", PathBuf, Concatenated, PassThroughPath),
take_arg!("-include-pch", PathBuf, CanBeSeparated, PreprocessorArgumentPath),
take_arg!("-load", PathBuf, Separated, ExtraHashFile),
take_arg!("-mllvm", OsString, Separated, PassThrough),
flag!("-no-opaque-pointers", PreprocessorArgumentFlag),
take_arg!("-plugin-arg", OsString, Concatenated('-'), PassThrough),
take_arg!("--rocm-path", PathBuf, Concatenated, PassThroughPath),
take_arg!("-target", OsString, Separated, PassThrough),
flag!("-verify", PreprocessorArgumentFlag),
take_arg!("/winsysroot", PathBuf, CanBeSeparated, PassThroughPath),
Expand Down Expand Up @@ -489,6 +489,68 @@ mod test {
assert_eq!(ovec!["--offload-arch=gfx900"], b.common_args);
}

#[test]
fn test_parse_arguments_hip_paths() {
let a = parses!(
"-c",
"foo.cpp",
"-x",
"hip",
"--offload-arch=gfx900",
"-o",
"foo.o",
"--hip-path=/usr"
);
assert_eq!(Some("foo.cpp"), a.input.to_str());
assert_eq!(Language::Hip, a.language);
assert_map_contains!(
a.outputs,
(
"obj",
ArtifactDescriptor {
path: PathBuf::from("foo.o"),
optional: false
}
)
);
assert!(a.preprocessor_args.is_empty());
assert_eq!(
ovec!["--offload-arch=gfx900", "--hip-path=/usr"],
a.common_args
);

let b = parses!(
"-c",
"foo.cpp",
"-x",
"hip",
"--offload-arch=gfx900",
"-o",
"foo.o",
"--hip-device-lib-path=/usr/lib64/amdgcn/bitcode"
);
assert_eq!(Some("foo.cpp"), b.input.to_str());
assert_eq!(Language::Hip, b.language);
assert_map_contains!(
b.outputs,
(
"obj",
ArtifactDescriptor {
path: PathBuf::from("foo.o"),
optional: false
}
)
);
assert!(b.preprocessor_args.is_empty());
assert_eq!(
ovec![
"--offload-arch=gfx900",
"--hip-device-lib-path=/usr/lib64/amdgcn/bitcode"
],
b.common_args
);
}

#[test]
fn test_dependent_lib() {
let a = parses!(
Expand Down

0 comments on commit 68b2b45

Please sign in to comment.