oracle / graal

GraalVM compiles Java applications into native executables that start instantly, scale fast, and use fewer compute resources 🚀
https://www.graalvm.org
Other
20.4k stars 1.64k forks source link

LINK : fatal error LNK1181: cannot open input file on Windows #7928

Closed 15669072513 closed 11 months ago

15669072513 commented 11 months ago

Describe the issue i was use graalvm maven plugin generate native image file,but causing linking failure on windows

my environment is ok ,i can execute the HelloWorld.java correct.but when i use maven ,it fail.

Steps to reproduce the issue Please include both build steps as well as run steps

  1. I import a maven dependency:

    <dependency>
            <groupId>com.alipay.tianqian</groupId>
            <artifactId>tianqian_secret_sdk</artifactId>
            <version>1.1.20230328</version>
            <exclusions>
                <exclusion>
                    <groupId>org.apache.logging.log4j</groupId>
                    <artifactId>*</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
  2. TThere is a algo dir static resources should be included image

  3. Here i include the dir in the pom.xml:

          <plugin>
                        <groupId>org.graalvm.buildtools</groupId>
                        <artifactId>native-maven-plugin</artifactId>
                         <executions>
              <execution>
                <id>build-native</id>
                <goals>
                  <goal>compile-no-fork</goal>
                </goals>
                <phase>package</phase>
              </execution>
              </executions>
                        <configuration>
                            <verbose>true</verbose>
                            <mainClass>com.antgroup.oss.gitprepushhook.PrePushHook</mainClass>
                            <buildArgs>
                                --enable-all-security-services
                                --report-unsupported-elements-at-runtime
                                -H:+RemoveSaturatedTypeFlows
                                --allow-incomplete-classpath
                                -H:ReflectionConfigurationFiles=./reflection.json
                                -H:IncludeResources=algo\\.*
                                -H:-UseContainerSupport
                                -H:+TraceNativeToolUsage
                            </buildArgs>
                        </configuration>
                    </plugin>
  4. open vs2022 x64 Native Tool CMD execute : mvn -Pnative -DskipTest package

  5. here is the error output

    
    [6/7] Compiling methods...    [*******]                                                                 (52.2s @ 4.23GB)
    >> 'C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.38.33130\bin\HostX64\x64\cl.exe' '/Fec:\Users\gujin\git-pre-push-hook\target\git-pre-push-hook.exe' 'c:\Users\gujin\git-pre-push-hook\target\git-pre-push-hook.obj' 'C:\Users\gujin\Downloads\graalvm-ce-java17-22.3.1\lib\svm\clibraries\windows-amd64\libchelper.lib' 'C:\Users\gujin\Downloads\graalvm-ce-java17-22.3.1\lib\static\windows-amd64\net.lib' 'C:\Users\gujin\Downloads\graalvm-ce-java17-22.3.1\lib\static\windows-amd64\nio.lib' 'C:\Users\gujin\Downloads\graalvm-ce-java17-22.3.1\lib\static\windows-amd64\management_ext.lib' 'C:\Users\gujin\Downloads\graalvm-ce-java17-22.3.1\lib\static\windows-amd64\java.lib' 'C:\Users\gujin\Downloads\graalvm-ce-java17-22.3.1\lib\static\windows-amd64\fdlibm.lib' 'C:\Users\gujin\Downloads\graalvm-ce-java17-22.3.1\lib\static\windows-amd64\sunmscapi.lib' 'C:\Users\gujin\Downloads\graalvm-ce-java17-22.3.1\lib\static\windows-amd64\zip.lib' 'C:\Users\gujin\Downloads\graalvm-ce-java17-22.3.1\lib\svm\clibraries\windows-amd64\jvm.lib' /MD 'C:\Users\gujin\Downloads\graalvm-ce-java17-22.3.1\lib\svm\clibraries\windows-amd64\libchelper.lib' 'C:\Users\gujin\Downloads\graalvm-ce-java17-22.3.1\lib\static\windows-amd64\net.lib' 'C:\Users\gujin\Downloads\graalvm-ce-java17-22.3.1\lib\static\windows-amd64\nio.lib' 'C:\Users\gujin\Downloads\graalvm-ce-java17-22.3.1\lib\static\windows-amd64\management_ext.lib' 'C:\Users\gujin\Downloads\graalvm-ce-java17-22.3.1\lib\static\windows-amd64\java.lib' 'C:\Users\gujin\Downloads\graalvm-ce-java17-22.3.1\lib\static\windows-amd64\fdlibm.lib' 'C:\Users\gujin\Downloads\graalvm-ce-java17-22.3.1\lib\static\windows-amd64\sunmscapi.lib' 'C:\Users\gujin\Downloads\graalvm-ce-java17-22.3.1\lib\static\windows-amd64\zip.lib' 'C:\Users\gujin\Downloads\graalvm-ce-java17-22.3.1\lib\svm\clibraries\windows-amd64\jvm.lib' /link /INCREMENTAL:NO /NODEFAULTLIB:LIBCMT /FILEALIGN:4096 '/IMPLIB:c:\Users\gujin\git-pre-push-hook\target\git-pre-push-hook.lib' '/LIBPATH:C:\Users\gujin\Downloads\graalvm-ce-java17-22.3.1\lib\static\windows-amd64' '/LIBPATH:C:\Users\gujin\Downloads\graalvm-ce-java17-22.3.1\lib\svm\clibraries\windows-amd64' winhttp.lib psapi.lib ncrypt.lib crypt32.lib version.lib advapi32.lib ws2_32.lib secur32.lib iphlpapi.lib userenv.lib setargv.obj shell32.lib /export:JDK_LoadSystemLibrary /export:JNU_CallMethodByName /export:JNU_CallMethodByNameV /export:JNU_CallStaticMethodByName /export:JNU_ClassString /export:JNU_GetEnv /export:JNU_GetFieldByName /export:JNU_GetStaticFieldByName /export:JNU_IsInstanceOfByName /export:JNU_NewObjectByName /export:JNU_NewStringPlatform /export:JNU_SetFieldByName /export:JNU_ThrowArrayIndexOutOfBoundsException /export:JNU_ThrowByName /export:JNU_ThrowIOException /export:JNU_ThrowIllegalArgumentException /export:JNU_ThrowInternalError /export:JNU_ThrowNullPointerException /export:JNU_ThrowOutOfMemoryError /export:getEncodingFromLangID /export:getJavaIDFromLangID /export:JVM_CurrentTimeMillis /export:JVM_RaiseSignal /export:jio_snprintf
    ># Microsoft (R) C/C++ Optimizing Compiler Version 19.38.33130 for x64
    ># Copyright (C) Microsoft Corporation.  All rights reserved.
    >#
    ># Microsoft (R) Incremental Linker Version 14.38.33130.0
    ># Copyright (C) Microsoft Corporation.  All rights reserved.
    >#
    ># /out:c:\Users\gujin\git-pre-push-hook\target\git-pre-push-hook.exe
    ># /INCREMENTAL:NO
    ># /NODEFAULTLIB:LIBCMT
    ># /FILEALIGN:4096
    ># /IMPLIB:c:\Users\gujin\git-pre-push-hook\target\git-pre-push-hook.lib
    ># /LIBPATH:C:\Users\gujin\Downloads\graalvm-ce-java17-22.3.1\lib\static\windows-amd64
    ># /LIBPATH:C:\Users\gujin\Downloads\graalvm-ce-java17-22.3.1\lib\svm\clibraries\windows-amd64
    ># winhttp.lib
    ># psapi.lib
    ># ncrypt.lib
    ># crypt32.lib
    ># version.lib
    ># advapi32.lib
    ># ws2_32.lib
    ># secur32.lib
    ># iphlpapi.lib
    ># userenv.lib
    ># setargv.obj
    ># shell32.lib
    ># /export:JDK_LoadSystemLibrary
    ># /export:JNU_CallMethodByName
    ># /export:JNU_CallMethodByNameV
    ># /export:JNU_CallStaticMethodByName
    ># /export:JNU_ClassString
    ># /export:JNU_GetEnv
    ># /export:JNU_GetFieldByName
    ># /export:JNU_GetStaticFieldByName
    ># /export:JNU_IsInstanceOfByName
    ># /export:JNU_NewObjectByName
    ># /export:JNU_NewStringPlatform
    ># /export:JNU_SetFieldByName
    ># /export:JNU_ThrowArrayIndexOutOfBoundsException
    ># /export:JNU_ThrowByName
    ># /export:JNU_ThrowIOException
    ># /export:JNU_ThrowIllegalArgumentException
    ># /export:JNU_ThrowInternalError
    ># /export:JNU_ThrowNullPointerException
    ># /export:JNU_ThrowOutOfMemoryError
    ># /export:getEncodingFromLangID
    ># /export:getJavaIDFromLangID
    ># /export:JVM_CurrentTimeMillis
    ># /export:JVM_RaiseSignal
    ># /export:jio_snprintf
    ># c:\Users\gujin\git-pre-push-hook\target\git-pre-push-hook.obj
    ># C:\Users\gujin\Downloads\graalvm-ce-java17-22.3.1\lib\svm\clibraries\windows-amd64\libchelper.lib
    ># C:\Users\gujin\Downloads\graalvm-ce-java17-22.3.1\lib\static\windows-amd64\net.lib
    ># C:\Users\gujin\Downloads\graalvm-ce-java17-22.3.1\lib\static\windows-amd64\nio.lib
    ># C:\Users\gujin\Downloads\graalvm-ce-java17-22.3.1\lib\static\windows-amd64\management_ext.lib
    ># C:\Users\gujin\Downloads\graalvm-ce-java17-22.3.1\lib\static\windows-amd64\java.lib
    ># C:\Users\gujin\Downloads\graalvm-ce-java17-22.3.1\lib\static\windows-amd64\fdlibm.lib
    ># C:\Users\gujin\Downloads\graalvm-ce-java17-22.3.1\lib\static\windows-amd64\sunmscapi.lib
    ># C:\Users\gujin\Downloads\graalvm-ce-java17-22.3.1\lib\static\windows-amd64\zip.lib
    ># C:\Users\gujin\Downloads\graalvm-ce-java17-22.3.1\lib\svm\clibraries\windows-amd64\jvm.lib
    ># C:\Users\gujin\Downloads\graalvm-ce-java17-22.3.1\lib\svm\clibraries\windows-amd64\libchelper.lib
    ># C:\Users\gujin\Downloads\graalvm-ce-java17-22.3.1\lib\static\windows-amd64\net.lib
    ># C:\Users\gujin\Downloads\graalvm-ce-java17-22.3.1\lib\static\windows-amd64\nio.lib
    ># C:\Users\gujin\Downloads\graalvm-ce-java17-22.3.1\lib\static\windows-amd64\management_ext.lib
    ># C:\Users\gujin\Downloads\graalvm-ce-java17-22.3.1\lib\static\windows-amd64\java.lib
    ># C:\Users\gujin\Downloads\graalvm-ce-java17-22.3.1\lib\static\windows-amd64\fdlibm.lib
    ># C:\Users\gujin\Downloads\graalvm-ce-java17-22.3.1\lib\static\windows-amd64\sunmscapi.lib
    ># C:\Users\gujin\Downloads\graalvm-ce-java17-22.3.1\lib\static\windows-amd64\zip.lib
    ># C:\Users\gujin\Downloads\graalvm-ce-java17-22.3.1\lib\svm\clibraries\windows-amd64\jvm.lib
    >#    Creating library c:\Users\gujin\git-pre-push-hook\target\git-pre-push-hook.lib and object c:\Users\gujin\git-pre-push-hook\target\git-pre-push-hook.exp
    >> 'C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.38.33130\bin\HostX64\x64\cl.exe' '/Fec:\Users\gujin\git-pre-push-hook\target\java.dll' 'C:\Users\gujin\AppData\Local\Temp\SVM-3054740578333572780\git-pre-push-hook.lib' msvcrt.lib /link /dll /implib:java.lib /export:JDK_LoadSystemLibrary /export:JNU_CallMethodByName /export:JNU_CallMethodByNameV /export:JNU_CallStaticMethodByName /export:JNU_ClassString /export:JNU_GetEnv /export:JNU_GetFieldByName /export:JNU_GetStaticFieldByName /export:JNU_IsInstanceOfByName /export:JNU_NewObjectByName /export:JNU_NewStringPlatform /export:JNU_SetFieldByName /export:JNU_ThrowArrayIndexOutOfBoundsException /export:JNU_ThrowByName /export:JNU_ThrowIOException /export:JNU_ThrowIllegalArgumentException /export:JNU_ThrowInternalError /export:JNU_ThrowNullPointerException /export:JNU_ThrowOutOfMemoryError /export:getEncodingFromLangID /export:getJavaIDFromLangID
    ># Microsoft (R) C/C++ Optimizing Compiler Version 19.38.33130 for x64
    ># Copyright (C) Microsoft Corporation.  All rights reserved.
    >#
    ># Microsoft (R) Incremental Linker Version 14.38.33130.0
    ># Copyright (C) Microsoft Corporation.  All rights reserved.
    >#
    ># /out:c:\Users\gujin\git-pre-push-hook\target\java.dll
    ># /dll
    ># /implib:java.lib
    ># /export:JDK_LoadSystemLibrary
    ># /export:JNU_CallMethodByName
    ># /export:JNU_CallMethodByNameV
    ># /export:JNU_CallStaticMethodByName
    ># /export:JNU_ClassString
    ># /export:JNU_GetEnv
    ># /export:JNU_GetFieldByName
    ># /export:JNU_GetStaticFieldByName
    ># /export:JNU_IsInstanceOfByName
    ># /export:JNU_NewObjectByName
    ># /export:JNU_NewStringPlatform
    ># /export:JNU_SetFieldByName
    ># /export:JNU_ThrowArrayIndexOutOfBoundsException
    ># /export:JNU_ThrowByName
    ># /export:JNU_ThrowIOException
    ># /export:JNU_ThrowIllegalArgumentException
    ># /export:JNU_ThrowInternalError
    ># /export:JNU_ThrowNullPointerException
    ># /export:JNU_ThrowOutOfMemoryError
    ># /export:getEncodingFromLangID
    ># /export:getJavaIDFromLangID
    ># C:\Users\gujin\AppData\Local\Temp\SVM-3054740578333572780\git-pre-push-hook.lib
    ># msvcrt.lib
    ># LINK : fatal error LNK1181: cannot open input file 'C:\Users\gujin\AppData\Local\Temp\SVM-3054740578333572780\git-pre-push-hook.lib'

[7/7] Creating image... (0.0s @ 2.50GB) Fatal error: com.oracle.svm.core.util.VMError$HostedError: should not reach here at org.graalvm.nativeimage.builder/com.oracle.svm.core.util.VMError.shouldNotReachHere(VMError.java:64) at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.jdk.JNIRegistrationSupport.makeShimDLL(JNIRegistrationSupport.java:273) at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.jdk.JNIRegistrationSupport.makeShimDLLs(JNIRegistrationSupport.java:247) at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.jdk.JNIRegistrationSupport.afterImageWrite(JNIRegistrationSupport.java:192) at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.lambda$doRun$8(NativeImageGenerator.java:724) at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.FeatureHandler.forEachFeature(FeatureHandler.java:85) at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:724) at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.run(NativeImageGenerator.java:535) at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.buildImage(NativeImageGeneratorRunner.java:403) at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.build(NativeImageGeneratorRunner.java:580) at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.main(NativeImageGeneratorRunner.java:128)

                    6.9s (3.0% of total time) in 38 GCs | Peak RSS: 5.99GB | CPU load: 4.45

Produced artifacts: c:\Users\gujin\git-pre-push-hook\target\awt.dll (jdk_lib) c:\Users\gujin\git-pre-push-hook\target\git-pre-push-hook.build_artifacts.txt (txt) c:\Users\gujin\git-pre-push-hook\target\git-pre-push-hook.exe (executable)

Failed generating 'c:\Users\gujin\git-pre-push-hook\target\git-pre-push-hook' after 3m 46s. Error: Image build request failed with exit status 1 [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 04:15 min [INFO] Finished at: 2023-12-04T10:21:13+08:00 [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.graalvm.buildtools:native-maven-plugin:0.9.28:compile-no-fork (build-native) on project git-pre-push-hook: Execution of C:\Users\gujin\Downloads\graalvm-ce-java17-22.3.1\bin\native-image.cmd @target\tmp\native-image-1027028260236657520.args com.antgroup.oss.gitprepushhook.PrePushHook returned non-zero result -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException



**Describe GraalVM and your environment:**
 - GraalVM version  22.3.1
- JDK  version: 17
- OS: Windows 10 Enterprise LTSC
- vs 2022 

**Other information:**
I guess it is because of the Internal Maven Dependency,if i delete the code, i compile success. but when i use the code , should  it  show detail  reasons not just simply fail  ?
hamzaGhaissi commented 11 months ago

Hi can you please share a small reproducer, also the whole stack trace (not as an image)

hamzaGhaissi commented 11 months ago

Sure no problem

15669072513 commented 11 months ago

Hello ,i have edited the issue which include all the information.

15669072513 commented 11 months ago

and this ,it has already generate the git-pre-push-hook.lib in target dir ,why it still try to find it in the Temp dir ? image