Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved error messages for linking failure #47052

Merged
merged 2 commits into from
Jan 1, 2018
Merged

Improved error messages for linking failure #47052

merged 2 commits into from
Jan 1, 2018

Conversation

fschutt
Copy link
Contributor

@fschutt fschutt commented Dec 28, 2017

Partial fix for #46998

It's unnecessary to print the linker options if there is no linker installed in the first place. Currently, for libraries, the output is still printed, but that should be cleaned up in the future. If you don't have gcc or g++ installed, so that no linker is installed on the system, the output is now this:

$ ./rustc hello.rs
error: linker `cc` not found
  |
  = note: No such file or directory (os error 2)

error: aborting due to previous error

For libraries, the linker arguments are still printed, but they should be cleaned up in further commits.

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @pnkfelix (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@fschutt
Copy link
Contributor Author

fschutt commented Dec 28, 2017

Oh I see, I can't use TODO comments. I'll take them out for now.

@estebank
Copy link
Contributor

@fschutt you'll need to modify compile-fail/issue-10755.rs to test for the new output ("linker llllll not found"). Could you also squash your commits?

r=me after the test is fixed.

@fschutt
Copy link
Contributor Author

fschutt commented Dec 28, 2017

It's rebased now and test should be fixed.

I would say that the other things (like printing library paths, extra help, etc.) can be done in a seperate PR.

r? @estebank

@rust-highfive rust-highfive assigned estebank and unassigned pnkfelix Dec 28, 2017
@estebank
Copy link
Contributor

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Dec 29, 2017

📌 Commit f78dd66 has been approved by estebank

@bors
Copy link
Contributor

bors commented Dec 29, 2017

⌛ Testing commit f78dd66c77db34b92cba5499f30a699cdf6332fa with merge b889e175a36bf1d4bf371769bd3a0d1c5bfdd709...

@bors
Copy link
Contributor

bors commented Dec 29, 2017

💔 Test failed - status-travis

@fschutt
Copy link
Contributor Author

fschutt commented Dec 29, 2017

This is a problem in cargo, not rustc.

Basically, in src/tools/cargo/plugins.rs the line 284 is wrong:

    assert_that(bar.cargo("build").arg("--verbose"),
                execs().with_stderr_contains("\
[COMPILING] foo v0.0.1 ([..])
[RUNNING] `rustc [..] -C ar=nonexistent-ar -C linker=nonexistent-linker [..]`
[ERROR] could not exec the linker [..]
"));

... so the change in the error message breaks the build. Will do a seperate PR to cargo, because I think this is the only way to fix this.

@fschutt
Copy link
Contributor Author

fschutt commented Dec 29, 2017

See rust-lang/cargo#4871

bors added a commit to rust-lang/cargo that referenced this pull request Dec 29, 2017
Update cargo tests for rust-lang/rust#47052

This test message currently breaks the build. The old error message was:

```
error: could not exec the linker `cc`: No such file or directory (os error 2)
  |
  = note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-L" "/home/felix/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "hello.hello0.rcgu.o" "hello.hello1.rcgu.o" "-o" "hello" "hello.crate.allocator.rcgu.o" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-nodefaultlibs" "-L" "/home/felix/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/home/felix/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-d3700976135c3f09.rlib" "/home/felix/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc_jemalloc-8a207564cfc9f224.rlib" "/home/felix/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-4712d699ce2d50e5.rlib" "/home/felix/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-7224935811a361fe.rlib" "/home/felix/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc_system-3343c92f30e63266.rlib" "/home/felix/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-6e8aafa8bd1a67de.rlib" "/home/felix/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-a8b7c0565b6366c3.rlib" "/home/felix/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd_unicode-512049fc390dec2e.rlib" "/home/felix/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-ba1f12eb6cef9a1a.rlib" "/home/felix/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-53aab67ab6317c59.rlib" "-Wl,-Bdynamic" "-l" "dl" "-l" "rt" "-l" "pthread" "-l" "pthread" "-l" "gcc_s" "-l" "c" "-l" "m" "-l" "rt" "-l" "pthread" "-l" "util" "-l" "util"

error: aborting due to previous error
```

The new error message is:

```
error: linker `cc` not found
  |
  = note: No such file or directory (os error 2)

error: aborting due to previous error
```

This currently breaks rust-lang/rust#47052.

**NOTE:** I don't know if I handled the "ticks" around the linker name correctly (if cargo test is smart enough to see that the ticks are part of the omitted part). My reasoning was that in the rustc code the ticks are in the source and not part of the linkers name - so if rustc changes, this will probably break again.

EDIT: fixed error message
@fschutt
Copy link
Contributor Author

fschutt commented Dec 29, 2017

@bors r+

@bors
Copy link
Contributor

bors commented Dec 29, 2017

@fschutt: 🔑 Insufficient privileges: Not in reviewers

@fschutt
Copy link
Contributor Author

fschutt commented Dec 29, 2017

Sorry. The fix is merged in cargo now, I just wanted to retry.

@kennytm
Copy link
Member

kennytm commented Dec 29, 2017

@bors r=estebank

@bors
Copy link
Contributor

bors commented Dec 29, 2017

💡 This pull request was already approved, no need to approve it again.

  • This pull request previously failed. You should add more commits to fix the bug, or use retry to trigger a build again.
  • There's another pull request that is currently being tested, blocking this pull request: Update RLS and Rustfmt #47051

@bors
Copy link
Contributor

bors commented Dec 29, 2017

📌 Commit f78dd66 has been approved by estebank

@fschutt fschutt closed this Dec 29, 2017
@fschutt fschutt reopened this Dec 29, 2017
@bors
Copy link
Contributor

bors commented Dec 30, 2017

💡 This pull request was already approved, no need to approve it again.

  • This pull request previously failed. You should add more commits to fix the bug, or use retry to trigger a build again.
  • There's another pull request that is currently being tested, blocking this pull request: update books for next release #47076

@bors
Copy link
Contributor

bors commented Dec 30, 2017

📌 Commit f78dd66 has been approved by estebank

@bors
Copy link
Contributor

bors commented Dec 30, 2017

⌛ Testing commit f78dd66c77db34b92cba5499f30a699cdf6332fa with merge 7025aea940b8ac199e35a0ea197914848e5b81b9...

@bors
Copy link
Contributor

bors commented Dec 30, 2017

💔 Test failed - status-appveyor

@estebank
Copy link
Contributor

@fschutt the cargo dependency in this repo doesn't track master in the cargo repo, it has to be manually updated with a PR (like #47051). There was a file src/tools/toolstate.toml where you could mark one of these out of repo dependencies as broken, but I don't see it in master anymore, I'm not sure how it is supposed to work now. Do you want to create a PR updating cargo? Also, neat solution by making it compatible with both versions :)

@kennytm
Copy link
Member

kennytm commented Dec 31, 2017

@estebank The new instructions for rls, rustfmt, miri and clippy are in https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#breaking-tools-built-with-the-compiler. Basically, the PR author doesn't need to care about these tools anymore. If they are broken after merging the PR, somebody else (the tool maintainers) can clean up the mess afterwards.

Cargo is unaffected by toolstate.toml though, before or now. It can never be broken.

@fschutt Since the "cargo fix" (rust-lang/cargo#4871) has already been merged on the cargo side, you just need to update the cargo submodule, and then create a separate PR or push a commit here.

cd src/tools/cargo
git checkout master
git pull origin master --ff-only
cd ../..
cargo update -p cargo
git add Cargo.lock tools/cargo
git ci -m 'Update cargo'

@kennytm kennytm added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Dec 31, 2017
@fschutt
Copy link
Contributor Author

fschutt commented Dec 31, 2017

@kennytm Done - should I squash this with the previous commit or rather leave it seperate? I'd personally leave it seperate so that it's clear when cargo was updated.

@kennytm
Copy link
Member

kennytm commented Dec 31, 2017

@fschutt Keep it separate, thanks.

@kennytm kennytm 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 Dec 31, 2017
@kennytm
Copy link
Member

kennytm commented Dec 31, 2017

@bors r=estebank rollup-

@bors
Copy link
Contributor

bors commented Dec 31, 2017

📌 Commit aae8c29 has been approved by estebank

@kennytm kennytm added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 31, 2017
@estebank
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Dec 31, 2017

💡 This pull request was already approved, no need to approve it again.

@bors
Copy link
Contributor

bors commented Dec 31, 2017

📌 Commit aae8c29 has been approved by estebank

@bors
Copy link
Contributor

bors commented Dec 31, 2017

🔒 Merge conflict

@fschutt
Copy link
Contributor Author

fschutt commented Dec 31, 2017

I'm not really sure where the merge conflict was ...

@kennytm
Copy link
Member

kennytm commented Dec 31, 2017

@fschutt Maybe Cargo.lock or some other submodules. Please rebase on the latest master and see if git complains about anything.

# assume origin = https://github.com/rust-lang/rust.git
# and   fschutt = git@github.com:fschutt/rust.git
git pull origin master --rebase
git push fschutt master -f

…lled

It's unnecessary to print the linker options if there is no linker installed.
Currently, for libraries, the output is still printed, see #46998 for
discussion
@fschutt
Copy link
Contributor Author

fschutt commented Dec 31, 2017

Git said that there was a merge conflict in src/Cargo.lock, but it didn't show any conflicts, i.e. there were no conflict markers in the file. It just said that both branches (rustlang/rust and fschutt/rust) had modified the file. But no conflict markers.

I rebased and pushed as you said - Git did not complain about anything here, no merge conflict during the rebase. Hope this fixes it.

@estebank
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Dec 31, 2017

📌 Commit 7c13fa3 has been approved by estebank

@fschutt
Copy link
Contributor Author

fschutt commented Dec 31, 2017

happy new year, by the way

@bors
Copy link
Contributor

bors commented Jan 1, 2018

⌛ Testing commit 7c13fa3 with merge 037bc65...

bors added a commit that referenced this pull request Jan 1, 2018
Improved error messages for linking failure

Partial fix for #46998

It's unnecessary to print the linker options if there is no linker installed in the first place. Currently, for libraries, the output is still printed, but that should be cleaned up in the future. If you don't have gcc or g++ installed, so that no linker is installed on the system, the output is now this:

```
$ ./rustc hello.rs
error: linker `cc` not found
  |
  = note: No such file or directory (os error 2)

error: aborting due to previous error
```

For libraries, the linker arguments are still printed, but they should be cleaned up in further commits.
@bors
Copy link
Contributor

bors commented Jan 1, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: estebank
Pushing 037bc65 to master...

@bors bors merged commit 7c13fa3 into rust-lang:master Jan 1, 2018
@bors bors mentioned this pull request Jan 1, 2018
10 tasks
bors added a commit that referenced this pull request Jan 1, 2018
Add compiler docs testing to CI.

Fixes #47025.
I don't know if `x86_64-gnu` is the right builder for this, but there seems to be time left on [Travis](https://travis-ci.org/rust-lang/rust/jobs/307488864).

Remaining problems blocking this PR:
- [x] broken links caused by rustdoc issues:
  - [x] `pub use self::Enum::...`: #46766 and #46767 (fixed by #47050, thanks @ollie27!)
  - [x] `impl Deref for DerefToStdType`: #32129 (ignored in linkchecker)
  - [x] `#[feature(decl_macro)]` and `use std::vec`: #47038 (ignored in linkchecker)
  - [x]  `rustc_data_structures::sync::{Lrc, RwLock}` aliases `std` types: #32130 (ignored in linkchecker)
- [x] markdown differences, in rust repository and in external crates, now failing the build with #46880 merged (all fixed)
- [x] multiple crate updates needed: `rand`, `log`, `parking_lot_core`, `flate2`
  - [x] submodule updates needed to deduplicate dependencies: `rust-installer`, ~`cargo`~ (done by #47052)
  - [x] #44953 test broken by `log` update (removed, this can be controversial)
- [x] Waiting `x86_64-gnu` build results ([done](https://travis-ci.org/rust-lang/rust/builds/323451069))

See individual commits for more details.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants