Skip to content

Commit

Permalink
Support release-size releaseMode in Scala Native (#2754)
Browse files Browse the repository at this point in the history
Co-authored-by: Tobias Roeser <[email protected]>

Pull request: #2754
  • Loading branch information
lolgab authored Sep 18, 2023
1 parent 95c68ca commit 55d04b4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions contrib/bloop/src/mill/contrib/bloop/BloopImpl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ class BloopImpl(ev: () => Evaluator, wd: os.Path) extends ExternalModule { outer
case ReleaseMode.Debug => BloopConfig.LinkerMode.Debug
case ReleaseMode.ReleaseFast => BloopConfig.LinkerMode.Release
case ReleaseMode.ReleaseFull => BloopConfig.LinkerMode.Release
case ReleaseMode.ReleaseSize => BloopConfig.LinkerMode.Release
},
gc = m.nativeGC(),
targetTriple = m.nativeTarget(),
Expand Down
10 changes: 9 additions & 1 deletion scalanativelib/src/mill/scalanativelib/api/ScalaNativeApi.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,23 @@ object LTO {

sealed abstract class ReleaseMode(val value: String)
object ReleaseMode {
val values = Seq(Debug, ReleaseFast, ReleaseFull)
val values = Seq(Debug, ReleaseFast, ReleaseFull, ReleaseSize)

case object Debug extends ReleaseMode("debug")
case object ReleaseFast extends ReleaseMode("release-fast")
case object ReleaseFull extends ReleaseMode("release-full")

/**
* Optimizes output binary size and still have relatively fast runtime performance.
* Equivalent to `-Oz` switch of `clang`.
* Since Scala Native 0.4.10
*/
case object ReleaseSize extends ReleaseMode("release-size")

implicit val rwDebug: ReadWriter[Debug.type] = macroRW[Debug.type]
implicit val rwReleaseFast: ReadWriter[ReleaseFast.type] = macroRW[ReleaseFast.type]
implicit val rwReleaseFull: ReadWriter[ReleaseFull.type] = macroRW[ReleaseFull.type]
implicit val rwReleaseSize: ReadWriter[ReleaseSize.type] = macroRW[ReleaseSize.type]
implicit val rw: ReadWriter[ReleaseMode] = macroRW[ReleaseMode]
}

Expand Down

0 comments on commit 55d04b4

Please sign in to comment.