Skip to content

sort out librust_builtin placement #18800

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

Closed
aturon opened this issue Nov 9, 2014 · 5 comments
Closed

sort out librust_builtin placement #18800

aturon opened this issue Nov 9, 2014 · 5 comments
Labels
A-linkage Area: linking into static, shared libraries and binaries

Comments

@aturon
Copy link
Member

aturon commented Nov 9, 2014

The test run-pass/sepcomp-lib-lto.rs can fail on android apparently due to the fact that a pthread shim dependency is present in libstd (as part of librust_builtin), but it stripped out early. It may be possible to work around this by moving the dependency into liballoc instead, but a more thorough examination is needed.

@aturon
Copy link
Member Author

aturon commented Nov 9, 2014

cc @alexcrichton

@huonw huonw added the A-linkage Area: linking into static, shared libraries and binaries label Nov 9, 2014
@alexcrichton
Copy link
Member

The problem here on android was as follows:

  • jemalloc requires the pthread_atfork symbol, which android does not provide. jemalloc is also statically linked to liballoc
  • We provide a dummy definition of pthread_atfork in rust_builtin.c, which is assembled into librust_builtin.a and is statically linked to libstd.
  • When building with LTO, we remove all rust-generated code from an rlib (it's all in the LTO object), but we still link the rlib.
  • When linking, we pass libstd's rlib first, then liballoc's rlib on the command line.
  • The linker detects that we're not using any symbols from the libstd's rlib by the time its reached on the command line (scans from left-to-right) because we actually aren't using any symbols from librust_builtin.a or any other objects in the archive.
  • The linker then strips librust_builtin.a from the linkage step, which then later yields an unresolved reference.

The solution here is to break apart rust_builtin.c to be less of a conglomerate and instead link specific symbols to specific libraries wherever necessary. For example all of the time-related functionality should be a lib linked directly to libtime, not to libstd. In this example we need to link the pthread_atfork symbol directly to liballoc, not to libstd, because libstd is not the one that needs it.

Just some general cleanup, most things should still work as advertised!

@steveklabnik
Copy link
Member

Triage: this test is still ignored on android, but I don't know what librust_builtin is nowadays.

@huonw
Copy link
Member

huonw commented Jan 5, 2016

I don't know what librust_builtin is nowadays.

Dead! So I guess this can be closed, but should we check if the affected test was actually fixed?

@alexcrichton
Copy link
Member

Yeah I think this is all taken care of, so closing.

kennytm added a commit to kennytm/rust that referenced this issue Jul 20, 2018
Enable run-pass/sepcomp-lib-lto.rs on Android

rust-lang#18800 is fixed, so it should be safe to restore this test.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-linkage Area: linking into static, shared libraries and binaries
Projects
None yet
Development

No branches or pull requests

4 participants