about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2018-01-16 15:02:31 -0800
committerAlex Crichton <alex@alexcrichton.com>2018-01-23 14:13:47 -0800
commit8bde2acfc7876148ebfe192780434dbb969eded3 (patch)
tree214b953ac0b69b6185e8de690f7c4f8588287f95 /src/test
parent4e3901d35f6a8652f67111e7272263c9e62ab3e1 (diff)
downloadrust-8bde2acfc7876148ebfe192780434dbb969eded3.tar.gz
rust-8bde2acfc7876148ebfe192780434dbb969eded3.zip
rustc: Add `-C lto=val` option
This commit primarily adds the ability to control what kind of LTO happens when
rustc performs LTO, namely allowing values to be specified to the `-C lto`
option, such as `-C lto=thin` and `-C lto=fat`. (where "fat" is the previous
kind of LTO, throw everything in one giant module)

Along the way this also refactors a number of fields which store information
about whether LTO/ThinLTO are enabled to unify them all into one field through
which everything is dispatched, hopefully removing a number of special cases
throughout.

This is intended to help mitigate #47409 but will require a backport as well,
and this would unfortunately need to be an otherwise insta-stable option.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/run-make/codegen-options-parsing/Makefile6
-rw-r--r--src/test/run-pass/fat-lto.rs17
-rw-r--r--src/test/run-pass/thinlto/all-crates.rs17
-rw-r--r--src/test/run-pass/thinlto/thin-lto-inlines2.rs2
4 files changed, 38 insertions, 4 deletions
diff --git a/src/test/run-make/codegen-options-parsing/Makefile b/src/test/run-make/codegen-options-parsing/Makefile
index 81e06043c87..fda96a8b1fb 100644
--- a/src/test/run-make/codegen-options-parsing/Makefile
+++ b/src/test/run-make/codegen-options-parsing/Makefile
@@ -16,11 +16,11 @@ all:
 	$(RUSTC) -C extra-filename=foo dummy.rs 2>&1
 	#Option taking no argument
 	$(RUSTC) -C lto= dummy.rs 2>&1 | \
-		$(CGREP) 'codegen option `lto` takes no value'
+		$(CGREP) 'codegen option `lto` - one of `thin`, `fat`, or'
 	$(RUSTC) -C lto=1 dummy.rs 2>&1 | \
-		$(CGREP) 'codegen option `lto` takes no value'
+		$(CGREP) 'codegen option `lto` - one of `thin`, `fat`, or'
 	$(RUSTC) -C lto=foo dummy.rs 2>&1 | \
-		$(CGREP) 'codegen option `lto` takes no value'
+		$(CGREP) 'codegen option `lto` - one of `thin`, `fat`, or'
 	$(RUSTC) -C lto dummy.rs
 
 	# Should not link dead code...
diff --git a/src/test/run-pass/fat-lto.rs b/src/test/run-pass/fat-lto.rs
new file mode 100644
index 00000000000..453eede261c
--- /dev/null
+++ b/src/test/run-pass/fat-lto.rs
@@ -0,0 +1,17 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// compile-flags: -Clto=fat
+// no-prefer-dynamic
+
+fn main() {
+    println!("hello!");
+}
+
diff --git a/src/test/run-pass/thinlto/all-crates.rs b/src/test/run-pass/thinlto/all-crates.rs
new file mode 100644
index 00000000000..772a9ec8293
--- /dev/null
+++ b/src/test/run-pass/thinlto/all-crates.rs
@@ -0,0 +1,17 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// compile-flags: -Clto=thin
+// no-prefer-dynamic
+// min-llvm-version 4.0
+
+fn main() {
+    println!("hello!");
+}
diff --git a/src/test/run-pass/thinlto/thin-lto-inlines2.rs b/src/test/run-pass/thinlto/thin-lto-inlines2.rs
index 0e8ad08a5f6..6020f72415d 100644
--- a/src/test/run-pass/thinlto/thin-lto-inlines2.rs
+++ b/src/test/run-pass/thinlto/thin-lto-inlines2.rs
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// compile-flags: -Z thinlto -C codegen-units=8 -O -C lto
+// compile-flags: -C codegen-units=8 -O -C lto=thin
 // aux-build:thin-lto-inlines-aux.rs
 // min-llvm-version 4.0
 // no-prefer-dynamic