File tree Expand file tree Collapse file tree 4 files changed +66
-0
lines changed
src/test/run-make-fulldeps Expand file tree Collapse file tree 4 files changed +66
-0
lines changed Original file line number Diff line number Diff line change 1+ -include ../tools.mk
2+
3+ ifeq (musl,$(findstring musl,$(TARGET ) ) )
4+ all : skip
5+ else
6+ all : test
7+ endif
8+
9+ test : foo
10+ $(call RUN,foo)
11+
12+ skip :
13+ echo " expected failure"
14+
15+ foo : foo.rs $(call NATIVE_STATICLIB,foo)
16+ $(RUSTC ) $< -lfoo $(EXTRACXXFLAGS )
17+
18+ $(TMPDIR ) /libfoo.o : foo.cpp
19+ $(call COMPILE_OBJ_CXX,$@ ,$< )
20+
21+ .PHONY : all test skip
Original file line number Diff line number Diff line change 1+ // Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+ // file at the top-level directory of this distribution and at
3+ // http://rust-lang.org/COPYRIGHT.
4+ //
5+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+ // option. This file may not be copied, modified, or distributed
9+ // except according to those terms.
10+
11+ #include < stdint.h>
12+
13+ struct A {
14+ A () { v = 1234 ; }
15+ ~A () { v = 1 ; }
16+ uint32_t v;
17+ };
18+
19+ A a;
20+
21+ extern " C" {
22+ uint32_t get () {
23+ return a.v ;
24+ }
25+ }
Original file line number Diff line number Diff line change 1+ // Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+ // file at the top-level directory of this distribution and at
3+ // http://rust-lang.org/COPYRIGHT.
4+ //
5+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+ // option. This file may not be copied, modified, or distributed
9+ // except according to those terms.
10+
11+ // Tests that linking to C++ code with global destructors works.
12+
13+ extern { fn get ( ) -> u32 ; }
14+
15+ fn main ( ) {
16+ let i = unsafe { get ( ) } ;
17+ assert_eq ! ( i, 1234 ) ;
18+ }
Original file line number Diff line number Diff line change @@ -59,12 +59,14 @@ endif
5959
6060ifdef IS_MSVC
6161COMPILE_OBJ = $(CC ) -c -Fo:` cygpath -w $( 1) ` $(2 )
62+ COMPILE_OBJ_CXX = $(CXX ) -c -Fo:` cygpath -w $( 1) ` $(2 )
6263NATIVE_STATICLIB_FILE = $(1 ) .lib
6364NATIVE_STATICLIB = $(TMPDIR ) /$(call NATIVE_STATICLIB_FILE,$(1 ) )
6465OUT_EXE =-Fe:` cygpath -w $( TMPDIR) /$( call BIN,$( 1) ) ` \
6566 -Fo:` cygpath -w $( TMPDIR) /$( 1) .obj `
6667else
6768COMPILE_OBJ = $(CC ) -c -o $(1 ) $(2 )
69+ COMPILE_OBJ_CXX = $(CXX ) -c -o $(1 ) $(2 )
6870NATIVE_STATICLIB_FILE = lib$(1 ) .a
6971NATIVE_STATICLIB = $(call STATICLIB,$(1 ) )
7072OUT_EXE =-o $(TMPDIR ) /$(1 )
You can’t perform that action at this time.
0 commit comments