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

Don't remove generics unless certain they come from a statically linked lib. #65781

Closed

Conversation

pnkfelix
Copy link
Member

We can only link to monomorphizations from upstream crates if we know their linkage (and that linkage is static).

In the particular case of #64872, we get burned by an attempt to link to a monomorphization in libcore.rlib that ends up not being exported by libstd.dylib. (For that scenario, the attempt to lookup the linkage returns None, which led us terribly astray.)

Fix #64872

@rust-highfive
Copy link
Collaborator

r? @zackmdavis

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

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 24, 2019
@pnkfelix
Copy link
Member Author

r? @alexcrichton

@Centril
Copy link
Contributor

Centril commented Oct 24, 2019

@bors rollup=never

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-6.0 of your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
2019-10-24T22:46:25.9524846Z ##[command]git remote add origin https://github.com/rust-lang/rust
2019-10-24T22:46:25.9757489Z ##[command]git config gc.auto 0
2019-10-24T22:46:26.4910217Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2019-10-24T22:46:26.4919398Z ##[command]git config --get-all http.proxy
2019-10-24T22:46:26.4924172Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/65781/merge:refs/remotes/pull/65781/merge
---
2019-10-24T23:49:06.9388791Z .................................................................................................... 1600/9241
2019-10-24T23:49:12.3700375Z .................................................................................................... 1700/9241
2019-10-24T23:49:25.0325603Z .....................................................i...............i.............................. 1800/9241
2019-10-24T23:49:32.9877125Z .................................................................................................... 1900/9241
2019-10-24T23:49:47.3105924Z ...........................................iiiii.................................................... 2000/9241
2019-10-24T23:49:57.9039179Z .................................................................................................... 2200/9241
2019-10-24T23:50:00.4267949Z .................................................................................................... 2300/9241
2019-10-24T23:50:04.6097384Z .................................................................................................... 2400/9241
2019-10-24T23:50:27.5548062Z .................................................................................................... 2500/9241
---
2019-10-24T23:53:20.2639266Z ...............................................i...............i.................................... 4800/9241
2019-10-24T23:53:29.3693732Z .................................................................................................... 4900/9241
2019-10-24T23:53:37.8644452Z .................................................................................................... 5000/9241
2019-10-24T23:53:44.8131076Z .................................................................................................... 5100/9241
2019-10-24T23:53:55.0736635Z ...............................................ii.ii................................................ 5200/9241
2019-10-24T23:54:05.3408542Z .................................................................................................... 5400/9241
2019-10-24T23:54:15.5034899Z .................................................................................................... 5500/9241
2019-10-24T23:54:23.3309260Z ..............i..................................................................................... 5600/9241
2019-10-24T23:54:28.9324446Z .................................................................................................... 5700/9241
2019-10-24T23:54:28.9324446Z .................................................................................................... 5700/9241
2019-10-24T23:54:41.3470121Z .................................................................................................... 5800/9241
2019-10-24T23:54:53.5682794Z ...........ii...i..ii...........i................................................................... 5900/9241
2019-10-24T23:55:15.8561728Z .................................................................................................... 6100/9241
2019-10-24T23:55:23.4378131Z .................................................................................................... 6200/9241
2019-10-24T23:55:23.4378131Z .................................................................................................... 6200/9241
2019-10-24T23:55:37.4778913Z .................................i..ii.............................................................. 6300/9241
2019-10-24T23:55:58.7977211Z ...................................................................................................i 6500/9241
2019-10-24T23:56:01.0676313Z .................................................................................................... 6600/9241
2019-10-24T23:56:03.4825557Z ..........................................................................i......................... 6700/9241
2019-10-24T23:56:06.2951372Z .................................................................................................... 6800/9241
---
2019-10-25T00:00:40.7436067Z  finished in 5.695
2019-10-25T00:00:40.7628918Z Check compiletest suite=codegen mode=codegen (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2019-10-25T00:00:40.9226283Z 
2019-10-25T00:00:40.9226675Z running 153 tests
2019-10-25T00:00:44.0134225Z i....iii......iii..iiii...i.............................i..i..................i....i...........ii.i. 100/153
2019-10-25T00:00:45.9161772Z i..iiii..............i.........iii.i.........ii......
2019-10-25T00:00:45.9162265Z 
2019-10-25T00:00:45.9167764Z  finished in 5.154
2019-10-25T00:00:45.9365589Z Check compiletest suite=codegen-units mode=codegen-units (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2019-10-25T00:00:46.0870916Z 
---
2019-10-25T00:00:48.1164361Z ---- [codegen-units] codegen-units/partitioning/shared-generics.rs stdout ----
2019-10-25T00:00:48.1164703Z 
2019-10-25T00:00:48.1164920Z These items were contained but should not have been:
2019-10-25T00:00:48.1165879Z 
2019-10-25T00:00:48.1166541Z MONO_ITEM fn shared_generics_aux::generic_fn[0]<f32> @@ shared_generics_aux.3a1fbbbh-in-shared_generics.3a1fbbbh.volatile[External]
2019-10-25T00:00:48.1167139Z 
2019-10-25T00:00:48.1167842Z thread '[codegen-units] codegen-units/partitioning/shared-generics.rs' panicked at 'explicit panic', src/tools/compiletest/src/runtest.rs:2609:13
2019-10-25T00:00:48.1168166Z note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
2019-10-25T00:00:48.1168326Z 
---
2019-10-25T00:00:48.1171410Z 
2019-10-25T00:00:48.1178732Z thread 'main' panicked at 'Some tests failed', src/tools/compiletest/src/main.rs:537:22
2019-10-25T00:00:48.1179379Z 
2019-10-25T00:00:48.1179537Z 
2019-10-25T00:00:48.1181584Z command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "--compile-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib" "--run-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "--rustc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--src-base" "/checkout/src/test/codegen-units" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/codegen-units" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "codegen-units" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/usr/lib/llvm-6.0/bin/FileCheck" "--host-rustcflags" "-Crpath -O -Cdebuginfo=0 -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--target-rustcflags" "-Crpath -O -Cdebuginfo=0 -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--docck-python" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--gdb" "/usr/bin/gdb" "--quiet" "--llvm-version" "6.0.0\n" "--system-llvm" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--llvm-cxxflags" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"
2019-10-25T00:00:48.1182076Z 
2019-10-25T00:00:48.1182199Z 
2019-10-25T00:00:48.1247884Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
2019-10-25T00:00:48.1248188Z Build completed unsuccessfully in 1:07:19
2019-10-25T00:00:48.1248188Z Build completed unsuccessfully in 1:07:19
2019-10-25T00:00:48.1254777Z == clock drift check ==
2019-10-25T00:00:48.1272699Z   local time: Fri Oct 25 00:00:48 UTC 2019
2019-10-25T00:00:48.4218760Z   network time: Fri, 25 Oct 2019 00:00:48 GMT
2019-10-25T00:00:48.4219843Z == end clock drift check ==
2019-10-25T00:00:52.5734368Z 
2019-10-25T00:00:52.5846467Z ##[error]Bash exited with code '1'.
2019-10-25T00:00:52.5913046Z ##[section]Starting: Checkout
2019-10-25T00:00:52.5915365Z ==============================================================================
2019-10-25T00:00:52.5915425Z Task         : Get sources
2019-10-25T00:00:52.5915476Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@alexcrichton
Copy link
Member

Thanks for tracking this down @pnkfelix!

The fix here looks good to me, but I'm wary of the test since it's relies on so many unstable features. We've historically had a lot of problems keeping tests like this running over time. I think though the test can be simplified, I played around with it for a bit and this gist shows the files/script necessary to reproduce the bug today which I presume is fixed after this PR.

I think though the failing test may be legitimate because it's not actually sharing generics with the upstream crate. I believe that means that None should be interpreted as "use the upstream generics" if and only if the only output crate type is an rlib. If the output crate type contains a dylib then we can't use unlinked artifacts generics.

@pnkfelix
Copy link
Member Author

pnkfelix commented Oct 28, 2019

@alexcrichton when you write

The fix here looks good to me, [...] I think though the failing test may be legitimate because it's not actually sharing generics with the upstream crate.

then that means that the fix as written isn't actually 100% good, right? Because it has injected a failure in the test suite, and you believe that the test as written is solid (i.e., is not relying on ... lets say "underspecified" behavior in the compiler and/or platform)?

(And thus, I interpret your feedback as a request for me to update the PR to account for the interpretation of None that you have outlined in your comment.)

@pnkfelix
Copy link
Member Author

pnkfelix commented Oct 28, 2019

Oh, and also: Thank you for the narrowed test case, @alexcrichton ! 🎉

I had spent some time trying to make something similar (namely, something that did not rely on #![no_std] and #![no_core]) but for some reasons my attempts all failed, and I was beginning to worry something about this bug relied on core or std being involved...

So I'm glad that you have proven this to not be the case (though this also means that this bug potentially affects a larger audience than we previously knew about)

@pnkfelix
Copy link
Member Author

Actually, the more I poke at this, the more it seems like @alexcrichton 's reduced test case may be exposing a new variant of this bug that isn't fixed by my PR ... 😢

@pnkfelix
Copy link
Member Author

pnkfelix commented Oct 28, 2019

Actually, the more I poke at this, the more it seems like @alexcrichton 's reduced test case may be exposing a new variant of this bug that isn't fixed by my PR ... 😢

Specifically, it seems to me like we are falling into a case that looks like this (I renamed the crates in alex's reduced test case to a, b, c, and test, since they really have nothing to do with their original names anymore):

[DEBUG rustc_metadata::cstore_impl] compiling `test` (targets: [Dylib], dep-formats [(Dylib, [Dynamic, IncludedFromDylib, IncludedFromDylib, IncludedFromDylib, IncludedFromDylib, IncludedFromDylib, IncludedFromDylib, IncludedFromDylib, IncludedFromDylib, IncludedFromDylib, IncludedFromDylib, IncludedFromDylib, IncludedFromDylib, IncludedFromDylib, Static, Dynamic, IncludedFromDylib])]), def_id: DefId(15:0 ~ c[8787]) from crate `c`
[DEBUG rustc_metadata::cstore_impl] compiling `test` def_id: DefId(15:0 ~ c[8787]) might reuse generics from statically-linked crate `c`
[INFO  rustc_metadata::cstore_impl] compiling `test` def_id: DefId(15:0 ~ c[8787]) from crate `c`; remove_generics: false

In particular, it seems like we are falling into a case where the dep-format says you have an upstream crate of with this dependency format: (Dylib, [Dynamic, IncludedFromDylib, IncludedFromDylib, IncludedFromDylib, IncludedFromDylib, IncludedFromDylib, IncludedFromDylib, IncludedFromDylib, IncludedFromDylib, IncludedFromDylib, IncludedFromDylib, IncludedFromDylib, IncludedFromDylib, IncludedFromDylib, Static, Dynamic, IncludedFromDylib]), and then we end up further seeing that the item in question is coming from a Static import into that upstream crate.

But look at the very first element of the tuple, aka the (ignored!) _ty in this code:

let formats = tcx.dependency_formats(LOCAL_CRATE);
let remove_generics = formats.iter().any(|(_ty, list)| {
match list.get(def_id.krate.as_usize() - 1) {
Some(Linkage::IncludedFromDylib) | Some(Linkage::Dynamic) => true,
_ => false,
}
});

It is a Dylib, and I cannot figure out whether that is relevant here or not.

(What does the first element of the tuple, the _ty there, what does that denote? The type of the crate we are currently compiling? Or the type of the immediate dependency?)

I need to experiment more.

@bjorn3
Copy link
Member

bjorn3 commented Oct 28, 2019

What does the first element of the tuple, the _ty there, what does that denote? The type of the crate we are currently compiling? Or the type of the immediate dependency?

I think the crate type for the current crate:

crate fn calculate(tcx: TyCtxt<'_>) -> Dependencies {

@alexcrichton
Copy link
Member

then that means that the fix as written isn't actually 100% good, right?

Heh, that's "shame on me" for writing half the comment approving this, then seeing the CI failure, but then failing to back and rewrite the original words of the comment now that the failure was noticed.

What does the first element of the tuple, the _ty there, what does that denote?

I believe it means that for the crate type output _ty, the list represents the way each crate is going to be linked.

@pnkfelix
Copy link
Member Author

What does the first element of the tuple, the _ty there, what does that denote?

I believe it means that for the crate type output _ty, the list represents the way each crate is going to be linked.

ah. Now I see: this is how we represent the fact that the current crate may have multiple output types. So the length of dependency_formats should correspond to the number of output crate types we are building for the current crate. Does that sound correct?

@pnkfelix
Copy link
Member Author

pnkfelix commented Oct 28, 2019

Actually, the more I poke at this, the more it seems like @alexcrichton 's reduced test case may be exposing a new variant of this bug that isn't fixed by my PR ... 😢

or maybe its a variant that is not fixed by the new version of this PR that attempts to incorporate @alexcrichton's feedback (by handling None in a more nuanced fashion), and that is why I'm getting confused: I am trying to draft the change suggested by @alexcrichton, and at the same time I am trying to adopt his suggested new version of the test, and then I was surprised to see the test fail.

@pnkfelix
Copy link
Member Author

pnkfelix commented Oct 28, 2019

In any case, my current inclination is to push forward on landing, and nominating for beta-backport, the PR in its original non-nuanced form, where all it did was a diff that was essentially this:

@@ -243,17 +245,32 @@ provide! { <'tcx> tcx, def_id, other, cdata,
         // from this crate.
         let formats = tcx.dependency_formats(LOCAL_CRATE);
         let remove_generics = formats.iter().any(|(_ty, list)| {
             match list.get(def_id.krate.as_usize() - 1) {
-                Some(Linkage::IncludedFromDylib) | Some(Linkage::Dynamic) => true,
-                _ => false,
+                Some(Linkage::Static) => false,
+                _ => true,
              }
         });

For the short-term, I believe that will address the end-user visible semantic linking bug here.

And for the long-term, I would continue to push on the more nuanced form that fixes the aformentioned test regression that represents a failure to optimize.

@alexcrichton do you have objections to that plan?

@pnkfelix
Copy link
Member Author

pnkfelix commented Oct 29, 2019

Okay. I have now absolutely confirmed that the link failure still persists when I use the "nuanced" version of the change (i.e. the one where a None result leads us to make a decision based on the output crate types.

The reason this is happening is perhaps subtle.

In the test case, we have a chain of crate dependencies that looks like this:

a (rlib) <- b (dylib) <- c (rlib) <- test (dylib)

where both a and c define instantiations of u32 as Object, and each arrow represents a extern crate immediately to that upstream crate (and only that one).

The problem as I currently understand it is:

  • We make a choice when compiling rlib c (not test) about whether we can re-use the generics from a (via dylib b).
  • When we compile c, the dependency formats are all None, because the computed dependency format list is empty: (targets: [Rlib], dep-formats [(Rlib, [])]) (I'm still not clear one whether this is correct or not, but it is what is happening).
  • Under my original non-nuanced change, the None signals that we cannot re-use the upstream generics, so we end up putting code for u32 as Object::method into the codegen for libc.rlib. And then when we build test.dylib, linking succeeds.
  • Under the nuanced change that, given None, then dispatches based on the output crate type: we do not put the code for u32 as Object::method into the codegen for libc.rlib, because its output type is rlib and so we assume we can reuse the definition from the upstream crate. But this assumption is proven false when we try to build libtest.dylib.

In short: the current crate output type is not enough to make a decision here. The problem may be witnessed at the time when we compile libtest.dylib, but the bug happens at the time when we compile libc.rlib.

postscript: And now that I've actually typed the horrifying filename libc.rlib, I realize that I should have named the regression test crates differently (to e.g. c1 <- c2 <- c3 <- test). (But oh well, {a,b,c,test} is pretty good if you overlook the libc.* stuff.)

@pnkfelix
Copy link
Member Author

  • When we compile c, the dependency formats are all None, because the computed dependency format list is empty: (targets: [Rlib], dep-formats [(Rlib, [])]) (I'm still not clear one whether this is correct or not, but it is what is happening).

This is the point in the code where we decide to return an empty list here:

if preferred_linkage == Linkage::NotLinked {
// If the crate is not linked, there are no link-time dependencies.
return Vec::new();
}

  • Maybe that's the bug? I.e. we still may need to compute the upstream dependency formats for an rlib, because that will dictate decisions about what we end up doing for the codegen on this rlib, which in turn will affect whether downstream crates will be able to link or not...

@pnkfelix
Copy link
Member Author

(this is now ready for re-review)

@pnkfelix pnkfelix added beta-nominated Nominated for backporting to the compiler in the beta channel. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 29, 2019
@pnkfelix
Copy link
Member Author

Also, I should have cc'ed @michaelwoerister on this from the start. Whoops!

@@ -1,6 +1,7 @@
// ignore-tidy-linelength
// no-prefer-dynamic
// compile-flags:-Zprint-mono-items=eager -Zshare-generics=yes -Zincremental=tmp/partitioning-tests/shared-generics-exe
// FIXME: Use `-Z share-generics-for-unknown-linkage` to workaround rust-lang/rust#65890
// compile-flags:-Zprint-mono-items=eager -Zshare-generics=yes -Zincremental=tmp/partitioning-tests/shared-generics-exe -Z share-generics-for-unknown-linkage
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little worried that the new -Z flag is needed here, do you know what effect that'll have on general crate compilations? I think we still want to be sure that a debug mode compile shares as many generics as it possibly can, and release mode should be fine both before/after this change since no sharing happens.

Basically do general cargo build scenarios still share generics amongst all of their rlib crates?

Copy link
Member Author

@pnkfelix pnkfelix Oct 30, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure they do not, since this test itself serves as evidence of a case where we see less sharing. I take that to be further work that would need to be addressed in say #65890

they will be statically linked.

In the particular case of rust-lang#64872, we get burned by an
attempt to link to a monomorphization in libcore.rlib that ends up not
being exported by libstd.dylib. (For that scenario, the attempt to
lookup the linkage returns `None`, which led us terribly astray.)
(That scenario is encoded in a test in a follow-on commit.)

Also added some `log::info` output for the `None` case, because I want
easy access in all of our builds to inspect what goes on in this
logic.

In response to review feedback, I had tried to revise the fix to be
more nuanced in handling of `None` (i.e., the case which I've
previously asserted to be "unknown linkage"). Alex's take on matters
is that we should use the output crate type to determine what format
the dependency here will have. However, further testing showed that
approach to be flawed.

So I added debugflag: `-Z share-generics-for-unknown-linkage`, to make
it easy to recover the earlier behavior (which I nonetheless assert to
be buggy in general), and use that flag to keep one of our codegen
tests working.
(Many thanks to alex for 1. making this even smaller than what I had
originally minimized, and 2. pointing out that there is precedent for
having ui tests with crate dependency chains of length > 2, thus
allowing me to avoid encoding this as a run-make test.)
@pnkfelix
Copy link
Member Author

nominating for discussion at the T-compiler meeting; I feel like I need to get more inputs in order to weigh the trade-offs here.

@alexcrichton
Copy link
Member

Oh sorry I forgot to review those comments, thanks for writing this out though @pnkfelix!

I want to write down some general thoughts about this regression before I get to the specifics later too. Anything with the dylib crate type I personally consider extremely niche and I personally believe should have zero impact on standard Rust users only using rlibs. Everything with dylib in my opinion is "hack it till it works so long as it doesn't hurt any other use cases". In that sense if we reduce reuse of generics with rlibs today just to fix a bug with the dylib crate type, then I would prefer that we not do that and change the dylib use case instead.

The original bug report was originally spawned from rust-lang/wg-cargo-std-aware#32 which is what started this whole chain of events. The original feature for std-aware Cargo, however, is no longer necessary since rust-lang/cargo#7353 landed, since Cargo no longer ever builds a dylib crate type for libstd in -Zbuild-std mode.

What we ended up doing was trading one bug report (#64319) for another (#64872). Both of these bug reports are basically "dylib crate type shenanigans". I don't really personally see a prioritization between the two of them, but if we had to choose between "fix both and lose sharing between pure rlibs" or "revert the original PR and leave a bug open" I would revert #64324 and leave #64319 open.

So all that's to say that if the fix for #64872 regresses performance or functionality with every day use of Cargo/rustc, I do not think we should merge a fix and we should revert #64324 because I don't think anyone cares about #64319 being fixed at this time.


Ok so now on to the specifics!

This is honestly so complicated that I think regardless of everything else here I'd probably just revert my original PR. I think you're right that maybe this is a case that necessitates calculating linkage types for rlibs. Alternatively the fix in #64324 needs to be completely different, actually exporting generic instantiations from the dylib crate type instead of trying to hide them. This is all so complicated though I sort of wish we could apply some different hammer to fix all this, trying to get it all to precisely align just isn't worth the effort because dylib just isn't worth it :(

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-6.0 of your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
2019-10-30T15:35:51.5901009Z ##[command]git remote add origin https://github.com/rust-lang/rust
2019-10-30T15:35:51.6106603Z ##[command]git config gc.auto 0
2019-10-30T15:35:51.6174502Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2019-10-30T15:35:51.6244616Z ##[command]git config --get-all http.proxy
2019-10-30T15:35:51.6390607Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/65781/merge:refs/remotes/pull/65781/merge
---
2019-10-30T16:35:20.8197307Z .................................................................................................... 1600/9264
2019-10-30T16:35:26.6115953Z .................................................................................................... 1700/9264
2019-10-30T16:35:38.9128955Z ..............................................F............i...............i........................ 1800/9264
2019-10-30T16:35:46.9956704Z .................................................................................................... 1900/9264
2019-10-30T16:36:01.4211697Z .................................................iiiii.............................................. 2000/9264
2019-10-30T16:36:12.2301361Z .................................................................................................... 2200/9264
2019-10-30T16:36:14.8781351Z .................................................................................................... 2300/9264
2019-10-30T16:36:19.3327353Z .................................................................................................... 2400/9264
2019-10-30T16:36:41.6596185Z .................................................................................................... 2500/9264
---
2019-10-30T16:39:32.8375989Z ..................................................i...............i................................. 4800/9264
2019-10-30T16:39:41.7228247Z .................................................................................................... 4900/9264
2019-10-30T16:39:50.2542266Z .................................................................................................... 5000/9264
2019-10-30T16:39:56.4102186Z .................................................................................................... 5100/9264
2019-10-30T16:40:06.6965245Z ...................................................ii.ii...........i................................ 5200/9264
2019-10-30T16:40:16.7925460Z .................................................................................................... 5400/9264
2019-10-30T16:40:26.7206557Z .................................................................................................... 5500/9264
2019-10-30T16:40:34.2354891Z ........................i........................................................................... 5600/9264
2019-10-30T16:40:40.8578039Z .................................................................................................... 5700/9264
2019-10-30T16:40:40.8578039Z .................................................................................................... 5700/9264
2019-10-30T16:40:52.5232720Z .................................................................................................... 5800/9264
2019-10-30T16:41:04.3687759Z .........ii...i..ii...........i..................................................................... 5900/9264
2019-10-30T16:41:26.0875830Z .................................................................................................... 6100/9264
2019-10-30T16:41:34.2261007Z .................................................................................................... 6200/9264
2019-10-30T16:41:34.2261007Z .................................................................................................... 6200/9264
2019-10-30T16:41:50.0378008Z ............................i..ii................................................................... 6300/9264
2019-10-30T16:42:10.1661700Z ..............................................................................................i..... 6500/9264
2019-10-30T16:42:12.4832610Z .................................................................................................... 6600/9264
2019-10-30T16:42:14.8428076Z .....................................................................i.............................. 6700/9264
2019-10-30T16:42:17.8007842Z .................................................................................................... 6800/9264
---
2019-10-30T16:46:55.2746245Z ....................................................................i............................... 9200/9264
2019-10-30T16:47:06.2754219Z ................................................................
2019-10-30T16:47:06.2755288Z failures:
2019-10-30T16:47:06.2793800Z 
2019-10-30T16:47:06.2794668Z ---- [ui] ui/cross-crate/issue-64872/chain-of-rlibs-and-dylibs.rs stdout ----
2019-10-30T16:47:06.2794907Z 
2019-10-30T16:47:06.2795663Z error: aux-build `/checkout/src/test/ui/cross-crate/issue-64872/auxiliary/rexport_obj.rs` source not found
2019-10-30T16:47:06.2796359Z [ERROR compiletest::runtest] fatal error, panic: "aux-build `/checkout/src/test/ui/cross-crate/issue-64872/auxiliary/rexport_obj.rs` source not found"
2019-10-30T16:47:06.2796943Z thread '[ui] ui/cross-crate/issue-64872/chain-of-rlibs-and-dylibs.rs' panicked at 'fatal error', src/tools/compiletest/src/runtest.rs:2262:9
2019-10-30T16:47:06.2797340Z 
2019-10-30T16:47:06.2797475Z 
2019-10-30T16:47:06.2797626Z failures:
2019-10-30T16:47:06.2797626Z failures:
2019-10-30T16:47:06.2798057Z     [ui] ui/cross-crate/issue-64872/chain-of-rlibs-and-dylibs.rs
2019-10-30T16:47:06.2798940Z test result: FAILED. 9222 passed; 1 failed; 41 ignored; 0 measured; 0 filtered out
2019-10-30T16:47:06.2799470Z 
2019-10-30T16:47:06.2837864Z thread 'main' panicked at 'Some tests failed', src/tools/compiletest/src/main.rs:537:22
2019-10-30T16:47:06.2855652Z 
2019-10-30T16:47:06.2855652Z 
2019-10-30T16:47:06.2855945Z 
2019-10-30T16:47:06.2860513Z command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "--compile-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib" "--run-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "--rustc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--src-base" "/checkout/src/test/ui" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "ui" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/usr/lib/llvm-6.0/bin/FileCheck" "--host-rustcflags" "-Crpath -O -Cdebuginfo=0 -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--target-rustcflags" "-Crpath -O -Cdebuginfo=0 -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--docck-python" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--gdb" "/usr/bin/gdb" "--quiet" "--llvm-version" "6.0.0\n" "--system-llvm" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--llvm-cxxflags" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"
2019-10-30T16:47:06.2861519Z 
2019-10-30T16:47:06.2861845Z 
2019-10-30T16:47:06.2874566Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
2019-10-30T16:47:06.9946831Z Build completed unsuccessfully in 1:04:36
2019-10-30T16:47:06.9946831Z Build completed unsuccessfully in 1:04:36
2019-10-30T16:47:06.9997534Z == clock drift check ==
2019-10-30T16:47:06.9997631Z   local time: Wed Oct 30 16:47:06 UTC 2019
2019-10-30T16:47:06.9997688Z   network time: Wed, 30 Oct 2019 16:47:06 GMT
2019-10-30T16:47:06.9997738Z == end clock drift check ==
2019-10-30T16:47:07.5145046Z 
2019-10-30T16:47:07.5252908Z ##[error]Bash exited with code '1'.
2019-10-30T16:47:07.5290123Z ##[section]Starting: Checkout
2019-10-30T16:47:07.5292092Z ==============================================================================
2019-10-30T16:47:07.5292168Z Task         : Get sources
2019-10-30T16:47:07.5292216Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@pnkfelix
Copy link
Member Author

based on @alexcrichton 's comment, I am going to switch gears and focus on reverting PR #64324 (or a subset thereof; much of the changes are purely internal and can remain, to reduce churn)

@pnkfelix pnkfelix removed I-nominated beta-nominated Nominated for backporting to the compiler in the beta channel. labels Oct 31, 2019
@pnkfelix
Copy link
Member Author

pnkfelix commented Nov 1, 2019

This is honestly so complicated that I think regardless of everything else here I'd probably just revert my original PR. I think you're right that maybe this is a case that necessitates calculating linkage types for rlibs. Alternatively the fix in #64324 needs to be completely different, actually exporting generic instantiations from the dylib crate type instead of trying to hide them. This is all so complicated though I sort of wish we could apply some different hammer to fix all this, trying to get it all to precisely align just isn't worth the effort because dylib just isn't worth it :(

So, @alexcrichton : I am totally board with a plan to focus on a revert of PR #64324 and have started working on it.

However, I immediately noticed that the entirety of the code that we are discussing in this PR, namely the logic here:

let remove_generics = formats.iter().any(|(_ty, list)| {
match list.get(def_id.krate.as_usize() - 1) {
Some(Linkage::IncludedFromDylib) | Some(Linkage::Dynamic) => true,
_ => false,
}

... was entirely added in PR #64324 , specifically here

So ... on the one hand you are worried about the potential negative impact of landing this PR (#65781), but doesn't it seem like reverting PR #64324 would likely have at least the same negative impact?

(Or maybe much of the effect of remove_generics was accomplished via some other means prior to #64324 ... I'm just musing at this point while I wait for my trimmed down attempt at a revert to build...)

@pnkfelix
Copy link
Member Author

pnkfelix commented Nov 1, 2019

So ... on the one hand you are worried about the potential negative impact of landing this PR (#65781), but doesn't it seem like reverting PR #64324 would likely have at least the same negative impact?

Well, it seems like this hypothesis was wrong; for some reason, PR #66018 does not suffer from the same regression to the share-generics test from which this PR had suffered.

@pnkfelix
Copy link
Member Author

pnkfelix commented Nov 1, 2019

closing in favor of PR #66018

@pnkfelix pnkfelix closed this Nov 1, 2019
tmandry added a commit to tmandry/rust that referenced this pull request Nov 1, 2019
…r=alexcrichton

Revert PR 64324: dylibs export generics again (for now)

As discussed on PR rust-lang#65781, this is a targeted attempt to undo the main semantic change from PR rust-lang#64324, by putting `dylib` back in the set of crate types that export generic symbols.

The main reason to do this is that PR rust-lang#64324 had unanticipated side-effects that caused bugs like rust-lang#64872, and in the opinion of @alexcrichton and myself, the impact of rust-lang#64872 is worse than rust-lang#64319.

In other words, it is better for us, in the short term, to reopen rust-lang#64319 as currently unfixed for now than to introduce new bugs like rust-lang#64872.

Fix rust-lang#64872

Reopen rust-lang#64319
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. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

linking of libtest failed
6 participants