Skip to content

lld crash with -flto -fno-math-errno libopenlibm.a #516

@Andarwinux

Description

@Andarwinux

llvm-mingw nightly

git clone --depth=1 -b master https://github.com/JuliaMath/openlibm.git
cd openlibm
cmake -GNinja -Bbuild -DCMAKE_C_COMPILER=x86_64-w64-mingw32-clang -DCMAKE_ASM_COMPILER=x86_64-w64-mingw32-clang -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_SYSTEM_PROCESSOR=x86_64 -DBUILD_SHARED_LIBS=OFF
ninja -C build

cat > "test.c" <<EOF
#include <math.h>
#include <stdlib.h>
int main(int argc, char **argv) {
    if(argc<3) return 1;
    double x = atof(argv[1]);
    double y = atof(argv[2]);
    double z = pow(x, y);
    return (int)z;
}
EOF

x86_64-w64-mingw32-clang -fno-math-errno -flto=thin test.c build/libopenlibm.a
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
 #0 0x0000784fe672f755 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/arch/workspace/llvm-mingw/bin/../lib/libLLVM.so.21.1+0x2f2f755)
 #1 0x0000784fe672e4a3 llvm::sys::RunSignalHandlers() (/home/arch/workspace/llvm-mingw/bin/../lib/libLLVM.so.21.1+0x2f2e4a3)
 #2 0x0000784fe673006a (/home/arch/workspace/llvm-mingw/bin/../lib/libLLVM.so.21.1+0x2f3006a)
 #3 0x0000784fe3044690 (/usr/lib/libc.so.6+0x44690)
 #4 0x000056c947c9e40e (/home/arch/workspace/llvm-mingw/bin/ld.lld+0x1e240e)
 #5 0x0000784fe66dfb21 (/home/arch/workspace/llvm-mingw/bin/../lib/libLLVM.so.21.1+0x2edfb21)
 #6 0x0000784fe66dfaaf (/home/arch/workspace/llvm-mingw/bin/../lib/libLLVM.so.21.1+0x2edfaaf)
 #7 0x0000784fe66df326 (/home/arch/workspace/llvm-mingw/bin/../lib/libLLVM.so.21.1+0x2edf326)
 #8 0x0000784fe35006f4 std::default_delete<std::thread::_State>::operator()(std::thread::_State*) const /usr/src/debug/gcc/gcc-build/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/unique_ptr.h:93:2
 #9 0x0000784fe35006f4 std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State>>::~unique_ptr() /usr/src/debug/gcc/gcc-build/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/unique_ptr.h:399:17
#10 0x0000784fe35006f4 execute_native_thread_routine /usr/src/debug/gcc/gcc/libstdc++-v3/src/c++11/thread.cc:106:5
#11 0x0000784fe30a87f6 start_thread /usr/src/debug/glibc/glibc/nptl/pthread_create.c:448:8
#12 0x0000784fe313d81c (/usr/lib/libc.so.6+0x13d81c)
clang: error: unable to execute command: Segmentation fault (core dumped)
clang: error: linker command failed due to signal (use -v to see invocation)

Compiling test.c with any one of these options will not cause a crash: -fmath-errno, -fno-lto, -fno-builtin

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions