File tree Expand file tree Collapse file tree 5 files changed +25
-2
lines changed
src/test/run-make-fulldeps Expand file tree Collapse file tree 5 files changed +25
-2
lines changed Original file line number Diff line number Diff line change 44 $(call RUN,foo)
55
66foo : foo.rs $(call NATIVE_STATICLIB,foo)
7- $(RUSTC ) $< -lfoo $(EXTRACXXFLAGS )
7+ $(RUSTC ) $< -lfoo $(EXTRARSCXXFLAGS )
88
99$(TMPDIR ) /libfoo.o : foo.cpp
1010 $(call COMPILE_OBJ_CXX,$@ ,$< )
Original file line number Diff line number Diff line change 22// are ignored by catch_unwind. Also tests that Rust panics can unwind through
33// C++ code.
44
5+ // For linking libstdc++ on MinGW
6+ #![ cfg_attr( all( windows, target_env = "gnu" ) , feature( static_nobundle) ) ]
7+
58#![ feature( unwind_attributes) ]
69
710use std:: panic:: { catch_unwind, AssertUnwindSafe } ;
Original file line number Diff line number Diff line change 66 $(call RUN,foo)
77
88foo : foo.rs $(call NATIVE_STATICLIB,foo)
9- $(RUSTC ) $< -lfoo $(EXTRACXXFLAGS )
9+ $(RUSTC ) $< -lfoo $(EXTRARSCXXFLAGS )
1010
1111$(TMPDIR ) /libfoo.o : foo.cpp
1212 $(call COMPILE_OBJ_CXX,$@ ,$< )
Original file line number Diff line number Diff line change 11// Tests that linking to C++ code with global destructors works.
22
3+ // For linking libstdc++ on MinGW
4+ #![ cfg_attr( all( windows, target_env = "gnu" ) , feature( static_nobundle) ) ]
5+
36extern { fn get ( ) -> u32 ; }
47
58fn main ( ) {
Original file line number Diff line number Diff line change @@ -81,6 +81,22 @@ ifdef IS_MSVC
8181else
8282 EXTRACFLAGS := -lws2_32 -luserenv
8383 EXTRACXXFLAGS := -lstdc++
84+ # So this is a bit hacky: we can't use the DLL version of libstdc++ because
85+ # it pulls in the DLL version of libgcc, which means that we end up with 2
86+ # instances of the DW2 unwinding implementation. This is a problem on
87+ # i686-pc-windows-gnu because each module (DLL/EXE) needs to register its
88+ # unwind information with the unwinding implementation, and libstdc++'s
89+ # __cxa_throw won't see the unwinding info we registered with our statically
90+ # linked libgcc.
91+ #
92+ # Now, simply statically linking libstdc++ would fix this problem, except
93+ # that it is compiled with the expectation that pthreads is dynamically
94+ # linked as a DLL and will fail to link with a statically linked libpthread.
95+ #
96+ # So we end up with the following hack: we link use static-nobundle to only
97+ # link the parts of libstdc++ that we actually use, which doesn't include
98+ # the dependency on the pthreads DLL.
99+ EXTRARSCXXFLAGS := -l static-nobundle=stdc++
84100endif
85101else
86102ifeq ($(UNAME ) ,Darwin)
@@ -98,6 +114,7 @@ ifeq ($(UNAME),OpenBSD)
98114else
99115 EXTRACFLAGS := -lm -lrt -ldl -lpthread
100116 EXTRACXXFLAGS := -lstdc++
117+ EXTRARSCXXFLAGS := -lstdc++
101118endif
102119endif
103120endif
You can’t perform that action at this time.
0 commit comments