[llvm-bugs] [Bug 34122] New: Cannot compile with `-static` when using exceptions with target x86_64-w64-windows-gnu

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Aug 8 12:33:49 PDT 2017


https://bugs.llvm.org/show_bug.cgi?id=34122

            Bug ID: 34122
           Summary: Cannot compile with `-static` when using exceptions
                    with target x86_64-w64-windows-gnu
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: dario.ostuni at gmail.com
                CC: llvm-bugs at lists.llvm.org

Created attachment 18947
  --> https://bugs.llvm.org/attachment.cgi?id=18947&action=edit
program.cpp

When trying to compile `program.cpp` (in attachment) with `-static` for target
x86_64-w64-windows-gnu this is what happens:
```
$ x86_64-w64-mingw32-clang++ -o program.exe -pthread -static -v program.cpp
clang version 6.0.0 (trunk 310227)
Target: x86_64-w64-windows-gnu
Thread model: posix
InstalledDir: /usr/bin
 "/usr/bin/clang-6.0" -cc1 -triple x86_64-w64-windows-gnu -emit-obj -mrelax-all
-disable-free -disable-llvm-verifier -discard-value-names -main-file-name
program.cpp -static-define -mrelocation-model pic -pic-level 2 -mthread-model
posix -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables
-target-cpu x86-64 -momit-leaf-frame-pointer -v -dwarf-column-info
-debugger-tuning=gdb -nostdsysteminc -nobuiltininc -resource-dir
/usr/lib/clang/6.0.0 -isystem /usr/bin/../lib/clang/6.0.0/include -isystem
/usr/x86_64-w64-mingw32/include/c++/7.1.1 -isystem
/usr/x86_64-w64-mingw32/include/c++/7.1.1/x86_64-w64-mingw32 -isystem
/usr/x86_64-w64-mingw32/include -fdeprecated-macro -fdebug-compilation-dir /tmp
-ferror-limit 19 -fmessage-length 132 -pthread -fno-use-cxa-atexit
-fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option
-fcolor-diagnostics -o /tmp/program-26420f.o -x c++ program.cpp
clang -cc1 version 6.0.0 based upon LLVM 6.0.0svn-r310227 default target
x86_64-unknown-linux-gnu
#include "..." search starts here:
#include <...> search starts here:
 /usr/bin/../lib/clang/6.0.0/include
 /usr/x86_64-w64-mingw32/include/c++/7.1.1
 /usr/x86_64-w64-mingw32/include/c++/7.1.1/x86_64-w64-mingw32
 /usr/x86_64-w64-mingw32/include
End of search list.
 "/usr/bin/x86_64-w64-mingw32-ld" -m i386pep -Bstatic -o program.exe
/usr/x86_64-w64-mingw32/lib/crt2.o
/usr/lib/gcc/x86_64-w64-mingw32/7.1.1/crtbegin.o
-L/usr/lib/gcc/x86_64-w64-mingw32/7.1.1 -L/usr/lib/gcc/x86_64-w64-mingw32/7.1.1
-L/usr/x86_64-w64-mingw32/lib -L/usr/lib
-L/usr/x86_64-w64-mingw32/sys-root/mingw/lib /tmp/program-26420f.o -lstdc++
--start-group -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt -lpthread
-ladvapi32 -lshell32 -luser32 -lkernel32 --end-group
/usr/lib/gcc/x86_64-w64-mingw32/7.1.1/crtend.o
/tmp/program-26420f.o:(.text+0xa2): undefined reference to
`__imp___dynamic_cast'
/tmp/program-26420f.o:(.text+0xb7): undefined reference to
`__imp___cxa_bad_cast'
/tmp/program-26420f.o:(.text+0xf1): undefined reference to
`__imp___cxa_begin_catch'
/tmp/program-26420f.o:(.text+0x146): undefined reference to
`__imp___cxa_end_catch'
/tmp/program-26420f.o:(.text+0x161): undefined reference to
`__imp___cxa_end_catch'
/tmp/program-26420f.o:(.text[__clang_call_terminate]+0x7): undefined reference
to `__imp___cxa_begin_catch'
clang-6.0: error: linker command failed with exit code 1 (use -v to see
invocation)
```
There is an associated issue on github:
https://github.com/tpoechtrager/wclang/issues/32

The author of wclang has some insight of what is happening here:
https://github.com/tpoechtrager/wclang/issues/32#issuecomment-320678320

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170808/33879c43/attachment.html>


More information about the llvm-bugs mailing list