@@ -15,6 +15,12 @@ pub fn cc() -> Cc {
1515 Cc :: new ( )
1616}
1717
18+ /// Construct a new platform-specific CXX compiler invocation.
19+ #[ track_caller]
20+ pub fn cxx ( ) -> Cc {
21+ Cc :: cxx ( )
22+ }
23+
1824/// A platform-specific C compiler invocation builder. The specific C compiler used is
1925/// passed down from compiletest.
2026#[ derive( Debug ) ]
@@ -44,6 +50,21 @@ impl Cc {
4450 Self { cmd }
4551 }
4652
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+
4768 /// Specify path of the input file.
4869 pub fn input < P : AsRef < Path > > ( & mut self , path : P ) -> & mut Self {
4970 self . cmd . arg ( path. as_ref ( ) ) ;
@@ -192,3 +213,41 @@ pub fn extra_cxx_flags() -> Vec<&'static str> {
192213 }
193214 }
194215}
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