Skip to content

[clang] [test] Skip a test that sets PATH= on Windows #95096

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 13, 2024

Conversation

mstorsjo
Copy link
Member

@mstorsjo mstorsjo commented Jun 11, 2024

The same has been done in a couple other existing tests, that also are skipped on Windows (e.g. ld-path.c). Some tests that really do want to test setting the path on Windows does it differently, see e.g. ps4-ps5-linker-win.c.

Since a65771f, the spirv-toolchain.cl test does one test where PATH is set. Setting PATH does work in some build configurations - however, if built with e.g. llvm-mingw, the built Clang executable depends on libc++.dll (and libunwind.dll) which are found in PATH. If the PATH is overridden, the newly built Clang executable no longer can run.

@mstorsjo mstorsjo requested a review from MaskRay June 11, 2024 10:21
@mstorsjo
Copy link
Member Author

CC @linehill

@llvmbot llvmbot added clang Clang issues not falling into any other category clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' labels Jun 11, 2024
@llvmbot
Copy link
Member

llvmbot commented Jun 11, 2024

@llvm/pr-subscribers-clang-driver

@llvm/pr-subscribers-clang

Author: Martin Storsjö (mstorsjo)

Changes

The same has been done in a couple other existing tests, that also are skipped on Windows (e.g. ld-path.c). Some tests that really do want to test setting the path on Windows does it differently, see e.g. ps4-ps5-linker-win.c.

Since a65771f, the spirv-toolchain.cl test does one test where PATH is set. Setting PATH does work in some build configurations - however, if built with e.g. llvm-mingw, the built Clang executable depends on libc++.dll (and libunwind.dll) which are found in PATH. If the PATH is overridden, the newly built Clang executable no longer can run.


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

1 Files Affected:

  • (modified) clang/test/Driver/spirv-toolchain.cl (+5)
diff --git a/clang/test/Driver/spirv-toolchain.cl b/clang/test/Driver/spirv-toolchain.cl
index de818177cb19f..2c9f9db80cad6 100644
--- a/clang/test/Driver/spirv-toolchain.cl
+++ b/clang/test/Driver/spirv-toolchain.cl
@@ -1,3 +1,8 @@
+/// One test uses the PATH environment variable; on Windows, we may need to retain
+/// the original path for the built Clang binary to be able to execute (as it is
+/// used for locating dependent DLLs).
+// UNSUPPORTED: system-windows
+
 // Check object emission.
 // RUN: %clang -### --target=spirv64 -x cl -c %s 2>&1 | FileCheck --check-prefix=SPV64 %s
 // RUN: %clang -### --target=spirv64 %s 2>&1 | FileCheck --check-prefix=SPV64 %s

@linehill
Copy link
Contributor

Could the single test with the PATH manipulation be moved to a separate test file which is disabled on Windows? That way we could keep running the other tests on Windows.

@mstorsjo
Copy link
Member Author

Could the single test with the PATH manipulation be moved to a separate test file which is disabled on Windows? That way we could keep running the other tests on Windows.

That's certainly an option, too.

@mstorsjo mstorsjo force-pushed the clang-test-path-windows branch from 1608c82 to 8e5e09f Compare June 11, 2024 11:51
// RUN: mkdir -p %t/versioned
// RUN: touch %t/versioned/llvm-spirv-%llvm-version-major \
// RUN: && chmod +x %t/versioned/llvm-spirv-%llvm-version-major
// RUN: env "PATH=%t/versioned" %clang -### --target=spirv64 -x cl -c %s 2>&1 \
Copy link
Member

Choose a reason for hiding this comment

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

Instead of creating a file, consider %if !system-windows

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, updated the PR to use %if !system-windows instead - tested that it does seem to work as expected here.

The same has been done in a couple other existing tests, that also
are skipped on Windows (e.g. ld-path.c). Some tests that really
do want to test setting the path on Windows does it differently,
see e.g. ps4-ps5-linker-win.c.

Since a65771f, the spirv-toolchain.cl
test does one test where PATH is set. Setting PATH does work in
some build configurations - however, if built with e.g. llvm-mingw,
the built Clang executable depends on libc++.dll (and libunwind.dll)
which are found in PATH. If the PATH is overridden, the newly built
Clang executable no longer can run.

Split the test that requires setting PATH to a separate file,
and mark it as unsupported on Windows.
@mstorsjo mstorsjo force-pushed the clang-test-path-windows branch from 8e5e09f to 11b5778 Compare June 12, 2024 12:14
@mstorsjo mstorsjo merged commit f5a93c5 into llvm:main Jun 13, 2024
7 checks passed
@mstorsjo mstorsjo deleted the clang-test-path-windows branch June 13, 2024 07:46
mstorsjo added a commit to mstorsjo/llvm-project that referenced this pull request May 1, 2025
mstorsjo added a commit to mstorsjo/llvm-project that referenced this pull request May 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants