native-build-tools icon indicating copy to clipboard operation
native-build-tools copied to clipboard

Build fails when moving to maven plugin version 0.10.3

Open itineric opened this issue 1 year ago • 4 comments

Describe the bug Moved from maven plugin version 0.10.2 to version 0.10.3 (nothing else changed, building in docker environment).

Logs

Sometimes I have

> com.oracle.svm.core.util.VMError$HostedError: Unable to run '/tmp/SVM-7190424573437323119/AArch64LibCHelperDirectives' to compute offsets in C data structures. Is it possible that your antivirus software interferes and puts the resulting file into quarantine?

or

> com.oracle.svm.core.util.VMError$HostedError: Unable to run '/tmp/SVM-17858907294964428047/BuiltinDirectives' to compute offsets in C data structures. Is it possible that your antivirus software interferes and puts the resulting file into quarantine?

And some other times:

         [] Error: Error compiling query code (in /tmp/SVM-48586303440702563/PosixDirectives.c). Compiler command '/opt/x86_64-linux-musl-native/bin/gcc -Wal
l -Werror -o /tmp/SVM-48586303440702563/PosixDirectives /tmp/SVM-48586303440702563/PosixDirectives.c' output included error: /tmp/SVM-48586303440702563/Posix
Directives.c:82:117: error: ???LC_ADDRESS??? undeclared (first use in this function)
         []     method com.oracle.svm.core.posix.headers.Errno.ETIMEDOUT()
         []     C file contents around line 82:
         []     /tmp/SVM-48586303440702563/PosixDirectives.c:81:     printf("NativeCodeInfo:PosixDirectives:ConstantInfo:ETIMEDOUT:PropertyInfo:value=%lX\n",
 ((unsigned long)ETIMEDOUT));
         []     /tmp/SVM-48586303440702563/PosixDirectives.c:82:     printf("NativeCodeInfo:PosixDirectives:ConstantInfo:LC_ADDRESS:PropertyInfo:size=%lu\n",
 ((unsigned long)sizeof(LC_ADDRESS)));
         []     /tmp/SVM-48586303440702563/PosixDirectives.c:83:     printf("NativeCodeInfo:PosixDirectives:ConstantInfo:LC_ADDRESS:PropertyInfo:signedness=$
%s$\n", ((LC_ADDRESS>=0 ? 1 : 0)) ? "UNSIGNED" : "SIGNED");
         [] Error: Error compiling query code (in /tmp/SVM-48586303440702563/PosixDirectives.c). Compiler command '/opt/x86_64-linux-musl-native/bin/gcc -Wal
l -Werror -o /tmp/SVM-48586303440702563/PosixDirectives /tmp/SVM-48586303440702563/PosixDirectives.c' output included error: /tmp/SVM-48586303440702563/Posix
Directives.c:94:124: error: ???LC_IDENTIFICATION??? undeclared (first use in this function)
         []     method com.oracle.svm.core.posix.headers.Locale.LC_CTYPE()
         []     C file contents around line 94:
         []     /tmp/SVM-48586303440702563/PosixDirectives.c:93:     printf("NativeCodeInfo:PosixDirectives:ConstantInfo:LC_CTYPE:PropertyInfo:value=%lX\n",
((unsigned long)LC_CTYPE));
         []     /tmp/SVM-48586303440702563/PosixDirectives.c:94:     printf("NativeCodeInfo:PosixDirectives:ConstantInfo:LC_IDENTIFICATION:PropertyInfo:size=
%lu\n", ((unsigned long)sizeof(LC_IDENTIFICATION)));
         []     /tmp/SVM-48586303440702563/PosixDirectives.c:95:     printf("NativeCodeInfo:PosixDirectives:ConstantInfo:LC_IDENTIFICATION:PropertyInfo:signe
dness=$%s$\n", ((LC_IDENTIFICATION>=0 ? 1 : 0)) ? "UNSIGNED" : "SIGNED");
         [] Error: Error compiling query code (in /tmp/SVM-48586303440702563/PosixDirectives.c). Compiler command '/opt/x86_64-linux-musl-native/bin/gcc -Wal
l -Werror -o /tmp/SVM-48586303440702563/PosixDirectives /tmp/SVM-48586303440702563/PosixDirectives.c' output included error: /tmp/SVM-48586303440702563/Posix
Directives.c:97:121: error: ???LC_MEASUREMENT??? undeclared (first use in this function)
         []     method com.oracle.svm.core.posix.headers.Locale.LC_IDENTIFICATION()
         []     C file contents around line 97:
         []     /tmp/SVM-48586303440702563/PosixDirectives.c:96:     printf("NativeCodeInfo:PosixDirectives:ConstantInfo:LC_IDENTIFICATION:PropertyInfo:value
=%lX\n", ((unsigned long)LC_IDENTIFICATION));
         []     /tmp/SVM-48586303440702563/PosixDirectives.c:97:     printf("NativeCodeInfo:PosixDirectives:ConstantInfo:LC_MEASUREMENT:PropertyInfo:size=%lu
\n", ((unsigned long)sizeof(LC_MEASUREMENT)));
         []     /tmp/SVM-48586303440702563/PosixDirectives.c:98:     printf("NativeCodeInfo:PosixDirectives:ConstantInfo:LC_MEASUREMENT:PropertyInfo:signedne
ss=$%s$\n", ((LC_MEASUREMENT>=0 ? 1 : 0)) ? "UNSIGNED" : "SIGNED");
...
...
...
...

System Info:

  • OS: debian inside docker
  • GraalVM Version 17.0.9 CE
  • Java Version 17
  • Plugin version native-maven-plugin:0.10.13

itineric avatar Oct 21 '24 15:10 itineric

We looked into this and find it highly unlikely that it comes from the version bump in the maven plugin. Please try this by downgrading the plugin to 0.10.2 in the same docker environment.

The reason why we think it is not Maven related is because the failure indicates that there are missing header files on the docker container. This error is purely in Native Image and Maven does not even see that in any circumstance.

vjovanov avatar Nov 04 '24 15:11 vjovanov

trying to upgrade this version again, still having the issue with 0.10.3 and 0.10.4

What makes you belive there is a missing header in the docker image? I do not find any information about was may be missing.

itineric avatar Jan 22 '25 15:01 itineric

I finally found the issue. It is related to that breaking change: https://github.com/graalvm/native-build-tools/commit/90abd0bc59d62e7e497922c22a43fdfc1999de7c#diff-e69cd9817043e503f9d8aadfad08867aeb9e02e33435f8fe7eea7f1225e12794L246 My single <arg> containing many arguments is not interpreted the same way as before. I think the --static --libc=musl are not used at all. So the compilation of the .c files in the SVM-xxx folder are at best "not compilable" (the error makes you think there are missing headers), at worth: the executable file is compiled but not executable at all (not statically linked as expected).

itineric avatar Jan 22 '25 16:01 itineric

The real beaking change is here: https://github.com/graalvm/native-build-tools/blame/27986882a3e797b39ee5783a76706622791db347/native-maven-plugin/src/main/java/org/graalvm/buildtools/maven/AbstractNativeImageMojo.java#L250 The split with the second argument can lead to arguments being lost, depending on the order the arguments are provided.

itineric avatar Jan 22 '25 17:01 itineric