Skip to content

Commit bc3f54d

Browse files
committed
[lit] Keep original cfg file case around.
There's been some back and forth if the cfg paths in the config_map should be normcase()d. The argument for is that it allows using all-lower spelling in cmd on Windows, the argument against that doing so is lossy. Before the relative-paths-in-generated-lit.site.cfg.py work, there was no downside to calling normcase(), but with it we need a hack to recover the original case. This time, normcase() the hashtable key, but store the original cased key in addition to the value. This fixes both cons, at the cost of a few bytes more memory. Differential Revision: https://reviews.llvm.org/D78169
1 parent 591be7e commit bc3f54d

File tree

5 files changed

+8
-15
lines changed

5 files changed

+8
-15
lines changed

llvm/cmake/modules/AddLLVM.cmake

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1423,16 +1423,10 @@ endfunction()
14231423
# path. Since this uses __file__, it has to be emitted into python files that
14241424
# use it and can't be in a lit module. Use with make_paths_relative().
14251425
string(CONCAT LLVM_LIT_PATH_FUNCTION
1426-
# Lit converts config paths to lower case in discovery.py, before
1427-
# loading the config. This causes __file__ to be all lower-case (including
1428-
# the drive letter), but several clang tests pass -include %s and a
1429-
# clang warning checks that passed case matches on-disk cache. So it's
1430-
# important that this restores the on-disk case of the prefix.
14311426
"# Allow generated file to be relocatable.\n"
14321427
"def path(p):\n"
14331428
" if not p: return ''\n"
14341429
" p = os.path.join(os.path.dirname(os.path.abspath(__file__)), p)\n"
1435-
" if os.name == 'nt' and os.path.isabs(p): return p[0].upper() + p[1:]\n"
14361430
" return p\n"
14371431
)
14381432

llvm/utils/lit/lit/discovery.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ def search1(path):
5353
config_map = litConfig.params.get('config_map')
5454
if config_map:
5555
cfgpath = os.path.realpath(cfgpath)
56-
cfgpath = os.path.normcase(cfgpath)
57-
target = config_map.get(cfgpath)
56+
t, target = config_map.get(os.path.normcase(cfgpath), (None, None))
57+
assert t is None or t == cfgpath
5858
if target:
5959
cfgpath = target
6060

llvm/utils/lit/lit/llvm/config.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ def __init__(self, lit_config, config):
115115

116116
def with_environment(self, variable, value, append_path=False):
117117
if append_path:
118-
# For paths, we should be able to take a list of them and process all
119-
# of them.
118+
# For paths, we should be able to take a list of them and process
119+
# all of them.
120120
paths_to_add = value
121121
if lit.util.is_string(paths_to_add):
122122
paths_to_add = [paths_to_add]
@@ -135,8 +135,8 @@ def norm(x):
135135
# and adding each to the beginning would result in b c a. So we
136136
# need to iterate in reverse to end up with the original ordering.
137137
for p in reversed(paths_to_add):
138-
# Move it to the front if it already exists, otherwise insert it at the
139-
# beginning.
138+
# Move it to the front if it already exists, otherwise insert
139+
# it at the beginning.
140140
p = norm(p)
141141
try:
142142
paths.remove(p)

llvm/utils/lit/tests/Inputs/config-map-discovery/driver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
main_config = os.path.realpath(main_config)
77
main_config = os.path.normcase(main_config)
88

9-
config_map = {main_config : sys.argv[2]}
9+
config_map = {os.path.normcase(main_config) : (main_config, sys.argv[2])}
1010
builtin_parameters = {'config_map' : config_map}
1111

1212
if __name__=='__main__':

llvm/utils/llvm-lit/llvm-lit.in

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ config_map = {}
99
def map_config(source_dir, site_config):
1010
global config_map
1111
source_dir = os.path.realpath(source_dir)
12-
source_dir = os.path.normcase(source_dir)
1312
site_config = os.path.normpath(site_config)
14-
config_map[source_dir] = site_config
13+
config_map[os.path.normcase(source_dir)] = source_dir, site_config
1514

1615
# Set up some builtin parameters, so that by default the LLVM test suite
1716
# configuration file knows how to find the object tree.

0 commit comments

Comments
 (0)