unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Scala package
@ 2021-05-17 23:01 Julien Lepiller
  2021-05-18  7:08 ` Leo Prikler
  0 siblings, 1 reply; 13+ messages in thread
From: Julien Lepiller @ 2021-05-17 23:01 UTC (permalink / raw)
  To: guix-devel

[-- Attachment #1: Type: text/plain, Size: 560 bytes --]

Hi Guix!

I have the attached file that build Scala, although it's not
bootstrapped at all. It contains %binary-scala, a few dependencies of
Scala we haven't packaged yet, and the final scala, built from
%binary-scala, without sbt (which requires Scala too).

Since I've tried and failed to bootstrap Scala for so long, I think
it's time to give up. I can't always create miracles.

If this is acceptable, I will send actual patches later, and rework the
sbt package I had around 2018 (I managed to build it with a Scala
compiler, without a pre-existing sbt).

[-- Attachment #2: scala.scm --]
[-- Type: text/x-scheme, Size: 10568 bytes --]

(use-modules
  (guix build-system ant)
  (guix build-system copy)
  (guix git-download)
  (guix download)
  (guix packages)
  ((guix licenses) #:prefix license:)
  (gnu packages java))

(define %binary-scala
  (package
    (name "scala")
    (version "2.13.4")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://downloads.lightbend.com/scala/"
                                  version  "/scala-" version ".tgz"))
              (sha256
               (base32
                "1alcnzmxga00nsvgy8yky91zw5b4q0xg2697vrrdgjlglpxiqwdw"))))
    (build-system copy-build-system)
    (arguments
     `(#:install-plan
       '(("." ""))
       #:phases
       (modify-phases %standard-phases
         (add-before 'install 'set-java-home
           (lambda* (#:key inputs #:allow-other-keys)
             (substitute* (find-files "bin" ".")
               (("^#!.*" shebang)
                (string-append shebang "\nJAVA_HOME="
                               (assoc-ref inputs "openjdk"))))))
         (add-before 'set-java-home 'remove-unneeded
           (lambda _
             (for-each delete-file (find-files "bin" "bat$")))))))
    (inputs
     `(("openjdk" ,openjdk14)))
    (home-page "https://scala-lang.org/")
    (synopsis "Scala programming language")
    (description "Scala combines object-oriented and functional programming in
one concise, high-level language.  Scala's static types help avoid bugs in
complex applications, and its JVM and JavaScript runtimes let you build
high-performance systems with easy access to huge ecosystems of libraries.")
    (license license:bsd-3)))

(define scala-asm
  (package
    (inherit java-asm)
    (version "9.1.0")
    (source (origin
              (method git-fetch)
              (uri (git-reference
                     (url "https://github.com/scala/scala-asm")
                     (commit "s-9.1")))
              (file-name (git-file-name "scala-asm" version))
              (sha256
               (base32
                "1wsrlb6kb0fwxjdqanxqgmq4qcyq9gqn129w3l4bj7gvlspll33l"))))
    (arguments
     `(#:jar-name "java-asm.jar"
       #:source-dir "src/main/java"
       ;; no tests
       #:tests? #f))))

(define java-jline3-terminal
  (package
    (name "java-jline3-terminal")
    (version "3.19.0")
    (source (origin
              (method git-fetch)
              (uri (git-reference
                     (url "https://github.com/jline/jline3")
                     (commit (string-append "jline-parent-" version))))
              (file-name (git-file-name name version))
              (sha256
               (base32
                "16cfbkbj925c92xnwq5sbg7v57yh840g0mh95iyzkkajxirz9qn9"))
              (snippet
               ;; calls maven, and conflicts with ant
               `(delete-file "build"))))
    (build-system ant-build-system)
    (arguments
     `(#:jar-name "jline3-terminal.jar"
       #:source-dir "terminal/src/main/java"
       #:test-dir "terminal/src/test"
       #:phases
       (modify-phases %standard-phases
         ;(add-after 'unpack 'make-files-writable
         ;  (lambda _
         ;    (for-each make-file-writable (find-files "."))
         ;    #t))
         (add-before 'build 'copy-resources
           (lambda _
             (copy-recursively
               "terminal/src/main/resources/"
               "build/classes")
             #t)))))
    (native-inputs
     `(("java-easymock" ,java-easymock)
       ("java-junit" ,java-junit)))
    (home-page "")
    (synopsis "")
    (description "")
    (license #f)))

(define java-jline3-reader
  (package
    (inherit java-jline3-terminal)
    (name "java-jline3-reader")
    (arguments
     `(#:jar-name "jline3-reader.jar"
       #:source-dir "reader/src/main/java"
       #:test-dir "reader/src/test"))
    (inputs
     `(("java-jline3-terminal" ,java-jline3-terminal)))))

(define scala
  (package
    (inherit %binary-scala)
    (source (origin
              (method git-fetch)
              (uri (git-reference
                     (url "https://github.com/scala/scala")
                     (commit (string-append "v" (package-version %binary-scala)))))
              (file-name (git-file-name "scala" (package-version %binary-scala)))
              (sha256
               (base32
                "0a6n0wnklya5mvcj03b64my7c30m2zw7spm9j1byv1rraxxjm1q1"))))
    (build-system ant-build-system)
    (arguments
     `(#:tests? #f
       #:phases
       (modify-phases %standard-phases
         (replace 'build
           (lambda* (#:key inputs #:allow-other-keys)
             (define* (build-project directory name #:optional (jar? #t))
               (let* ((build-dir (string-append "build/class/" name))
                      (jar-name (string-append name ".jar"))
                      (java-files (find-files directory ".*.java$"))
                      (scala-files (find-files directory ".*.scala$")))
                 (mkdir-p build-dir)
                 (format #t "Building project ~a...~%" name)
                 (unless (eq? scala-files '())
                   (apply invoke "scalac" "-classpath"
                          (string-append
                            ;; Add any top-level directory in build that may contain
                            ;; .class files, but don't actually add build/ iteself or
                            ;; any individual class file.
                            (string-join
                              (filter (lambda (s) (eq? (string-count s #\/) 1))
                                      (find-files "build" "." #:directories? #t))
                              ":"))
                          "-d" build-dir "-nobootcp"
                          (append scala-files java-files)))
                 (unless (eq? java-files '())
                   (apply invoke "javac" "-classpath"
                          (string-append
                            (getenv "CLASSPATH") ":"
                            (string-join
                              (filter (lambda (s) (eq? (string-count s #\/) 1))
                                      (find-files "build" "." #:directories? #t))
                              ":"))
                          "-g" "-source" "1.8" "-target" "1.8"
                          "-d" build-dir java-files))
                 (mkdir-p "build/jar")
                 (if jar?
                   (invoke "jar" "cf" (string-append "build/jar/" jar-name)
                           "-C" build-dir "."))))

             (let ((scala-asm (assoc-ref inputs "scala-asm")))
               (setenv "CLASSPATH" (string-join (find-files scala-asm ".*.jar$") ":")))
             (setenv "JAVA_OPTS" "-Xmx1G")
             (build-project "src/library" "scala-library")
             (build-project "src/reflect" "scala-reflect")
             (build-project "src/compiler" "scala-compiler" #f)
             (build-project "src/interactive" "scala-compiler-interactive" #f)
             (build-project "src/scaladoc" "scala-compiler-doc" #f)
             (build-project "src/repl" "scala-repl" #f)
             (build-project "src/repl-frontend" "scala-repl-frontend" #f)
             (build-project "src/scalap" "scalap")

             ;; create scala-compiler.jar as a union of some of those above
             (mkdir-p "build/class/compiler")
             (with-directory-excursion "build/class/compiler"
               (let ((scala-asm (assoc-ref inputs "scala-asm")))
                 (invoke "jar" "xf" (car (find-files scala-asm ".*.jar$"))))
               (copy-recursively "../scala-compiler" ".")
               (copy-recursively "../scala-compiler-interactive" ".")
               (copy-recursively "../scala-compiler-doc" ".")
               (copy-recursively "../scala-repl" ".")
               (copy-recursively "../scala-repl-frontend" "."))
             (invoke "jar" "cf" "build/jar/scala-compiler.jar"
                     "-C" "build/class/compiler" ".")))
         (replace 'install
           (lambda* (#:key inputs outputs #:allow-other-keys)
             (let* ((out (assoc-ref outputs "out"))
                    (lib (string-append out "/lib"))
                    (jna (assoc-ref inputs "java-native-access"))
                    (jline-terminal (assoc-ref inputs "java-jline3-terminal"))
                    (jline-reader (assoc-ref inputs "java-jline3-reader")))
               (mkdir-p lib)
               (for-each
                 (lambda (jar)
                   (copy-file jar (string-append lib "/" (basename jar))))
                 (find-files "build/jar" ".*.jar$"))
               (symlink (car (find-files jna "linux-.*.jar$"))
                        (string-append lib "/jna-lib.jar"))
               (symlink (car (find-files jna "jna.jar$"))
                        (string-append lib "/jna.jar"))
               (symlink (car (find-files jline-reader ".*.jar$"))
                        (string-append lib "/jline-reader.jar"))
               (symlink (car (find-files jline-terminal ".*.jar$"))
                        (string-append lib "/jline-terminal.jar")))))
         (add-after 'install 'install-bin
           (lambda* (#:key outputs #:allow-other-keys)
             (let* ((out (assoc-ref outputs "out"))
                    (bin (string-append out "/bin")))
               (define (install-script script class)
                 (let ((script (string-append bin "/" script)))
                   (copy-file "src/compiler/templates/tool-unix.tmpl" script)
                   ;; See project/ScalaTool and build.sbt
                   (substitute* script
                     (("@@") "@")
                     (("@class@") class)
                     (("@properties@") "-Dscala.home=\"$SCALA_HOME\"")
                     (("@javaflags@") "-Xmx256M -Xms32M")
                     (("@toolflags@") "")
                     (("@classpath@") ""))
                   (chmod script #o755)))
               (mkdir-p bin)
               (install-script "scala" "scala.tools.nsc.MainGenericRunner")
               (install-script "scalac" "scala.tools.nsc.Main")
               (install-script "fsc" "scala.tools.nsc.fsc.CompileClient")
               (install-script "scaladoc" "scala.tools.nsc.ScalaDoc")
               (install-script "scalap" "scala.tools.scalap.Main"))))
         )))
    (inputs
     `(("scala" ,%binary-scala)
       ("scala-asm" ,scala-asm)
       ("java-jline3-terminal" ,java-jline3-terminal)
       ("java-jline3-reader" ,java-jline3-reader)
       ("java-native-access" ,java-native-access)))))

%binary-scala
;scala-asm
;java-jline3
;scala

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Scala package
  2021-05-17 23:01 Scala package Julien Lepiller
@ 2021-05-18  7:08 ` Leo Prikler
  2021-05-18  9:44   ` Ricardo Wurmus
  0 siblings, 1 reply; 13+ messages in thread
From: Leo Prikler @ 2021-05-18  7:08 UTC (permalink / raw)
  To: Julien Lepiller, guix-devel

Hi Julien,

Am Dienstag, den 18.05.2021, 01:01 +0200 schrieb Julien Lepiller:
> Hi Guix!
> 
> I have the attached file that build Scala, although it's not
> bootstrapped at all. It contains %binary-scala, a few dependencies of
> Scala we haven't packaged yet, and the final scala, built from
> %binary-scala, without sbt (which requires Scala too).
> 
> Since I've tried and failed to bootstrap Scala for so long, I think
> it's time to give up. I can't always create miracles.

Some points relevant to bootstrapping:
- The last version, that ships "scalai" written in Java seems to be 
  v1.4.0+4.  Perhaps one can use scalai to bootstrap scalac within it.
- The last version, that does not "require" sbt is 2.11.x,
  though with your workaround we can also build later versions.

Would it generally be possible to use scalac 1.4 to compile any 2.x
version?  (We can first assume that we have this scalac as binary, and 
hopefully construct our chain from there similar to Rust.  Then we
"only" need to somehow bootstrap 1.4)

> If this is acceptable, I will send actual patches later, and rework
> the sbt package I had around 2018 (I managed to build it with a Scala
> compiler, without a pre-existing sbt).
IIRC, there are some bootstrap binaries well hidden within Guix source
code, but this obviously does not look nice.

>     (license license:bsd-3)))
I think it's actually Apache 2.0



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Scala package
  2021-05-18  7:08 ` Leo Prikler
@ 2021-05-18  9:44   ` Ricardo Wurmus
  2021-05-18 11:15     ` Julien Lepiller
  2021-05-18 14:00     ` Daniel Trujillo Viedma
  0 siblings, 2 replies; 13+ messages in thread
From: Ricardo Wurmus @ 2021-05-18  9:44 UTC (permalink / raw)
  To: Leo Prikler; +Cc: guix-devel


Leo Prikler <leo.prikler@student.tugraz.at> writes:

> Hi Julien,
>
> Am Dienstag, den 18.05.2021, 01:01 +0200 schrieb Julien 
> Lepiller:
>> Hi Guix!
>> 
>> I have the attached file that build Scala, although it's not
>> bootstrapped at all. It contains %binary-scala, a few 
>> dependencies of
>> Scala we haven't packaged yet, and the final scala, built from
>> %binary-scala, without sbt (which requires Scala too).
>> 
>> Since I've tried and failed to bootstrap Scala for so long, I 
>> think
>> it's time to give up. I can't always create miracles.
>
> Some points relevant to bootstrapping:
> - The last version, that ships "scalai" written in Java seems to 
> be 
>   v1.4.0+4.  Perhaps one can use scalai to bootstrap scalac 
>   within it.
> - The last version, that does not "require" sbt is 2.11.x,
>   though with your workaround we can also build later versions.

We tried building a clean bootstrap chain for Scala for years. 
Back then I went down the rabbit hole and found that early scalac 
is written in Pizza; but it turned out that Pizza is written in 
Pizza and is released under the old Artistic License, which is 
considered non-free.

    https://logs.guix.gnu.org/guix/2018-04-08.log#230002
    https://logs.guix.gnu.org/guix/2018-04-09.log#073740

I pointed a branch at an old Scala commit that contains the old 
Socos compiler source, which ostensibly are written in Java, but 
actually are not:

    https://github.com/rekado/scala-bootstrap/tree/bootstrap

This is at around version 1.4.0.4, as you wrote above.

Since the old days Scala Native has grown considerably, and 
perhaps we can reuse some of its native libraries.  I’m not too 
hopeful, because the bulk of it is still written in Scala, 
obviously, but there are parts that are written in C / C++, which 
might come in handy.

    https://github.com/scala-native/scala-native

-- 
Ricardo


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Scala package
  2021-05-18  9:44   ` Ricardo Wurmus
@ 2021-05-18 11:15     ` Julien Lepiller
  2021-05-18 11:36       ` Leo Prikler
  2021-05-18 21:35       ` Ludovic Courtès
  2021-05-18 14:00     ` Daniel Trujillo Viedma
  1 sibling, 2 replies; 13+ messages in thread
From: Julien Lepiller @ 2021-05-18 11:15 UTC (permalink / raw)
  To: Ricardo Wurmus, Leo Prikler; +Cc: guix-devel

[-- Attachment #1: Type: text/plain, Size: 2689 bytes --]

The old scala is written in a superset of java5, that requires PiCo to build, and PiCo was built with JaCo. They were developped at EPFL, and you can find a binary for it, but no source: http://zenger.org/jaco/

Apparently, JaCo was later reimplemented in Keris, whose source code is available. However, KeCo (the Keris compiler) is written in Keris.

It is not even clear that building an old version of scala is going to work, as the language evolved a lot since then.

I think the best way to bootstrap would be to reimplement Scala in another language. I tried that too, but even the parser is crazy.

Le 18 mai 2021 05:44:42 GMT-04:00, Ricardo Wurmus <rekado@elephly.net> a écrit :
>
>Leo Prikler <leo.prikler@student.tugraz.at> writes:
>
>> Hi Julien,
>>
>> Am Dienstag, den 18.05.2021, 01:01 +0200 schrieb Julien 
>> Lepiller:
>>> Hi Guix!
>>> 
>>> I have the attached file that build Scala, although it's not
>>> bootstrapped at all. It contains %binary-scala, a few 
>>> dependencies of
>>> Scala we haven't packaged yet, and the final scala, built from
>>> %binary-scala, without sbt (which requires Scala too).
>>> 
>>> Since I've tried and failed to bootstrap Scala for so long, I 
>>> think
>>> it's time to give up. I can't always create miracles.
>>
>> Some points relevant to bootstrapping:
>> - The last version, that ships "scalai" written in Java seems to 
>> be 
>>   v1.4.0+4.  Perhaps one can use scalai to bootstrap scalac 
>>   within it.
>> - The last version, that does not "require" sbt is 2.11.x,
>>   though with your workaround we can also build later versions.
>
>We tried building a clean bootstrap chain for Scala for years. 
>Back then I went down the rabbit hole and found that early scalac 
>is written in Pizza; but it turned out that Pizza is written in 
>Pizza and is released under the old Artistic License, which is 
>considered non-free.
>
>    https://logs.guix.gnu.org/guix/2018-04-08.log#230002
>    https://logs.guix.gnu.org/guix/2018-04-09.log#073740
>
>I pointed a branch at an old Scala commit that contains the old 
>Socos compiler source, which ostensibly are written in Java, but 
>actually are not:
>
>    https://github.com/rekado/scala-bootstrap/tree/bootstrap
>
>This is at around version 1.4.0.4, as you wrote above.
>
>Since the old days Scala Native has grown considerably, and 
>perhaps we can reuse some of its native libraries.  I’m not too 
>hopeful, because the bulk of it is still written in Scala, 
>obviously, but there are parts that are written in C / C++, which 
>might come in handy.
>
>    https://github.com/scala-native/scala-native
>
>-- 
>Ricardo

[-- Attachment #2: Type: text/html, Size: 3506 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Scala package
  2021-05-18 11:15     ` Julien Lepiller
@ 2021-05-18 11:36       ` Leo Prikler
  2021-05-18 12:37         ` Julien Lepiller
  2021-05-18 21:35       ` Ludovic Courtès
  1 sibling, 1 reply; 13+ messages in thread
From: Leo Prikler @ 2021-05-18 11:36 UTC (permalink / raw)
  To: Julien Lepiller, Ricardo Wurmus; +Cc: guix-devel

Am Dienstag, den 18.05.2021, 07:15 -0400 schrieb Julien Lepiller:
> The old scala is written in a superset of java5, that requires PiCo
> to build, and PiCo was built with JaCo. They were developped at EPFL,
> and you can find a binary for it, but no source: 
> http://zenger.org/jaco/
> 
> Apparently, JaCo was later reimplemented in Keris, whose source code
> is available. However, KeCo (the Keris compiler) is written in Keris.
> 
> It is not even clear that building an old version of scala is going
> to work, as the language evolved a lot since then.
> 
> I think the best way to bootstrap would be to reimplement Scala in
> another language. I tried that too, but even the parser is crazy.
Thanks Julien and Ricardo for the detailed explanation of what goes
wrong here.

Would a bootstrap chain from 2.0.x work at least, so that the crazy
Scala parser can target a specific (early) version and we get a
slightly smaller binary or are the gains from that too minimal?  This
is also a concern going forward, can we always hope to "bootstrap" the
next Scala version with the one currently packaged in Guix?

> Le 18 mai 2021 05:44:42 GMT-04:00, Ricardo Wurmus <rekado@elephly.net
> > a écrit :
> > Leo Prikler <leo.prikler@student.tugraz.at> writes:
> > 
> > >  Hi Julien,
> > > 
> > >  Am Dienstag, den 18.05.2021, 01:01 +0200 schrieb Julien 
> > >  Lepiller:
> > > > Hi Guix!
> > > > 
> > > > I have the attached file that build Scala, although it's not
> > > > bootstrapped at all. It contains %binary-scala, a few 
> > > > dependencies of
> > > > Scala we haven't packaged yet, and the final scala, built from
> > > > %binary-scala, without sbt (which requires Scala too).
> > > > 
> > > > Since I've tried and failed to bootstrap Scala for so long, I 
> > > > think
> > > > it's time to give up. I can't always create miracles.
> > > 
> > >  Some points relevant to bootstrapping:
> > >  - The last version, that ships "scalai" written in Java seems
> > > to 
> > >  be 
> > >    v1.4.0+4.  Perhaps one can use scalai to bootstrap scalac 
> > >    within it.
> > >  - The last version, that does not "require" sbt is 2.11.x,
> > >    though with your workaround we can also build later versions.
> > 
> > We tried building a clean bootstrap chain for Scala for years. 
> > Back then I went down the rabbit hole and found that early scalac 
> > is written in Pizza; but it turned out that Pizza is written in 
> > Pizza and is released under the old Artistic License, which is 
> > considered non-free.
> > 
> >     https://logs.guix.gnu.org/guix/2018-04-08.log#230002
> >     https://logs.guix.gnu.org/guix/2018-04-09.log#073740
> > 
> > I pointed a branch at an old Scala commit that contains the old 
> > Socos compiler source, which ostensibly are written in Java, but 
> > actually are not:
> > 
> >     https://github.com/rekado/scala-bootstrap/tree/bootstrap
> > 
> > This is at around version 1.4.0.4, as you wrote above.
> > 
> > Since the old days Scala Native has grown considerably, and 
> > perhaps we can reuse some of its native libraries.  I’m not too 
> > hopeful, because the bulk of it is still written in Scala, 
> > obviously, but there are parts that are written in C / C++, which 
> > might come in handy.
> > 
> >     https://github.com/scala-native/scala-native



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Scala package
  2021-05-18 11:36       ` Leo Prikler
@ 2021-05-18 12:37         ` Julien Lepiller
  2021-05-18 13:52           ` Leo Prikler
  0 siblings, 1 reply; 13+ messages in thread
From: Julien Lepiller @ 2021-05-18 12:37 UTC (permalink / raw)
  To: Leo Prikler; +Cc: guix-devel

Le Tue, 18 May 2021 13:36:43 +0200,
Leo Prikler <leo.prikler@student.tugraz.at> a écrit :

> Am Dienstag, den 18.05.2021, 07:15 -0400 schrieb Julien Lepiller:
> > The old scala is written in a superset of java5, that requires PiCo
> > to build, and PiCo was built with JaCo. They were developped at
> > EPFL, and you can find a binary for it, but no source: 
> > http://zenger.org/jaco/
> > 
> > Apparently, JaCo was later reimplemented in Keris, whose source code
> > is available. However, KeCo (the Keris compiler) is written in
> > Keris.
> > 
> > It is not even clear that building an old version of scala is going
> > to work, as the language evolved a lot since then.
> > 
> > I think the best way to bootstrap would be to reimplement Scala in
> > another language. I tried that too, but even the parser is crazy.  
> Thanks Julien and Ricardo for the detailed explanation of what goes
> wrong here.
> 
> Would a bootstrap chain from 2.0.x work at least, so that the crazy
> Scala parser can target a specific (early) version and we get a
> slightly smaller binary or are the gains from that too minimal?  This
> is also a concern going forward, can we always hope to "bootstrap" the
> next Scala version with the one currently packaged in Guix?

That's not even clear it would be possible. Citing discussion on
Scala's forum
(https://contributors.scala-lang.org/t/compiling-scala-and-sbt-for-debian-distro/3620/12)

The Scala 2.12 compiler is written in Scala 2.12 and uses the Scala
2.12 standard library. Compiling it with 2.11 isn’t an option.

and later:

If that was the only hurdle you had to clear, you might be fine. But it
isn’t the only hurdle; the compiler was re-bootstrapped several dozen
times between 2.11.6 and 2.12.9. (And then a bunch more times after
that to get to 2.13.0.)

so we would get an enormous bootstrap chain, and it's not even
guaranteed that each bootstrap can be replayed nicely.

> 
> > Le 18 mai 2021 05:44:42 GMT-04:00, Ricardo Wurmus
> > <rekado@elephly.net  
> > > a écrit :
> > > Leo Prikler <leo.prikler@student.tugraz.at> writes:
> > >   
> > > >  Hi Julien,
> > > > 
> > > >  Am Dienstag, den 18.05.2021, 01:01 +0200 schrieb Julien 
> > > >  Lepiller:  
> > > > > Hi Guix!
> > > > > 
> > > > > I have the attached file that build Scala, although it's not
> > > > > bootstrapped at all. It contains %binary-scala, a few 
> > > > > dependencies of
> > > > > Scala we haven't packaged yet, and the final scala, built from
> > > > > %binary-scala, without sbt (which requires Scala too).
> > > > > 
> > > > > Since I've tried and failed to bootstrap Scala for so long, I 
> > > > > think
> > > > > it's time to give up. I can't always create miracles.  
> > > > 
> > > >  Some points relevant to bootstrapping:
> > > >  - The last version, that ships "scalai" written in Java seems
> > > > to 
> > > >  be 
> > > >    v1.4.0+4.  Perhaps one can use scalai to bootstrap scalac 
> > > >    within it.
> > > >  - The last version, that does not "require" sbt is 2.11.x,
> > > >    though with your workaround we can also build later
> > > > versions.  
> > > 
> > > We tried building a clean bootstrap chain for Scala for years. 
> > > Back then I went down the rabbit hole and found that early scalac 
> > > is written in Pizza; but it turned out that Pizza is written in 
> > > Pizza and is released under the old Artistic License, which is 
> > > considered non-free.
> > > 
> > >     https://logs.guix.gnu.org/guix/2018-04-08.log#230002
> > >     https://logs.guix.gnu.org/guix/2018-04-09.log#073740
> > > 
> > > I pointed a branch at an old Scala commit that contains the old 
> > > Socos compiler source, which ostensibly are written in Java, but 
> > > actually are not:
> > > 
> > >     https://github.com/rekado/scala-bootstrap/tree/bootstrap
> > > 
> > > This is at around version 1.4.0.4, as you wrote above.
> > > 
> > > Since the old days Scala Native has grown considerably, and 
> > > perhaps we can reuse some of its native libraries.  I’m not too 
> > > hopeful, because the bulk of it is still written in Scala, 
> > > obviously, but there are parts that are written in C / C++, which 
> > > might come in handy.
> > > 
> > >     https://github.com/scala-native/scala-native  
> 



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Scala package
  2021-05-18 12:37         ` Julien Lepiller
@ 2021-05-18 13:52           ` Leo Prikler
  0 siblings, 0 replies; 13+ messages in thread
From: Leo Prikler @ 2021-05-18 13:52 UTC (permalink / raw)
  To: Julien Lepiller; +Cc: guix-devel

Am Dienstag, den 18.05.2021, 14:37 +0200 schrieb Julien Lepiller:
> Le Tue, 18 May 2021 13:36:43 +0200,
> Leo Prikler <leo.prikler@student.tugraz.at> a écrit :
> 
> > Am Dienstag, den 18.05.2021, 07:15 -0400 schrieb Julien Lepiller:
> > > The old scala is written in a superset of java5, that requires
> > > PiCo
> > > to build, and PiCo was built with JaCo. They were developped at
> > > EPFL, and you can find a binary for it, but no source: 
> > > http://zenger.org/jaco/
> > > 
> > > Apparently, JaCo was later reimplemented in Keris, whose source
> > > code
> > > is available. However, KeCo (the Keris compiler) is written in
> > > Keris.
> > > 
> > > It is not even clear that building an old version of scala is
> > > going
> > > to work, as the language evolved a lot since then.
> > > 
> > > I think the best way to bootstrap would be to reimplement Scala
> > > in
> > > another language. I tried that too, but even the parser is
> > > crazy.  
> > Thanks Julien and Ricardo for the detailed explanation of what goes
> > wrong here.
> > 
> > Would a bootstrap chain from 2.0.x work at least, so that the crazy
> > Scala parser can target a specific (early) version and we get a
> > slightly smaller binary or are the gains from that too
> > minimal?  This
> > is also a concern going forward, can we always hope to "bootstrap"
> > the
> > next Scala version with the one currently packaged in Guix?
> 
> That's not even clear it would be possible. Citing discussion on
> Scala's forum
> (
> https://contributors.scala-lang.org/t/compiling-scala-and-sbt-for-debian-distro/3620/12
> )
> 
> The Scala 2.12 compiler is written in Scala 2.12 and uses the Scala
> 2.12 standard library. Compiling it with 2.11 isn’t an option.
> 
> and later:
> 
> If that was the only hurdle you had to clear, you might be fine. But
> it
> isn’t the only hurdle; the compiler was re-bootstrapped several dozen
> times between 2.11.6 and 2.12.9. (And then a bunch more times after
> that to get to 2.13.0.)
> 
> so we would get an enormous bootstrap chain, and it's not even
> guaranteed that each bootstrap can be replayed nicely.
So in the end we would always be forced to bootstrap Scala 2.x.y from
more or less that exact 2.x.y?  How does anyone find this acceptable?



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Scala package
  2021-05-18  9:44   ` Ricardo Wurmus
  2021-05-18 11:15     ` Julien Lepiller
@ 2021-05-18 14:00     ` Daniel Trujillo Viedma
  1 sibling, 0 replies; 13+ messages in thread
From: Daniel Trujillo Viedma @ 2021-05-18 14:00 UTC (permalink / raw)
  To: guix-devel

El 18/5/21 a las 11:44, Ricardo Wurmus escribió:
>
> Leo Prikler <leo.prikler@student.tugraz.at> writes:
>
>> Hi Julien,
>>
>> Am Dienstag, den 18.05.2021, 01:01 +0200 schrieb Julien Lepiller:
>>> Hi Guix!
>>>
>>> I have the attached file that build Scala, although it's not
>>> bootstrapped at all. It contains %binary-scala, a few dependencies of
>>> Scala we haven't packaged yet, and the final scala, built from
>>> %binary-scala, without sbt (which requires Scala too).
>>>
>>> Since I've tried and failed to bootstrap Scala for so long, I think
>>> it's time to give up. I can't always create miracles.
>>
>> Some points relevant to bootstrapping:
>> - The last version, that ships "scalai" written in Java seems to be   
>> v1.4.0+4.  Perhaps one can use scalai to bootstrap scalac within it.
>> - The last version, that does not "require" sbt is 2.11.x,
>>   though with your workaround we can also build later versions.
>
> We tried building a clean bootstrap chain for Scala for years. Back 
> then I went down the rabbit hole and found that early scalac is 
> written in Pizza; but it turned out that Pizza is written in Pizza and 
> is released under the old Artistic License, which is considered non-free.
>
>    https://logs.guix.gnu.org/guix/2018-04-08.log#230002
>    https://logs.guix.gnu.org/guix/2018-04-09.log#073740
>
> I pointed a branch at an old Scala commit that contains the old Socos 
> compiler source, which ostensibly are written in Java, but actually 
> are not:
>
>    https://github.com/rekado/scala-bootstrap/tree/bootstrap
>
> This is at around version 1.4.0.4, as you wrote above.
>
> Since the old days Scala Native has grown considerably, and perhaps we 
> can reuse some of its native libraries.  I’m not too hopeful, because 
> the bulk of it is still written in Scala, obviously, but there are 
> parts that are written in C / C++, which might come in handy.
>
>    https://github.com/scala-native/scala-native
>

Hi all! My name is Daniel, I'm from Spain, this is my first contribution 
to Guix (well, to a discussion, actually)


I've seen this thread about Scala, and I would like to know more about 
the progress in bootstrapping in Scala. Scala (2) is my main language 
right now, but I want to try other purest options, Lisp being one of 
them, and also want to transition to Guix and contributing packages, 
eventually. I love what you, people, built.


Probably you know about this, but here is a link to an IRC channel about 
this: https://www.bootstrappable.org/projects/jvm-languages.html


It would be nice to have an exact dependency graph so that we can easily 
see the dead ends, and find the the most cost-effective solution. 
Probably translate old Scala code to a similar, already bootstrapped 
language would be a better option than building a compiler for Scala...


Thank you!

Dani.




^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Scala package
  2021-05-18 11:15     ` Julien Lepiller
  2021-05-18 11:36       ` Leo Prikler
@ 2021-05-18 21:35       ` Ludovic Courtès
  2021-05-19 15:35         ` Katherine Cox-Buday
  1 sibling, 1 reply; 13+ messages in thread
From: Ludovic Courtès @ 2021-05-18 21:35 UTC (permalink / raw)
  To: Julien Lepiller; +Cc: guix-devel, Leo Prikler

Hi,

Julien Lepiller <julien@lepiller.eu> skribis:

> I think the best way to bootstrap would be to reimplement Scala in another language. I tried that too, but even the parser is crazy.

Could you share a link to that so everyone realizes just how far you
went?  :-)

That OCaml now has a clean bootstrapping story can hopefully give GHC
and Scala folks an incentive to catch up.

How about writing a blog post?  Ricardo and you could summarize your
heroic efforts, like Ricardo did for GHC (and it’d be a truly
interesting read I’m sure, both for those interested in Scala’s history
and for those interested in compilers).  And in conclusion, you could
say: “Look, a major competitor is doing it right.”  :-)

(And in the meantime, I fully appreciate that when you say it’s maybe
time to give up, it probably *is* time.)

Ludo’.



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Scala package
  2021-05-18 21:35       ` Ludovic Courtès
@ 2021-05-19 15:35         ` Katherine Cox-Buday
  2021-05-20 19:09           ` Shyam Saran
  0 siblings, 1 reply; 13+ messages in thread
From: Katherine Cox-Buday @ 2021-05-19 15:35 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel, Leo Prikler

Ludovic Courtès <ludo@gnu.org> writes:

>> I think the best way to bootstrap would be to reimplement Scala in
> another language. I tried that too, but even the parser is crazy.

Yes, the syntax is complex. Maybe even worse than C++ in terms of
parsing. I abandoned scala awhile ago, but I saw that with its latest
release, maybe some things got simplified. Maybe it's worth another
look?

> Could you share a link to that so everyone realizes just how far you
> went?  :-)

Before I outright abandoned the language, I was looking into
bootstrapping this too. I did not go nearly as far, but was strongly
dissuaded by core scala contributers from even trying (to be fair, they
probably don't hold bootstrapping in high regard as we do).

The only thought I have to contribute is: would it be possible to
bootstrap off of a binary seed, and then do what's possible to grow that
down to prior versions as much as possible? It's a compromise, but it at
least gets Guix into the scala ecosystem and provides scaffolding to
work off of. Of course this might run contrary to Guix's goals/needs.

-- 
Katherine


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Scala package
  2021-05-19 15:35         ` Katherine Cox-Buday
@ 2021-05-20 19:09           ` Shyam Saran
  2021-05-20 19:34             ` Julien Lepiller
  0 siblings, 1 reply; 13+ messages in thread
From: Shyam Saran @ 2021-05-20 19:09 UTC (permalink / raw)
  To: Katherine Cox-Buday; +Cc: guix-devel, Leo Prikler

[-- Attachment #1: Type: text/plain, Size: 1654 bytes --]

Many people want to move all their development work on guix

example android sdk app development, yes scala, gradle, kotlin, groovy etc
(even blockstack, ethereum) required to be packaged
As many of you, and Julien trying this.

So more than contributing code, please provide a blog post from which, who
all want to help
can also get guidance.


Thanks

syam





On Wed, 19 May 2021 at 21:06, Katherine Cox-Buday <cox.katherine.e@gmail.com>
wrote:

> Ludovic Courtès <ludo@gnu.org> writes:
>
> >> I think the best way to bootstrap would be to reimplement Scala in
> > another language. I tried that too, but even the parser is crazy.
>
> Yes, the syntax is complex. Maybe even worse than C++ in terms of
> parsing. I abandoned scala awhile ago, but I saw that with its latest
> release, maybe some things got simplified. Maybe it's worth another
> look?
>
> > Could you share a link to that so everyone realizes just how far you
> > went?  :-)
>
> Before I outright abandoned the language, I was looking into
> bootstrapping this too. I did not go nearly as far, but was strongly
> dissuaded by core scala contributers from even trying (to be fair, they
> probably don't hold bootstrapping in high regard as we do).
>
> The only thought I have to contribute is: would it be possible to
> bootstrap off of a binary seed, and then do what's possible to grow that
> down to prior versions as much as possible? It's a compromise, but it at
> least gets Guix into the scala ecosystem and provides scaffolding to
> work off of. Of course this might run contrary to Guix's goals/needs.
>
> --
> Katherine
>
>

[-- Attachment #2: Type: text/html, Size: 2280 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Scala package
  2021-05-20 19:09           ` Shyam Saran
@ 2021-05-20 19:34             ` Julien Lepiller
  2021-05-21  9:32               ` Shyam Saran
  0 siblings, 1 reply; 13+ messages in thread
From: Julien Lepiller @ 2021-05-20 19:34 UTC (permalink / raw)
  To: guix-devel, Shyam Saran, Katherine Cox-Buday; +Cc: Leo Prikler

[-- Attachment #1: Type: text/plain, Size: 1897 bytes --]

I'll think about that. Note that we already have Groovy, as it's properly bootstrapped :)

Le 20 mai 2021 15:09:08 GMT-04:00, Shyam Saran <syamsaran12345@gmail.com> a écrit :
>Many people want to move all their development work on guix
>
>example android sdk app development, yes scala, gradle, kotlin, groovy
>etc
>(even blockstack, ethereum) required to be packaged
>As many of you, and Julien trying this.
>
>So more than contributing code, please provide a blog post from which,
>who
>all want to help
>can also get guidance.
>
>
>Thanks
>
>syam
>
>
>
>
>
>On Wed, 19 May 2021 at 21:06, Katherine Cox-Buday
><cox.katherine.e@gmail.com>
>wrote:
>
>> Ludovic Courtès <ludo@gnu.org> writes:
>>
>> >> I think the best way to bootstrap would be to reimplement Scala in
>> > another language. I tried that too, but even the parser is crazy.
>>
>> Yes, the syntax is complex. Maybe even worse than C++ in terms of
>> parsing. I abandoned scala awhile ago, but I saw that with its latest
>> release, maybe some things got simplified. Maybe it's worth another
>> look?
>>
>> > Could you share a link to that so everyone realizes just how far
>you
>> > went?  :-)
>>
>> Before I outright abandoned the language, I was looking into
>> bootstrapping this too. I did not go nearly as far, but was strongly
>> dissuaded by core scala contributers from even trying (to be fair,
>they
>> probably don't hold bootstrapping in high regard as we do).
>>
>> The only thought I have to contribute is: would it be possible to
>> bootstrap off of a binary seed, and then do what's possible to grow
>that
>> down to prior versions as much as possible? It's a compromise, but it
>at
>> least gets Guix into the scala ecosystem and provides scaffolding to
>> work off of. Of course this might run contrary to Guix's goals/needs.
>>
>> --
>> Katherine
>>
>>

[-- Attachment #2: Type: text/html, Size: 2665 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Scala package
  2021-05-20 19:34             ` Julien Lepiller
@ 2021-05-21  9:32               ` Shyam Saran
  0 siblings, 0 replies; 13+ messages in thread
From: Shyam Saran @ 2021-05-21  9:32 UTC (permalink / raw)
  To: Julien Lepiller; +Cc: guix-devel, Leo Prikler, Katherine Cox-Buday

[-- Attachment #1: Type: text/plain, Size: 2190 bytes --]

It is helpful for our beloved OS -thanks
it will be helpful for app development.
At present, I do not know any of groovy, scala (will learn.)


On Fri, 21 May 2021 at 01:05, Julien Lepiller <julien@lepiller.eu> wrote:

> I'll think about that. Note that we already have Groovy, as it's properly
> bootstrapped :)
>
> Le 20 mai 2021 15:09:08 GMT-04:00, Shyam Saran <syamsaran12345@gmail.com>
> a écrit :
>>
>>
>> Many people want to move all their development work on guix
>>
>> example android sdk app development, yes scala, gradle, kotlin, groovy
>> etc (even blockstack, ethereum) required to be packaged
>> As many of you, and Julien trying this.
>>
>> So more than contributing code, please provide a blog post from which,
>> who all want to help
>> can also get guidance.
>>
>>
>> Thanks
>>
>> syam
>>
>>
>>
>>
>>
>> On Wed, 19 May 2021 at 21:06, Katherine Cox-Buday <
>> cox.katherine.e@gmail.com> wrote:
>>
>>> Ludovic Courtès <ludo@gnu.org> writes:
>>>
>>> >> I think the best way to bootstrap would be to reimplement Scala in
>>> > another language. I tried that too, but even the parser is crazy.
>>>
>>> Yes, the syntax is complex. Maybe even worse than C++ in terms of
>>> parsing. I abandoned scala awhile ago, but I saw that with its latest
>>> release, maybe some things got simplified. Maybe it's worth another
>>> look?
>>>
>>> > Could you share a link to that so everyone realizes just how far you
>>> > went?  :-)
>>>
>>> Before I outright abandoned the language, I was looking into
>>> bootstrapping this too. I did not go nearly as far, but was strongly
>>> dissuaded by core scala contributers from even trying (to be fair, they
>>> probably don't hold bootstrapping in high regard as we do).
>>>
>>> The only thought I have to contribute is: would it be possible to
>>> bootstrap off of a binary seed, and then do what's possible to grow that
>>> down to prior versions as much as possible? It's a compromise, but it at
>>> least gets Guix into the scala ecosystem and provides scaffolding to
>>> work off of. Of course this might run contrary to Guix's goals/needs.
>>>
>>> --
>>> Katherine
>>>
>>>

[-- Attachment #2: Type: text/html, Size: 3309 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2021-05-22 12:09 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-17 23:01 Scala package Julien Lepiller
2021-05-18  7:08 ` Leo Prikler
2021-05-18  9:44   ` Ricardo Wurmus
2021-05-18 11:15     ` Julien Lepiller
2021-05-18 11:36       ` Leo Prikler
2021-05-18 12:37         ` Julien Lepiller
2021-05-18 13:52           ` Leo Prikler
2021-05-18 21:35       ` Ludovic Courtès
2021-05-19 15:35         ` Katherine Cox-Buday
2021-05-20 19:09           ` Shyam Saran
2021-05-20 19:34             ` Julien Lepiller
2021-05-21  9:32               ` Shyam Saran
2021-05-18 14:00     ` Daniel Trujillo Viedma

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).