File tree 12 files changed +123
-5
lines changed
ci/docker/x86_64-gnu-debug
test/run-make-fulldeps/cross-lang-lto-clang
12 files changed +123
-5
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ matrix:
19
19
- env : IMAGE=x86_64-gnu-llvm-6.0 RUST_BACKTRACE=1
20
20
if : type = pull_request OR branch = auto
21
21
22
- - env : IMAGE=dist- x86_64-linux DEPLOY=1
22
+ - env : IMAGE=x86_64-gnu-debug
23
23
if : branch = try OR branch = auto
24
24
25
25
# "alternate" deployments, these are "nightlies" but have LLVM assertions
Original file line number Diff line number Diff line change @@ -1108,9 +1108,7 @@ impl Step for Compiletest {
1108
1108
} ;
1109
1109
let lldb_exe = if builder. config . lldb_enabled && !target. contains ( "emscripten" ) {
1110
1110
// Test against the lldb that was just built.
1111
- builder. llvm_out ( target)
1112
- . join ( "bin" )
1113
- . join ( "lldb" )
1111
+ builder. llvm_out ( target) . join ( "bin" ) . join ( "lldb" )
1114
1112
} else {
1115
1113
PathBuf :: from ( "lldb" )
1116
1114
} ;
@@ -1127,6 +1125,26 @@ impl Step for Compiletest {
1127
1125
}
1128
1126
}
1129
1127
1128
+ if let Some ( var) = env:: var_os ( "RUSTBUILD_FORCE_CLANG_BASED_TESTS" ) {
1129
+ match & var. to_string_lossy ( ) . to_lowercase ( ) [ ..] {
1130
+ "1" | "yes" | "on" => {
1131
+ assert ! ( builder. config. lldb_enabled,
1132
+ "RUSTBUILD_FORCE_CLANG_BASED_TESTS needs Clang/LLDB to \
1133
+ be built.") ;
1134
+ let clang_exe = builder. llvm_out ( target) . join ( "bin" ) . join ( "clang" ) ;
1135
+ cmd. arg ( "--run-clang-based-tests-with" ) . arg ( clang_exe) ;
1136
+ }
1137
+ "0" | "no" | "off" => {
1138
+ // Nothing to do.
1139
+ }
1140
+ other => {
1141
+ // Let's make sure typos don't get unnoticed
1142
+ panic ! ( "Unrecognized option '{}' set in \
1143
+ RUSTBUILD_FORCE_CLANG_BASED_TESTS", other) ;
1144
+ }
1145
+ }
1146
+ }
1147
+
1130
1148
// Get paths from cmd args
1131
1149
let paths = match & builder. config . cmd {
1132
1150
Subcommand :: Test { ref paths, .. } => & paths[ ..] ,
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
7
7
curl \
8
8
ca-certificates \
9
9
python2.7 \
10
+ python2.7-dev \
10
11
git \
11
12
cmake \
12
13
sudo \
@@ -16,9 +17,15 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
16
17
COPY scripts/sccache.sh /scripts/
17
18
RUN sh /scripts/sccache.sh
18
19
20
+ ENV RUSTBUILD_FORCE_CLANG_BASED_TESTS 1
19
21
ENV RUN_CHECK_WITH_PARALLEL_QUERIES 1
22
+
20
23
ENV RUST_CONFIGURE_ARGS \
21
24
--build=x86_64-unknown-linux-gnu \
22
25
--enable-debug \
26
+ --enable-lld \
27
+ --enable-lldb \
23
28
--enable-optimize
24
- ENV SCRIPT python2.7 ../x.py build
29
+ ENV SCRIPT \
30
+ python2.7 ../x.py build && \
31
+ python2.7 ../x.py test src/test/run-make-fulldeps --test-args clang
Original file line number Diff line number Diff line change
1
+ # needs-matching-clang
2
+
3
+ # This test makes sure that cross-language inlining actually works by checking
4
+ # the generated machine code.
5
+
6
+ -include ../tools.mk
7
+
8
+ all : cpp-executable rust-executable
9
+
10
+ cpp-executable :
11
+ $(RUSTC ) -Zcross-lang-lto=on -o $(TMPDIR ) /librustlib-xlto.a -Copt-level=2 -Ccodegen-units=1 ./rustlib.rs
12
+ $(CLANG ) -flto=thin -fuse-ld=lld -L $(TMPDIR ) -lrustlib-xlto -o $(TMPDIR ) /cmain ./cmain.c -O3
13
+ # Make sure we don't find a call instruction to the function we expect to
14
+ # always be inlined.
15
+ llvm-objdump -d $(TMPDIR ) /cmain | $(CGREP ) -v -e " call.*rust_always_inlined"
16
+ # As a sanity check, make sure we do find a call instruction to a
17
+ # non-inlined function
18
+ llvm-objdump -d $(TMPDIR ) /cmain | $(CGREP ) -e " call.*rust_never_inlined"
19
+
20
+ rust-executable :
21
+ $(CLANG ) ./clib.c -flto=thin -c -o $(TMPDIR ) /clib.o -O2
22
+ (cd $( TMPDIR) ; $( AR) crus ./libxyz.a ./clib.o)
23
+ $(RUSTC ) -Zcross-lang-lto=on -L$(TMPDIR ) -Copt-level=2 -Clinker=$(CLANG ) -Clink-arg=-fuse-ld=lld ./main.rs -o $(TMPDIR ) /rsmain
24
+ llvm-objdump -d $(TMPDIR ) /rsmain | $(CGREP ) -e " call.*c_never_inlined"
25
+ llvm-objdump -d $(TMPDIR ) /rsmain | $(CGREP ) -v -e " call.*c_always_inlined"
Original file line number Diff line number Diff line change
1
+ #include <stdint.h>
2
+
3
+ uint32_t c_always_inlined () {
4
+ return 1234 ;
5
+ }
6
+
7
+ __attribute__((noinline )) uint32_t c_never_inlined () {
8
+ return 12345 ;
9
+ }
Original file line number Diff line number Diff line change
1
+ #include <stdint.h>
2
+
3
+ // A trivial function defined in Rust, returning a constant value. This should
4
+ // always be inlined.
5
+ uint32_t rust_always_inlined ();
6
+
7
+
8
+ uint32_t rust_never_inlined ();
9
+
10
+ int main (int argc , char * * argv ) {
11
+ return rust_never_inlined () + rust_always_inlined ();
12
+ }
Original file line number Diff line number Diff line change
1
+ #[ link( name = "xyz" ) ]
2
+ extern "C" {
3
+ fn c_always_inlined ( ) -> u32 ;
4
+ fn c_never_inlined ( ) -> u32 ;
5
+ }
6
+
7
+ fn main ( ) {
8
+ unsafe {
9
+ println ! ( "blub: {}" , c_always_inlined( ) + c_never_inlined( ) ) ;
10
+ }
11
+ }
Original file line number Diff line number Diff line change
1
+ #![ crate_type="staticlib" ]
2
+
3
+ #[ no_mangle]
4
+ pub extern "C" fn rust_always_inlined ( ) -> u32 {
5
+ 42
6
+ }
7
+
8
+ #[ no_mangle]
9
+ #[ inline( never) ]
10
+ pub extern "C" fn rust_never_inlined ( ) -> u32 {
11
+ 421
12
+ }
Original file line number Diff line number Diff line change @@ -144,6 +144,10 @@ pub struct Config {
144
144
/// (or, alternatively, to silently run them like regular run-pass tests).
145
145
pub force_valgrind : bool ,
146
146
147
+ /// The path to the Clang executable to run Clang-based tests with. If
148
+ /// `None` then these tests will be ignored.
149
+ pub run_clang_based_tests_with : Option < String > ,
150
+
147
151
/// The directory containing the tests to run
148
152
pub src_base : PathBuf ,
149
153
Original file line number Diff line number Diff line change @@ -111,6 +111,11 @@ impl EarlyProps {
111
111
if ignore_llvm ( config, ln) {
112
112
props. ignore = Ignore :: Ignore ;
113
113
}
114
+
115
+ if config. run_clang_based_tests_with . is_none ( ) &&
116
+ config. parse_needs_matching_clang ( ln) {
117
+ props. ignore = Ignore :: Ignore ;
118
+ }
114
119
}
115
120
116
121
if ( config. mode == common:: DebugInfoGdb || config. mode == common:: DebugInfoBoth ) &&
@@ -705,6 +710,10 @@ impl Config {
705
710
}
706
711
}
707
712
713
+ fn parse_needs_matching_clang ( & self , line : & str ) -> bool {
714
+ self . parse_name_directive ( line, "needs-matching-clang" )
715
+ }
716
+
708
717
/// Parses a name-value directive which contains config-specific information, e.g., `ignore-x86`
709
718
/// or `normalize-stderr-32bit`.
710
719
fn parse_cfg_name_directive ( & self , line : & str , prefix : & str ) -> ParsedNameDirective {
Original file line number Diff line number Diff line change @@ -108,6 +108,12 @@ pub fn parse_config(args: Vec<String>) -> Config {
108
108
"force-valgrind" ,
109
109
"fail if Valgrind tests cannot be run under Valgrind" ,
110
110
)
111
+ . optopt (
112
+ "" ,
113
+ "run-clang-based-tests-with" ,
114
+ "path to Clang executable" ,
115
+ "PATH" ,
116
+ )
111
117
. optopt (
112
118
"" ,
113
119
"llvm-filecheck" ,
@@ -298,6 +304,7 @@ pub fn parse_config(args: Vec<String>) -> Config {
298
304
docck_python : matches. opt_str ( "docck-python" ) . unwrap ( ) ,
299
305
valgrind_path : matches. opt_str ( "valgrind-path" ) ,
300
306
force_valgrind : matches. opt_present ( "force-valgrind" ) ,
307
+ run_clang_based_tests_with : matches. opt_str ( "run-clang-based-tests-with" ) ,
301
308
llvm_filecheck : matches. opt_str ( "llvm-filecheck" ) . map ( |s| PathBuf :: from ( & s) ) ,
302
309
src_base,
303
310
build_base : opt_path ( matches, "build-base" ) ,
Original file line number Diff line number Diff line change @@ -2587,6 +2587,10 @@ impl<'test> TestCx<'test> {
2587
2587
cmd. env ( "RUSTC_LINKER" , linker) ;
2588
2588
}
2589
2589
2590
+ if let Some ( ref clang) = self . config . run_clang_based_tests_with {
2591
+ cmd. env ( "CLANG" , clang) ;
2592
+ }
2593
+
2590
2594
// We don't want RUSTFLAGS set from the outside to interfere with
2591
2595
// compiler flags set in the test cases:
2592
2596
cmd. env_remove ( "RUSTFLAGS" ) ;
You can’t perform that action at this time.
0 commit comments