eclipse-openj9 / openj9

Eclipse OpenJ9: A Java Virtual Machine for OpenJDK that's optimized for small footprint, fast start-up, and high throughput. Builds on Eclipse OMR (https://github.com/eclipse/omr) and combines with the Extensions for OpenJDK for OpenJ9 repo.
Other
3.28k stars 721 forks source link

Multiple target patterns error for CMake #19410

Closed AswathySK closed 6 months ago

AswathySK commented 6 months ago

Java -version output

$ java -version openjdk version "11.0.22" 2024-01-16 IBM Semeru Runtime Open Edition 11.0.22.0 (build 11.0.22+7) Eclipse OpenJ9 VM 11.0.22.0 (build openj9-0.43.0, JRE 11 Windows Server 2019 amd64-64-Bit Compressed References 20240131_835 (JIT enabled, AOT enabled) OpenJ9 - 2c3d78b48 OMR - ea8124dbc

Summary of problem

While running build compile for a windows 19 machine (with VS2022 ) I am running into multiple target patterns. Stop. make[6]: *** [CMakeFiles/Makefile2:8528: runtime/compiler/CMakeFiles/j9jit.dir/all] Error 2 error while running make all.

I have faced this issue before and by rolling down version of cmake to v3.20.1 helped me avoid this error. Since cygwin installer only has recent versions of packages to be installed for the recent cygwin installer cmake v3.20.1 is unavailable, only v3.23 and higher is available at the moment.

job reference: https://hyc-runtimes-jenkins.swg-devops.com/job/Build_JDK11_x86-64_windows_Personal/1595/console

Diagnostic files

[2024-04-27T15:13:55.413Z] [ 51%] Built target j9gcbase
[2024-04-27T15:14:01.747Z] Consolidate compiler generated dependencies of target j9jit
[2024-04-27T15:14:03.595Z] runtime/compiler/CMakeFiles/j9jit.dir/compiler_depend.make:287797: *** multiple target patterns.  Stop.
[2024-04-27T15:14:03.595Z] make[6]: *** [CMakeFiles/Makefile2:8528: runtime/compiler/CMakeFiles/j9jit.dir/all] Error 2
[2024-04-27T15:14:03.595Z] make[6]: *** Waiting for unfinished jobs....
[2024-04-27T15:14:06.083Z] Consolidate compiler generated dependencies of target omrgc
[2024-04-27T15:14:07.364Z] [ 64%] Built target omrgc
[2024-04-27T15:14:07.364Z] make[5]: *** [CMakeFiles/Makefile2:3351: runtime/CMakeFiles/j9ddr.dir/rule] Error 2
[2024-04-27T15:14:07.364Z] make[4]: *** [Makefile:238: runtime/CMakeFiles/j9ddr.dir/rule] Error 2
[2024-04-27T15:14:07.364Z] make[3]: *** [/cygdrive/c/users/jenkins/workspace/build_jdk11_x86-64_windows_personal/closed/OpenJ9.gmk:566: build-j9] Error 2
[2024-04-27T15:14:07.364Z] make[2]: *** [/cygdrive/c/users/jenkins/workspace/build_jdk11_x86-64_windows_personal/closed/custom/Main.gmk:50: j9vm-build] Error 2
[2024-04-27T15:14:07.364Z] 
[2024-04-27T15:14:07.364Z] ERROR: Build failed for target 'all' in configuration 'windows-x86_64-normal-server-release' (exit code 2) 
[2024-04-27T15:14:10.618Z] 
[2024-04-27T15:14:10.618Z] No indication of failed target found.

I tried uninstalling cmake from cygwin and installed v3.20.1 from source and linked cygwins /usr/bin/cmake to the installed directory. But for that the build is using Nmake instead of cmake .

21:02:03  ====
21:02:03  -- Building for: NMake Makefiles
21:02:04  -- The C compiler identification is unknown
21:02:05  -- The CXX compiler identification is unknown
21:02:05  CMake Error at CMakeLists.txt:25 (project):
21:02:05    The CMAKE_C_COMPILER:
21:02:05  
21:02:05      /cygdrive/c/users/jenkins/workspace/build_jdk11_x86-64_windows_personal/build/windows-x86_64-normal-server-release/tools/cl
21:02:05  
21:02:05    is not a full path to an existing compiler tool.
21:02:05  
21:02:05    To use the NMake generator with Visual C++, cmake must be run from a shell
21:02:05    that can use the compiler cl from the command line.  This environment is
21:02:05    unable to invoke the cl compiler.  To fix this problem, run cmake from the
21:02:05    Visual Studio Command Prompt (vcvarsall.bat).
21:02:05  
21:02:05    Tell CMake where to find the compiler by setting either the environment
21:02:05    variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
21:02:05    the compiler, or to the compiler name if it is in the PATH.
21:02:05  
21:02:05  
21:02:05  CMake Error at CMakeLists.txt:25 (project):
21:02:05    The CMAKE_CXX_COMPILER:
21:02:05  
21:02:05      /cygdrive/c/users/jenkins/workspace/build_jdk11_x86-64_windows_personal/build/windows-x86_64-normal-server-release/tools/cl
21:02:05  
21:02:05    is not a full path to an existing compiler tool.
21:02:05  
21:02:05    To use the NMake generator with Visual C++, cmake must be run from a shell
21:02:05    that can use the compiler cl from the command line.  This environment is
21:02:05    unable to invoke the cl compiler.  To fix this problem, run cmake from the
21:02:05    Visual Studio Command Prompt (vcvarsall.bat).
21:02:05  
21:02:05    Tell CMake where to find the compiler by setting either the environment
21:02:05    variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
21:02:05    to the compiler, or to the compiler name if it is in the PATH.
21:02:05  
21:02:05  
21:02:05  -- Configuring incomplete, errors occurred!
pshipton commented 6 months ago

@keithc-ca any ideas?

keithc-ca commented 6 months ago

I've seen this myself and wasn't quite sure why it didn't happen in jenkins builds. I narrowed it down to management of dependencies for .nasm files. I'm updating my cmake version, perhaps it's fixed already.

pshipton commented 6 months ago

Related to https://github.ibm.com/runtimes/infrastructure/issues/8822

keithc-ca commented 6 months ago

cmake version 3.28.3 didn't fare any better.

AswathySK commented 6 months ago

@keithc-ca , cmake version in most of our build machines are 3.14.5. And personally when I encountered this error last time rolling down cmake to 3.20.1 did the trick.

What do you think is different in higher cmake versions that might be causing this issue?

keithc-ca commented 6 months ago

Older versions of cmake don't automatically track dependencies for .nasm files. It seems the new tracking doesn't play nicely with our use of fixpath.sh.

For example, consider AMD64CompressString.nasm; nasm creates a .d file which says:

runtime/compiler/CMakeFiles/j9jit.dir/x/amd64/runtime/AMD64CompressString.nasm.obj : \
  c:\space\jdk21\openj9\runtime\compiler\x\amd64\runtime\AMD64CompressString.nasm \
  c:\space\jdk21\build\normal\vm\runtime\oti\jilconsts.inc \
  c:\space\jdk21\openj9\runtime\compiler\x\amd64\runtime\AMD64CompressString.inc

Then cmake translates this the following rule in runtime/compiler/CMakeFiles/j9jit.dir/compiler_depend.make:

runtime/compiler/CMakeFiles/j9jit.dir/x/amd64/runtime/AMD64CompressString.nasm.obj: /cygdrive/c/space/jdk21/openj9/runtime/compiler/x/amd64/runtime/AMD64CompressString.nasm \
  runtime/compiler/c:/space/jdk21/build/normal/vm/runtime/oti/jilconsts.inc \
  runtime/compiler/c:/space/jdk21/openj9/runtime/compiler/x/amd64/runtime/AMD64CompressString.inc \
  runtime/compiler/c:/space/jdk21/openj9/runtime/compiler/x/amd64/runtime/AMD64CompressString.nasm

It seems that cmake's preference for using relative paths doesn't work so well.

My plan is to just disable automatic dependency management for .nasm files on Windows.

AswathySK commented 6 months ago

rerunning compile: https://hyc-runtimes-jenkins.swg-devops.com/view/OpenJ9%20-%20Personal/job/Pipeline-Build-Test-Personal/21971/console