Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign uprustc: Group linked libraries where needed #49316
Conversation
rust-highfive
assigned
michaelwoerister
Mar 23, 2018
This comment has been minimized.
This comment has been minimized.
|
(rust_highfive has picked a reviewer for you, use r? to override) |
rust-highfive
added
the
S-waiting-on-review
label
Mar 23, 2018
alexcrichton
force-pushed the
alexcrichton:start-group-end-group
branch
from
7394e66
to
60e6480
Mar 23, 2018
alexcrichton
referenced this pull request
Mar 23, 2018
Closed
Multiple codegen units breaks linking: "undefined reference to rust_begin_unwind" #47074
This comment has been minimized.
This comment has been minimized.
|
|
alexcrichton
force-pushed the
alexcrichton:start-group-end-group
branch
3 times, most recently
from
3b41480
to
eec0d65
Mar 23, 2018
japaric
referenced this pull request
Mar 27, 2018
Closed
Fix linking issues when using multiple codegen units #53
michaelwoerister
reviewed
Mar 27, 2018
|
Thanks, @alexcrichton! r=me with the nits addressed. |
| // Linkage::NotLinked | | ||
| // Linkage::IncludedFromDylib => continue, | ||
| // _ => {} | ||
| // } |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| if group_end.is_some() && group_start.is_none() { | ||
| group_end = None; | ||
| } | ||
|
|
This comment has been minimized.
This comment has been minimized.
michaelwoerister
Mar 27, 2018
Contributor
Maybe add an assert!(group_start.is_some() == group_end.is_some())?
This comment has been minimized.
This comment has been minimized.
alexcrichton
Mar 27, 2018
Author
Member
Ah unfortunately that assertion tripped when I added it, so I ended up having to implement it this way for libstd specifically
alexcrichton
force-pushed the
alexcrichton:start-group-end-group
branch
from
eec0d65
to
8ad2f7f
Mar 27, 2018
This comment has been minimized.
This comment has been minimized.
|
@bors: r=michaelwoerister |
This comment has been minimized.
This comment has been minimized.
|
|
bors
added
S-waiting-on-bors
and removed
S-waiting-on-review
labels
Mar 27, 2018
This comment has been minimized.
This comment has been minimized.
|
|
bors
added
S-waiting-on-author
and removed
S-waiting-on-bors
labels
Mar 28, 2018
alexcrichton
force-pushed the
alexcrichton:start-group-end-group
branch
from
8ad2f7f
to
50ad5f9
Mar 28, 2018
This comment has been minimized.
This comment has been minimized.
|
@bors: r=michaelwoerister |
This comment has been minimized.
This comment has been minimized.
|
|
bors
added
S-waiting-on-bors
and removed
S-waiting-on-author
labels
Mar 28, 2018
This comment has been minimized.
This comment has been minimized.
bors
added a commit
that referenced
this pull request
Mar 29, 2018
This comment has been minimized.
This comment has been minimized.
|
|
bors
added
S-waiting-on-review
and removed
S-waiting-on-bors
labels
Mar 29, 2018
japaric
referenced this pull request
Mar 29, 2018
Merged
Initial commit of the second newsletter. Still some TODOs for @japaric #73
alexcrichton
force-pushed the
alexcrichton:start-group-end-group
branch
from
50ad5f9
to
88114f6
Mar 29, 2018
This comment has been minimized.
This comment has been minimized.
|
@bors: r=michaelwoerister |
This comment has been minimized.
This comment has been minimized.
|
|
bors
added
S-waiting-on-bors
and removed
S-waiting-on-review
labels
Mar 29, 2018
This comment has been minimized.
This comment has been minimized.
bors
added a commit
that referenced
this pull request
Mar 29, 2018
This comment has been minimized.
This comment has been minimized.
|
|
bors
merged commit 88114f6
into
rust-lang:master
Mar 30, 2018
alexcrichton
deleted the
alexcrichton:start-group-end-group
branch
Mar 30, 2018
glandium
referenced this pull request
Mar 31, 2018
Closed
It's impossible to write a panic crate for no_std #48661
This comment has been minimized.
This comment has been minimized.
|
@alexcrichton it seems that panic_fmt is not in the "missing lang items" list so this logic doesn't add {start,end}-group when only that lang item is in play. |
This comment has been minimized.
This comment has been minimized.
|
@japaric hm it's listed here but I may be misremembering what that's used for. Do you have an example I can poke around? |
This comment has been minimized.
This comment has been minimized.
|
@alexcrichton #48661 (comment) still produces a shared library that contains an undefined reference to rust_begin_unwind. The linker invocation looks like this: "cc"
"-Wl,--as-needed"
"-Wl,-z,noexecstack"
"-m64"
"-L"
"$SYSROOT/lib/rustlib/x86_64-unknown-linux-gnu/lib"
"$PWD/target/release/deps/bar.bar0.rcgu.o"
"-o"
"$PWD/target/release/deps/libbar.so"
"-Wl,--version-script=/tmp/rustc.NVjXDd5FIjVZ/list"
"-Wl,--gc-sections"
"-Wl,-z,relro,-z,now"
"-Wl,-O1"
"-nodefaultlibs"
"-L"
"/home/japaric/tmp/bar/target/release/deps"
"-L"
"$SYSROOT/lib/rustlib/x86_64-unknown-linux-gnu/lib"
"-Wl,-Bstatic"
# -Wl,--start-group
"$PWD/target/release/deps/libpanic-3f5354702551e825.rlib"
"$SYSROOT/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-4d12ce26aecbbf20.rlib"
# -Wl,--end-group
"-shared"
"-Wl,-Bdynamic"I would expect the logic added in this PR to add the {start,end}-group flags in the places where I added comments, but today's nightly doesn't add those flags to the linker invocation. If you re-invoke the linker with the {start,end}-group flags you get a shared library with a defined rust_begin_unwind symbol. |
This comment has been minimized.
This comment has been minimized.
|
Ok thanks for the info! I think I've narrowed this down and am testing a fix |
alexcrichton
added a commit
to alexcrichton/rust
that referenced
this pull request
Apr 4, 2018
alexcrichton
referenced this pull request
Apr 4, 2018
Merged
Fix another circular deps link args issue #49672
This comment has been minimized.
This comment has been minimized.
|
I've posted #49672 with a fix for that |
alexcrichton commentedMar 23, 2018
This commit fixes a longstanding issue with the compiler with circular
dependencies between libcore and libstd. The
corecrate requires at least onesymbol, the ability to unwind. The
stdcrate is the crate which actuallydefines this symbol, but the
stdcrate also depends on thecorecrate.This circular dependency is in general disallowed in Rust as crates cannot have
cycles amongst them. A special exception is made just for core/std, but this is
also unfortunately incompatible with how GNU linkers work. GNU linkers will
process undefined symbols in a left-to-right fashion, only actually linking an
rlib like libstd if there are any symbols used from it. This strategy is
incompatible with circular dependencies because if we otherwise don't use
symbols from libstd we don't discover that we needed it until we're later
processing libcore's symbols!
To fix this GNU linkers support the
--start-groupand--end-groupoptionswhich indicate "libraries between these markers may have circular dependencies
amongst them. The linker invocation has been updated to automatically pass these
arguments when we're invoking a GNU linker and automatically calculate where the
arguments need to go (around libstd and libcore)
Closes #18807
Closes #47074