Skip to content

[BOLT] Use llvm-nm by default on Windows #151805

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 5, 2025
Merged

Conversation

slydiman
Copy link
Contributor

@slydiman slydiman commented Aug 2, 2025

Use llvm-nm by default instead of nm in case of Windows host.

Use `llvm-nm` by default instead of `nm` in case of Windows host.
@llvmbot
Copy link
Member

llvmbot commented Aug 2, 2025

@llvm/pr-subscribers-bolt

Author: Dmitry Vasilyev (slydiman)

Changes

Use llvm-nm by default instead of nm in case of Windows host.


Full diff: https://github.com/llvm/llvm-project/pull/151805.diff

1 Files Affected:

  • (modified) bolt/test/link_fdata.py (+10-2)
diff --git a/bolt/test/link_fdata.py b/bolt/test/link_fdata.py
index 898dce8e3fb5f..24c0963989cd1 100755
--- a/bolt/test/link_fdata.py
+++ b/bolt/test/link_fdata.py
@@ -9,6 +9,7 @@
 
 import argparse
 import os
+import platform
 import shutil
 import subprocess
 import sys
@@ -19,7 +20,11 @@
 parser.add_argument("objfile", help="Object file to extract symbol values from")
 parser.add_argument("output")
 parser.add_argument("prefix", nargs="?", default="FDATA", help="Custom FDATA prefix")
-parser.add_argument("--nmtool", default="nm", help="Path to nm tool")
+parser.add_argument(
+    "--nmtool",
+    default="llvm-nm" if platform.system() == "Windows" else "nm",
+    help="Path to nm tool",
+)
 parser.add_argument("--no-lbr", action="store_true")
 parser.add_argument("--no-redefine", action="store_true")
 
@@ -86,7 +91,10 @@
             exit("ERROR: unexpected input:\n%s" % line)
 
 # Read nm output: <symbol value> <symbol type> <symbol name>
-is_llvm_nm = os.path.basename(os.path.realpath(shutil.which(args.nmtool))) == "llvm-nm"
+# Ignore .exe on Windows host.
+is_llvm_nm = os.path.basename(os.path.realpath(shutil.which(args.nmtool))).startswith(
+    "llvm-nm"
+)
 nm_output = subprocess.run(
     [
         args.nmtool,

Copy link
Member

@paschalis-mpeis paschalis-mpeis left a comment

Choose a reason for hiding this comment

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

Looks good, thanks. I'm curious what @aaupov and @yota9 think, as we plan to make it the default for all platforms, correct?

IIRC, we had a test that relied on GNU nm --synthetic (was llvm-nm --special-syms not working there too?).
However, that part of the test is disabled until #138232 by @yota9 is merged.

Is there anything else holding us back from making llvm-nm the default on all platforms? Linux AArch64 appears to be ready for this too.

@slydiman slydiman merged commit c233deb into llvm:main Aug 5, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants