Skip to content

Commit 7db64e2

Browse files
committed
Disable relative paths in lit.site.cfg in presence of symlinks
See https://reviews.llvm.org/D77184#1961208
1 parent 0f9e1e3 commit 7db64e2

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

llvm/cmake/modules/AddLLVM.cmake

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1501,11 +1501,15 @@ function(configure_lit_site_cfg site_in site_out)
15011501
get_filename_component(OUTPUT_DIR ${site_out} DIRECTORY)
15021502
execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-c" "\n
15031503
import os, sys\n
1504-
drive = os.path.splitdrive(sys.argv[1])[0]\n
1504+
base = sys.argv[1]
1505+
def haslink(p):\n
1506+
if not p or p == os.path.dirname(p): return False\n
1507+
return os.path.islink(p) or haslink(os.path.dirname(p))\n
15051508
def relpath(p):\n
15061509
if not p: return ''\n
1507-
if os.path.splitdrive(p)[0] != drive: return p\n
1508-
return os.path.relpath(p, sys.argv[1]).replace(os.sep, '/')\n
1510+
if os.path.splitdrive(p)[0] != os.path.splitdrive(base)[0]: return p\n
1511+
if haslink(p) or haslink(base): return p\n
1512+
return os.path.relpath(p, base).replace(os.sep, '/')\n
15091513
sys.stdout.write(';'.join(relpath(p) for p in sys.argv[2].split(';')))"
15101514
${OUTPUT_DIR}
15111515
${ARG_PATH_VALUES_ESCAPED}

0 commit comments

Comments
 (0)