-
JEP
-
Resolution: Unresolved
-
P4
-
Julian Waters
-
Infrastructure
-
Open
-
JDK
Summary
Port the JDK to Windows/MSYS2 UCRT64 with the gcc compiler as the primary compiler.
Goals
Although not a primary goal to support compiling the JDK outside of an MSYS2 environment, it is also hoped that standalone gcc compilers in other environments, such as Windows Subsystem for Linux 2 (WSL2) will also be able to compile the JDK for use within their own environments, provided the gcc compiler meets all the requirements listed below.
Success Metrics
The Windows JDK can be compiled with gcc with no regressions to other platforms or the standard Windows JDK, with high performance to boot. Minimal effects on all JDK code is a goal of this JEP.
Motivation
MSYS2 is a widely used software distribution and development environment for Windows, with many different subsystems for software distributions compiled and linked with a multitude of different runtime libraries. MINGW64, the original subsystem this project is based on, is also available as a subsystem, although it is not the focus of this JEP. Many software projects that this environment would otherwise have available as packages are heavily reliant on a working JDK, which all of the MSYS2 subsystems lack due to not being able to compile the JDK with an available MSYS2 compiler for binary compatibility. gcc, the MSYS2 environment's primary compiler, is currently not supported for compiling a Windows JDK. Given the widespread use of MSYS2 and its subsystems, the ability of compiling a JDK for even one of them would be valuable. Additionally, gcc is widely known to be an optimizing compiler that produces extremely performant production code, giving yet another motivating secondary factor for the port.
Description
The MSYS2 environment's different subsystems actually link to very different variants of Windows Runtime Libraries; A decision must be made on which ones are accepted by the JDK, as supporting some of the older and deprecated ones pose a significant compatibility risk and maintenance efforts.
The Windows/UCRT64 port will only support the ucrt linked variant of gcc and MSYS2 subsystem, which links natively to the Windows ucrt runtime. Support for the other gcc subsystems, or for gcc that is distributed with Cygwin, will never be considered, as these either link to emulation layers or the obsolete msvcrt runtime library. These unsupported subsystems include MINGW32, MINGW64, and the MSYS2 subsystem itself. Support for clang, which is a secondary compiler within MSYS2 that links to ucrt, is not within the scope of this JEP.
The port will support the following HotSpot subsystems:
- The template interpreter,
- The C1 (client) JIT compiler,
- The C2 (server) JIT compiler, and
- All current mainline GCs, including ZGC and Shenandoah.
The focus of this JEP is on the porting efforts that are required, as well as the possible integration of the port into the JDK main-line repository, as at the time of writing this work is still experimental.
Currently we have a number of trivial changes in the shared part of JDK. These are mostly conditionally activated code that require mild reordering or fixing of JDK code to remove assumptions about the compiler used based on the operating system, so the risk to shared code and other platforms are minimal.
There are also changes to the build system of the JDK to enable it to handle a different compiler other than the microsoft toolchain when compiling a Windows JDK. To reduce to amount of changes required within source code, changes to the build system were preferred over changes to the JDK's source.
The current diff between JDK mainline and the UCRT64 port can be obtained by:
$ git clone https://github.com/TheShermanTanker/jdk compiler
$ cd jdk
$ git diff master..compiler
Alternatively, an easy-to-read diff is also available here.
Testing
Testing is currently still in progress, as the work presented here is still highly experimental.
Risks and Assumptions
There are a few issues regarding the compatibility of the gcc and microsoft compilers, as the former lacks several essential features the latter has that the JDK relies on. One such example is Structured Exception Handling support, which we hope to resolve soon.
- relates to
-
JDK-8289275 Remove incorrect __declspec(dllimport) attributes from pointers in jdk.crypto.cryptoki
- Resolved
-
JDK-8292314 Cleanup legacy address handling
- Resolved
-
JDK-8293595 tstrings::any() is missing an overload
- Resolved
-
JDK-8295990 Improve make handling of strip flags
- Resolved
-
JDK-8301659 Resolve initialization reordering issues on Windows for libawt and libsaproc
- Resolved
-
JDK-8301756 Missed constructor from 8301659
- Resolved
-
JDK-8302838 jabswitch main() should avoid calling exit explicitly
- Resolved
-
JDK-8303169 Remove Windows specific workaround from libdt
- Resolved
-
JDK-8303227 JniObjWithEnv should be NullablePointer compliant
- Resolved
-
JDK-8311104 dangling-gsl warning in libwixhelper.cpp
- Resolved
-
JDK-8302460 System C++ Compiler for cross compiling gcc is dangerously wrong
- Closed
-
JDK-8295146 Clean up native code with newer C/C++ language features
- In Progress
-
JDK-8241499 Enable new "permissive-" for standard C++ compliance on Visual Studio if possible
- Resolved
-
JDK-8247283 Enable the new conformant preprocessor option in Visual Studio
- Resolved
-
JDK-8292008 Transition the JDK to the common standard of C11
- Resolved
-
JDK-8296115 Allow for compiling the JDK with strict standards conformance
- Resolved
-
JDK-8304930 Enable Link Time Optimization as an option for Visual C++
- Resolved
-
JDK-8304939 os::win32::exit_process_or_thread should be marked noreturn
- Resolved
-
JDK-8309551 Release Note: javac should emit headers with the LL suffix instead of i64 for Windows
- Resolved
-
JDK-8305955 Remove Visual C++ specific workaround in javac
- In Progress
-
JDK-8294314 Minimize disabled warnings in hotspot
- Resolved
-
JDK-8307145 windowsaccessbridge.dll erroneously includes private methods in its C API
- Resolved
-
JDK-8291454 Missing check for JLI C runtime library in CoreLibraries.gmk
- Resolved
-
JDK-8291511 Redefinition of EXIT_FAILURE in libw2k_lsa_auth
- Resolved
-
JDK-8291959 FileFontStrike#initNative does not properly initialize IG Table on Windows
- Resolved
-
JDK-8300488 Incorrect usage of CATCH_BAD_ALLOC as a macro call
- Resolved
-
JDK-8301129 Link to debuginfo files should only be made after stripping
- Resolved
-
JDK-8301443 Clean broken comments from Windows code
- Resolved
-
JDK-8302671 libawt has a memmove decay error
- Resolved
-
JDK-8302837 Kernel32.cpp array memory release invokes undefined behaviour
- Resolved
-
JDK-8305650 os::lasterror incorrectly truncates buffer in os_windows.cpp
- Closed
-
JDK-8303810 Restore attribute positions after JDK-8303839 to match JDK-8302124
- Closed
-
JDK-8295231 Move all linking of native libraries to make
- Resolved
-
JDK-8313139 Redefine INTERNAL_VISIBILITY when on Windows
- Open
-
JDK-8294281 Allow warnings to be disabled on a per-file basis
- Resolved
-
JDK-8292226 Prepare make for better Link Time Optimization support
- Resolved
-
JDK-8295070 Introduce more target combinations for compiler flags
- Resolved
-
JDK-8305341 Alignment should be enforced by alignas instead of compiler specific attributes
- Resolved
-
JDK-8307160 Fix AWT/2D/A11Y to support the permissive- flag on the Microsoft Visual C compiler
- Resolved
-
JDK-8310728 Enable Zc:inline flag in Visual Studio build
- Resolved