scala/scala-dev

Partest test case jvm/natives.scala failed on MacOS M1 platform

liang3zy22 opened this issue · 9 comments

Reproduction steps

sbt> restarrFull
sbt>partest jvm

Problem

jvm/natives.scala test case failed. I checked the codes, the script test/files/jvm/mkLibNatives.sh doesn't generate new natives library for ARM platform.

The script uses javah, which isn't present on JDK 10+, as per https://docs.oracle.com/en/java/javase/18/migrate/removed-tools-and-components.html#GUID-12237744-E23B-42F8-8892-26BA1BDD63F2.

We have the option of fixing the script to use javac -h instead (which should work on 8, 11, and 17), or simply leaving it alone and requiring that it be run on Java 8.

Even on Java 8, the script fails with Error: Could not find class file for 'Test$'.

What does one have to do for the natives-jvm.obj directory test/files/jvm to exist...? It comes into being briefly, then gets deleted.

I hoped --no-exec (as in partest --no-exec test/files/jvm/natives.scala) would cause the .obj directory to be left behind, but no dice.

Ah, here we go: you need to pass --debug to partest and then the directory stays around 👍

hahaha

commit 9b3b1847ce5c12902ab2b1ba1018208d33ae8c9d
Author: Gilles Dubochet <gilles.dubochet@epfl.ch>
Date:   Wed May 13 16:09:14 2009 +0000

    Disabled "natives" test because its annoyance /...
    
    Disabled "natives" test because its annoyance / usefulness ratio was
    considered to be too low.

it got re-enabled later (by Toni in 2010)

There is a special secret ceremony for when you're using partest --debug, but I see partest --help works.

its annoyance / usefulness ratio was considered to be too low.

s/low/high, though arguably if a test is not annoying you, it may not be doing its job.

the following changes to mkLibNatives.sh help:

-  CC_OPTIONS="-c -arch ppc -arch i386 -arch x86_64"
-  CC_INCLUDES="-I/System/Library/Frameworks/JavaVM.framework/Headers"
+  CC_OPTIONS="-c -arch i386 -arch x86_64 -arch arm64"
+  CC_INCLUDES="-I${JAVA_HOME}/include -I${JAVA_HOME}/include/darwin"

but then it bombs out because -framework JavaVM doesn't work on recent MacOS

this seems to help

-  LNK_OPTIONS="-dynamiclib -framework JavaVM"
+  LNK_OPTIONS="-L${JAVA_HOME}/jre/lib/server -dynamiclib -ljvm"

I smell success nearby

@liang3zy22 thanks for reporting

(we'll merge the fix forward from 2.12.x to 2.13.x before too much longer)