Skip to content

chore: add the scala-library projects (non-bootstrapped and bootstrapped) #23510

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

Merged
merged 4 commits into from
Jul 18, 2025

Conversation

hamzaremmal
Copy link
Member

Add the configuration for the scala-library project in sbt.
For now, this configuration is disabled and doesn't publish anything until we enable it in 3.8.0

* - The only commands you should run on this project are `publish` and `publishLocal`
* - This project produces no artifacts and has no sources
*/
lazy val `scala-library` = project.in(file("scala-library"))
Copy link
Member Author

Choose a reason for hiding this comment

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

FYI: publishSettings are missing here, but I prefer to add them when we are ready to release

Comment on lines 41 to 46
@experimental
opaque type into[+T] >: T = T
//@experimental
//opaque type into[+T] >: T = T

/** Unwrap an `into` */
extension [T](x: into[T])
@experimental def underlying: T = x
//extension [T](x: into[T])
// @experimental def underlying: T = x
Copy link
Member Author

Choose a reason for hiding this comment

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

Obviously this must be fixed before merging the PR. This triggers a stale symbol only in the new stdlib...

@hamzaremmal hamzaremmal force-pushed the scalalib-sbt branch 2 times, most recently from 266a732 to 6e3e584 Compare July 18, 2025 13:01
version := dottyVersion,
versionScheme := Some("semver-spec"),
crossPaths := false, // org.scala-lang:scala-library doesn't have a crosspath
// NOTE: The only difference here is that we drop `-Werror` and semanticDB for now
Copy link
Member Author

Choose a reason for hiding this comment

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

semanticDB fails because the definitions are not present in Predef, which will be fixed in another PR and -Werror is self explanatory. Too many warnings for now that will have to be fixed later (some even in scala 2)

// Add the source directories for the stdlib (non-boostrapped)
Compile / unmanagedSourceDirectories := Seq(baseDirectory.value / "src"),
Compile / unmanagedSourceDirectories += baseDirectory.value / "src-non-bootstrapped",
// NOTE: The only difference here is that we drop `-Werror` and semanticDB for now
Copy link
Member Author

Choose a reason for hiding this comment

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

Comment on lines +1469 to +1500
val externalLibraryDeps = (`scala3-library` / Compile / externalDependencyClasspath).value.map(_.data).toSet
val externalCompilerDeps = (`scala3-compiler` / Compile / externalDependencyClasspath).value.map(_.data).toSet

// IMPORTANT: We need to use actual jars to form the ScalaInstance and not
// just directories containing classfiles because sbt maintains a cache of
// compiler instances. This cache is invalidated based on timestamps
// however this is only implemented on jars, directories are never
// invalidated.
val tastyCore = (`tasty-core` / Compile / packageBin).value
val scala3Library = (`scala3-library` / Compile / packageBin).value
val scala3Interfaces = (`scala3-interfaces` / Compile / packageBin).value
val scala3Compiler = (`scala3-compiler` / Compile / packageBin).value

val libraryJars = Array(scala3Library) ++ externalLibraryDeps
val compilerJars = Seq(tastyCore, scala3Interfaces, scala3Compiler) ++ (externalCompilerDeps -- externalLibraryDeps)

Defaults.makeScalaInstance(
scalaVersion.value,
libraryJars = libraryJars,
allCompilerJars = compilerJars,
allDocJars = Seq.empty,
state.value,
scalaInstanceTopLoader.value
)
},
scalaCompilerBridgeBinaryJar := {
Some((`scala3-sbt-bridge` / Compile / packageBin).value)
},
Copy link
Member Author

Choose a reason for hiding this comment

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

This still uses the old compiler that uses the old stdlib, in another PR, when I add the versions of the compiler with the new stdlib as a dependency, we will proceed to the swap.

Copy link
Member Author

@hamzaremmal hamzaremmal left a comment

Choose a reason for hiding this comment

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

Note that many other settings are required to be added before moving to prod. This is just one step to move forward in the build for now.

@hamzaremmal hamzaremmal changed the title chore: add the scala-library project chore: add the scala-library projects (non-bootstrapped and bootstrapped) Jul 18, 2025
@hamzaremmal
Copy link
Member Author

Also, I'm explicitly splitting and duplicating the settings in each project as want to know exactly the configuration and not to start follow methods to see what gets configured and what doesn't. This is a choice, not a bad implementation.

uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17
Copy link
Member Author

@hamzaremmal hamzaremmal Jul 18, 2025

Choose a reason for hiding this comment

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

We are already compiling the migration of stdlib with 17, ahead of the switch to Java 17 in 3.8.0

@hamzaremmal hamzaremmal enabled auto-merge July 18, 2025 14:32
permissions:
contents: read

jobs:
Copy link
Contributor

Choose a reason for hiding this comment

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

Tests CI directives e.g. [skip_ci] or [compile_nonboostrapped] are missing, currently we have already multiple jobs that would execute even though they're told to not be executed. If possible we should gradually try to unify all of GHA jobs

Copy link
Member Author

Choose a reason for hiding this comment

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

I prefer not to have them for multiple reasons:

  • This is a temporary files
  • CI will have to be redesigned anyways (subsequent PR)
  • I prefer always checking this during the transition period (until we actually proceed to the swap). I don't want to have any surprises down the road.

Compile / unmanagedSourceDirectories := Seq(baseDirectory.value / "src"),
Compile / unmanagedSourceDirectories += baseDirectory.value / "src-bootstrapped",
// NOTE: The only difference here is that we drop `-Werror` and semanticDB for now
Compile / scalacOptions := Seq("-deprecation", "-feature", "-unchecked", "-encoding", "UTF8", "-language:implicitConversions"),
Copy link
Contributor

Choose a reason for hiding this comment

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

NIT: we're using here 2 ways of providing settings: using seperate strings ("-encoding", "UTF8"), and using a single argument with separator (-language:implicitConversions).
Maybe let's pick a single style and use it?
Personally I'm in favour of replacing -encoding:UTF8 change as it's easier to ready when all data is kept in single token.

Comment on lines +1432 to +1442
Compile / scalacOptions := Seq("-deprecation", "-feature", "-unchecked", "-encoding", "UTF8", "-language:implicitConversions"),
(Compile / scalacOptions) ++= Seq(
// Needed so that the library sources are visible when `dotty.tools.dotc.core.Definitions#init` is called
"-sourcepath", (Compile / sourceDirectories).value.map(_.getCanonicalPath).distinct.mkString(File.pathSeparator),
),
// Only publish compilation artifacts, no test artifacts
Compile / publishArtifact := true,
Test / publishArtifact := false,
// Do not allow to publish this project for now
publish / skip := true,
// Project specific target folder. sbt doesn't like having two projects using the same target folder
Copy link
Contributor

@WojciechMazur WojciechMazur Jul 18, 2025

Choose a reason for hiding this comment

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

I understand the argument of explicit, duplicated, configuration, but maybe let's create a Def.settings directly above these project definitions with the common parts that are known to be always shared between the two?
Otherwise, sooner or later these 2 would diverge.

So stuff like the marked settings, crossPaths, versionScheme, moduleName can be defined in a single place

Copy link
Member Author

Choose a reason for hiding this comment

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

I have a branch with these kind of changes but it's coming later. For now, I just need the base project to unblock some rebases like explicitly null checking the stdlib and stuff

@hamzaremmal hamzaremmal merged commit 5899730 into scala:main Jul 18, 2025
31 checks passed
@hamzaremmal hamzaremmal deleted the scalalib-sbt branch July 18, 2025 18:12
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.

3 participants