Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

graalvm-ce-20.2.0 -> 20.3.0 + darwin support. #105815

Merged
merged 2 commits into from Feb 2, 2021

Conversation

stevana
Copy link
Contributor

@stevana stevana commented Dec 3, 2020

Motivation for this change

Bump version to the latest release and add Darwin support (used to be Linux only).

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@SuperSandro2000
Copy link
Member

SuperSandro2000 commented Dec 3, 2020

Result of nixpkgs-review pr 105815 run on x86_64-linux 1

2 packages failed to build:
  • babashka
  • clj-kondo
2 packages built:
  • graalvm11-ce
  • graalvm8-ce

babashka

-H:ClassInitialization=org.postgresql.sspi.SSPIClient:run_time \
-H:CLibraryPath=/nix/store/k7z4k4az6jrrg7zn3mlk3w4zxlpyfmca-graalvm11-ce-20.3.0/lib/svm/clibraries/linux-amd64 \
-H:ReflectionConfigurationFiles=/nix/store/n244mqpbrbdsn1m6pb29ra5riak8ihvg-reflection.json \
-H:Name=bb \

]
[bb:23]    classlist:   4,033.38 ms,  0.96 GB
[bb:23]        (cap):   1,036.71 ms,  0.96 GB
[bb:23]        setup:   1,501.86 ms,  0.96 GB
Error: Incompatible change of initialization policy for java.lang.Math$RandomNumberGeneratorHolder: trying to change RUN_TIME from the command line to RERUN for random number generator
com.oracle.svm.core.util.UserError$UserException: Incompatible change of initialization policy for java.lang.Math$RandomNumberGeneratorHolder: trying to change RUN_TIME from the command line to RERUN for random number generator
    at com.oracle.svm.core.util.UserError.abort(UserError.java:68)
    at com.oracle.svm.hosted.classinitialization.ClassInitializationConfiguration.insertRec(ClassInitializationConfiguration.java:99)
    at com.oracle.svm.hosted.classinitialization.ClassInitializationConfiguration.insertRec(ClassInitializationConfiguration.java:113)
    at com.oracle.svm.hosted.classinitialization.ClassInitializationConfiguration.insertRec(ClassInitializationConfiguration.java:113)
    at com.oracle.svm.hosted.classinitialization.ClassInitializationConfiguration.insertRec(ClassInitializationConfiguration.java:113)
    at com.oracle.svm.hosted.classinitialization.ClassInitializationConfiguration.insert(ClassInitializationConfiguration.java:64)
    at com.oracle.svm.hosted.classinitialization.ConfigurableClassInitialization.rerunInitialization(ConfigurableClassInitialization.java:379)
    at com.oracle.svm.core.jdk.RandomNumbersFeature.duringSetup(RandomNumbersFeature.java:42)
    at com.oracle.svm.hosted.NativeImageGenerator.lambda$setupNativeImage$12(NativeImageGenerator.java:882)
    at com.oracle.svm.hosted.FeatureHandler.forEachFeature(FeatureHandler.java:70)
    at com.oracle.svm.hosted.NativeImageGenerator.setupNativeImage(NativeImageGenerator.java:882)
    at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:556)
    at com.oracle.svm.hosted.NativeImageGenerator.lambda$run$0(NativeImageGenerator.java:471)
    at java.base/java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1407)
    at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
    at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
    at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
    at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
    at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
Error: Image build request failed with exit status 1
com.oracle.svm.driver.NativeImage$NativeImageError: Image build request failed with exit status 1
    at com.oracle.svm.driver.NativeImage.showError(NativeImage.java:1647)
    at com.oracle.svm.driver.NativeImage.build(NativeImage.java:1397)
    at com.oracle.svm.driver.NativeImage.performBuild(NativeImage.java:1358)
    at com.oracle.svm.driver.NativeImage.main(NativeImage.java:1317)
    at com.oracle.svm.driver.NativeImage$JDK9Plus.main(NativeImage.java:1829)

@stevana
Copy link
Contributor Author

stevana commented Dec 4, 2020

Fixed the babashka build, but clj-kondo still fails:

these derivations will be built:
  /nix/store/lwp8315zhvqwi7m0dwwg3vpk998ivnv8-clj-kondo-2020.11.07.drv
building '/nix/store/lwp8315zhvqwi7m0dwwg3vpk998ivnv8-clj-kondo-2020.11.07.drv'...
patching sources
configuring
no configure script, doing nothing
building
Executing [
/nix/store/k7z4k4az6jrrg7zn3mlk3w4zxlpyfmca-graalvm11-ce-20.3.0/bin/java \
-XX:+UseParallelGC \
-XX:+UnlockExperimentalVMOptions \
-XX:+EnableJVMCI \
-Dtruffle.TrustAllTruffleRuntimeProviders=true \
-Dtruffle.TruffleRuntime=com.oracle.truffle.api.impl.DefaultTruffleRuntime \
-Dgraalvm.ForcePolyglotInvalid=true \
-Dgraalvm.locatorDisabled=true \
-Dsubstratevm.IgnoreGraalVersionCheck=true \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.aarch64=ALL-UNNAMED \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.amd64=ALL-UNNAMED \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.code.site=ALL-UNNAMED \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.code.stack=ALL-UNNAMED \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.code=ALL-UNNAMED \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.common=ALL-UNNAMED \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.hotspot.aarch64=ALL-UNNAMED \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.hotspot.amd64=ALL-UNNAMED \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.hotspot.sparc=ALL-UNNAMED \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.hotspot=ALL-UNNAMED \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.meta=ALL-UNNAMED \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.runtime=ALL-UNNAMED \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.services=ALL-UNNAMED \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.sparc=ALL-UNNAMED \
--add-exports=org.graalvm.truffle/com.oracle.truffle.api=ALL-UNNAMED \
--add-opens=jdk.internal.vm.compiler/org.graalvm.compiler.debug=ALL-UNNAMED \
--add-opens=jdk.internal.vm.compiler/org.graalvm.compiler.nodes=ALL-UNNAMED \
--add-opens=jdk.unsupported/sun.reflect=ALL-UNNAMED \
--add-opens=java.base/jdk.internal.module=ALL-UNNAMED \
--add-opens=java.base/jdk.internal.ref=ALL-UNNAMED \
--add-opens=java.base/jdk.internal.reflect=ALL-UNNAMED \
--add-opens=java.base/java.io=ALL-UNNAMED \
--add-opens=java.base/java.lang=ALL-UNNAMED \
--add-opens=java.base/java.lang.reflect=ALL-UNNAMED \
--add-opens=java.base/java.lang.invoke=ALL-UNNAMED \
--add-opens=java.base/java.lang.ref=ALL-UNNAMED \
--add-opens=java.base/java.net=ALL-UNNAMED \
--add-opens=java.base/java.nio=ALL-UNNAMED \
--add-opens=java.base/java.nio.file=ALL-UNNAMED \
--add-opens=java.base/java.security=ALL-UNNAMED \
--add-opens=java.base/javax.crypto=ALL-UNNAMED \
--add-opens=java.base/java.util=ALL-UNNAMED \
--add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED \
--add-opens=java.base/sun.security.x509=ALL-UNNAMED \
--add-opens=java.base/jdk.internal.logger=ALL-UNNAMED \
--add-opens=java.desktop/sun.java2d.cmm.profiles=ALL-UNNAMED \
--add-opens=org.graalvm.sdk/org.graalvm.nativeimage.impl=ALL-UNNAMED \
--add-opens=org.graalvm.sdk/org.graalvm.polyglot=ALL-UNNAMED \
--add-opens=org.graalvm.truffle/com.oracle.truffle.polyglot=ALL-UNNAMED \
--add-opens=org.graalvm.truffle/com.oracle.truffle.api.impl=ALL-UNNAMED \
-XX:+UseJVMCINativeLibrary \
-Xss10m \
-Xms1g \
-Xmx14g \
-Duser.country=US \
-Duser.language=en \
-Djava.awt.headless=true \
-Dorg.graalvm.version=20.3.0 \
-Dorg.graalvm.config= \
-Dcom.oracle.graalvm.isaot=true \
-Djava.system.class.loader=com.oracle.svm.hosted.NativeImageSystemClassLoader \
-Xshare:off \
--module-path \
/nix/store/k7z4k4az6jrrg7zn3mlk3w4zxlpyfmca-graalvm11-ce-20.3.0/lib/truffle/truffle-api.jar \
-Djdk.internal.lambda.disableEagerInitialization=true \
-Djdk.internal.lambda.eagerlyInitialize=false \
-Djava.lang.invoke.InnerClassLambdaMetafactory.initializeLambdas=false \
-Dclojure.spec.skip-macros=true \
-Dclojure.compiler.direct-linking=true \
-Xmx3g \
-javaagent:/nix/store/k7z4k4az6jrrg7zn3mlk3w4zxlpyfmca-graalvm11-ce-20.3.0/lib/svm/builder/svm.jar \
-cp \
/nix/store/k7z4k4az6jrrg7zn3mlk3w4zxlpyfmca-graalvm11-ce-20.3.0/lib/svm/builder/llvm-platform-specific-shadowed.jar:/nix/store/k7z4k4az6jrrg7zn3mlk3w4zxlpyfmca-graalvm11-ce-20.3.0/lib/svm/builder/svm-llvm.jar:/nix/store/k7z4k4az6jrrg7zn3mlk3w4zxlpyfmca-graalvm11-ce-20.3.0/lib/svm/builder/llvm-wrapper-shadowed.jar:/nix/store/k7z4k4az6jrrg7zn3mlk3w4zxlpyfmca-graalvm11-ce-20.3.0/lib/svm/builder/pointsto.jar:/nix/store/k7z4k4az6jrrg7zn3mlk3w4zxlpyfmca-graalvm11-ce-20.3.0/lib/svm/builder/objectfile.jar:/nix/store/k7z4k4az6jrrg7zn3mlk3w4zxlpyfmca-graalvm11-ce-20.3.0/lib/svm/builder/javacpp-shadowed.jar:/nix/store/k7z4k4az6jrrg7zn3mlk3w4zxlpyfmca-graalvm11-ce-20.3.0/lib/svm/builder/svm.jar \
'com.oracle.svm.hosted.NativeImageGeneratorRunner$JDK9Plus' \
-watchpid \
4 \
-imagecp \
/nix/store/k7z4k4az6jrrg7zn3mlk3w4zxlpyfmca-graalvm11-ce-20.3.0/lib/svm/library-support.jar:/nix/store/hzg60jrz9n277b1d9wz6jihh5fmf605y-clj-kondo-2020.11.07-standalone.jar \
-H:Path=/build \
-H:Class=clj_kondo.main \
-H:ClassInitialization=org.graalvm.polyglot:build_time \
-H:Features=org.graalvm.home.HomeFinderFeature \
-H:+ReportExceptionStackTraces \
'-H:IncludeResources=clj_kondo/impl/cache/built_in/.*' \
-H:ClassInitialization=:build_time \
-H:Log=registerResource: \
-H:FallbackThreshold=0 \
-H:CLibraryPath=/nix/store/k7z4k4az6jrrg7zn3mlk3w4zxlpyfmca-graalvm11-ce-20.3.0/lib/svm/clibraries/linux-amd64 \
-H:ReflectionConfigurationFiles=/nix/store/2853gvf93rlwwkzp8libm2xbs43a5vab-reflection.json \
-H:Name=clj-kondo \

]
Fatal error:com.oracle.svm.core.util.VMError$HostedError: Option name "TruffleMultiThreaded" has multiple definitions: com.oracle.svm.truffle.api.SubstrateTruffleOptions.TruffleMultiThreaded and com.oracle.svm.truffle.api.SubstateTruffleOptions.TruffleMultiThreaded
        at com.oracle.svm.core.util.VMError.shouldNotReachHere(VMError.java:68)
        at com.oracle.svm.hosted.option.HostedOptionParser.collectOptions(HostedOptionParser.java:89)
        at com.oracle.svm.hosted.option.HostedOptionParser.<init>(HostedOptionParser.java:62)
        at com.oracle.svm.hosted.NativeImageGeneratorRunner.buildImage(NativeImageGeneratorRunner.java:238)
        at com.oracle.svm.hosted.NativeImageGeneratorRunner.build(NativeImageGeneratorRunner.java:509)
        at com.oracle.svm.hosted.NativeImageGeneratorRunner.main(NativeImageGeneratorRunner.java:115)
        at com.oracle.svm.hosted.NativeImageGeneratorRunner$JDK9Plus.main(NativeImageGeneratorRunner.java:541)
Error: Image build request failed with exit status 1
com.oracle.svm.driver.NativeImage$NativeImageError: Image build request failed with exit status 1
        at com.oracle.svm.driver.NativeImage.showError(NativeImage.java:1647)
        at com.oracle.svm.driver.NativeImage.build(NativeImage.java:1397)
        at com.oracle.svm.driver.NativeImage.performBuild(NativeImage.java:1358)
        at com.oracle.svm.driver.NativeImage.main(NativeImage.java:1317)
        at com.oracle.svm.driver.NativeImage$JDK9Plus.main(NativeImage.java:1829)
builder for '/nix/store/lwp8315zhvqwi7m0dwwg3vpk998ivnv8-clj-kondo-2020.11.07.drv' failed with exit code 1
error: build of '/nix/store/lwp8315zhvqwi7m0dwwg3vpk998ivnv8-clj-kondo-2020.11.07.drv' failed

/cc @borkdude

@ofborg ofborg bot requested a review from jlesquembre December 4, 2020 07:54
@borkdude
Copy link

borkdude commented Dec 4, 2020

@stevana Babashka only compiles with 20.2.0 at this moment, due to a dependency on svm.jar for version 20.2.0. The next version of babashka will use 20.3.0.

See https://github.com/borkdude/babashka/blob/master/doc/build.md

@stevana
Copy link
Contributor Author

stevana commented Dec 4, 2020

@borkdude Babashka seems to compile fine with 20.3.0 (checkout this branch, and do nix-build -A babashka)? clj-kondo however doesn't, c.f. the log above.

@borkdude
Copy link

borkdude commented Dec 4, 2020

@stevana Same thing: https://github.com/borkdude/clj-kondo/blob/master/doc/build.md

Clj-kondo has a hard dependency on borkdude/clj-reflector-graal-java11-fix "0.0.1-graalvm-20.2.0".
You could try to override that dep for the nixOS build, otherwise it likely won't compile with 20.3.0. I'm surprised babashka does work with 20.3.0.

@stevana
Copy link
Contributor Author

stevana commented Dec 4, 2020

Thanks for the pointers!

It seems to me that specific dependencies cannot be overridden on the nix level, because the nix package simply pulls a clj-kondo uberjar from github releases and feeds that to native-image. I think I'll leave this to the clj-kondo nix package maintainers to figure out. Worst case we can just wait until clj-kondo supports 20.3.0.

@borkdude
Copy link

borkdude commented Dec 4, 2020

I will bump babashka and clj-kondo both to 20.3.0 before the end of the year (at least that's the plan).

@stevana
Copy link
Contributor Author

stevana commented Dec 4, 2020

Cool, no rush from my side. By the way, in case you didn't see it already, the following one-line change is needed for babashka to work with 20.3.0: d255424 .

@borkdude
Copy link

borkdude commented Dec 4, 2020

@stevana Thanks. Yes, that change is also in my 20.3.0 branch.

@bennyandresen
Copy link
Contributor

I welcome darwin support and I've been the person that upgraded clj-kondo and babashka the most this year.

babashka can be version bumped from my side (on graalvm-ce-20.2) before this is merged, but clj-kondo v2020.12.12 fails.

So it appears that there is a dependency here from clj-kondo and in a minor way for babashka (due to the one-line removal).

Having two PRs open and having it depend on it one another is very messy.
I don't know the proper nixpkgs-way to untangle it. Thoughts?

@borkdude
Copy link

borkdude commented Dec 13, 2020

clj-kondo v2020.12.12 uses graalvm-ce-20.3.0 (as opposed to the previous version which used graalvm-ce-20.2.0).

@borkdude
Copy link

Both clj-kondo and babashka newest are now compiled using GraalVM 20.3.0.

@stevana
Copy link
Contributor Author

stevana commented Dec 14, 2020

This is my first nixpkgs PR, so I don't know what the right protocol is neither.

The fact that the same code can compile with version V of GraalVM and not compile on version V+1 is garbage.

I see two options:

  1. we update graalvm, babaska and clj-kondo in the same PR (ugly and probably not "the nixpkgs way" to do things);
  2. we need to make babaska and clj-kondo compile with both graalvm 20.2.0 and 20.3.0, then we can first upgrade the babahska and clj-kondo nix-packages, and then in a separate PR graalvm from 20.2.0 to 20.3.0 (this PR).

Both are ugly, but then so is GraalVM, so what can you do? :-)

My guess is that the first option is the least work for everybody involved, is it "allowed" from a nixpkgs PR perspective though? Or are there other options (assuming three dependent PRs is out of question)?

@borkdude
Copy link

borkdude commented Dec 14, 2020

@stevana Note that this is not entirely GraalVM's fault.

clj-kondo and babashka depend on a specific library which is pinned to a GraalVM version to work around a Java 11 problem in Clojure's Reflector class.

https://github.com/borkdude/clj-reflector-graal-java11-fix

This causes the main incompatibility problem with other GraalVM versions.

@borkdude
Copy link

So overriding that library to the GraalVM version you want to use, should solve the main problem. But this will require you to make your own uberjars and not depend on the one that is distributed on Github releases.

@bennyandresen
Copy link
Contributor

For reproduction purposes I never went the "build the package in nixos" because you need to declare every single dependency in Nix.

That would open a whole new can of worms as Hydra won't allow to access the internet to grab dependencies. (Although clojars and maven should be fine for a nixpkgs translation, because they are append-only as far as I know.)

@stevana
Copy link
Contributor Author

stevana commented Dec 15, 2020

@bennyandresen In case you wanna try going down that route, the following worked for me in another project and could probably be adopted for babashaka/clj-kondo:

{ sources ? import ./nix/sources.nix
, pkgs ? import sources.nixpkgs {}
}:
with pkgs;

let
  mvn2nix = import (fetchTarball https://github.com/fzakaria/mvn2nix/archive/master.tar.gz) {};
  mavenRepository =
    mvn2nix.buildMavenRepositoryFromLockFile { file = ./mvn2nix-lock.json; };
  inherit (import sources.gitignore {}) gitignoreSource;
in stdenv.mkDerivation rec {
  pname = "...";
  version = "latest";
  name = "${pname}-${version}";
  src = gitignoreSource ./.;

  buildInputs = [ clojure jdk11_headless graalvm11-ce ];

  buildPhase = ''
    export CLASSPATH=$(find ${mavenRepository} -name "*.jar" -printf ':%h/%f')
    export builddir=$TMP/classes
    mkdir -p $builddir

    echo "compiling lock fix workaround"
    javac java/src/lockfix/LockFix.java -cp $CLASSPATH -d $builddir

    echo "compiling clojure sources"
    # On Darwin `clj` tries to create some folder in the home directory...
    ${lib.optionalString stdenv.isDarwin ''
    export HOME=$TMP/home
    mkdir -p $HOME
    ''}
    clj -Scp src:$CLASSPATH:$builddir \
      -J-Djava.awt.headless=true \
      -J-Dclojure.compile.path=$builddir \
      -M -e "(compile (quote ${pname}.core))"

    echo "creating manifest file"
    echo "Main-Class: ${pname}.core" > manifest.txt
    echo "Class-Path: ." >> manifest.txt
    find ${mavenRepository} -name '*.jar' -printf '  %h/%f\n' >> manifest.txt
    cat manifest.txt

    echo "creating fat/uber jar"
    jar cvfm ${name}.jar manifest.txt -C $builddir .

    echo "compiling native image"
    native-image \
      -jar ${name}.jar \
      -H:Name=${pname} \
      ${lib.optionalString stdenv.isDarwin ''-H:-CheckToolchain''} \
      -H:+ReportExceptionStackTraces \
      -J-Dclojure.spec.skip-macros=true \
      -J-Dclojure.compiler.direct-linking=true \
      -J-Djava.awt.headless=true \
      -J-Dclojure.tools.logging.factory=clojure.tools.logging.impl/slf4j-factory \
      --initialize-at-build-time \
      --initialize-at-run-time=sun.font.SunFontManager \
      --initialize-at-run-time=sun.font.StrikeCache \
      --initialize-at-run-time=sun.font.SunLayoutEngine \
      --initialize-at-run-time=sun.font.FontManagerNativeLibrary \
      --initialize-at-run-time=sun.awt.X11GraphicsConfig \
      --initialize-at-run-time=javax.imageio.ImageTypeSpecifier \
      --initialize-at-run-time=sun.java2d.SurfaceData \
      --initialize-at-run-time='com.sun.imageio.plugins.jpeg.JPEG$JCS' \
      --initialize-at-run-time='sun.awt.dnd.SunDropTargetContextPeer$EventDispatcher' \
      --report-unsupported-elements-at-runtime \
      --allow-incomplete-classpath \
      --verbose \
      --no-fallback \
      --no-server
  '';

  installPhase = ''
    mkdir -p $out/bin
    install -Dm755 ${pname} $out/bin/${pname}
  '';
}

Before you build (and after any dependency change), you need to run:

clj -Spom
nix run -f https://github.com/fzakaria/mvn2nix/archive/master.tar.gz \
--command mvn2nix --repositories=https://repo1.maven.org/maven2/ https://repo.clojars.org > mvn2nix-lock.json

to pin the dependencies in nix.

@taku0
Copy link
Contributor

taku0 commented Dec 28, 2020

irb doesn't work on macOS. It works on Linux.

for i in graalvm11-ce graalvm8-ce
do
  nix-build -I nixpkgs=. -o "${i}" -A pkgs."${i}"
done

graalvm11-ce/bin/graalpython -c 'print(1 + 1)' # OK
graalvm11-ce/bin/ruby -e 'puts(1 + 1)' # OK
graalvm11-ce/bin/node -e 'console.log(1 + 1)' # OK

echo '1 + 1' | graalvm11-ce/bin/graalpython # OK
echo '1 + 1' | graalvm11-ce/bin/irb # Could not find OpenSSL headers, install via Homebrew or MacPorts or set OPENSSL_PREFIX
echo '1 + 1' | graalvm11-ce/bin/node -i # OK
echo '1 + 1' | graalvm11-ce/bin/jshell # OK

graalvm8-ce/bin/graalpython -c 'print(1 + 1)' # OK
graalvm8-ce/bin/ruby -e 'puts(1 + 1)' # OK
graalvm8-ce/bin/node -e 'console.log(1 + 1)' # OK

echo '1 + 1' | graalvm8-ce/bin/graalpython # OK
echo '1 + 1' | graalvm8-ce/bin/irb # Could not find OpenSSL headers, install via Homebrew or MacPorts or set OPENSSL_PREFIX
echo '1 + 1' | graalvm8-ce/bin/node -i # OK

@stevana
Copy link
Contributor Author

stevana commented Dec 28, 2020

@taku0 Thanks for testing! Could you please have another look to see if my last commits fixed the problem on MacOS?

$out/bin/node -e 'console.log(1 + 1)'

echo '1 + 1' | $out/bin/graalpython
echo '1 + 1' | $out/bin/irb
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still having Could not find OpenSSL headers, install via Homebrew or MacPorts or set OPENSSL_PREFIX.

OPENSSL_PREFIX=${openssl} bash $out/languages/ruby/lib/truffle/post_install_hook.sh may resolve this, but it results in <internal:core> core/kernel.rb:260:in `require': Library "/usr/lib/libSystem.B.dylib" does not exist. (RuntimeError). I have no idea how to fix this.

Linux version also have a problem. bin/ruby -e 'require "openssl"' results in languages/ruby/lib/mri/openssl.so:in `<LoadModulesNode>': libtruffleruby.so: cannot open shared object file: No such file or directory (NFIUnsatisfiedLinkError) (RuntimeError)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

languages/ruby/lib/mri/openssl.so requires libssl.so.10 and libcrypto.so.10 but we only have libssl.so.1.1 and libcrypto.so.1.1. Neither patchelf --set-rpath ${openssl_1_0_2} nor patchelf --replace-needed libssl.so.10 libssl.so.1.1 --replace-needed libcrypto.so.10 libcrypto.so.1.1 --set-rpath ${openssl} work. It checks OpenSSL version at runtime. The standard way to fix this is using languages/ruby/lib/truffle/post_install_hook.sh, but it invokes languages/llvm/native/bin/clang and it not works. I have no idea how to fix this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I commented out the irb check and added a TODO comment about it not working.

(I'm not using ruby and I suspect that this didn't work in graalvm-ce-20.2.0 either, so I guess this PR doesn't introduce a regression.)

@ofborg ofborg bot requested a review from DerGuteMoritz January 2, 2021 12:47
@ericdallo
Copy link
Member

BTW 21.0.0 is released, maybe we should bump it again?

@stevana
Copy link
Contributor Author

stevana commented Jan 25, 2021

Fixed conflicts, lets bump to 21.0.0 in a separate PR? (This will break babashka and clj-kondo again.)

@ofborg ofborg bot requested a review from glittershark January 25, 2021 11:30
@thiagokokada
Copy link
Contributor

@SuperSandro2000 can you merge this?

@ericdallo
Copy link
Member

Gentle ping @SuperSandro2000, could you help us here? :)

@ericdallo
Copy link
Member

I just manually change the version to 21.0.0 and it worked like a charm, it'd be really good if we could merge this to then open another PR to the 21.0.0

@SuperSandro2000
Copy link
Member

Lets ignore the remaining darwin build failures for now. I would merge it if I could squash the build history or the commits would fit the contributing guide.

@ericdallo
Copy link
Member

ericdallo commented Jan 31, 2021

@stevana could you squash the commits into a single one?

@stevana
Copy link
Contributor Author

stevana commented Jan 31, 2021

Squashed.

Copy link
Member

@SuperSandro2000 SuperSandro2000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry that I missed that.

Comment on lines 168 to 174
propagatedBuildInputs = [ setJavaClassPath zlib ] ++
# On Darwin native-image calls clang and it
# tries to include <Foundation/Foundation.h>,
# and Interactive Ruby (irb) requires OpenSSL
# headers.
lib.optionals stdenv.hostPlatform.isDarwin
[ darwin.apple_sdk.frameworks.Foundation openssl ];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
propagatedBuildInputs = [ setJavaClassPath zlib ] ++
# On Darwin native-image calls clang and it
# tries to include <Foundation/Foundation.h>,
# and Interactive Ruby (irb) requires OpenSSL
# headers.
lib.optionals stdenv.hostPlatform.isDarwin
[ darwin.apple_sdk.frameworks.Foundation openssl ];
propagatedBuildInputs = [ setJavaClassPath zlib ] ++
# On Darwin native-image calls clang and it
# tries to include <Foundation/Foundation.h>,
# and Interactive Ruby (irb) requires OpenSSL
# headers.
lib.optionals stdenv.hostPlatform.isDarwin
[ Foundation openssl ];

@@ -1,48 +1,60 @@
{ lib, stdenv, fetchurl, perl, unzip, glibc, zlib, setJavaClassPath }:
{ lib, stdenv, fetchurl, perl, unzip, glibc, zlib, setJavaClassPath, darwin, openssl }:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{ lib, stdenv, fetchurl, perl, unzip, glibc, zlib, setJavaClassPath, darwin, openssl }:
{ lib, stdenv, fetchurl, perl, unzip, glibc, zlib, setJavaClassPath, Foundation, openssl }:

Please inherit Foundation from in top level. inherit (darwin.apple_sdk.frameworks) Foundation

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You forgot the inherit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand your suggestion. How can I inherit (darwin.apple_sdk.frameworks) Foundation when darwin isn't in scope?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, thanks, fixed!

@ericdallo
Copy link
Member

ericdallo commented Feb 1, 2021

@GrahamcOfBorg build graalvm8-ce graalvm11-ce babashka clj-kondo

@ericdallo

This comment has been minimized.

@ericdallo

This comment has been minimized.

@ericdallo

This comment has been minimized.

(Also bumps babashka and clj-kondo.)
@SuperSandro2000
Copy link
Member

This is a semi-automatic executed nixpkgs-review with nixpkgs-review-checks extension. It is checked by a human on a best effort basis and does not build all packages (e.g. lumo, tensorflow or pytorch).
If you have any questions or problems please reach out to SuperSandro2000 on IRC.

Result of nixpkgs-review pr 105815 run on x86_64-linux 1

4 packages built:
  • babashka
  • clj-kondo
  • graalvm11-ce
  • graalvm8-ce

@SuperSandro2000
Copy link
Member

This is a semi-automatic executed nixpkgs-review with nixpkgs-review-checks extension. It is checked by a human on a best effort basis and does not build all packages (e.g. lumo, tensorflow or pytorch).
If you have any questions or problems please reach out to SuperSandro2000 on IRC.

Result of nixpkgs-review pr 105815 run on x86_64-darwin 1

4 packages built:
  • babashka
  • clj-kondo
  • graalvm11-ce
  • graalvm8-ce

Copy link
Member

@SuperSandro2000 SuperSandro2000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

other

pkgs/development/compilers/graalvm/community-edition.nix Outdated Show resolved Hide resolved
@SuperSandro2000 SuperSandro2000 merged commit bf6df71 into NixOS:master Feb 2, 2021
@stevana stevana deleted the graalmv-20.3.0-darwin branch February 3, 2021 07:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants