In the MSYS2 environment, the system is currently detected as a Cygwin 
environment. As a result, the following code is not executed under MSYS2, which 
in turn breaks the execution of `cmd.exe /c`:

  if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys2"; then
    # Must be done prior to calling any commands to avoid mangling of command 
line
    export MSYS2_ARG_CONV_EXCL="*"
  fi


I considered three possible approaches to fix this issue:
1. Modify `basic_windows.m4` so that `MSYS2_ARG_CONV_EXCL="*"` is also set in 
non‑MSYS2 environments (such as WSL and Cygwin).
2. Introduce the following logic early in the `configure` processing and set 
the environment variable `$MSYSTEM_CHOST` to the MSYS2 value:

if test "x$MSYSTEM" != "x"; then
  MSYSTEM_CHOST="x86_64-pc-msys"
fi

3. Add a note to `build.md` (the approach adopted in this PR).

Approaches 1 and 2 are better in the sense that they do not require any 
additional steps at build time, but they also have issues.
With approach 1, the build proceeds as if it were in a Cygwin environment even 
though it is actually an MSYS2 environment, which could lead to unexpected 
errors.
With approach 2, the logic needs to run very early in the configure process 
(before PLATFORM_SETUP_OPENJDK_BUILD_AND_TARGET), and introducing 
platform‑specific handling at such an early stage is not recommended.
For these reasons, I chose approach 3.

One concern I still have is whether this issue also occurs with the ARM version 
of MSYS2. Unfortunately, I do not have access to an ARM Windows environment and 
cannot verify this myself. For now, the addition to `build.md` is limited to 
`x86‑64`.  
If someone can confirm that the same problem occurs (or does not occur) on the 
latest ARM version of MSYS2, I will update the documentation accordingly.

-------------

Commit messages:
 - initial commit

Changes: https://git.openjdk.org/jdk/pull/29810/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=29810&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8378218
  Stats: 6 lines in 2 files changed: 6 ins; 0 del; 0 mod
  Patch: https://git.openjdk.org/jdk/pull/29810.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/29810/head:pull/29810

PR: https://git.openjdk.org/jdk/pull/29810

Reply via email to