This is an archive of the discontinued LLVM Phabricator instance.

[lit] Fix a problem with spaces in the python path by adding quotes around it
ClosedPublic

Authored by asmith on Feb 13 2018, 3:54 PM.

Diff Detail

Repository
rLLD LLVM Linker

Event Timeline

asmith created this revision.Feb 13 2018, 3:54 PM
asmith edited the summary of this revision. (Show Details)Feb 13 2018, 3:55 PM

I wonder if it would be worth fixing this in lit? Seems like each substitution should be inherently quoted. Do you know where in lit this is actually failing? I only bring this up because this is the second such bug you've fixed of this nature, so if it's a recurring problem then we should perhaps fix it at the source. For example, what if %clang also has spaces in the path? Will that also fail?

I agree that making a change to lit to pass the quoted path is the "correct" change, but it's a more disruptive change (see below) and since only a handful of tests invoke %python, I think we should change the tests to pass quotes instead. That said, I'm happy to make the change either way to conform to standards.

Details:

I did some reading through the lit code and %clang will actually work correctly. It looks like python is the only one that is explicitly set rather than using one of the helper functions which set the path correctly. The explicit call for python does not:

self.config.substitutions.append(('%python', sys.executable))

(the code is here: llvm\utils\lit\lit\llvm\config.py)

Changing this to something like:

python_path = r"'{}'".format(sys.executable)
self.config.substitutions.append(('%python', python_path))

will fix the issues from the current change, however, there are tests that will start failing instead because they expect that the path does not have quotes around it. For example, there are two LLVM tests that start failing:

LLVM :: BugPoint/compile-custom.ll
LLVM :: BugPoint/unsymbolized.ll

I suspect there may be other tests in clang/LLD/LLDB. Note that one of these tests (unsymbolized.ll) has a trivial fix of removing the quotes around %python, but compile-custom.ll does not because the command it's using is more complicated:

; RUN: bugpoint -load %llvmshlibdir/BugpointPasses%shlibext --compile-custom --compile-command="%python %/s.py arg1 arg2" --opt-command opt --output-prefix %t %s | FileCheck %s

Since I've not run all of the possible lit tests yet, I am not sure whether any other failures will have non-trivial changes as well.

This revision was not accepted when it landed; it landed in state Needs Review.Feb 20 2018, 4:05 PM
This revision was automatically updated to reflect the committed changes.