File tree 5 files changed +25
-2
lines changed
src/test/run-make-fulldeps
5 files changed +25
-2
lines changed Original file line number Diff line number Diff line change 4
4
$(call RUN,foo)
5
5
6
6
foo : foo.rs $(call NATIVE_STATICLIB,foo)
7
- $(RUSTC ) $< -lfoo $(EXTRACXXFLAGS )
7
+ $(RUSTC ) $< -lfoo $(EXTRARSCXXFLAGS )
8
8
9
9
$(TMPDIR ) /libfoo.o : foo.cpp
10
10
$(call COMPILE_OBJ_CXX,$@ ,$< )
Original file line number Diff line number Diff line change 2
2
// are ignored by catch_unwind. Also tests that Rust panics can unwind through
3
3
// C++ code.
4
4
5
+ // For linking libstdc++ on MinGW
6
+ #![ cfg_attr( all( windows, target_env = "gnu" ) , feature( static_nobundle) ) ]
7
+
5
8
#![ feature( unwind_attributes) ]
6
9
7
10
use std:: panic:: { catch_unwind, AssertUnwindSafe } ;
Original file line number Diff line number Diff line change 6
6
$(call RUN,foo)
7
7
8
8
foo : foo.rs $(call NATIVE_STATICLIB,foo)
9
- $(RUSTC ) $< -lfoo $(EXTRACXXFLAGS )
9
+ $(RUSTC ) $< -lfoo $(EXTRARSCXXFLAGS )
10
10
11
11
$(TMPDIR ) /libfoo.o : foo.cpp
12
12
$(call COMPILE_OBJ_CXX,$@ ,$< )
Original file line number Diff line number Diff line change 1
1
// Tests that linking to C++ code with global destructors works.
2
2
3
+ // For linking libstdc++ on MinGW
4
+ #![ cfg_attr( all( windows, target_env = "gnu" ) , feature( static_nobundle) ) ]
5
+
3
6
extern { fn get ( ) -> u32 ; }
4
7
5
8
fn main ( ) {
Original file line number Diff line number Diff line change @@ -81,6 +81,22 @@ ifdef IS_MSVC
81
81
else
82
82
EXTRACFLAGS := -lws2_32 -luserenv
83
83
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++
84
100
endif
85
101
else
86
102
ifeq ($(UNAME ) ,Darwin)
@@ -98,6 +114,7 @@ ifeq ($(UNAME),OpenBSD)
98
114
else
99
115
EXTRACFLAGS := -lm -lrt -ldl -lpthread
100
116
EXTRACXXFLAGS := -lstdc++
117
+ EXTRARSCXXFLAGS := -lstdc++
101
118
endif
102
119
endif
103
120
endif
You can’t perform that action at this time.
0 commit comments