Bug 1457483 Retrieve nm from environment for check_vanilla_allocations.py r?glandium draft
authorTom Ritter <tom@mozilla.com>
Fri, 27 Apr 2018 10:25:35 -0500
changeset 789172 e309e51af47b32fc6f36c43ab94cf69ba2cb6403
parent 789171 04e5a1363ba966af2fcfb0365bd3966b4de7d256
push id108208
push userbmo:tom@mozilla.com
push dateFri, 27 Apr 2018 18:43:07 +0000
reviewersglandium
bugs1457483
milestone61.0a1
Bug 1457483 Retrieve nm from environment for check_vanilla_allocations.py r?glandium MozReview-Commit-ID: 5kQDj2lFVHd
config/check_vanilla_allocations.py
--- a/config/check_vanilla_allocations.py
+++ b/config/check_vanilla_allocations.py
@@ -37,16 +37,17 @@
 #----------------------------------------------------------------------------
 
 from __future__ import print_function
 
 import argparse
 import re
 import subprocess
 import sys
+import os
 
 # The obvious way to implement this script is to search for occurrences of
 # malloc et al, succeed if none are found, and fail is some are found.
 # However, "none are found" does not necessarily mean "none are present" --
 # this script could be buggy.  (Or the output format of |nm| might change in
 # the future.)
 #
 # So jsutil.cpp deliberately contains a (never-called) function that contains a
@@ -71,17 +72,17 @@ def main():
     parser.add_argument('file', type=str,
                         help='name of the file to check')
     args = parser.parse_args()
 
     # Run |nm|.  Options:
     # -u: show only undefined symbols
     # -C: demangle symbol names
     # -A: show an object filename for each undefined symbol
-    cmd = ['nm', '-u', '-C', '-A', args.file]
+    cmd = [os.environ.get('NM', 'nm'), '-u', '-C', '-A', args.file]
     lines = subprocess.check_output(cmd, universal_newlines=True,
                                     stderr=subprocess.PIPE).split('\n')
 
     # alloc_fns contains all the vanilla allocation/free functions that we look
     # for. Regexp chars are escaped appropriately.
 
     alloc_fns = [
         # Matches |operator new(unsigned T)|, where |T| is |int| or |long|.