Skip to content

Require rlibs for dependent crates when linking static executables#44279

Merged
bors merged 2 commits into
rust-lang:masterfrom
smaeul:crt_static-deps
Sep 25, 2017
Merged

Require rlibs for dependent crates when linking static executables#44279
bors merged 2 commits into
rust-lang:masterfrom
smaeul:crt_static-deps

Conversation

@smaeul

@smaeul smaeul commented Sep 2, 2017

Copy link
Copy Markdown
Contributor

This handles the case for CrateTypeExecutable and +crt_static. I reworked the match block to avoid duplicating the attempt_static and error checking code again (this case would have been a copy of the CrateTypeCdylib/CrateTypeStaticlib case).

On linux-musl targets where std was built with crt_static = false in config.toml, this change brings the test suite from entirely failing to mostly passing.

This change should not affect behavior for other crate types, or for targets which do not respect +crt_static.

@rust-highfive

Copy link
Copy Markdown
Contributor

r? @eddyb

(rust_highfive has picked a reviewer for you, use r? to override)

@eddyb

eddyb commented Sep 3, 2017

Copy link
Copy Markdown
Contributor

r? @alexcrichton

@rust-highfive rust-highfive assigned alexcrichton and unassigned eddyb Sep 3, 2017
@alexcrichton

Copy link
Copy Markdown
Member

@bors: r+

@bors

bors commented Sep 5, 2017

Copy link
Copy Markdown
Collaborator

📌 Commit 4950756 has been approved by alexcrichton

@arielb1 arielb1 added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Sep 5, 2017
@alexcrichton

Copy link
Copy Markdown
Member

@bors: rollup

GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Sep 8, 2017
Require rlibs for dependent crates when linking static executables

This handles the case for `CrateTypeExecutable` and `+crt_static`. I reworked the match block to avoid duplicating the `attempt_static` and error checking code again (this case would have been a copy of the `CrateTypeCdylib`/`CrateTypeStaticlib` case).

On `linux-musl` targets where `std` was built with `crt_static = false` in `config.toml`, this change brings the test suite from entirely failing to mostly passing.

This change should not affect behavior for other crate types, or for targets which do not respect `+crt_static`.
@bors

bors commented Sep 8, 2017

Copy link
Copy Markdown
Collaborator

☔ The latest upstream changes (presumably #44142) made this pull request unmergeable. Please resolve the merge conflicts.

@carols10cents

Copy link
Copy Markdown
Member

@bors: r=alexcrichton

@bors

bors commented Sep 11, 2017

Copy link
Copy Markdown
Collaborator

📌 Commit 6b4bdbd has been approved by alexcrichton

@carols10cents

Copy link
Copy Markdown
Member

@bors: rollup

GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Sep 13, 2017
Require rlibs for dependent crates when linking static executables

This handles the case for `CrateTypeExecutable` and `+crt_static`. I reworked the match block to avoid duplicating the `attempt_static` and error checking code again (this case would have been a copy of the `CrateTypeCdylib`/`CrateTypeStaticlib` case).

On `linux-musl` targets where `std` was built with `crt_static = false` in `config.toml`, this change brings the test suite from entirely failing to mostly passing.

This change should not affect behavior for other crate types, or for targets which do not respect `+crt_static`.
@aidanhs

aidanhs commented Sep 13, 2017

Copy link
Copy Markdown
Contributor

This this caused a failure in #44550 (best guess)
@bors r- rollup-

[00:53:43] ---- [compile-fail] compile-fail/rmeta_lib.rs stdout ----
[00:53:43] 	
[00:53:43] error: error pattern ' crate `rmeta_meta` required to be available in rlib, but it was not available' not found!

@smaeul

smaeul commented Sep 13, 2017

Copy link
Copy Markdown
Contributor Author

It looks like the compile failure is happening in the intended way, but the error message is different because it's being caught earlier. Should I just change the expected error message in the test?

Edit: hmm, but the error path and therefore the message will be different based on whether the executable was static. Do I need another special case here? should we make the error messages match?

@alexcrichton

Copy link
Copy Markdown
Member

If possible yeah let's just get the errors to emit through a common path to ensure that they're the same

@carols10cents

Copy link
Copy Markdown
Member

[00:03:44] tidy error: /checkout/src/test/compile-fail/rmeta_lib.rs:13: line longer than 100 chars

tidy error for you @smaeul!

@carols10cents carols10cents added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Sep 18, 2017
@smaeul

smaeul commented Sep 18, 2017

Copy link
Copy Markdown
Contributor Author

How do I fix that without making the error message shorter?

@kennytm

kennytm commented Sep 18, 2017

Copy link
Copy Markdown
Member

@smaeul You could remove the spaces around error-pattern. The line is now exactly 100 chars.

//error-pattern:crate `rmeta_meta` required to be available in rlib format, but it was not available

This handles the case for `CrateTypeExecutable` and `+crt_static`. I
reworked the match block to avoid duplicating the `attempt_static` and
error checking code again (this case would have been a copy of the
`CrateTypeCdylib`/`CrateTypeStaticlib` case).

On `linux-musl` targets where `std` was built with `crt_static = false`
in `config.toml`, this change brings the test suite from entirely
failing to mostly passing.

This change should not affect behavior for other crate types, or for
targets which do not respect `+crt_static`.
@arielb1

arielb1 commented Sep 19, 2017

Copy link
Copy Markdown
Contributor

Test failure:

[00:49:18] error: error pattern ' dependency `cdylib_dep` not found in rlib format' not found!
[00:49:18] status: exit code: 101
[00:49:18] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/compile-fail/cdylib-deps-must-be-static.rs" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/compile-fail" "--target=x86_64-unknown-linux-gnu" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/compile-fail/cdylib-deps-must-be-static.stage2-x86_64-unknown-linux-gnu" "-Crpath" "-O" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/compile-fail/cdylib-deps-must-be-static.stage2-x86_64-unknown-linux-gnu.compile-fail.libaux" "-A" "unused"
[00:49:18] stdout:
[00:49:18] ------------------------------------------
[00:49:18] 
[00:49:18] ------------------------------------------
[00:49:18] stderr:
[00:49:18] ------------------------------------------
[00:49:18] warning: unused extern crate
[00:49:18]   --> /checkout/src/test/compile-fail/cdylib-deps-must-be-static.rs:18:1
[00:49:18]    |
[00:49:18] 18 | extern crate cdylib_dep;
[00:49:18]    | ^^^^^^^^^^^^^^^^^^^^^^^^
[00:49:18]    |
[00:49:18]    = note: #[warn(unused_extern_crates)] on by default
[00:49:18] 
[00:49:18] error: crate `cdylib_dep` required to be available in rlib format, but it was not available in this form
[00:49:18] 
[00:49:18] error: aborting due to previous error
[00:49:18] 
[00:49:18] 
[00:49:18] ------------------------------------------
[00:49:18] 
[00:49:18] thread '[compile-fail] compile-fail/cdylib-deps-must-be-static.rs' panicked at 'explicit panic', /checkout/src/tools/compiletest/src/runtest.rs:2433:8
[00:49:18] note: Run with `RUST_BACKTRACE=1` for a backtrace.
[00:49:18] 
[00:49:18] 
[00:49:18] failures:
[00:49:18]     [compile-fail] compile-fail/cdylib-deps-must-be-static.rs
[00:49:18] 
[00:49:18] test result: �[31mFAILED�(B�[m. 2736 passed; 1 failed; 13 ignored; 0 measured; 0 filtered out
[00:49:18] 
[00:49:18] thread 'main' panicked at 'Some tests failed', /checkout/src/tools/compiletest/src/main.rs:323:21
[00:49:18] 

@carols10cents

Copy link
Copy Markdown
Member

This looks like it's ready for rereview @alexcrichton !

@carols10cents carols10cents added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Sep 25, 2017
@alexcrichton

Copy link
Copy Markdown
Member

@bors: r+

@bors

bors commented Sep 25, 2017

Copy link
Copy Markdown
Collaborator

📌 Commit 314c2b1 has been approved by alexcrichton

@bors

bors commented Sep 25, 2017

Copy link
Copy Markdown
Collaborator

⌛ Testing commit 314c2b1 with merge 6c476ce...

bors added a commit that referenced this pull request Sep 25, 2017
Require rlibs for dependent crates when linking static executables

This handles the case for `CrateTypeExecutable` and `+crt_static`. I reworked the match block to avoid duplicating the `attempt_static` and error checking code again (this case would have been a copy of the `CrateTypeCdylib`/`CrateTypeStaticlib` case).

On `linux-musl` targets where `std` was built with `crt_static = false` in `config.toml`, this change brings the test suite from entirely failing to mostly passing.

This change should not affect behavior for other crate types, or for targets which do not respect `+crt_static`.
@bors

bors commented Sep 25, 2017

Copy link
Copy Markdown
Collaborator

☀️ Test successful - status-appveyor, status-travis
Approved by: alexcrichton
Pushing 6c476ce to master...

@bors bors merged commit 314c2b1 into rust-lang:master Sep 25, 2017
@smaeul smaeul deleted the crt_static-deps branch September 26, 2017 03:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants