File tree 2 files changed +60
-0
lines changed
src/test/run-make/min-global-align
2 files changed +60
-0
lines changed Original file line number Diff line number Diff line change
1
+ -include ../tools.mk
2
+
3
+ # This tests ensure that global variables respect the target minimum alignment.
4
+ # The three bools `STATIC_BOOL`, `STATIC_MUT_BOOL`, and `CONST_BOOL` all have
5
+ # type-alignment of 1, but some targets require greater global alignment.
6
+
7
+ SRC = min_global_align.rs
8
+ LL = $(TMPDIR ) /min_global_align.ll
9
+
10
+ all :
11
+ ifeq ($(UNAME ) ,Linux)
12
+ # Most targets are happy with default alignment -- take i686 for example.
13
+ ifeq ($(filter x86,$(LLVM_COMPONENTS ) ) ,x86)
14
+ $(RUSTC) --target=i686-unknown-linux-gnu --emit=llvm-ir $(SRC)
15
+ [ "$$(grep -c 'align 1' "$(LL)")" -eq "3" ]
16
+ endif
17
+ # SystemZ requires even alignment for PC-relative addressing.
18
+ ifeq ($(filter systemz,$(LLVM_COMPONENTS ) ) ,systemz)
19
+ $(RUSTC) --target=s390x-unknown-linux-gnu --emit=llvm-ir $(SRC)
20
+ [ "$$(grep -c 'align 2' "$(LL)")" -eq "3" ]
21
+ endif
22
+ endif
Original file line number Diff line number Diff line change
1
+ // Copyright 2017 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
+ #![ feature( no_core, lang_items) ]
12
+ #![ crate_type="rlib" ]
13
+ #![ no_core]
14
+
15
+ pub static STATIC_BOOL : bool = true ;
16
+
17
+ pub static mut STATIC_MUT_BOOL : bool = true ;
18
+
19
+ const CONST_BOOL : bool = true ;
20
+ pub static CONST_BOOL_REF : & ' static bool = & CONST_BOOL ;
21
+
22
+
23
+ #[ lang = "sized" ]
24
+ trait Sized { }
25
+
26
+ #[ lang = "copy" ]
27
+ trait Copy { }
28
+
29
+ #[ lang = "freeze" ]
30
+ trait Freeze { }
31
+
32
+ #[ lang = "sync" ]
33
+ trait Sync { }
34
+ impl Sync for bool { }
35
+ impl Sync for & ' static bool { }
36
+
37
+ #[ lang="drop_in_place" ]
38
+ pub unsafe fn drop_in_place < T : ?Sized > ( _: * mut T ) { }
You can’t perform that action at this time.
0 commit comments