Skip to content

Commit

Permalink
buildGraalvm: use NATIVE_IMAGE_DEPRECATED_BUILDER_SANITATION instead …
Browse files Browse the repository at this point in the history
…of CC wrapper

Instead of using a hacky CC wrapper to re-inject the environment
variables needed to build, we set the
NATIVE_IMAGE_DEPRECATED_BUILDER_SANITATION=true that is in 21.0.0
release changelog:
https://github.com/oracle/graal/blob/489611a304ec808cdcb1e07e9a9799e6240fd2e1/substratevm/CHANGELOG.md?plain=1#L48

This is deprecated behavior for now, and will be removed in future, but
this will allow us more time until we figure a proper solution.

See:
- oracle/graal#7502
- oracle/graal#7981
- oracle/graal#6095
  • Loading branch information
thiagokokada authored and Mic92 committed Dec 17, 2023
1 parent 3913ff5 commit 68824f8
Showing 1 changed file with 9 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 ]);
Expand Down Expand Up @@ -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'
Expand Down

0 comments on commit 68824f8

Please sign in to comment.