From b7863da78fec29d193819b77970f53b62730a4a5 Mon Sep 17 00:00:00 2001
From: Brad King <brad.king@kitware.com>
Date: Thu, 21 Oct 2021 10:47:39 -0400
Subject: ci: Avoid OpenWatcom linker temp file collisions

When `wlink` needs to spill into a temporary file, code in `spillio.c`
checks environment variables `WLINKTMP`, `TMP`, and `TMPDIR` to get a
directory for temporary files.  It searches for a name `WLK02112.xx*`
that doesn't exist, where `*` starts at `a` and increments.  Then it
opens the file with the chosen name.  This can race among concurrent
`wlink` invocations that may all chose the same name before opening,
and causes errors like:

    Error! E3008: cannot open C:\...\Temp\WLK02112.xxa : Permission denied

Since `wmake` does not run parallel jobs, this normally isn't a problem.
However, our test suite runs multiple tests in parallel.  Each test has
its own `wmake` invocation, and therefore can run `wlink` concurrently.

Set `WLINKTMP=.` in the environment to tell each `wlink` to place
temporary files in its own working directory, which will be different
for each separate `wmake` invocation in our test suite.
---
 .gitlab/os-windows.yml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.gitlab/os-windows.yml b/.gitlab/os-windows.yml
index 15d883d..298b719 100644
--- a/.gitlab/os-windows.yml
+++ b/.gitlab/os-windows.yml
@@ -181,6 +181,7 @@
         - Set-Item -Force -Path "env:INCLUDE" -Value "$pwdpath\.gitlab\watcom\h;$pwdpath\.gitlab\watcom\h\nt"
         - Set-Item -Force -Path "env:EDPATH" -Value "$pwdpath\.gitlab\watcom\eddat"
         - Set-Item -Force -Path "env:WATCOM" -Value "$pwdpath\.gitlab\watcom"
+        - Set-Item -Force -Path "env:WLINKTMP" -Value "."
         - build/install/bin/ctest --output-on-failure -V -S .gitlab/ci/ctest_test_external.cmake
 
     interruptible: true
-- 
cgit v0.12