-
Notifications
You must be signed in to change notification settings - Fork 362
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix detection of multithreading usage - it was broken, becouse shutdo…
…wn hooks and weak references registry are using threads (#3856)
- Loading branch information
1 parent
d4bfe5d
commit a06f46d
Showing
8 changed files
with
62 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
enablePlugins(ScalaNativePlugin) | ||
|
||
nativeConfig ~= { | ||
_.withMultithreading(None) // force detection | ||
} | ||
|
||
scalaVersion := { | ||
val scalaVersion = System.getProperty("scala.version") | ||
if (scalaVersion == null) | ||
throw new RuntimeException( | ||
"""|The system property 'scala.version' is not defined. | ||
|Specify this property using the scriptedLaunchOpts -D.""".stripMargin | ||
) | ||
else scalaVersion | ||
} |
9 changes: 9 additions & 0 deletions
9
scripted-tests/run/detect-multithreading/project/scala-native.sbt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
val pluginVersion = System.getProperty("plugin.version") | ||
if (pluginVersion == null) | ||
throw new RuntimeException( | ||
"""|The system property 'plugin.version' is not defined. | ||
|Specify this property using the scriptedLaunchOpts -D.""".stripMargin | ||
) | ||
else addSbtPlugin("org.scala-native" % "sbt-scala-native" % pluginVersion) | ||
} |
10 changes: 10 additions & 0 deletions
10
scripted-tests/run/detect-multithreading/src/main/scala/MultiThreaded.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import scala.scalanative.unsafe._ | ||
import scala.scalanative.libc.stdio._ | ||
import scala.scalanative.meta.LinktimeInfo.isMultithreadingEnabled | ||
|
||
object MultiThreaded { | ||
def main(args: Array[String]): Unit = { | ||
assert(isMultithreadingEnabled == true) | ||
new Thread(() => println("hello world")).start() | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
scripted-tests/run/detect-multithreading/src/main/scala/SingleThreaded.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import scala.scalanative.unsafe._ | ||
import scala.scalanative.libc.stdio._ | ||
import scala.scalanative.meta.LinktimeInfo.isMultithreadingEnabled | ||
|
||
object SingleThreaded { | ||
def main(args: Array[String]): Unit = { | ||
assert(isMultithreadingEnabled == false) | ||
println("Hello world") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
> set Compile/mainClass := Some("SingleThreaded") | ||
> run | ||
|
||
> set Compile/mainClass := Some("MultiThreaded") | ||
> run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters