[llvm] [ms] [llvm-ml] Add llvm-ml64 alias (PR #131854)
Eric Astor via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 19 12:02:08 PDT 2025
https://github.com/ericastor updated https://github.com/llvm/llvm-project/pull/131854
>From 1f6fb2d73ff1caa7bba5ae80f88c415135ae64a5 Mon Sep 17 00:00:00 2001
From: Eric Astor <epastor at google.com>
Date: Tue, 18 Mar 2025 16:21:20 +0000
Subject: [PATCH 1/5] [ms] [llvm-ml] Add llvm-ml64 alias
Rather than requiring users to pass `-m64` to the `llvm-ml` driver to get 64-bit behavior, we add the `llvm-ml64` alias, matching the behavior of `ML.EXE` and `ML64.EXE`.
The original flavor/bitness flags still work, but the alias should make some workflows easier.
---
llvm/test/tools/llvm-ml/dot_operator.asm | 2 +-
llvm/test/tools/llvm-ml/extern.asm | 4 ++--
llvm/test/tools/llvm-ml/feat00.asm | 8 ++++----
llvm/test/tools/llvm-ml/feat00_override.asm | 6 +++---
llvm/test/tools/llvm-ml/indirect_branch.asm | 4 ++--
llvm/test/tools/llvm-ml/macro.asm | 2 +-
llvm/test/tools/llvm-ml/ml32-context.asm | 2 +-
llvm/test/tools/llvm-ml/nested_proc.asm | 4 ++--
llvm/test/tools/llvm-ml/proc.asm | 4 ++--
llvm/test/tools/llvm-ml/proc_frame.asm | 2 +-
llvm/test/tools/llvm-ml/repeat_directives.asm | 2 +-
llvm/test/tools/llvm-ml/rip_relative_addressing.asm | 4 ++--
llvm/test/tools/llvm-ml/strings_errors.asm | 2 +-
llvm/test/tools/llvm-ml/struct.asm | 2 +-
llvm/tools/llvm-ml/CMakeLists.txt | 3 +++
15 files changed, 27 insertions(+), 24 deletions(-)
diff --git a/llvm/test/tools/llvm-ml/dot_operator.asm b/llvm/test/tools/llvm-ml/dot_operator.asm
index 37f753eeba513..006c6baaec909 100644
--- a/llvm/test/tools/llvm-ml/dot_operator.asm
+++ b/llvm/test/tools/llvm-ml/dot_operator.asm
@@ -1,4 +1,4 @@
-; RUN: llvm-ml -m64 -filetype=s %s /Fo - | FileCheck %s
+; RUN: llvm-ml64 -filetype=s %s /Fo - | FileCheck %s
.data
diff --git a/llvm/test/tools/llvm-ml/extern.asm b/llvm/test/tools/llvm-ml/extern.asm
index cec75ad2662ee..9126f9d06090a 100644
--- a/llvm/test/tools/llvm-ml/extern.asm
+++ b/llvm/test/tools/llvm-ml/extern.asm
@@ -1,5 +1,5 @@
-; RUN: llvm-ml -m32 -filetype=s %s /Fo - | FileCheck %s --check-prefixes=CHECK,CHECK-32
-; RUN: llvm-ml -m64 -filetype=s %s /Fo - | FileCheck %s --check-prefixes=CHECK,CHECK-64
+; RUN: llvm-ml -filetype=s %s /Fo - | FileCheck %s --check-prefixes=CHECK,CHECK-32
+; RUN: llvm-ml64 -filetype=s %s /Fo - | FileCheck %s --check-prefixes=CHECK,CHECK-64
extern foo : dword, bar : word, baz : proc
; CHECK: .extern foo
diff --git a/llvm/test/tools/llvm-ml/feat00.asm b/llvm/test/tools/llvm-ml/feat00.asm
index ff8df9d151aab..4ecc977391b5f 100644
--- a/llvm/test/tools/llvm-ml/feat00.asm
+++ b/llvm/test/tools/llvm-ml/feat00.asm
@@ -1,8 +1,8 @@
-; RUN: llvm-ml -m32 %s /Fo - | llvm-readobj --syms - | FileCheck %s --check-prefix=CHECK-OBJ --check-prefix=CHECK-OBJ-NOSAFESEH
-; RUN: llvm-ml -m64 %s /Fo - | llvm-readobj --syms - | FileCheck %s --check-prefix=CHECK-OBJ --check-prefix=CHECK-OBJ-NOSAFESEH
+; RUN: llvm-ml %s /Fo - | llvm-readobj --syms - | FileCheck %s --check-prefix=CHECK-OBJ --check-prefix=CHECK-OBJ-NOSAFESEH
+; RUN: llvm-ml64 %s /Fo - | llvm-readobj --syms - | FileCheck %s --check-prefix=CHECK-OBJ --check-prefix=CHECK-OBJ-NOSAFESEH
-; RUN: llvm-ml -m32 -safeseh %s /Fo - | llvm-readobj --syms - | FileCheck %s --check-prefix=CHECK-OBJ --check-prefix=CHECK-OBJ-SAFESEH
-; RUN: llvm-ml -m64 -safeseh %s /Fo %t.obj 2>&1 | FileCheck %s --check-prefix=CHECK-SAFESEH64
+; RUN: llvm-ml -safeseh %s /Fo - | llvm-readobj --syms - | FileCheck %s --check-prefix=CHECK-OBJ --check-prefix=CHECK-OBJ-SAFESEH
+; RUN: llvm-ml64 -safeseh %s /Fo %t.obj 2>&1 | FileCheck %s --check-prefix=CHECK-SAFESEH64
; RUN: llvm-readobj --syms %t.obj | FileCheck %s --check-prefix=CHECK-OBJ --check-prefix=CHECK-OBJ-NOSAFESEH
; CHECK-SAFESEH64: warning: /safeseh applies only to 32-bit X86 platforms; ignoring.
diff --git a/llvm/test/tools/llvm-ml/feat00_override.asm b/llvm/test/tools/llvm-ml/feat00_override.asm
index fc5035874b32d..bd4c5b5b984c2 100644
--- a/llvm/test/tools/llvm-ml/feat00_override.asm
+++ b/llvm/test/tools/llvm-ml/feat00_override.asm
@@ -1,6 +1,6 @@
-; RUN: llvm-ml -m32 %s /Fo - | llvm-readobj --syms - | FileCheck %s
-; RUN: llvm-ml -m64 %s /Fo - | llvm-readobj --syms - | FileCheck %s
-; RUN: llvm-ml -m32 -safeseh %s /Fo - | llvm-readobj --syms - | FileCheck %s
+; RUN: llvm-ml %s /Fo - | llvm-readobj --syms - | FileCheck %s
+; RUN: llvm-ml64 %s /Fo - | llvm-readobj --syms - | FileCheck %s
+; RUN: llvm-ml -safeseh %s /Fo - | llvm-readobj --syms - | FileCheck %s
.code
diff --git a/llvm/test/tools/llvm-ml/indirect_branch.asm b/llvm/test/tools/llvm-ml/indirect_branch.asm
index 12c847c47df0e..3f54c0c5392a0 100644
--- a/llvm/test/tools/llvm-ml/indirect_branch.asm
+++ b/llvm/test/tools/llvm-ml/indirect_branch.asm
@@ -1,5 +1,5 @@
-; RUN: llvm-ml -m64 -filetype=s %s /Fo - | FileCheck %s --check-prefixes=CHECK-64,CHECK
-; RUN: llvm-ml -m32 -filetype=s %s /Fo - | FileCheck %s --check-prefixes=CHECK-32,CHECK
+; RUN: llvm-ml64 -filetype=s %s /Fo - | FileCheck %s --check-prefixes=CHECK-64,CHECK
+; RUN: llvm-ml -filetype=s %s /Fo - | FileCheck %s --check-prefixes=CHECK-32,CHECK
ifdef rax
extern fn_ref_extern : qword
diff --git a/llvm/test/tools/llvm-ml/macro.asm b/llvm/test/tools/llvm-ml/macro.asm
index 3373ff4837f7c..a5bf86cfde010 100644
--- a/llvm/test/tools/llvm-ml/macro.asm
+++ b/llvm/test/tools/llvm-ml/macro.asm
@@ -1,4 +1,4 @@
-; RUN: llvm-ml -m64 -filetype=s %s /Fo - | FileCheck %s
+; RUN: llvm-ml64 -filetype=s %s /Fo - | FileCheck %s
.data
diff --git a/llvm/test/tools/llvm-ml/ml32-context.asm b/llvm/test/tools/llvm-ml/ml32-context.asm
index a701605a8af54..b7980f5954540 100644
--- a/llvm/test/tools/llvm-ml/ml32-context.asm
+++ b/llvm/test/tools/llvm-ml/ml32-context.asm
@@ -1,4 +1,4 @@
-; RUN: llvm-ml -m32 -filetype=s %s /Fo - | FileCheck %s
+; RUN: llvm-ml -filetype=s %s /Fo - | FileCheck %s
.386p
.model flat
diff --git a/llvm/test/tools/llvm-ml/nested_proc.asm b/llvm/test/tools/llvm-ml/nested_proc.asm
index 540541f597fc3..e1597042f45fa 100644
--- a/llvm/test/tools/llvm-ml/nested_proc.asm
+++ b/llvm/test/tools/llvm-ml/nested_proc.asm
@@ -1,5 +1,5 @@
-; RUN: llvm-ml -m32 -filetype=s %s /Fo - | FileCheck %s
-; RUN: llvm-ml -m64 -filetype=s %s /Fo - | FileCheck %s
+; RUN: llvm-ml -filetype=s %s /Fo - | FileCheck %s
+; RUN: llvm-ml64 -filetype=s %s /Fo - | FileCheck %s
.code
diff --git a/llvm/test/tools/llvm-ml/proc.asm b/llvm/test/tools/llvm-ml/proc.asm
index c8ad818176036..4bb784b8e063f 100644
--- a/llvm/test/tools/llvm-ml/proc.asm
+++ b/llvm/test/tools/llvm-ml/proc.asm
@@ -1,5 +1,5 @@
-; RUN: llvm-ml -m32 -filetype=s %s /Fo - | FileCheck %s
-; RUN: llvm-ml -m64 -filetype=s %s /Fo - | FileCheck %s
+; RUN: llvm-ml -filetype=s %s /Fo - | FileCheck %s
+; RUN: llvm-ml64 -filetype=s %s /Fo - | FileCheck %s
.code
diff --git a/llvm/test/tools/llvm-ml/proc_frame.asm b/llvm/test/tools/llvm-ml/proc_frame.asm
index e3967f1d9bec4..6cab92105bf53 100644
--- a/llvm/test/tools/llvm-ml/proc_frame.asm
+++ b/llvm/test/tools/llvm-ml/proc_frame.asm
@@ -1,4 +1,4 @@
-; RUN: llvm-ml -m64 -filetype=s %s /Fo - | FileCheck %s
+; RUN: llvm-ml64 -filetype=s %s /Fo - | FileCheck %s
.code
diff --git a/llvm/test/tools/llvm-ml/repeat_directives.asm b/llvm/test/tools/llvm-ml/repeat_directives.asm
index dc47d9aac725b..44b6759675602 100644
--- a/llvm/test/tools/llvm-ml/repeat_directives.asm
+++ b/llvm/test/tools/llvm-ml/repeat_directives.asm
@@ -1,4 +1,4 @@
-; RUN: llvm-ml -m64 -filetype=s %s /Fo - | FileCheck %s
+; RUN: llvm-ml64 -filetype=s %s /Fo - | FileCheck %s
.data
diff --git a/llvm/test/tools/llvm-ml/rip_relative_addressing.asm b/llvm/test/tools/llvm-ml/rip_relative_addressing.asm
index c005b9721c07e..2f22b04942a0a 100644
--- a/llvm/test/tools/llvm-ml/rip_relative_addressing.asm
+++ b/llvm/test/tools/llvm-ml/rip_relative_addressing.asm
@@ -1,5 +1,5 @@
-; RUN: llvm-ml -m32 -filetype=s %s /Fo - | FileCheck %s --check-prefixes=CHECK,CHECK-32
-; RUN: llvm-ml -m64 -filetype=s %s /Fo - | FileCheck %s --check-prefixes=CHECK,CHECK-64
+; RUN: llvm-ml -filetype=s %s /Fo - | FileCheck %s --check-prefixes=CHECK,CHECK-32
+; RUN: llvm-ml64 -filetype=s %s /Fo - | FileCheck %s --check-prefixes=CHECK,CHECK-64
.data
foo DWORD 28
diff --git a/llvm/test/tools/llvm-ml/strings_errors.asm b/llvm/test/tools/llvm-ml/strings_errors.asm
index c860d45e08019..4e1823ce9e971 100644
--- a/llvm/test/tools/llvm-ml/strings_errors.asm
+++ b/llvm/test/tools/llvm-ml/strings_errors.asm
@@ -1,4 +1,4 @@
-; RUN: not llvm-ml -m64 -filetype=s %s /Fo /dev/null 2>&1 | FileCheck %s --implicit-check-not=error:
+; RUN: not llvm-ml64 -filetype=s %s /Fo /dev/null 2>&1 | FileCheck %s --implicit-check-not=error:
.code
diff --git a/llvm/test/tools/llvm-ml/struct.asm b/llvm/test/tools/llvm-ml/struct.asm
index 7fb22fe2a0aa9..ba8bd752cc5c6 100644
--- a/llvm/test/tools/llvm-ml/struct.asm
+++ b/llvm/test/tools/llvm-ml/struct.asm
@@ -1,4 +1,4 @@
-; RUN: llvm-ml -m64 -filetype=s %s /Fo - | FileCheck %s
+; RUN: llvm-ml64 -filetype=s %s /Fo - | FileCheck %s
.data
BAZ STRUCT
diff --git a/llvm/tools/llvm-ml/CMakeLists.txt b/llvm/tools/llvm-ml/CMakeLists.txt
index 30097178db23d..bd231bfdb0ea3 100644
--- a/llvm/tools/llvm-ml/CMakeLists.txt
+++ b/llvm/tools/llvm-ml/CMakeLists.txt
@@ -22,3 +22,6 @@ add_llvm_tool(llvm-ml
MLTableGen
GENERATE_DRIVER
)
+
+llvm_add_tool_symlink(LLD llvm-ml64 llvm-ml ALWAYS_GENERATE)
+llvm_install_symlink(LLD llvm-ml64 llvm-ml ALWAYS_GENERATE)
>From 75f8917166de38dce9fa49fe6d4460b562199c46 Mon Sep 17 00:00:00 2001
From: Eric Astor <epastor at google.com>
Date: Tue, 18 Mar 2025 16:45:28 +0000
Subject: [PATCH 2/5] Add llvm-ml64 alias to Bazel BUILD.bzl files
>From 17239db31f71faf906672fa78d20558b4ee82ee4 Mon Sep 17 00:00:00 2001
From: Eric Astor <epastor at google.com>
Date: Tue, 18 Mar 2025 16:45:07 +0000
Subject: [PATCH 3/5] Add explicit architecture flag behavior testing
---
llvm/test/tools/llvm-ml/architecture.asm | 9 +++++++++
llvm/test/tools/llvm-ml/architecture_errors.asm | 10 ++++++++++
utils/bazel/llvm-project-overlay/llvm/BUILD.bazel | 8 ++++++++
3 files changed, 27 insertions(+)
create mode 100644 llvm/test/tools/llvm-ml/architecture.asm
create mode 100644 llvm/test/tools/llvm-ml/architecture_errors.asm
diff --git a/llvm/test/tools/llvm-ml/architecture.asm b/llvm/test/tools/llvm-ml/architecture.asm
new file mode 100644
index 0000000000000..7bcf30bd5e5d6
--- /dev/null
+++ b/llvm/test/tools/llvm-ml/architecture.asm
@@ -0,0 +1,9 @@
+; RUN: llvm-ml64 -filetype=s %s /Fo - | FileCheck %s --implicit-check-not=error:
+; RUN: llvm-ml -m64 -filetype=s %s /Fo - | FileCheck %s --implicit-check-not=error:
+
+.code
+
+xor rax, rax
+; CHECK: xor rax, rax
+
+end
diff --git a/llvm/test/tools/llvm-ml/architecture_errors.asm b/llvm/test/tools/llvm-ml/architecture_errors.asm
new file mode 100644
index 0000000000000..9908dafce0b2e
--- /dev/null
+++ b/llvm/test/tools/llvm-ml/architecture_errors.asm
@@ -0,0 +1,10 @@
+; RUN: not llvm-ml -filetype=s %s /Fo - 2>&1 | FileCheck %s
+; RUN: not llvm-ml -m32 -filetype=s %s /Fo - 2>&1 | FileCheck %s
+; RUN: not llvm-ml64 -m32 -filetype=s %s /Fo - 2>&1 | FileCheck %s
+
+.code
+
+; CHECK: :[[# @LINE + 1]]:5: error: register %rax is only available in 64-bit mode
+xor rax, rax
+
+end
\ No newline at end of file
diff --git a/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel b/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
index ef80af43c216b..8ed7e3b9ecf87 100644
--- a/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
@@ -5116,6 +5116,14 @@ llvm_driver_cc_binary(
deps = [":llvm-ml-lib"],
)
+genrule(
+ name = "gen_llvm-ml64",
+ srcs = [":llvm-ml"],
+ outs = ["llvm-ml64"],
+ cmd = "ln -sf $$(basename $<) $@",
+ output_to_bindir = 1,
+)
+
cc_binary(
name = "llvm-modextract",
srcs = glob([
>From 4d617a616258f2e057a74f3da78d144853599b28 Mon Sep 17 00:00:00 2001
From: Eric Astor <epastor at google.com>
Date: Tue, 18 Mar 2025 21:03:44 +0000
Subject: [PATCH 4/5] Use the correct/standard features to provide the
llvm-ml64 alias
---
llvm/tools/llvm-ml/CMakeLists.txt | 3 +--
utils/bazel/llvm-project-overlay/llvm/BUILD.bazel | 9 +++------
2 files changed, 4 insertions(+), 8 deletions(-)
diff --git a/llvm/tools/llvm-ml/CMakeLists.txt b/llvm/tools/llvm-ml/CMakeLists.txt
index bd231bfdb0ea3..d3dfb87d92b98 100644
--- a/llvm/tools/llvm-ml/CMakeLists.txt
+++ b/llvm/tools/llvm-ml/CMakeLists.txt
@@ -23,5 +23,4 @@ add_llvm_tool(llvm-ml
GENERATE_DRIVER
)
-llvm_add_tool_symlink(LLD llvm-ml64 llvm-ml ALWAYS_GENERATE)
-llvm_install_symlink(LLD llvm-ml64 llvm-ml ALWAYS_GENERATE)
+add_llvm_tool_symlink(llvm-ml64 llvm-ml)
diff --git a/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel b/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
index 8ed7e3b9ecf87..af81b4407a823 100644
--- a/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
@@ -5116,12 +5116,9 @@ llvm_driver_cc_binary(
deps = [":llvm-ml-lib"],
)
-genrule(
- name = "gen_llvm-ml64",
- srcs = [":llvm-ml"],
- outs = ["llvm-ml64"],
- cmd = "ln -sf $$(basename $<) $@",
- output_to_bindir = 1,
+binary_alias(
+ name = "llvm-ml64",
+ binary = ":llvm-ml",
)
cc_binary(
>From 7983df198b59110fec0590069f5b30e652bec5c3 Mon Sep 17 00:00:00 2001
From: Eric Astor <epastor at google.com>
Date: Wed, 19 Mar 2025 13:33:15 +0000
Subject: [PATCH 5/5] ... and remember to declare the test dependency on
llvm-ml64
---
llvm/test/CMakeLists.txt | 1 +
1 file changed, 1 insertion(+)
diff --git a/llvm/test/CMakeLists.txt b/llvm/test/CMakeLists.txt
index 1e4651210cd02..d984193875fa2 100644
--- a/llvm/test/CMakeLists.txt
+++ b/llvm/test/CMakeLists.txt
@@ -109,6 +109,7 @@ set(LLVM_TEST_DEPENDS
llvm-mc
llvm-mca
llvm-ml
+ llvm-ml64
llvm-modextract
llvm-mt
llvm-nm
More information about the llvm-commits
mailing list