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

rustc: Add _imp_ symbols later in compilation #45348

Merged
merged 1 commit into from
Oct 21, 2017

Conversation

alexcrichton
Copy link
Member

On MSVC targets rustc will add symbols prefixed with _imp_ to LLVM modules to
"emulate" dllexported statics as that workaround is still in place after #27438
hasn't been solved otherwise. These statics, however, were getting gc'd by
ThinLTO accidentally which later would cause linking failures.

This commit updates the location we add such symbols to happen just before
codegen to ensure that (a) they're not eliminated by the optimizer and (b) the
optimizer doesn't even worry about them.

Closes #45347

@rust-highfive
Copy link
Collaborator

r? @eddyb

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

@alexcrichton
Copy link
Member Author

r? @michaelwoerister

@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 Oct 18, 2017
Copy link
Member

@michaelwoerister michaelwoerister left a comment

Choose a reason for hiding this comment

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

Thanks, @alexcrichton!

r=me with the comment in the test case added.

// <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.

Copy link
Member

Choose a reason for hiding this comment

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

Could you add a comment what this is all about? Otherwise one might be a little lost when this test fails.

On MSVC targets rustc will add symbols prefixed with `_imp_` to LLVM modules to
"emulate" dllexported statics as that workaround is still in place after rust-lang#27438
hasn't been solved otherwise. These statics, however, were getting gc'd by
ThinLTO accidentally which later would cause linking failures.

This commit updates the location we add such symbols to happen just before
codegen to ensure that (a) they're not eliminated by the optimizer and (b) the
optimizer doesn't even worry about them.

Closes rust-lang#45347
@alexcrichton
Copy link
Member Author

@bors: r=michaelwoerister

@bors
Copy link
Contributor

bors commented Oct 18, 2017

📌 Commit 3541ffb has been approved by michaelwoerister

@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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 18, 2017
@bors
Copy link
Contributor

bors commented Oct 20, 2017

⌛ Testing commit 3541ffb with merge 0e612b6c44ca77fa77c60680ebf0f8a498902dee...

@bors
Copy link
Contributor

bors commented Oct 20, 2017

💔 Test failed - status-appveyor

@kennytm kennytm 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 Oct 20, 2017
@kennytm
Copy link
Member

kennytm commented Oct 20, 2017

The test against xsv failed on check-aux x86_64-pc-windows-msvc

[01:08:09] failures:
[01:08:09] 
[01:08:09] ---- test_frequency::prop_frequency stdout ----
[01:08:09] 	[C:\projects\rust\build\ct\xsv\target\debug\xit\prop_frequency\test-821]: "C:\\projects\\rust\\build\\ct\\xsv\\target\\debug\\xsv" "frequency" "in.csv" "-j" "4" "--limit" "0"
[01:08:09] [C:\projects\rust\build\ct\xsv\target\debug\xit\prop_frequency\test-823]: "C:\\projects\\rust\\build\\ct\\xsv\\target\\debug\\xsv" "frequency" "in.csv" "-j" "4" "--limit" "0"
...
[01:08:09] [C:\projects\rust\build\ct\xsv\target\debug\xit\prop_frequency\test-957]: "C:\\projects\\rust\\build\\ct\\xsv\\target\\debug\\xsv" "frequency" "in.csv" "-j" "4" "--limit" "0"
[01:08:09] thread 'test_frequency::prop_frequency' panicked at '[quickcheck] TEST FAILED (runtime error). Arguments: (CsvData { data: [[[239, 187, 191]], [[]]] })
[01:08:09] Error: "called `Option::unwrap()` on a `None` value"', C:\Users\appveyor\.cargo\registry\src\git.luolix.top-1ecc6299db9ec823\quickcheck-0.4.1\src\tester.rs:147:27
[01:08:09] 
[01:08:09] 
[01:08:09] failures:
[01:08:09]     test_frequency::prop_frequency
[01:08:09] 
[01:08:09] test result: FAILED. 420 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out
[01:08:09] 
[01:08:09] error: test failed, to rerun pass '--test tests'

@alexcrichton
Copy link
Member Author

wut

@alexcrichton
Copy link
Member Author

That test failure is a quickcheck-based test, and otherwise this PR should only affect linkage (not runtime), so I'm going to retry assuming it's spurious. If this lands I'll open an issue upstream.

@bors: retry

@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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 20, 2017
@bors
Copy link
Contributor

bors commented Oct 20, 2017

⌛ Testing commit 3541ffb with merge 6511b4f...

bors added a commit that referenced this pull request Oct 20, 2017
rustc: Add `_imp_` symbols later in compilation

On MSVC targets rustc will add symbols prefixed with `_imp_` to LLVM modules to
"emulate" dllexported statics as that workaround is still in place after #27438
hasn't been solved otherwise. These statics, however, were getting gc'd by
ThinLTO accidentally which later would cause linking failures.

This commit updates the location we add such symbols to happen just before
codegen to ensure that (a) they're not eliminated by the optimizer and (b) the
optimizer doesn't even worry about them.

Closes #45347
@bors
Copy link
Contributor

bors commented Oct 21, 2017

☀️ Test successful - status-appveyor, status-travis
Approved by: michaelwoerister
Pushing 6511b4f to master...

kennytm added a commit to kennytm/rust that referenced this pull request Oct 26, 2017
This fixes a flaky test which caused spurious failures in rust-lang#45348 and rust-lang#45380
@kennytm kennytm mentioned this pull request Oct 26, 2017
@alexcrichton alexcrichton deleted the thinlto-timp branch October 28, 2017 12:56
bors added a commit that referenced this pull request Oct 31, 2017
cargotest: Update xsv.

This fixes a flaky test which caused spurious failures in #45348 and #45380.
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.

ThinLTO breaks MSVC _imp_ symbols
6 participants