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

chore: Add support for Scala Native 0.5.0 #2293

Merged
merged 1 commit into from Mar 13, 2024

Conversation

tgodzik
Copy link
Contributor

@tgodzik tgodzik commented Mar 9, 2024

No description provided.

@tgodzik
Copy link
Contributor Author

tgodzik commented Mar 11, 2024

The failing tests are unrelated, I am fixing it I hope in #2295

@tgodzik tgodzik requested review from adpi2 and sjrd March 11, 2024 14:24
Copy link
Contributor

@sjrd sjrd left a comment

Choose a reason for hiding this comment

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

Looks good as far as I can tell. Perhaps @kyouko-taiga would like to chime in?

Comment on lines +40 to 41
case LinkerMode.Release if bloop.util.CrossPlatform.isMac => build.LTO.full
case LinkerMode.Release => build.LTO.thin
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems pretty weird to do something different for Mac than others? Is that something the sbt plugin does as well?

Choose a reason for hiding this comment

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

It's mostly related to LLVM compilation errors happening only on MacOS with LTO=thin
scala-native/scala-native#3833 No idea how to fix it currently.

I have no idea about rest of the codebase and I guess there is no way to configure LTO directly, however we might detect the LTO using env variables? There is a dedicated method to do it, it's used in the sbt plugin.
https://github.com/scala-native/scala-native/blob/4b9f6314a90336d448e0b5cb0fdcb3f122f5c47b/tools/src/main/scala/scala/scalanative/build/Discover.scala#L25

It might be beneficial, because LTO.full can be sometimes slow, so maybe defaulting to LTO.none would be a good choice?
Also, in some configurations LTO=thin might work on MacOS, (see our nightly builds https://github.com/scala-native/scala-native/actions/runs/8226709422/job/22494744082 where we use LLVM linker lld and LLVM distribution of clang instead of the one shipped with MacOS (it does not work on M1 chips though)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm... so for now only change in tests? OR default to none, which would be better?

Choose a reason for hiding this comment

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

Defaulting to none is the safest option in my opinion.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Switched to none as a default

Copy link

@WojciechMazur WojciechMazur left a comment

Choose a reason for hiding this comment

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

Overall looks good to me
I don't know how it my affect the bloop sbt integration but the ScalaNativeKeys were removed from sbt plugin in 0.5.0 (see PR )

@tgodzik
Copy link
Contributor Author

tgodzik commented Mar 11, 2024

I don't know how it my affect the bloop sbt integration but the ScalaNativeKeys were removed from sbt plugin in 0.5.0 (see PR )

Och, that would not be easy to replace, we use that heavily 😨 https://github.com/scalacenter/bloop/blob/main/integrations/sbt-bloop/src/main/scala/bloop/integrations/sbt/SbtBloop.scala#L741

Why were they removed? How to get the native configuration now?

@WojciechMazur
Copy link

Why were they removed? How to get the native configuration now?

In the whole 0.4.x line these were just a legacy settings and used special order of their initialization to copy their values to nativeConfig task. In all 0.4.x releases and in 0.5.x nativeConfig: Task[build.NativeConfig] is the only effective source of configuration.

https://github.com/scala-native/scala-native/blob/8f1e7d01b82f2fd946fc735461138c791a5e8677/sbt-scala-native/src/main/scala/scala/scalanative/sbtplugin/ScalaNativePlugin.scala#L36-L39

If you have access to scala-native::tools artifact on classpath at that point it should not be a problem to obtain these. Otherwise, we can think about some way to expose nativeConfig in a simple format to bloop

@tgodzik
Copy link
Contributor Author

tgodzik commented Mar 12, 2024

In the whole 0.4.x line these were just a legacy settings and used special order of their initialization to copy their values to nativeConfig task. In all 0.4.x releases and in 0.5.x nativeConfig: Task[build.NativeConfig] is the only effective source of configuration.

I will try and do a follow up to handle that.

@tgodzik tgodzik merged commit c257033 into scalacenter:main Mar 13, 2024
15 of 17 checks passed
@tgodzik tgodzik deleted the support_0.5 branch March 13, 2024 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants