Add test case for including upstream object files in staticlibs when doing cross-lang LTO.

This commit is contained in:
Michael Woerister 2018-08-03 17:09:50 +02:00
parent 386e000c5f
commit 3742f4d9f6
3 changed files with 54 additions and 0 deletions

View File

@ -0,0 +1,23 @@
-include ../tools.mk
# This test makes sure that we don't loose upstream object files when compiling
# staticlibs with -Zcross-lang-lto
all: staticlib.rs upstream.rs
$(RUSTC) upstream.rs -Z cross-lang-lto -Ccodegen-units=1
# Check No LTO
$(RUSTC) staticlib.rs -Z cross-lang-lto -Ccodegen-units=1 -L. -o $(TMPDIR)/staticlib.a
(cd $(TMPDIR); llvm-ar x ./staticlib.a)
# Make sure the upstream object file was included
ls upstream.*.rcgu.o
# Cleanup
rm $(TMPDIR)/*
# Check ThinLTO
$(RUSTC) upstream.rs -Z cross-lang-lto -Ccodegen-units=1 -Clto=thin
$(RUSTC) staticlib.rs -Z cross-lang-lto -Ccodegen-units=1 -Clto=thin -L. -o $(TMPDIR)/staticlib.a
(cd $(TMPDIR); llvm-ar x ./staticlib.a)
ls upstream.*.rcgu.o

View File

@ -0,0 +1,18 @@
// 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.
#![crate_type="staticlib"]
extern crate upstream;
#[no_mangle]
pub extern fn bar() {
upstream::foo();
}

View File

@ -0,0 +1,13 @@
// 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.
#![crate_type = "rlib"]
pub fn foo() {}