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

Dependencies for host are used for target when set in grpc_deps #797

Closed
ignasl opened this issue Jul 24, 2019 · 4 comments
Closed

Dependencies for host are used for target when set in grpc_deps #797

ignasl opened this issue Jul 24, 2019 · 4 comments

Comments

@ignasl
Copy link
Contributor

ignasl commented Jul 24, 2019

I have defined and registered my own scala_proto_toolchain:

scala_proto_toolchain(
    name = "my_shiny_toolchain",
    grpc_deps = [
        "//important/dependency"
    ],
    code_generator = "//important/generator:my_generator"
)

Naturally, I am declaring the rule for proto and another scala library that depends on it:

scalapb_proto_library(
   name = "my_proto",
   deps = [...]
)

scala_library(
   name = "my_library",
   deps = [
      ":my_proto",
      "//important/dependency"
   ]
)

So dependencies are eventually set-up like this:

  1. my_proto -> //important/dependency
  2. my_library -> //important/dependency
  3. my_library -> my_proto

Now, the problem arises that when "my_library" gets built, the classpath contains two copies of the //important/dependency jars:

  1. /bazel-out/host/bin/important/dependency/dependency.jar
  2. /bazel-out/darwin-fastbuild/bin/important/dependency/dependency.jar

This is a problem, because jars meant for the host find their way into dependency list meant for the target. I cannot remove the //important/dependency' from the grpc_deps` list, because generated code requires it and this causes compile failures.

I believe (correct me if I am wrong) that bazel or rules_scala incorrectly resolves libraries' paths to host. With JVM languages compilers can happily accept them because they are essentially different. However, if this was, for example, C++ cross-platform build (host is x86 and target ARM) compiler would not allow it. Since bazel supports cross-compiling, the issue must be with scala_rules. Otherwise, please, let me know what am doing wrong.

@ignasl ignasl changed the title Dependencies for host are used for targed when set in grpc_deps Dependencies for host are used for targed when set in grpc_deps Jul 24, 2019
@ignasl ignasl changed the title Dependencies for host are used for targed when set in grpc_deps Dependencies for host are used for target when set in grpc_deps Jul 24, 2019
@ignasl
Copy link
Contributor Author

ignasl commented Jul 25, 2019

@ianoc-stripe, @ianoc could you provide some insights?

@ianoc-stripe
Copy link
Contributor

Hi @ignasl it would be great if you could add a test in a PR for this? it should be possible to write one that fails i believe? it would make it much easier to debug/fix.

@ianoc-stripe
Copy link
Contributor

@ignasl merged a changed yesterday i think should act as a workaround for you, unfortunately the api's changed slightly due to limitations in bazel in making this nicer at the moment. But it should stop the host deps coming for target

@ignasl
Copy link
Contributor Author

ignasl commented Aug 1, 2019

Thanks a lot for solving this one. API change is not a problem at all we are still in POC mode. I have already started experimenting.

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

2 participants