Skip to content

'undefined reference' linker errors when using LTO and static libraries #243

Description

@ljessendk

When using link-type-optimization (LTO) the linker will fail with 'undefined reference' errors.

Example:

load("//rules_cc:defs.bzl", "cc_binary", "cc_library")

cc_library(
    name = "hello_lib",
    srcs = ["lib.cpp"],
)

cc_binary(
    name = "hello_world_cpp",
    srcs = ["main.cpp"],
    deps = ["hello_lib"],
)

Will fail when build with:

bazel build --cxxopt=-flto=auto ...

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions