[compiler-rt] r364077 - [asan] Quote the path to the Python exe in case it has spaces

Reid Kleckner via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 21 09:54:58 PDT 2019


Author: rnk
Date: Fri Jun 21 09:54:58 2019
New Revision: 364077

URL: http://llvm.org/viewvc/llvm-project?rev=364077&view=rev
Log:
[asan] Quote the path to the Python exe in case it has spaces

These days, Python 3 installs itself into Program Files, so it often has
spaces. At first, I resisted this, and I reinstalled it globally into
C:/Python37, similar to the location used for Python 2.7. But then I
updated VS 2019, and it uninstalled my copy of Python and installed a
new one inside "C:/Program Files (x86)/Microsoft Visual Studio/". At
this point, I gave up and switched to using its built-in version of
Python. However, now these tests fail, and have to be made aware of the
possibility of spaces in paths. :(

Modified:
    compiler-rt/trunk/test/asan/lit.cfg

Modified: compiler-rt/trunk/test/asan/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/lit.cfg?rev=364077&r1=364076&r2=364077&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/lit.cfg (original)
+++ compiler-rt/trunk/test/asan/lit.cfg Fri Jun 21 09:54:58 2019
@@ -6,6 +6,15 @@ import re
 
 import lit.formats
 
+# Get shlex.quote if available (added in 3.3), and fall back to pipes.quote if
+# it's not available.
+try:
+  import shlex
+  sh_quote = shlex.quote
+except:
+  import pipes
+  sh_quote = pipes.quote
+
 def get_required_attr(config, attr_name):
   attr_value = getattr(config, attr_name, None)
   if attr_value == None:
@@ -149,11 +158,11 @@ else:
 # FIXME: De-hardcode this path.
 asan_source_dir = os.path.join(
   get_required_attr(config, "compiler_rt_src_root"), "lib", "asan")
+python_exec = sh_quote(get_required_attr(config, "python_executable"))
 # Setup path to asan_symbolize.py script.
 asan_symbolize = os.path.join(asan_source_dir, "scripts", "asan_symbolize.py")
 if not os.path.exists(asan_symbolize):
   lit_config.fatal("Can't find script on path %r" % asan_symbolize)
-python_exec = get_required_attr(config, "python_executable")
 config.substitutions.append( ("%asan_symbolize", python_exec + " " + asan_symbolize + " ") )
 # Setup path to sancov.py script.
 sanitizer_common_source_dir = os.path.join(
@@ -161,7 +170,6 @@ sanitizer_common_source_dir = os.path.jo
 sancov = os.path.join(sanitizer_common_source_dir, "scripts", "sancov.py")
 if not os.path.exists(sancov):
   lit_config.fatal("Can't find script on path %r" % sancov)
-python_exec = get_required_attr(config, "python_executable")
 config.substitutions.append( ("%sancov ", python_exec + " " + sancov + " ") )
 
 # Determine kernel bitness




More information about the llvm-commits mailing list