@@ -15,6 +15,12 @@ pub fn cc() -> Cc {
15
15
Cc :: new ( )
16
16
}
17
17
18
+ /// Construct a new platform-specific CXX compiler invocation.
19
+ #[ track_caller]
20
+ pub fn cxx ( ) -> Cc {
21
+ Cc :: cxx ( )
22
+ }
23
+
18
24
/// A platform-specific C compiler invocation builder. The specific C compiler used is
19
25
/// passed down from compiletest.
20
26
#[ derive( Debug ) ]
@@ -44,6 +50,21 @@ impl Cc {
44
50
Self { cmd }
45
51
}
46
52
53
+ /// Construct a new platform-specific C compiler invocation.
54
+ #[ track_caller]
55
+ pub fn cxx ( ) -> Self {
56
+ let compiler = env_var ( "CXX" ) ;
57
+
58
+ let mut cmd = Command :: new ( compiler) ;
59
+
60
+ let default_cflags = env_var ( "CXX_DEFAULT_FLAGS" ) ;
61
+ for flag in default_cflags. split ( char:: is_whitespace) {
62
+ cmd. arg ( flag) ;
63
+ }
64
+
65
+ Self { cmd }
66
+ }
67
+
47
68
/// Specify path of the input file.
48
69
pub fn input < P : AsRef < Path > > ( & mut self , path : P ) -> & mut Self {
49
70
self . cmd . arg ( path. as_ref ( ) ) ;
@@ -192,3 +213,41 @@ pub fn extra_cxx_flags() -> Vec<&'static str> {
192
213
}
193
214
}
194
215
}
216
+
217
+ /// `EXTRARSCXXFLAGS`
218
+ pub fn extra_rs_cxx_flags ( ) -> Vec < & ' static str > {
219
+ // Adapted from tools.mk (trimmed):
220
+ //
221
+ // ```makefile
222
+ // ifdef IS_WINDOWS
223
+ // ifdef IS_MSVC
224
+ // else
225
+ // EXTRARSCXXFLAGS := -lstatic:-bundle=stdc++
226
+ // endif
227
+ // else
228
+ // ifeq ($(UNAME),Darwin)
229
+ // EXTRARSCXXFLAGS := -lc++
230
+ // else
231
+ // ifeq ($(UNAME),FreeBSD)
232
+ // else
233
+ // ifeq ($(UNAME),SunOS)
234
+ // else
235
+ // ifeq ($(UNAME),OpenBSD)
236
+ // else
237
+ // EXTRARSCXXFLAGS := -lstdc++
238
+ // endif
239
+ // endif
240
+ // endif
241
+ // endif
242
+ // endif
243
+ // ```
244
+ if is_windows ( ) {
245
+ if is_msvc ( ) { vec ! [ ] } else { vec ! [ "-lstatic:-bundle=stdc++" ] }
246
+ } else {
247
+ match & uname ( ) [ ..] {
248
+ "Darwin" => vec ! [ "-lc++" ] ,
249
+ "FreeBSD" | "SunOS" | "OpenBSD" => vec ! [ ] ,
250
+ _ => vec ! [ "-lstdc++" ] ,
251
+ }
252
+ }
253
+ }
0 commit comments