buildGraalvm: fix native-image on darwin
On Darwin, it is apparently Oracle's intention to be hostile towards builds of Clang which are not by Apple. see https://github.com/oracle/graal/issues/12041 If you want native-image to both work on Darwin and use the nix-provided CC then you must pass it the flags to disable toolchain checking entirely. Since the flags are mandatory for functionality, they should be part of the wrapper.
This commit is contained in:
@@ -161,6 +161,10 @@ let
|
|||||||
"-EMACOSX_DEPLOYMENT_TARGET_FOR_TARGET"
|
"-EMACOSX_DEPLOYMENT_TARGET_FOR_TARGET"
|
||||||
"-ENIX_APPLE_SDK_VERSION"
|
"-ENIX_APPLE_SDK_VERSION"
|
||||||
];
|
];
|
||||||
|
checkToolchainFlags = lib.optionals stdenv.hostPlatform.isDarwin [
|
||||||
|
"-H:+UnlockExperimentalVMOptions"
|
||||||
|
"-H:-CheckToolchain"
|
||||||
|
];
|
||||||
in
|
in
|
||||||
''
|
''
|
||||||
# jni.h expects jni_md.h to be in the header search path.
|
# jni.h expects jni_md.h to be in the header search path.
|
||||||
@@ -181,7 +185,7 @@ let
|
|||||||
|
|
||||||
wrapProgram $out/bin/native-image \
|
wrapProgram $out/bin/native-image \
|
||||||
--prefix PATH : ${binPath} \
|
--prefix PATH : ${binPath} \
|
||||||
--add-flags "${toString (cLibsFlags ++ preservedNixVarFlags)}"
|
--add-flags "${toString (cLibsFlags ++ preservedNixVarFlags ++ checkToolchainFlags)}"
|
||||||
'';
|
'';
|
||||||
|
|
||||||
preFixup = lib.optionalString (stdenv.hostPlatform.isLinux) ''
|
preFixup = lib.optionalString (stdenv.hostPlatform.isLinux) ''
|
||||||
@@ -216,7 +220,7 @@ let
|
|||||||
$out/bin/java -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:+UseJVMCICompiler HelloWorld | fgrep 'Hello World'
|
$out/bin/java -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:+UseJVMCICompiler HelloWorld | fgrep 'Hello World'
|
||||||
|
|
||||||
echo "Ahead-Of-Time compilation"
|
echo "Ahead-Of-Time compilation"
|
||||||
$out/bin/native-image -H:+UnlockExperimentalVMOptions -H:-CheckToolchain -H:+ReportExceptionStackTraces -march=compatibility HelloWorld
|
$out/bin/native-image -H:+ReportExceptionStackTraces -march=compatibility HelloWorld
|
||||||
./helloworld | fgrep 'Hello World'
|
./helloworld | fgrep 'Hello World'
|
||||||
|
|
||||||
${
|
${
|
||||||
|
|||||||
Reference in New Issue
Block a user