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 upWeak external symbol support #11978
Conversation
This comment has been minimized.
This comment has been minimized.
|
I believe this breaks a current type system assumption that all extern fns are non-null. @nikomatsakis what you say? @alexcrichton do we already have mechanisms for specifying linkage on symbols? Are we going to end up gradually expanding this to every other type of linkage? |
This comment has been minimized.
This comment has been minimized.
|
We do not currently have a way to specify the linkage of symbols, and I remember that we removed the ability to do this awhile back. This is an interesting twist though in that it's only allowed on This seems reasonable to me and I'd be in favor of it (only on extern symbols), although I agree that going all the way and being able to specify any linkage may be the best way to go. Perhaps this should be behind a feature gate as well? I would slightly lean towards this not being behind a feature gate. |
This comment has been minimized.
This comment has been minimized.
|
This would also potentially be a good solution for out-of-crate lang items as suggested in the libprim change. |
This comment has been minimized.
This comment has been minimized.
|
On Sat, Feb 01, 2014 at 12:05:24PM -0800, Brian Anderson wrote:
We do presently assume that. |
This comment has been minimized.
This comment has been minimized.
|
@brson, @bnoordhuis, what would you think about a generic I think that the typesystem concern of expressing a "weak function" is very real, but we can work around it for now. |
This comment has been minimized.
This comment has been minimized.
|
@alexcrichton Done as you suggested. PTAL. |
alexcrichton
reviewed
Feb 7, 2014
| macro_rules, | ||
| managed_boxes, | ||
| simd, | ||
| thread_local)]; |
This comment has been minimized.
This comment has been minimized.
alexcrichton
Feb 7, 2014
Member
I'm getting the feeling that libstd essentially has #[feature(*)]...
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
alexcrichton
commented on ffb7d35
Feb 7, 2014
|
r+, nice work, and thank you! |
This comment has been minimized.
This comment has been minimized.
|
saw approval from alexcrichton |
This comment has been minimized.
This comment has been minimized.
|
merging bnoordhuis/rust/weak-symbol-support = ffb7d35 into auto |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
bors
added a commit
that referenced
this pull request
Feb 7, 2014
This comment has been minimized.
This comment has been minimized.
|
I have canceled the build, @brson reminded me that we should resolve the typesystem issue before merging. |
This comment has been minimized.
This comment has been minimized.
|
We discussed this at the meeting today, and the conclusion we reached is that we should only allow weak variables of the form: extern {
#[weak] static FOO: *T;
#[weak] static mut FOO_MUT: *T;
}This way we can get weak variables without violating the typesystem. This will involve a little bit of extra codegen on LLVM's side I believe. I think we'll have to declare something of type @bnoordhuis, sorry this took awhile. If you've grown busy in the meantime, I don't mind taking this over. |
This comment has been minimized.
This comment has been minimized.
|
@alexcrichton I won't have time to work on it this week. If you want to take over, that's fine. |
This comment has been minimized.
This comment has been minimized.
|
Can one then have a static #no_mangle in another rust crate that will |
This comment has been minimized.
This comment has been minimized.
|
@bnoordhuis no worries, and thanks for this initial work! I'll post a PR when I get this implemented. |
bnoordhuis commentedFeb 1, 2014
The first commit adds a #[weak] attribute, the second commit makes src/libstd/rt/thread.rs link weakly against __pthread_get_minstack(). Avoids the dlopen/dlsym/dlclose cycle for new threads that was introduced in commit 431edac.
I imagine it's possible that you first need to build rustc using the first commit before you can build the second commit. I can split this into two pull requests if that is the case.