Merge pull request #273961 from thiagokokada/workaround-graalvm-ce

graalvm-ce: use NATIVE_IMAGE_DEPRECATED_BUILDER_SANITATION instead of CC wrapper
This commit is contained in:
Thiago Kenji Okada
2023-12-13 20:55:14 +00:00
committed by GitHub
2 changed files with 16 additions and 16 deletions
@@ -49,6 +49,13 @@ stdenv.mkDerivation ({
nativeImageBuildArgs = nativeImageBuildArgs ++ extraNativeImageBuildArgs ++ [ graalvmXmx ];
# Workaround GraalVM issue where the builder does not have access to the
# environment variables since 21.0.0
# https://github.com/oracle/graal/pull/6095
# https://github.com/oracle/graal/pull/6095
# https://github.com/oracle/graal/issues/7502
env.NATIVE_IMAGE_DEPRECATED_BUILDER_SANITATION = "true";
buildPhase = args.buildPhase or ''
runHook preBuild
@@ -63,22 +63,7 @@ let
mkdir -p $out/bin
ln -s ${lib.getDev musl}/bin/musl-gcc $out/bin/${stdenv.hostPlatform.system}-musl-gcc
'');
# GraalVM 23.0.0+ (i.e.: JDK 21.0.0+) clean-up the environment inside darwin
# So we need to re-added some env vars to make everything work correctly again
darwin-cc = (runCommandCC "darwin-cc"
{
nativeBuildInputs = [ makeWrapper ];
buildInputs = [ darwin.apple_sdk.frameworks.Foundation zlib ];
} ''
makeWrapper ${stdenv.cc}/bin/cc $out/bin/cc \
--prefix NIX_CFLAGS_COMPILE_${stdenv.cc.suffixSalt} : "$NIX_CFLAGS_COMPILE" \
--prefix NIX_LDFLAGS_${stdenv.cc.suffixSalt} : "$NIX_LDFLAGS"
'');
binPath = lib.makeBinPath (
lib.optionals stdenv.isDarwin [ darwin-cc ]
++ lib.optionals useMusl [ musl-gcc ]
++ [ stdenv.cc ]
);
binPath = lib.makeBinPath (lib.optionals useMusl [ musl-gcc ] ++ [ stdenv.cc ]);
runtimeLibraryPath = lib.makeLibraryPath
([ cups ] ++ lib.optionals gtkSupport [ cairo glib gtk3 ]);
@@ -180,6 +165,14 @@ let
echo "Testing GraalVM"
$out/bin/java -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:+UseJVMCICompiler HelloWorld | fgrep 'Hello World'
# Workaround GraalVM issue where the builder does not have access to the
# environment variables since 21.0.0
# Only needed for native-image tests
# https://github.com/oracle/graal/pull/6095
# https://github.com/oracle/graal/pull/6095
# https://github.com/oracle/graal/issues/7502
export NATIVE_IMAGE_DEPRECATED_BUILDER_SANITATION="true";
echo "Ahead-Of-Time compilation"
$out/bin/native-image -H:+UnlockExperimentalVMOptions -H:-CheckToolchain -H:+ReportExceptionStackTraces HelloWorld
./helloworld | fgrep 'Hello World'