[llvm] AsmPrinter: Remove ELF's special lowerRelativeReference for unnamed_addr function (PR #132684)

Petr Hosek via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 31 23:33:56 PDT 2025


petrhosek wrote:

This broke the build of libc++abi for Fuchsia with the following error:
```
/b/s/w/ir/x/w/llvm_build/./bin/clang++ --target=x86_64-unknown-fuchsia --sysroot=/b/s/w/ir/x/w/sdk/arch/x64/sysroot -fPIC --target=x86_64-unknown-fuchsia -I/b/s/w/ir/x/w/sdk/pkg/sync/include -I/b/s/w/ir/x/w/sdk/pkg/fdio/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wno-unnecessary-virtual-specifier -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -ffunction-sections -fdata-sections -ffile-prefix-map=/b/s/w/ir/x/w/llvm_build/runtimes/runtimes-x86_64-unknown-fuchsia-bins=../../../llvm-llvm-project -ffile-prefix-map=/b/s/w/ir/x/w/llvm-llvm-project/= -no-canonical-prefixes  -O2 -g -DNDEBUG  -L/b/s/w/ir/x/w/sdk/arch/x64/lib -Wl,-z,defs -fuse-ld=lld  -Wl,--push-state,--as-needed,-lzircon,--pop-state -nostdlib++ --unwindlib=none -shared -Wl,-soname,libc++abi.so.1 -o /b/s/w/ir/x/w/llvm_build/lib/x86_64-unknown-fuchsia/libc++abi.so.1.0 libcxxabi/src/CMakeFiles/cxxabi_shared_objects.dir/cxa_aux_runtime.cpp.obj libcxxabi/src/CMakeFiles/cxxabi_shared_objects.dir/cxa_default_handlers.cpp.obj libcxxabi/src/CMakeFiles/cxxabi_shared_objects.dir/cxa_demangle.cpp.obj libcxxabi/src/CMakeFiles/cxxabi_shared_objects.dir/cxa_exception_storage.cpp.obj libcxxabi/src/CMakeFiles/cxxabi_shared_objects.dir/cxa_guard.cpp.obj libcxxabi/src/CMakeFiles/cxxabi_shared_objects.dir/cxa_handlers.cpp.obj libcxxabi/src/CMakeFiles/cxxabi_shared_objects.dir/cxa_vector.cpp.obj libcxxabi/src/CMakeFiles/cxxabi_shared_objects.dir/cxa_virtual.cpp.obj libcxxabi/src/CMakeFiles/cxxabi_shared_objects.dir/stdlib_exception.cpp.obj libcxxabi/src/CMakeFiles/cxxabi_shared_objects.dir/stdlib_stdexcept.cpp.obj libcxxabi/src/CMakeFiles/cxxabi_shared_objects.dir/stdlib_typeinfo.cpp.obj libcxxabi/src/CMakeFiles/cxxabi_shared_objects.dir/abort_message.cpp.obj libcxxabi/src/CMakeFiles/cxxabi_shared_objects.dir/fallback_malloc.cpp.obj libcxxabi/src/CMakeFiles/cxxabi_shared_objects.dir/private_typeinfo.cpp.obj libcxxabi/src/CMakeFiles/cxxabi_shared_objects.dir/stdlib_new_delete.cpp.obj libcxxabi/src/CMakeFiles/cxxabi_shared_objects.dir/cxa_exception.cpp.obj libcxxabi/src/CMakeFiles/cxxabi_shared_objects.dir/cxa_personality.cpp.obj libcxxabi/src/CMakeFiles/cxxabi_shared_objects.dir/cxa_thread_atexit.cpp.obj  -lc  /b/s/w/ir/x/w/llvm_build/lib/x86_64-unknown-fuchsia/libunwind.so.1.0 && :
ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol 'std::bad_cast::~bad_cast()'; recompile with -fPIC
>>> defined in libcxxabi/src/CMakeFiles/cxxabi_shared_objects.dir/stdlib_typeinfo.cpp.obj
>>> referenced by stdlib_typeinfo.cpp
>>>               libcxxabi/src/CMakeFiles/cxxabi_shared_objects.dir/stdlib_typeinfo.cpp.obj:(vtable for std::bad_cast (.local))

ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol 'std::bad_cast::~bad_cast()'; recompile with -fPIC
>>> defined in libcxxabi/src/CMakeFiles/cxxabi_shared_objects.dir/stdlib_typeinfo.cpp.obj
>>> referenced by stdlib_typeinfo.cpp
>>>               libcxxabi/src/CMakeFiles/cxxabi_shared_objects.dir/stdlib_typeinfo.cpp.obj:(vtable for std::bad_cast (.local))

ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol 'std::bad_cast::what() const'; recompile with -fPIC
>>> defined in libcxxabi/src/CMakeFiles/cxxabi_shared_objects.dir/stdlib_typeinfo.cpp.obj
>>> referenced by stdlib_typeinfo.cpp
>>>               libcxxabi/src/CMakeFiles/cxxabi_shared_objects.dir/stdlib_typeinfo.cpp.obj:(vtable for std::bad_cast (.local))

ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol 'std::bad_typeid::~bad_typeid()'; recompile with -fPIC
>>> defined in libcxxabi/src/CMakeFiles/cxxabi_shared_objects.dir/stdlib_typeinfo.cpp.obj
>>> referenced by stdlib_typeinfo.cpp
>>>               libcxxabi/src/CMakeFiles/cxxabi_shared_objects.dir/stdlib_typeinfo.cpp.obj:(vtable for std::bad_typeid (.local))

ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol 'std::bad_typeid::~bad_typeid()'; recompile with -fPIC
>>> defined in libcxxabi/src/CMakeFiles/cxxabi_shared_objects.dir/stdlib_typeinfo.cpp.obj
>>> referenced by stdlib_typeinfo.cpp
>>>               libcxxabi/src/CMakeFiles/cxxabi_shared_objects.dir/stdlib_typeinfo.cpp.obj:(vtable for std::bad_typeid (.local))

ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol 'std::exception::~exception()'; recompile with -fPIC
>>> defined in libcxxabi/src/CMakeFiles/cxxabi_shared_objects.dir/stdlib_exception.cpp.obj
>>> referenced by stdlib_exception.cpp
>>>               libcxxabi/src/CMakeFiles/cxxabi_shared_objects.dir/stdlib_exception.cpp.obj:(vtable for std::bad_alloc (.local))

ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol 'std::logic_error::~logic_error()'; recompile with -fPIC
>>> defined in libcxxabi/src/CMakeFiles/cxxabi_shared_objects.dir/stdlib_stdexcept.cpp.obj
>>> referenced by stdlib_stdexcept.cpp
>>>               libcxxabi/src/CMakeFiles/cxxabi_shared_objects.dir/stdlib_stdexcept.cpp.obj:(vtable for std::logic_error (.local))

ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol 'std::bad_typeid::what() const'; recompile with -fPIC
>>> defined in libcxxabi/src/CMakeFiles/cxxabi_shared_objects.dir/stdlib_typeinfo.cpp.obj
>>> referenced by stdlib_typeinfo.cpp
>>>               libcxxabi/src/CMakeFiles/cxxabi_shared_objects.dir/stdlib_typeinfo.cpp.obj:(vtable for std::bad_typeid (.local))

ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol 'std::logic_error::~logic_error()'; recompile with -fPIC
>>> defined in libcxxabi/src/CMakeFiles/cxxabi_shared_objects.dir/stdlib_stdexcept.cpp.obj
>>> referenced by stdlib_stdexcept.cpp
>>>               libcxxabi/src/CMakeFiles/cxxabi_shared_objects.dir/stdlib_stdexcept.cpp.obj:(vtable for std::logic_error (.local))

ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol 'std::type_info::~type_info()'; recompile with -fPIC
>>> defined in libcxxabi/src/CMakeFiles/cxxabi_shared_objects.dir/stdlib_typeinfo.cpp.obj
>>> referenced by stdlib_typeinfo.cpp
>>>               libcxxabi/src/CMakeFiles/cxxabi_shared_objects.dir/stdlib_typeinfo.cpp.obj:(vtable for std::type_info (.local))

ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol 'std::logic_error::what() const'; recompile with -fPIC
>>> defined in libcxxabi/src/CMakeFiles/cxxabi_shared_objects.dir/stdlib_stdexcept.cpp.obj
>>> referenced by stdlib_stdexcept.cpp
>>>               libcxxabi/src/CMakeFiles/cxxabi_shared_objects.dir/stdlib_stdexcept.cpp.obj:(vtable for std::logic_error (.local))

ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol 'std::type_info::~type_info()'; recompile with -fPIC
>>> defined in libcxxabi/src/CMakeFiles/cxxabi_shared_objects.dir/stdlib_typeinfo.cpp.obj
>>> referenced by stdlib_typeinfo.cpp
>>>               libcxxabi/src/CMakeFiles/cxxabi_shared_objects.dir/stdlib_typeinfo.cpp.obj:(vtable for std::type_info (.local))

ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol 'std::bad_alloc::~bad_alloc()'; recompile with -fPIC
>>> defined in libcxxabi/src/CMakeFiles/cxxabi_shared_objects.dir/stdlib_exception.cpp.obj
>>> referenced by stdlib_exception.cpp
>>>               libcxxabi/src/CMakeFiles/cxxabi_shared_objects.dir/stdlib_exception.cpp.obj:(vtable for std::bad_alloc (.local))

ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol 'std::bad_alloc::what() const'; recompile with -fPIC
>>> defined in libcxxabi/src/CMakeFiles/cxxabi_shared_objects.dir/stdlib_exception.cpp.obj
>>> referenced by stdlib_exception.cpp
>>>               libcxxabi/src/CMakeFiles/cxxabi_shared_objects.dir/stdlib_exception.cpp.obj:(vtable for std::bad_alloc (.local))

ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol 'std::exception::~exception()'; recompile with -fPIC
>>> defined in libcxxabi/src/CMakeFiles/cxxabi_shared_objects.dir/stdlib_exception.cpp.obj
>>> referenced by stdlib_exception.cpp
>>>               libcxxabi/src/CMakeFiles/cxxabi_shared_objects.dir/stdlib_exception.cpp.obj:(vtable for std::bad_array_new_length (.local))

ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol 'std::bad_array_new_length::~bad_array_new_length()'; recompile with -fPIC
>>> defined in libcxxabi/src/CMakeFiles/cxxabi_shared_objects.dir/stdlib_exception.cpp.obj
>>> referenced by stdlib_exception.cpp
>>>               libcxxabi/src/CMakeFiles/cxxabi_shared_objects.dir/stdlib_exception.cpp.obj:(vtable for std::bad_array_new_length (.local))

ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol 'std::runtime_error::~runtime_error()'; recompile with -fPIC
>>> defined in libcxxabi/src/CMakeFiles/cxxabi_shared_objects.dir/stdlib_stdexcept.cpp.obj
>>> referenced by stdlib_stdexcept.cpp
>>>               libcxxabi/src/CMakeFiles/cxxabi_shared_objects.dir/stdlib_stdexcept.cpp.obj:(vtable for std::runtime_error (.local))

ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol 'std::runtime_error::~runtime_error()'; recompile with -fPIC
>>> defined in libcxxabi/src/CMakeFiles/cxxabi_shared_objects.dir/stdlib_stdexcept.cpp.obj
>>> referenced by stdlib_stdexcept.cpp
>>>               libcxxabi/src/CMakeFiles/cxxabi_shared_objects.dir/stdlib_stdexcept.cpp.obj:(vtable for std::runtime_error (.local))

ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol 'std::runtime_error::what() const'; recompile with -fPIC
>>> defined in libcxxabi/src/CMakeFiles/cxxabi_shared_objects.dir/stdlib_stdexcept.cpp.obj
>>> referenced by stdlib_stdexcept.cpp
>>>               libcxxabi/src/CMakeFiles/cxxabi_shared_objects.dir/stdlib_stdexcept.cpp.obj:(vtable for std::runtime_error (.local))

ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol 'std::logic_error::~logic_error()'; recompile with -fPIC
>>> defined in libcxxabi/src/CMakeFiles/cxxabi_shared_objects.dir/stdlib_stdexcept.cpp.obj
>>> referenced by stdlib_stdexcept.cpp
>>>               libcxxabi/src/CMakeFiles/cxxabi_shared_objects.dir/stdlib_stdexcept.cpp.obj:(vtable for std::domain_error (.local))
```
Fuchsia uses C++ relative vtables by default so it looks like this is still being used. @PiJoules is familiar with the implementation of relative vtables and should be able to help with debugging.

Would it be possible to revert this change in the meantime?

https://github.com/llvm/llvm-project/pull/132684


More information about the llvm-commits mailing list