Skip to content

It's possible to statically link the same library twice #11727

@agluszak

Description

@agluszak

ATTENTION! Please read and follow:

  • if this is a question about how to build / test / query / deploy using Bazel, or a discussion starter, send it to [email protected]
  • if this is a bug or feature request, fill the form below as best as you can.

Description of the problem / feature request:

There was a check to make sure that a c++ shared library is not being linked in twice in different configurations (https://cs.opensource.google/bazel/bazel/+/master:src/main/java/com/google/devtools/build/lib/rules/cpp/LibrariesToLinkCollector.java;drc=137b759c8f6d37d7512d621571aa9446d5c1ec4d;l=246). One of my tasks was to make it a rule error and loosen the restriction so that people can use transitions in they own custom rules (see #11721). During the testing I found out that in a setup with a transition, where dynamically linked libraries will give an error, using static linking causes both versions of the same library to be linked in. This should probably be an error or at least a warning. I didn't change that behavior in my PR.

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

git clone https://github.com/agluszak/bazel-linking-twice.git
cd bazel-linking-twice
bazel build main
cat bazel-bin/main-2.params

What operating system are you running Bazel on?

gLinux

What's the output of bazel info release?

release 3.3.1
(binary built from my own branch #11721 shows the same behavior)

What's the output of git remote get-url origin ; git rev-parse master ; git rev-parse HEAD ?

[email protected]:agluszak/bazel.git
82e6b6a
6823cae

Have you found anything relevant by searching the web?

No, but I talked about it with @oquenchil

Any other information, logs, or outputs that you want to share?

Replace these lines with your answer.

If the files are large, upload as attachment or provide link.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2We'll consider working on this in future. (Assignee optional)team-Rules-CPPIssues for C++ rulestype: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions