Attached to this thread is related information I could find within the
JVM's build system (Posted to the top level to not clutter the discussion
below)

Information currently gathered by simply disabling Visual C++ and link.exe
specific flags if gcc is detected until build failure. Also had to come up
with the temporary solution of providing --with-msvcr-dll with a fake dll
for configure to pass. Autoconf had a lot of trouble with WSL (Unable to
find headers and so on), apparently due to issues with CreateProcess, so
this was all tested with MSYS2.

Not a very good way to test it, but it'll have to do for now. Build
currently fails when POSIX header dlfcn.h is encountered, hinting a check
is required to switch to Windows includes if needed. Managed to compile
(Including adlc) until HotSpot source code was reached

Relevant log for future reference (Paths truncated):
Building target 'images' in configuration 'windows-x86_64-server-release'
Compiling 1 files for BUILD_TOOLS_HOTSPOT
Compiling 8 files for BUILD_TOOLS_LANGTOOLS
Warning: No SCM configuration present and no .src-rev
Parsing 2 properties into enum-like class for jdk.compiler
Compiling 13 properties into resource bundles for jdk.javadoc
Compiling 16 properties into resource bundles for jdk.compiler
Compiling 7 properties into resource bundles for jdk.jshell
Compiling 12 properties into resource bundles for jdk.jdeps
Creating hotspot/variant-server/tools/adlc/adlc.exe from 13 file(s)
Compiling 2 files for BUILD_JVMTI_TOOLS
Compiling 127 files for BUILD_java.compiler.interim
Compiling 403 files for BUILD_jdk.compiler.interim
Compiling 238 files for BUILD_jdk.javadoc.interim
Creating support/modules_libs/java.base/server/jvm.dll from 1076 file(s)
In file included from src\hotspot\share/utilities/globalDefinitions.hpp:35,
from src\hotspot\share/memory/allocation.hpp:29,
from src\hotspot\share/classfile/classLoaderData.hpp:28,
from src\hotspot\share\precompiled\precompiled.hpp:34:
src\hotspot\share/utilities/globalDefinitions_gcc.hpp:45:10: fatal error:
dlfcn.h: No such file or directory
   45 | #include <dlfcn.h>
      |          ^~~~~~~~~
compilation terminated.
/usr/bin/bash: line 1: -DJDK_VERSION_STRING=19-internal: command not found
make[3]: *** [lib/CompileJvm.gmk:148:
build/windows-x86_64-server-release/hotspot/variant-server/libjvm/objects/jvm.dll.res]
Error 127


Areas of interest so far:
toolchain_microsoft.m4
May need to take a better look at it later to see if it can be enhanced to
handle other toolchains (Mostly since we need ucrtbase.dll and windres).
Could be renamed to toolchain_windows or something else if we do this.

flags.m4 flags-cflags.m4 and flags-ldflags.m4
May need some changes to check for platform. Seems to mostly be correct in
using only the compiler type to figure out what flags to use though

GensrcAdlc.gmk, line 37 onwards
First instance of hard assumption that a specific platform means a specific
compiler is being used

NativeCompilation.gmk, including but not just line 1081 and beyond
This specific area also assumes that Visual C++ is used just because the
target (Note to self: Not the current build OS!) is Windows. On first
glance seems to handle manifest embedding and generation of the import
library lib for a currently unknown dll (The latter wouldn't be needed if
we're using gcc)

Flags: (Visual C++) -> (gcc)

Compiler Flags:
-nologo -> Visual C++ specific
-EHsc -> Exception handling model, use -fno-exceptions and -funwind-tables
to substitute? (Used for ADLC)
-W3 -> Warning level, doesn't seem like there's an exact gcc match
-D_CRT_SECURE_NO_WARNINGS -> Visual C++ specific

Linker Flags:
-nologo -> Not required
-manifest -> ? (ucrt based gcc documentation on manifests is sparse)
-implib -> gcc doesn't require import libraries to link dynamically to dlls

Reply via email to