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

Do not emit single LLVM IR file for release mode + LTO none #3514

Merged
merged 1 commit into from
Oct 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 0 additions & 14 deletions tools/src/main/scala/scala/scalanative/build/Validator.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ object Validator {
(validateMainClass _)
.andThen(validateBasename)
.andThen(validateClasspath)
.andThen(checkCompilerConfig)
.apply(config)

// throws if Application with no mainClass
Expand Down Expand Up @@ -48,17 +47,4 @@ object Validator {
config.withClassPath(fclasspath)
}

private def checkCompilerConfig(config: Config): Config = {
val log = config.logger
(config.compilerConfig.mode, config.compilerConfig.lto) match {
case (mode: Mode.Release, LTO.None) =>
log.warn(
s"Build mode ${mode.name} combined with disabled LTO produces single, slow to compile output file." +
s" It's recommended to enable LTO.${LTO.thin.name} for best optimizations and faster builds."
)
case _ => ()
}
config
}

}
20 changes: 3 additions & 17 deletions tools/src/main/scala/scala/scalanative/codegen/llvm/CodeGen.scala
Original file line number Diff line number Diff line change
Expand Up @@ -125,23 +125,9 @@ object CodeGen {
}
}

// Generate a single LLVM IR file for the whole application.
// This is an adhoc form of LTO. We use it in release mode if
// Clang's LTO is not available.
def single(): Future[Seq[Path]] = Future {
val sorted = assembly.sortBy(_.name)
Impl(env, sorted).gen(id = "out", workDir) :: Nil
}

import build.Mode._
(config.mode, config.LTO) match {
case (ReleaseFast | ReleaseSize | ReleaseFull, build.LTO.None) =>
single()
case _ =>
if (config.compilerConfig.useIncrementalCompilation)
seperateIncrementally()
else separate()
}
if (config.compilerConfig.useIncrementalCompilation)
seperateIncrementally()
else separate()
}

object Impl {
Expand Down