Skip to content

Commit

Permalink
Fix is_flag_supported and create_compile_object_cmd
Browse files Browse the repository at this point in the history
Signed-off-by: Jiahao XU <[email protected]>
  • Loading branch information
NobodyXu committed Mar 30, 2024
1 parent f573a66 commit 6e72ff5
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 23 deletions.
25 changes: 14 additions & 11 deletions src/command_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,17 +385,20 @@ for help)"
}
}

pub(crate) fn command_add_output_file(
cmd: &mut Command,
dst: &Path,
cuda: bool,
msvc: bool,
clang: bool,
gnu: bool,
is_asm: bool,
is_arm: bool,
) {
if msvc && !clang && !gnu && !cuda && !(is_asm && is_arm) {
pub(crate) struct CmdAddOutputFileArgs {
pub(crate) cuda: bool,
pub(crate) is_assembler_msvc: bool,
pub(crate) msvc: bool,
pub(crate) clang: bool,
pub(crate) gnu: bool,
pub(crate) is_asm: bool,
pub(crate) is_arm: bool,
}

pub(crate) fn command_add_output_file(cmd: &mut Command, dst: &Path, args: CmdAddOutputFileArgs) {
if args.is_assembler_msvc
|| (args.msvc && !args.clang && !args.gnu && !args.cuda && !(args.is_asm && args.is_arm))
{
let mut s = OsString::from("-Fo");
s.push(dst);
cmd.arg(s);
Expand Down
30 changes: 18 additions & 12 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -637,12 +637,15 @@ impl Build {
command_add_output_file(
&mut cmd,
&obj,
self.cuda,
target.contains("msvc"),
clang,
gnu,
false,
is_arm,
CmdAddOutputFileArgs {
cuda: self.cuda,
is_assembler_msvc: false,
msvc: compiler.is_like_msvc(),
clang,
gnu,
is_asm: false,
is_arm,
},
);

// Checking for compiler flags does not require linking
Expand Down Expand Up @@ -1605,12 +1608,15 @@ impl Build {
command_add_output_file(
&mut cmd,
&obj.dst,
self.cuda,
is_assembler_msvc || compiler.is_like_msvc(),
clang,
gnu,
is_asm,
is_arm,
CmdAddOutputFileArgs {
cuda: self.cuda,
is_assembler_msvc,
msvc: compiler.is_like_msvc(),
clang,
gnu,
is_asm,
is_arm,
},
);
// armasm and armasm64 don't requrie -c option
if !is_assembler_msvc || !is_arm {
Expand Down

0 comments on commit 6e72ff5

Please sign in to comment.