Skip to content

-fwhole-program-vtables breaks in combination with -ffat-lto-objects #139440

Open
@Jannik2099

Description

@Jannik2099

the following

#include <stdexcept>

struct Foo : std::runtime_error {
    Foo() : runtime_error("") {}
};

Foo foo{};

when built into an object file with
clang++ -flto=thin -fwhole-program-vtables -ffat-lto-objects -fPIC -fvisibility=hidden -c foo.cpp -o foo.o
and then linked into a shared library with
clang++ -flto=thin -shared foo.o -o foo.so
will fail with
ld.lld: error: undefined hidden symbol: vtable for Foo

Removing either the -fwhole-program-vtables or -ffat-lto-objects when compiling the object file works fine.

Note that this isn't related to this specific underlying type, I only discovered it with std::runtime_error first. Reproduces on libstdc++ and libc++ (when linking dynamically)

Metadata

Metadata

Assignees

Labels

LTOLink time optimization (regular/full LTO or ThinLTO)

Type

No type

Projects

Status

Needs Triage

Relationships

None yet

Development

No branches or pull requests

Issue actions