This is an archive of the discontinued LLVM Phabricator instance.

[llvm-ml] Add support for the -o flag
AbandonedPublic

Authored by ayzhao on Apr 5 2022, 5:45 PM.

Details

Reviewers
epastor
hans
Summary

Many LLVM tools, such as clang-cl, that accept the flag /Fo to specify
output files are also tolerant of the -o flag to do the same thing. To
maintain parity with these other tools, llvm-ml should also support -o.

As with clang-cl, if both /Fo and -o are specified, then /Fo takes
precedence[0].

[0]: https://github.com/llvm/llvm-project/blob/175b9af484f483c3423ab2f78db5de7e25b64c31/clang/lib/Driver/ToolChains/Clang.cpp#L987-L992

Diff Detail

Event Timeline

ayzhao created this revision.Apr 5 2022, 5:45 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 5 2022, 5:46 PM
ayzhao requested review of this revision.Apr 5 2022, 5:46 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 5 2022, 5:46 PM
epastor requested changes to this revision.Apr 5 2022, 6:21 PM
epastor added inline comments.
llvm/test/tools/llvm-ml/output_flag.asm
9–12

Since we expect the same output in all cases, I don't think we need three different prefixes?

Also, we should probably test that you actually get no output if outputting to /dev/null.

This revision now requires changes to proceed.Apr 5 2022, 6:21 PM
ayzhao updated this revision to Diff 420931.Apr 6 2022, 9:54 AM

Reduce the number of test prefixes and check output to /dev/null

ayzhao marked an inline comment as done.Apr 6 2022, 9:55 AM
hans added a comment.Apr 6 2022, 9:59 AM

For clang-cl we support -o because MSVC supports it (although in the VS 2019 version I have it causes a warning saying it's deprecated). Does MSVC's ml.exe or ml64.exe support -o?

ayzhao updated this revision to Diff 420937.Apr 6 2022, 10:17 AM

Append a newline to the end of output_flag.asm

For clang-cl we support -o because MSVC supports it (although in the VS 2019 version I have it causes a warning saying it's deprecated). Does MSVC's ml.exe or ml64.exe support -o?

ml64.exe doesn't support -o, but I think there's still some value in adding it to llvm-ml

  1. It keeps command line flags consistent with other LLVM tools
  2. When cross-compiling from *nix to Windows, having *nix-style flags can be beneficial as Windows style flags beginning with a forward slash look like file paths. I believe that this would make things less buggy.
epastor accepted this revision.Apr 6 2022, 11:23 AM

I'm fine with this and want to remove my request for changes - but please make sure Hans approves as well.

This revision is now accepted and ready to land.Apr 6 2022, 11:23 AM
hans added a comment.Apr 6 2022, 1:32 PM

For clang-cl we support -o because MSVC supports it (although in the VS 2019 version I have it causes a warning saying it's deprecated). Does MSVC's ml.exe or ml64.exe support -o?

ml64.exe doesn't support -o, but I think there's still some value in adding it to llvm-ml

  1. It keeps command line flags consistent with other LLVM tools
  2. When cross-compiling from *nix to Windows, having *nix-style flags can be beneficial as Windows style flags beginning with a forward slash look like file paths. I believe that this would make things less buggy.

I thought the purpose of llvm-ml was to act as a drop-in replacement of ml64.exe, in which case that's the command-line interface it should have. If we try make it support both ml64.exe's options and GNU as-inspired options at the same time, I worry we might en up with a bad interface.

Other llvm tools generally use a Unix-style interface, where the -o option is common, but this is not common for MSVC's tools. For clang-cl, we only added it because MSVC supports it and there was code that relied on it (see discussion in https://github.com/llvm/llvm-project/issues/21268). What's the use case for llvm-ml supporting -o?

As for using the forward slashes in cross-compiles from Unix to Windows, ml64.exe (like the other MSVC tools) also accept the flags with dashes, i.e. -Fo should work.

I guess the summary is that unless there's a compelling use case that needs llvm-ml to support -o, we should stick to the flags that ml64.exe uses.

For clang-cl we support -o because MSVC supports it (although in the VS 2019 version I have it causes a warning saying it's deprecated). Does MSVC's ml.exe or ml64.exe support -o?

ml64.exe doesn't support -o, but I think there's still some value in adding it to llvm-ml

  1. It keeps command line flags consistent with other LLVM tools
  2. When cross-compiling from *nix to Windows, having *nix-style flags can be beneficial as Windows style flags beginning with a forward slash look like file paths. I believe that this would make things less buggy.

I thought the purpose of llvm-ml was to act as a drop-in replacement of ml64.exe, in which case that's the command-line interface it should have. If we try make it support both ml64.exe's options and GNU as-inspired options at the same time, I worry we might en up with a bad interface.

Other llvm tools generally use a Unix-style interface, where the -o option is common, but this is not common for MSVC's tools. For clang-cl, we only added it because MSVC supports it and there was code that relied on it (see discussion in https://github.com/llvm/llvm-project/issues/21268). What's the use case for llvm-ml supporting -o?

As for using the forward slashes in cross-compiles from Unix to Windows, ml64.exe (like the other MSVC tools) also accept the flags with dashes, i.e. -Fo should work.

I guess the summary is that unless there's a compelling use case that needs llvm-ml to support -o, we should stick to the flags that ml64.exe uses.

I'll abandon this patch given that -Fo exists.

ayzhao abandoned this revision.Apr 11 2022, 3:49 PM