<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - linker segfaults when using -shared on AMDGPU kernel"
href="https://bugs.llvm.org/show_bug.cgi?id=48345">48345</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>linker segfaults when using -shared on AMDGPU kernel
</td>
</tr>
<tr>
<th>Product</th>
<td>lld
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>release blocker
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>ELF
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>fwinter@jlab.org
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org, smithp352@googlemail.com
</td>
</tr></table>
<p>
<div>
<pre>When linking a module containing a really trivial function with ld.lld I get:
$ ld.lld -shared module.o -o module.so
ld.lld: /home/users/coe0193/llvm-project/lld/ELF/Arch/AMDGPU.cpp:48: virtual
uint32_t {anonymous}::AMDGPU::calcEFlags() const: Assertion
`!objectFiles.empty()' failed.
PLEASE submit a bug report to <a href="https://bugs.llvm.org/">https://bugs.llvm.org/</a> and include the crash
backtrace.
Stack dump:
0. Program arguments:
/home/users/coe0193/install/llvm-trunk-x86-amdgpu-debug/bin/ld.lld -shared
module_empty.o -o module_empty.so
#0 0x0000155552e30eed llvm::sys::PrintStackTrace(llvm::raw_ostream&, int)
/home/users/coe0193/llvm-project/llvm/lib/Support/Unix/Signals.inc:563:22
#1 0x0000155552e30fa4 PrintStackTraceSignalHandler(void*)
/home/users/coe0193/llvm-project/llvm/lib/Support/Unix/Signals.inc:630:1
#2 0x0000155552e2efa6 llvm::sys::RunSignalHandlers()
/home/users/coe0193/llvm-project/llvm/lib/Support/Signals.cpp:71:20
#3 0x0000155552e30934 SignalHandler(int)
/home/users/coe0193/llvm-project/llvm/lib/Support/Unix/Signals.inc:405:1
#4 0x000015555511ddd0 __restore_rt (/lib64/libpthread.so.0+0x12dd0)
#5 0x0000155551d6170f raise (/lib64/libc.so.6+0x3770f)
#6 0x0000155551d4bb25 abort (/lib64/libc.so.6+0x21b25)
#7 0x0000155551d4b9f9 _nl_load_domain.cold.0 (/lib64/libc.so.6+0x219f9)
#8 0x0000155551d59cc6 (/lib64/libc.so.6+0x2fcc6)
#9 0x000015555476b887 (anonymous namespace)::AMDGPU::calcEFlags() const
/home/users/coe0193/llvm-project/lld/ELF/Arch/AMDGPU.cpp:49:41
#10 0x00001555547cc335 void
lld::elf::LinkerDriver::link<llvm::object::ELFType<(llvm::support::endianness)1,
true> >(llvm::opt::InputArgList&)
/home/users/coe0193/llvm-project/lld/ELF/Driver.cpp:2209:3
#11 0x00001555547b1ed2 lld::elf::LinkerDriver::main(llvm::ArrayRef<char
const*>) /home/users/coe0193/llvm-project/lld/ELF/Driver.cpp:558:7
#12 0x00001555547ae1ad lld::elf::link(llvm::ArrayRef<char const*>, bool,
llvm::raw_ostream&, llvm::raw_ostream&)
/home/users/coe0193/llvm-project/lld/ELF/Driver.cpp:125:3
#13 0x000000000040810a lldMain(int, char const**, llvm::raw_ostream&,
llvm::raw_ostream&, bool)
/home/users/coe0193/llvm-project/lld/tools/lld/lld.cpp:153:12
#14 0x0000000000408581 main
/home/users/coe0193/llvm-project/lld/tools/lld/lld.cpp:211:19
#15 0x0000155551d4d6a3 __libc_start_main (/lib64/libc.so.6+0x236a3)
#16 0x00000000004073ee _start
(/home/users/coe0193/install/llvm-trunk-x86-amdgpu-debug/bin/ld.lld+0x4073ee)
Aborted (core dumped)
This bug is present in LLVM 11 release as well as in LLVM 12 current trunk (as
of Nov. 30th 2020).
On Linux I built llvm-project with
cmake ../llvm-project/llvm \
-DCMAKE_INSTALL_PREFIX="$HOME/install/llvm-trunk-x86-amdgpu-debug" \
-DLLVM_ENABLE_PROJECTS="clang;lld" \
-DCMAKE_BUILD_TYPE="Debug" \
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_CXX_COMPILER=g++ \
-DCMAKE_C_COMPILER=gcc \
-DLLVM_TARGETS_TO_BUILD="X86;AMDGPU"
To provoke the bug I created a small module written in LLVM IR containing a
simple AMDGPU kernel function, like
module.ll:
define amdgpu_kernel void @test() {
entry:
ret void
}
Then I compile this module with
$ clang -target amdgcn-amd-amdhsa -mcpu=gfx908 module.ll -o module.o
And try to link a shared library for it:
$ ld.lld -shared module.o -o module.so
This crashes the linker with the above back trace.
Please help!
Frank</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>