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

Fatal compilation error when using scala-pickles/boopickle libraries (probably macros-related) #118

Open
dkomanov opened this issue Jan 1, 2017 · 17 comments

Comments

@dkomanov
Copy link
Contributor

dkomanov commented Jan 1, 2017

Environment:

Ubuntu 16.04

bazel version 
Build label: 0.4.3rc6
Build target: bazel-out/local-fastbuild/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Wed Dec 21 15:53:43 2016 (1482335623)
Build timestamp: 1482335623
Build timestamp as int: 1482335623

In WORKSPACE:

git_repository(
    name = "io_bazel",
    remote = "git://github.com/bazelbuild/bazel.git",
    tag = "0.4.3",
)
git_repository(
    name = "io_bazel_rules_scala",
    remote = "https://github.com/bazelbuild/rules_scala.git",
    commit = "4f3fc159d64711f2b28d18b507cfe25c3348e4d5",
)
load("@io_bazel_rules_scala//scala:scala.bzl", "scala_repositories")
scala_repositories()

maven_jar(
    name = "me_chrons_boopickle_2_11",
    artifact = "me.chrons:boopickle_2.11:1.2.4",
)

In third_party/BUILD:

java_library(
    name = "me_chrons_boopickle_2_11",
    visibility = ["//visibility:public"],
    exports = [
        "@me_chrons_boopickle_2_11//jar",
    ],
)

SimpleCaseClass.scala:

package com.komanov.bazeltest

import boopickle.Default._

case class SimpleCaseClass(name: String)

object SimpleCaseClass {
  override def toByteArray(s: SimpleCaseClass) = {
    Pickle.intoBytes(s)
  }
}

Its BUILD file:

scala_library(
    name = "bazeltest",
    srcs = ["SimpleCaseClass.scala"],
    deps = ["//third_party:me_chrons_boopickle_2_11"],
)

When I try to build it:

bazel build --verbose_failures --worker_verbose //src/com/komanov/bazeltest
INFO: Found 1 target...
WARNING: Scalac worker (id 39) can no longer be used, because its process terminated itself or got killed.
INFO: Destroying Scalac worker (id 39)
INFO: Created new non-sandboxed Scalac worker (id 40), logging to .../.cache/bazel/_bazel_user/8284de460f2a76fffe4edd44c16c874d/bazel-workers/worker-40-Scalac.log
ERROR: .../src/com/komanov/bazeltest/BUILD:1:1: scala //src/com/komanov/bazeltest:bazeltest failed: Worker process did not return a correct WorkResponse. This is probably caused by a bug in the worker, writing unexpected other data to stdout.
Target //src/com/komanov/bazeltest:bazeltest failed to build
INFO: Elapsed time: 2.200s, Critical Path: 2.09s

worker-40-Scalac.log.txt

Looks like macros expansion related (non-macros code is working fine with this library).

@johnynek
Copy link
Member

johnynek commented Jan 1, 2017 via email

@ittaiz
Copy link
Member

ittaiz commented Jan 11, 2017

@johnynek is this due to bazelbuild/bazel#990?

@johnynek
Copy link
Member

johnynek commented Jan 11, 2017 via email

@ittaiz
Copy link
Member

ittaiz commented Jan 12, 2017 via email

@ittaiz
Copy link
Member

ittaiz commented Jan 15, 2017

@johnynek going back to this again- where do we generate an ijar for maven jars? from the code it seems to me, probably mistakenly, that we generate it only on targets we create. Hence sending it to ScalaCInvoker and such. Can you point me to the offender?
Thanks!

@johnynek
Copy link
Member

johnynek commented Jan 15, 2017 via email

@ittaiz
Copy link
Member

ittaiz commented Jan 15, 2017

Two (hopefully last) questions:

  1. Bazel itself does run ijar on maven_jars when you use //jar, no? That's why adding a //file solved Ignore scalatest in unused dependency checker #990 by allowing consumers to sidestep it, right?
  2. when you say "preferring file is probably the easiest way to go" you mean that users of rules_scala should just manually use //file across the board and so avoid this problem?

@johnynek
Copy link
Member

johnynek commented Jan 15, 2017 via email

@johnynek
Copy link
Member

johnynek commented Jan 15, 2017 via email

@ittaiz
Copy link
Member

ittaiz commented Jan 15, 2017

let's pull in @damienmg and ask if he knows if we have a way to make this distinction.
If not and it's not likely to get in we should probably update the readme

@damienmg
Copy link
Contributor

What are you trying to do exactly? I believe aspect can let you investigate these information. /cc @dslomov

@ittaiz
Copy link
Member

ittaiz commented Jan 16, 2017

We to bypass the ijar for maven jars. This is because the ijar for some scala maven jars which contains macros breaks the build. Seeing as people depend on maven jars in the following practice

java_library(
    name = "me_chrons_boopickle_2_11",
    visibility = ["//visibility:public"],
    exports = [
        "@me_chrons_boopickle_2_11//jar",
    ],
)

bazel runs ijar on the export. We'd like to get the "raw" jar.
What @johnynek said was that we need a way to know if the dependency is a maven/jar import and so try to take the full jar and not the ijar.

@damienmg
Copy link
Contributor

I still do not understand exactly how you want to do that, e.g. who is the consumer.

Also, why not fix ijar for it?

@ittaiz
Copy link
Member

ittaiz commented Jan 16, 2017

good questions and I'm not sure actually so I'll let @johnynek take a stab at them while I mull them over. Thanks for your guidance!

@johnynek
Copy link
Member

johnynek commented Jan 16, 2017 via email

@ittaiz
Copy link
Member

ittaiz commented Jan 16, 2017

@johnynek What we'd like to do is to analyze the dependencies on every invocation of a scala_* target type and if we see deps which arrive from jar import to use the jar and not ijar, right?

@johnynek
Copy link
Member

johnynek commented Jan 16, 2017 via email

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

No branches or pull requests

4 participants