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

Possible regression between 6.4.0 and 7.x: cc_library does not propagate linkopts option #23053

Closed
femshima opened this issue Jul 21, 2024 · 6 comments
Labels

Comments

@femshima
Copy link

femshima commented Jul 21, 2024

Description of the bug:

Hello. It seems that Bazel 7.x does not link library specified in linkopts of dependency, even though 6.4.0 do.

For example, the following code, which creates libtest.so, should link to libuim.so as specified in uim dependency. However, in 7.x, it does not link.

# BUILD.bazel

cc_library(
    name = "uim",
    hdrs = glob([
        "usr/include/uim/**"
    ]),
    copts = [
        ""
    ],
    includes = [
        "usr/include/uim"
    ],
    linkopts = [
        "-luim",
        "-luim-scm"
    ],
)

cc_library(
    name = "test_lib",
    srcs = ["test.cc"],
    deps = [
        ":uim",
    ]
)

cc_shared_library(
    name = "test",
    roots = ["test_lib"],
)

I confirmed that by executing ldd, and also looking at libtest.so-2.params file. When built with 7.x, the libtest.so-2.params file does not include -luim or -luim-scm line.

Also, when I copy linkopts to test_lib, it works fine.

cc_library(
    name = "test_lib",
    srcs = ["test.cc"],
    deps = [
        ":uim",
-   ]
+   ],
+   linkopts = [
+       "-luim",
+       "-luim-scm"
+   ],
)

Which category does this issue belong to?

C++ Rules

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

  1. Create WORKSPACE.bazel and MODULE.bazel.
  2. Create BUILD.bazel posted above.
  3. Create empty test.cc.
  4. Run bazel build test --experimental_cc_shared_library in either bazel 6.4.0 or 7.2.1.
  5. Check if src/bazel-bin/libtest.so-2.params contains -luim or -luim-scm.

Which operating system are you running Bazel on?

Linux

What is the output of bazel info release?

release 7.2.1 (used bazelisk)

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

No response

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

No response

If this is a regression, please try to identify the Bazel commit where the bug was introduced with bazelisk --bisect.

I tried to run bisect but failed, because 6.4.0 (good Bazel commit) is not an ancestor of 7.2.1 (bad Bazel commit), and their merge base commit fails to run.

Have you found anything relevant by searching the web?

No response

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

No response

@fmeum
Copy link
Collaborator

fmeum commented Aug 5, 2024

@oquenchil Is it possible that cc_shared_library now drops targets that don't contribute anything linkable (except linkopts)?

@fmeum
Copy link
Collaborator

fmeum commented Aug 5, 2024

@bazel-io flag

@bazel-io bazel-io added the potential release blocker Flagged by community members using "@bazel-io flag". Should be added to a release blocker milestone label Aug 5, 2024
@oquenchil
Copy link
Contributor

Probably broken by #20228 which fixed #19920.

The fix for this one would probably be to simply take the linkopts from the linker_input containing no libraries then discard it, so that it doesn't throw errors about it not being exported.

@keith
Copy link
Member

keith commented Aug 5, 2024

#21884

@iancha1992
Copy link
Member

@bazel-io fork 7.4.0

@comius
Copy link
Contributor

comius commented Sep 10, 2024

Duplicate of #21884

@comius comius marked this as a duplicate of #21884 Sep 10, 2024
@comius comius closed this as completed Sep 10, 2024
@Wyverald Wyverald closed this as not planned Won't fix, can't repro, duplicate, stale Oct 9, 2024
copybara-service bot pushed a commit that referenced this issue Oct 16, 2024
Fixes #21884
Fixes #23053

Closes #23215.

PiperOrigin-RevId: 686518093
Change-Id: I1a6699b169fe4291ad0dda3be7e74f38c8e37bf1
bazel-io pushed a commit to bazel-io/bazel that referenced this issue Oct 16, 2024
Fixes bazelbuild#21884
Fixes bazelbuild#23053

Closes bazelbuild#23215.

PiperOrigin-RevId: 686518093
Change-Id: I1a6699b169fe4291ad0dda3be7e74f38c8e37bf1
bazel-io pushed a commit to bazel-io/bazel that referenced this issue Oct 16, 2024
Fixes bazelbuild#21884
Fixes bazelbuild#23053

Closes bazelbuild#23215.

PiperOrigin-RevId: 686518093
Change-Id: I1a6699b169fe4291ad0dda3be7e74f38c8e37bf1
iancha1992 pushed a commit to iancha1992/bazel that referenced this issue Oct 16, 2024
Fixes bazelbuild#21884
Fixes bazelbuild#23053

Closes bazelbuild#23215.

PiperOrigin-RevId: 686518093
Change-Id: I1a6699b169fe4291ad0dda3be7e74f38c8e37bf1
github-merge-queue bot pushed a commit that referenced this issue Oct 17, 2024
…ibrary` (#24017)

Fixes #21884
Fixes #23053

Closes #23215.

PiperOrigin-RevId: 686518093
Change-Id: I1a6699b169fe4291ad0dda3be7e74f38c8e37bf1

Commit
0fdb36f

Co-authored-by: Fabian Meumertzheim <fabian@meumertzhe.im>
github-merge-queue bot pushed a commit that referenced this issue Oct 21, 2024
…ibrary` (#24005)

Fixes #21884
Fixes #23053

Closes #23215.

PiperOrigin-RevId: 686518093
Change-Id: I1a6699b169fe4291ad0dda3be7e74f38c8e37bf1

Commit
0fdb36f

Co-authored-by: Fabian Meumertzheim <fabian@meumertzhe.im>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants