Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rustc: Default to static linking dylibs
If a dylib is being produced, the compiler will now first check to see if it can be created entirely statically before falling back to dynamic dependencies. This behavior can be overridden with `-C prefer-dynamic`. Due to the alteration in behavior, this is a breaking change. Any previous users relying on dylibs implicitly maximizing dynamic dependencies should start passing `-C prefer-dynamic` to compilations. Closes #18499 [breaking-change]
- Loading branch information
1 parent
ff50f24
commit 3036b00
Showing
20 changed files
with
105 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
-include ../tools.mk | ||
|
||
all: $(TMPDIR)/libfoo.a | ||
$(RUSTC) foo.rs -C extra-filename=-383hf8 | ||
$(RUSTC) foo.rs -C extra-filename=-383hf8 -C prefer-dynamic | ||
$(RUSTC) bar.rs | ||
$(call RUN,bar) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
-include ../tools.mk | ||
|
||
all: | ||
$(RUSTC) both.rs | ||
$(RUSTC) both.rs -C prefer-dynamic | ||
$(RUSTC) dylib.rs -C prefer-dynamic | ||
$(RUSTC) prog.rs | ||
$(call RUN,prog) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
-include ../tools.mk | ||
all: | ||
$(RUSTC) bar.rs --crate-type=dylib | ||
$(RUSTC) bar.rs --crate-type=dylib -C prefer-dynamic | ||
$(RUSTC) foo.rs | ||
$(call RUN,foo) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
-include ../tools.mk | ||
|
||
all: | ||
$(RUSTC) foo.rs | ||
$(RUSTC) bar.rs | ||
$(CC) main.c -o $(call RUN_BINFILE,main) -lbar | ||
rm $(TMPDIR)/*.rlib | ||
rm $(call DYLIB,foo) | ||
$(call RUN,main) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright 2014 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 = "dylib"] | ||
|
||
extern crate foo; | ||
|
||
#[no_mangle] | ||
pub extern fn bar() { | ||
foo::foo(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Copyright 2014 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"] | ||
#![crate_type = "dylib"] | ||
|
||
pub fn foo() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright 2014 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. | ||
|
||
extern void bar(); | ||
|
||
int main() { | ||
bar(); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
-include ../tools.mk | ||
|
||
all: | ||
$(RUSTC) foo.rs | ||
$(RUSTC) foo.rs -C prefer-dynamic | ||
touch $(call DYLIB,foo-something-special) | ||
touch $(call DYLIB,foo-something-special2) | ||
$(RUSTC) bar.rs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3036b00
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
saw approval from pcwalton
at alexcrichton@3036b00
3036b00
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
merging alexcrichton/rust/dylib-harder = 3036b00 into auto
3036b00
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alexcrichton/rust/dylib-harder = 3036b00 merged ok, testing candidate = 21d9a298
3036b00
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some tests failed:
exception: http://buildbot.rust-lang.org/builders/auto-win-32-nopt-t/builds/1762
3036b00
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
saw approval from pcwalton
at alexcrichton@3036b00
3036b00
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
merging alexcrichton/rust/dylib-harder = 3036b00 into auto
3036b00
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alexcrichton/rust/dylib-harder = 3036b00 merged ok, testing candidate = eca8f11
3036b00
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all tests pass:
success: http://buildbot.rust-lang.org/builders/auto-mac-32-opt/builds/2120
success: http://buildbot.rust-lang.org/builders/auto-mac-64-opt/builds/2119
success: http://buildbot.rust-lang.org/builders/auto-mac-64-nopt-c/builds/2112
success: http://buildbot.rust-lang.org/builders/auto-mac-64-nopt-t/builds/2119
success: http://buildbot.rust-lang.org/builders/auto-linux-32-opt/builds/2113
success: http://buildbot.rust-lang.org/builders/auto-linux-32-nopt-c/builds/2112
success: http://buildbot.rust-lang.org/builders/auto-linux-32-nopt-t/builds/2112
success: http://buildbot.rust-lang.org/builders/auto-linux-64-opt/builds/2116
success: http://buildbot.rust-lang.org/builders/auto-linux-64-nopt-c/builds/2109
success: http://buildbot.rust-lang.org/builders/auto-linux-64-nopt-t/builds/2108
success: http://buildbot.rust-lang.org/builders/auto-linux-64-x-android-t/builds/2112
success: http://buildbot.rust-lang.org/builders/auto-win-32-opt/builds/1771
success: http://buildbot.rust-lang.org/builders/auto-win-32-nopt-t/builds/1764
success: http://buildbot.rust-lang.org/builders/auto-win-32-nopt-c/builds/1773
success: http://buildbot.rust-lang.org/builders/auto-win-64-opt/builds/610
success: http://buildbot.rust-lang.org/builders/auto-win-64-nopt-t/builds/605
success: http://buildbot.rust-lang.org/builders/auto-win-64-nopt-c/builds/598
3036b00
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fast-forwarding master to auto = eca8f11