Skip to content

Conversation

@kikairoya
Copy link
Contributor

As the Cygwin platform requires $PATH to be set in order to run unittests, do the same as for the regular Windows target.

@llvmbot llvmbot added clang Clang issues not falling into any other category clang-tools-extra clangd llvm-lit testing-tools labels Oct 17, 2025
@llvmbot
Copy link
Member

llvmbot commented Oct 17, 2025

@llvm/pr-subscribers-clang-tools-extra
@llvm/pr-subscribers-clangd

@llvm/pr-subscribers-clang

Author: Tomohiro Kashiwada (kikairoya)

Changes

As the Cygwin platform requires $PATH to be set in order to run unittests, do the same as for the regular Windows target.


Full diff: https://github.com/llvm/llvm-project/pull/163947.diff

6 Files Affected:

  • (modified) clang-tools-extra/clangd/unittests/lit.cfg.py (+2-2)
  • (modified) clang-tools-extra/include-cleaner/test/Unit/lit.cfg.py (+2-2)
  • (modified) clang-tools-extra/test/Unit/lit.cfg.py (+1-1)
  • (modified) clang/test/Unit/lit.cfg.py (+1-1)
  • (modified) llvm/utils/lit/tests/Inputs/googletest-cmd-wrapper/lit.cfg (+1-1)
  • (modified) polly/test/Unit/lit.cfg (+1-1)
diff --git a/clang-tools-extra/clangd/unittests/lit.cfg.py b/clang-tools-extra/clangd/unittests/lit.cfg.py
index 33aa9e61f4ce9..666e9879bb4ad 100644
--- a/clang-tools-extra/clangd/unittests/lit.cfg.py
+++ b/clang-tools-extra/clangd/unittests/lit.cfg.py
@@ -19,12 +19,12 @@
 
 if platform.system() == "Darwin":
     shlibpath_var = "DYLD_LIBRARY_PATH"
-elif platform.system() == "Windows":
+elif platform.system() == "Windows" or sys.platform == "cygwin":
     shlibpath_var = "PATH"
 else:
     shlibpath_var = "LD_LIBRARY_PATH"
 config.environment[shlibpath_var] = os.path.pathsep.join(
-    ("@SHLIBDIR@", "@LLVM_LIBS_DIR@", config.environment.get(shlibpath_var, ""))
+    (config.shlibdir, config.llvm_libs_dir, config.environment.get(shlibpath_var, ""))
 )
 
 # It is not realistically possible to account for all options that could
diff --git a/clang-tools-extra/include-cleaner/test/Unit/lit.cfg.py b/clang-tools-extra/include-cleaner/test/Unit/lit.cfg.py
index 0963351abe3b1..c4454df06b386 100644
--- a/clang-tools-extra/include-cleaner/test/Unit/lit.cfg.py
+++ b/clang-tools-extra/include-cleaner/test/Unit/lit.cfg.py
@@ -11,12 +11,12 @@
 
 if platform.system() == "Darwin":
     shlibpath_var = "DYLD_LIBRARY_PATH"
-elif platform.system() == "Windows":
+elif platform.system() == "Windows" or sys.platform == "cygwin":
     shlibpath_var = "PATH"
 else:
     shlibpath_var = "LD_LIBRARY_PATH"
 config.environment[shlibpath_var] = os.path.pathsep.join(
-    ("@SHLIBDIR@", "@LLVM_LIBS_DIR@", config.environment.get(shlibpath_var, ""))
+    (config.shlibdir, config.llvm_libs_dir, config.environment.get(shlibpath_var, ""))
 )
 
 # It is not realistically possible to account for all options that could
diff --git a/clang-tools-extra/test/Unit/lit.cfg.py b/clang-tools-extra/test/Unit/lit.cfg.py
index b7376a02c89e1..0254829ed67e4 100644
--- a/clang-tools-extra/test/Unit/lit.cfg.py
+++ b/clang-tools-extra/test/Unit/lit.cfg.py
@@ -21,7 +21,7 @@
 
 if platform.system() == "Darwin":
     shlibpath_var = "DYLD_LIBRARY_PATH"
-elif platform.system() == "Windows":
+elif platform.system() == "Windows" or sys.platform == "cygwin":
     shlibpath_var = "PATH"
 else:
     shlibpath_var = "LD_LIBRARY_PATH"
diff --git a/clang/test/Unit/lit.cfg.py b/clang/test/Unit/lit.cfg.py
index 37e91d0f8629f..ebe35a10e7f30 100644
--- a/clang/test/Unit/lit.cfg.py
+++ b/clang/test/Unit/lit.cfg.py
@@ -51,7 +51,7 @@ def find_shlibpath_var():
         yield "LD_LIBRARY_PATH"
     elif platform.system() == "Darwin":
         yield "DYLD_LIBRARY_PATH"
-    elif platform.system() == "Windows":
+    elif platform.system() == "Windows" or sys.platform == "cygwin":
         yield "PATH"
     elif platform.system() == "AIX":
         yield "LIBPATH"
diff --git a/llvm/utils/lit/tests/Inputs/googletest-cmd-wrapper/lit.cfg b/llvm/utils/lit/tests/Inputs/googletest-cmd-wrapper/lit.cfg
index 9f93bac51456d..d3eb987922995 100644
--- a/llvm/utils/lit/tests/Inputs/googletest-cmd-wrapper/lit.cfg
+++ b/llvm/utils/lit/tests/Inputs/googletest-cmd-wrapper/lit.cfg
@@ -2,5 +2,5 @@ import lit.formats
 
 config.name = "googletest-cmd-wrapper"
 config.test_format = lit.formats.GoogleTest(
-    "DummySubDir", "Test" if "win32" in sys.platform else ".exe", [sys.executable]
+    "DummySubDir", "Test" if sys.platform in ["win32", "cygwin"] else ".exe", [sys.executable]
 )
diff --git a/polly/test/Unit/lit.cfg b/polly/test/Unit/lit.cfg
index 6c450fbc54b5a..21d7bc4ab25c5 100644
--- a/polly/test/Unit/lit.cfg
+++ b/polly/test/Unit/lit.cfg
@@ -50,7 +50,7 @@ for var in [
 
 if platform.system() == 'Darwin':
     shlibpath_var = 'DYLD_LIBRARY_PATH'
-elif platform.system() == 'Windows':
+elif platform.system() == 'Windows' or sys.platform == "cygwin":
     shlibpath_var = 'PATH'
 else:
     shlibpath_var = 'LD_LIBRARY_PATH'

@llvmbot
Copy link
Member

llvmbot commented Oct 17, 2025

@llvm/pr-subscribers-testing-tools

Author: Tomohiro Kashiwada (kikairoya)

Changes

As the Cygwin platform requires $PATH to be set in order to run unittests, do the same as for the regular Windows target.


Full diff: https://github.com/llvm/llvm-project/pull/163947.diff

6 Files Affected:

  • (modified) clang-tools-extra/clangd/unittests/lit.cfg.py (+2-2)
  • (modified) clang-tools-extra/include-cleaner/test/Unit/lit.cfg.py (+2-2)
  • (modified) clang-tools-extra/test/Unit/lit.cfg.py (+1-1)
  • (modified) clang/test/Unit/lit.cfg.py (+1-1)
  • (modified) llvm/utils/lit/tests/Inputs/googletest-cmd-wrapper/lit.cfg (+1-1)
  • (modified) polly/test/Unit/lit.cfg (+1-1)
diff --git a/clang-tools-extra/clangd/unittests/lit.cfg.py b/clang-tools-extra/clangd/unittests/lit.cfg.py
index 33aa9e61f4ce9..666e9879bb4ad 100644
--- a/clang-tools-extra/clangd/unittests/lit.cfg.py
+++ b/clang-tools-extra/clangd/unittests/lit.cfg.py
@@ -19,12 +19,12 @@
 
 if platform.system() == "Darwin":
     shlibpath_var = "DYLD_LIBRARY_PATH"
-elif platform.system() == "Windows":
+elif platform.system() == "Windows" or sys.platform == "cygwin":
     shlibpath_var = "PATH"
 else:
     shlibpath_var = "LD_LIBRARY_PATH"
 config.environment[shlibpath_var] = os.path.pathsep.join(
-    ("@SHLIBDIR@", "@LLVM_LIBS_DIR@", config.environment.get(shlibpath_var, ""))
+    (config.shlibdir, config.llvm_libs_dir, config.environment.get(shlibpath_var, ""))
 )
 
 # It is not realistically possible to account for all options that could
diff --git a/clang-tools-extra/include-cleaner/test/Unit/lit.cfg.py b/clang-tools-extra/include-cleaner/test/Unit/lit.cfg.py
index 0963351abe3b1..c4454df06b386 100644
--- a/clang-tools-extra/include-cleaner/test/Unit/lit.cfg.py
+++ b/clang-tools-extra/include-cleaner/test/Unit/lit.cfg.py
@@ -11,12 +11,12 @@
 
 if platform.system() == "Darwin":
     shlibpath_var = "DYLD_LIBRARY_PATH"
-elif platform.system() == "Windows":
+elif platform.system() == "Windows" or sys.platform == "cygwin":
     shlibpath_var = "PATH"
 else:
     shlibpath_var = "LD_LIBRARY_PATH"
 config.environment[shlibpath_var] = os.path.pathsep.join(
-    ("@SHLIBDIR@", "@LLVM_LIBS_DIR@", config.environment.get(shlibpath_var, ""))
+    (config.shlibdir, config.llvm_libs_dir, config.environment.get(shlibpath_var, ""))
 )
 
 # It is not realistically possible to account for all options that could
diff --git a/clang-tools-extra/test/Unit/lit.cfg.py b/clang-tools-extra/test/Unit/lit.cfg.py
index b7376a02c89e1..0254829ed67e4 100644
--- a/clang-tools-extra/test/Unit/lit.cfg.py
+++ b/clang-tools-extra/test/Unit/lit.cfg.py
@@ -21,7 +21,7 @@
 
 if platform.system() == "Darwin":
     shlibpath_var = "DYLD_LIBRARY_PATH"
-elif platform.system() == "Windows":
+elif platform.system() == "Windows" or sys.platform == "cygwin":
     shlibpath_var = "PATH"
 else:
     shlibpath_var = "LD_LIBRARY_PATH"
diff --git a/clang/test/Unit/lit.cfg.py b/clang/test/Unit/lit.cfg.py
index 37e91d0f8629f..ebe35a10e7f30 100644
--- a/clang/test/Unit/lit.cfg.py
+++ b/clang/test/Unit/lit.cfg.py
@@ -51,7 +51,7 @@ def find_shlibpath_var():
         yield "LD_LIBRARY_PATH"
     elif platform.system() == "Darwin":
         yield "DYLD_LIBRARY_PATH"
-    elif platform.system() == "Windows":
+    elif platform.system() == "Windows" or sys.platform == "cygwin":
         yield "PATH"
     elif platform.system() == "AIX":
         yield "LIBPATH"
diff --git a/llvm/utils/lit/tests/Inputs/googletest-cmd-wrapper/lit.cfg b/llvm/utils/lit/tests/Inputs/googletest-cmd-wrapper/lit.cfg
index 9f93bac51456d..d3eb987922995 100644
--- a/llvm/utils/lit/tests/Inputs/googletest-cmd-wrapper/lit.cfg
+++ b/llvm/utils/lit/tests/Inputs/googletest-cmd-wrapper/lit.cfg
@@ -2,5 +2,5 @@ import lit.formats
 
 config.name = "googletest-cmd-wrapper"
 config.test_format = lit.formats.GoogleTest(
-    "DummySubDir", "Test" if "win32" in sys.platform else ".exe", [sys.executable]
+    "DummySubDir", "Test" if sys.platform in ["win32", "cygwin"] else ".exe", [sys.executable]
 )
diff --git a/polly/test/Unit/lit.cfg b/polly/test/Unit/lit.cfg
index 6c450fbc54b5a..21d7bc4ab25c5 100644
--- a/polly/test/Unit/lit.cfg
+++ b/polly/test/Unit/lit.cfg
@@ -50,7 +50,7 @@ for var in [
 
 if platform.system() == 'Darwin':
     shlibpath_var = 'DYLD_LIBRARY_PATH'
-elif platform.system() == 'Windows':
+elif platform.system() == 'Windows' or sys.platform == "cygwin":
     shlibpath_var = 'PATH'
 else:
     shlibpath_var = 'LD_LIBRARY_PATH'

@kikairoya
Copy link
Contributor Author

cc: @jeremyd2019 @mstorsjo

As the Cygwin platform requires $PATH to be set in order to run unittests,
do the same as for the regular Windows target.
@kikairoya kikairoya force-pushed the cygwin-unittest-path branch from 7239573 to efac315 Compare October 17, 2025 16:43
shlibpath_var = "LD_LIBRARY_PATH"
config.environment[shlibpath_var] = os.path.pathsep.join(
("@SHLIBDIR@", "@LLVM_LIBS_DIR@", config.environment.get(shlibpath_var, ""))
(config.shlibdir, config.llvm_libs_dir, config.environment.get(shlibpath_var, ""))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand what this change does here and how it relates to the rest of this change, same for the file below.

Copy link
Contributor Author

@kikairoya kikairoya Oct 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SHLIBDIR@ is replaced by CMake's configuration function, so it must be in lit.site.cfg.py.in but not lit.cfg.py.
lit.cfg.py must reference variables in generated lit.site.cfg.py.

config.llvm_libs_dir = "@LLVM_LIBS_DIR@"
config.shlibdir = "@SHLIBDIR@"

configure_lit_site_cfg(
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is odd, how did this code work before? Was it moved here and no one noticed that the values are no longer expanded?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds reasonable - but it sounds like a slightly different change from the rest of the theme of the patch. Or at the very least, it would need a mention in the commit message (PR description).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I'll split out to another PR and look into how it worked before.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is odd, how did this code work before? Was it moved here and no one noticed that the values are no longer expanded?

For Windows, since the pre-merge CI runs checks without -DLLVM_LINK_LLVM_DYLIB=ON, an additional $PATH isn't needed. llvm-mingw appears to do the same, although its releases are configured with dylib.

For Linux, DSOs are found via RUNPATH so $LD_LIBRARY_PATH isn't needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll split out to another PR

done. #164147

Copy link
Member

@mstorsjo mstorsjo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mstorsjo mstorsjo merged commit d4af5e6 into llvm:main Oct 20, 2025
10 checks passed
@llvm-ci
Copy link
Collaborator

llvm-ci commented Oct 20, 2025

LLVM Buildbot has detected a new failure on builder lldb-x86_64-debian running on lldb-x86_64-debian while building clang-tools-extra,clang,llvm,polly at step 6 "test".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/162/builds/33590

Here is the relevant piece of the build log for the reference
Step 6 (test) failure: build (failure)
...
PASS: lldb-api :: functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py (308 of 3252)
PASS: lldb-api :: lang/cpp/preferred_name/TestPreferredName.py (309 of 3252)
PASS: lldb-api :: functionalities/thread/exit_during_break/TestExitDuringBreak.py (310 of 3252)
PASS: lldb-api :: functionalities/tail_call_frames/cross_dso/TestCrossDSOTailCalls.py (311 of 3252)
PASS: lldb-api :: functionalities/tail_call_frames/ambiguous_tail_call_seq1/TestAmbiguousTailCallSeq1.py (312 of 3252)
PASS: lldb-api :: tools/lldb-dap/startDebugging/TestDAP_startDebugging.py (313 of 3252)
PASS: lldb-api :: lang/cpp/unique-types3/TestUniqueTypes3.py (314 of 3252)
PASS: lldb-api :: functionalities/breakpoint/breakpoint_names/TestBreakpointNames.py (315 of 3252)
PASS: lldb-api :: lang/c/vla/TestVLA.py (316 of 3252)
PASS: lldb-api :: lang/cpp/unique-types/TestUniqueTypes.py (317 of 3252)
FAIL: lldb-api :: tools/lldb-dap/output/TestDAP_output.py (318 of 3252)
******************** TEST 'lldb-api :: tools/lldb-dap/output/TestDAP_output.py' FAILED ********************
Script:
--
/usr/bin/python3 /home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/test/API/dotest.py -u CXXFLAGS -u CFLAGS --env LLVM_LIBS_DIR=/home/worker/2.0.1/lldb-x86_64-debian/build/./lib --env LLVM_INCLUDE_DIR=/home/worker/2.0.1/lldb-x86_64-debian/build/include --env LLVM_TOOLS_DIR=/home/worker/2.0.1/lldb-x86_64-debian/build/./bin --arch x86_64 --build-dir /home/worker/2.0.1/lldb-x86_64-debian/build/lldb-test-build.noindex --lldb-module-cache-dir /home/worker/2.0.1/lldb-x86_64-debian/build/lldb-test-build.noindex/module-cache-lldb/lldb-api --clang-module-cache-dir /home/worker/2.0.1/lldb-x86_64-debian/build/lldb-test-build.noindex/module-cache-clang/lldb-api --executable /home/worker/2.0.1/lldb-x86_64-debian/build/./bin/lldb --compiler /home/worker/2.0.1/lldb-x86_64-debian/build/./bin/clang --dsymutil /home/worker/2.0.1/lldb-x86_64-debian/build/./bin/dsymutil --make /usr/bin/gmake --llvm-tools-dir /home/worker/2.0.1/lldb-x86_64-debian/build/./bin --lldb-obj-root /home/worker/2.0.1/lldb-x86_64-debian/build/tools/lldb --lldb-libs-dir /home/worker/2.0.1/lldb-x86_64-debian/build/./lib --cmake-build-type Release -t /home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/test/API/tools/lldb-dap/output -p TestDAP_output.py
--
Exit Code: 1

Command Output (stdout):
--
lldb version 22.0.0git (https://github.com/llvm/llvm-project.git revision d4af5e6b0b4fef49c3277d4a13d279dfcc4e155a)
  clang revision d4af5e6b0b4fef49c3277d4a13d279dfcc4e155a
  llvm revision d4af5e6b0b4fef49c3277d4a13d279dfcc4e155a
Skipping the following test categories: ['libc++', 'msvcstl', 'dsym', 'gmodules', 'debugserver', 'objc']

--
Command Output (stderr):
--
Change dir to: /home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/test/API/tools/lldb-dap/output
runCmd: settings clear --all

output: 

runCmd: settings set symbols.enable-external-lookup false

output: 

runCmd: settings set target.inherit-tcc true

output: 

runCmd: settings set target.disable-aslr false

output: 

runCmd: settings set target.detach-on-error false

output: 


@kikairoya kikairoya deleted the cygwin-unittest-path branch October 20, 2025 21:44
Lukacma pushed a commit to Lukacma/llvm-project that referenced this pull request Oct 29, 2025
As the Cygwin platform requires $PATH to be set in order to run
unittests, do the same as for the regular Windows target.
aokblast pushed a commit to aokblast/llvm-project that referenced this pull request Oct 30, 2025
As the Cygwin platform requires $PATH to be set in order to run
unittests, do the same as for the regular Windows target.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang Clang issues not falling into any other category clang-tools-extra clangd llvm-lit testing-tools

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants