[llvm] b9fd375 - Revert "[lit] Keep original cfg file case around."

Nico Weber via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 15 14:19:53 PDT 2020


Author: Nico Weber
Date: 2020-04-15T17:19:39-04:00
New Revision: b9fd375d75d4bbf34453696127854d0192e3ccf6

URL: https://github.com/llvm/llvm-project/commit/b9fd375d75d4bbf34453696127854d0192e3ccf6
DIFF: https://github.com/llvm/llvm-project/commit/b9fd375d75d4bbf34453696127854d0192e3ccf6.diff

LOG: Revert "[lit] Keep original cfg file case around."

This reverts commit bc3f54de1827e58655c34477d09211cbc42589bd.

The patch breaks in the following two scenarios:

1. When manually passing an absolute path to llvm-lit with a lower-case
   drive letter: `python bin\llvm-lit.py -sv c:\llvm-project\clang\test\PCH`

2. When the PWD has a lower-case drive letter, like after running
   `cd c:\` with a lower-case "c:" (cmd's default is upper-case, but
   it takes case-ness from what's passed to `cd` apparently).

Added: 
    

Modified: 
    llvm/cmake/modules/AddLLVM.cmake
    llvm/utils/lit/lit/discovery.py
    llvm/utils/lit/lit/llvm/config.py
    llvm/utils/lit/tests/Inputs/config-map-discovery/driver.py
    llvm/utils/llvm-lit/llvm-lit.in

Removed: 
    


################################################################################
diff  --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index 8790b6e84152..633a3b0c0514 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -1423,10 +1423,16 @@ endfunction()
 # path. Since this uses __file__, it has to be emitted into python files that
 # use it and can't be in a lit module. Use with make_paths_relative().
 string(CONCAT LLVM_LIT_PATH_FUNCTION
+  # Lit converts config paths to lower case in discovery.py, before
+  # loading the config. This causes __file__ to be all lower-case (including
+  # the drive letter), but several clang tests pass -include %s and a
+  # clang warning checks that passed case matches on-disk cache. So it's
+  # important that this restores the on-disk case of the prefix.
   "# Allow generated file to be relocatable.\n"
   "def path(p):\n"
   "    if not p: return ''\n"
   "    p = os.path.join(os.path.dirname(os.path.abspath(__file__)), p)\n"
+  "    if os.name == 'nt' and os.path.isabs(p): return p[0].upper() + p[1:]\n"
   "    return p\n"
   )
 

diff  --git a/llvm/utils/lit/lit/discovery.py b/llvm/utils/lit/lit/discovery.py
index e743654f7fb4..d8054543d018 100644
--- a/llvm/utils/lit/lit/discovery.py
+++ b/llvm/utils/lit/lit/discovery.py
@@ -53,8 +53,8 @@ def search1(path):
         config_map = litConfig.params.get('config_map')
         if config_map:
             cfgpath = os.path.realpath(cfgpath)
-            t, target = config_map.get(os.path.normcase(cfgpath), (None, None))
-            assert t is None or t == cfgpath
+            cfgpath = os.path.normcase(cfgpath)
+            target = config_map.get(cfgpath)
             if target:
                 cfgpath = target
 

diff  --git a/llvm/utils/lit/lit/llvm/config.py b/llvm/utils/lit/lit/llvm/config.py
index 8b7d0c248605..fe0f1f4441ac 100644
--- a/llvm/utils/lit/lit/llvm/config.py
+++ b/llvm/utils/lit/lit/llvm/config.py
@@ -115,8 +115,8 @@ def __init__(self, lit_config, config):
 
     def with_environment(self, variable, value, append_path=False):
         if append_path:
-            # For paths, we should be able to take a list of them and process
-            # all of them.
+            # For paths, we should be able to take a list of them and process all
+            # of them.
             paths_to_add = value
             if lit.util.is_string(paths_to_add):
                 paths_to_add = [paths_to_add]
@@ -135,8 +135,8 @@ def norm(x):
             # and adding each to the beginning would result in b c a.  So we
             # need to iterate in reverse to end up with the original ordering.
             for p in reversed(paths_to_add):
-                # Move it to the front if it already exists, otherwise insert
-                # it at the beginning.
+                # Move it to the front if it already exists, otherwise insert it at the
+                # beginning.
                 p = norm(p)
                 try:
                     paths.remove(p)

diff  --git a/llvm/utils/lit/tests/Inputs/config-map-discovery/driver.py b/llvm/utils/lit/tests/Inputs/config-map-discovery/driver.py
index 296660263fa9..db9141b9b1bf 100644
--- a/llvm/utils/lit/tests/Inputs/config-map-discovery/driver.py
+++ b/llvm/utils/lit/tests/Inputs/config-map-discovery/driver.py
@@ -6,7 +6,7 @@
 main_config = os.path.realpath(main_config)
 main_config = os.path.normcase(main_config)
 
-config_map = {os.path.normcase(main_config) : (main_config, sys.argv[2])}
+config_map = {main_config : sys.argv[2]}
 builtin_parameters = {'config_map' : config_map}
 
 if __name__=='__main__':

diff  --git a/llvm/utils/llvm-lit/llvm-lit.in b/llvm/utils/llvm-lit/llvm-lit.in
index 34e79f27cf0b..bb510b4bc400 100755
--- a/llvm/utils/llvm-lit/llvm-lit.in
+++ b/llvm/utils/llvm-lit/llvm-lit.in
@@ -9,8 +9,9 @@ config_map = {}
 def map_config(source_dir, site_config):
     global config_map
     source_dir = os.path.realpath(source_dir)
+    source_dir = os.path.normcase(source_dir)
     site_config = os.path.normpath(site_config)
-    config_map[os.path.normcase(source_dir)] = source_dir, site_config
+    config_map[source_dir] = site_config
 
 # Set up some builtin parameters, so that by default the LLVM test suite
 # configuration file knows how to find the object tree.


        


More information about the llvm-commits mailing list