-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Remove dependency on libgcc-dw2-1.dll from win32 executables. #29177
Changes from 1 commit
1da4662
def917a
c807ff3
bd0cf1b
adce670
145b843
9a71c5c
d710f8b
afc3046
0332ee9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,11 +65,11 @@ pub fn opts() -> TargetOptions { | |
"-nostdlib".to_string(), | ||
), | ||
pre_link_objects_exe: vec!( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you be sure to add a comment for these fields? They'll probably want to point somewhere else, but just an indication about where to find info about what they're doing. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They are explained in the struct definition. Is that not enough? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah I was looking more of a "why are these passed on this platform" moreso than "what does this field do" |
||
"crt2.o".to_string(), | ||
"rsbegin.o".to_string(), | ||
"crt2.o".to_string(), // mingw C runtime initialization for executables | ||
"rsbegin.o".to_string(), // Rust compiler runtime initialization, see rsbegin.rs | ||
), | ||
pre_link_objects_dll: vec!( | ||
"dllcrt2.o".to_string(), | ||
"dllcrt2.o".to_string(), // mingw C runtime initialization for dlls | ||
"rsbegin.o".to_string(), | ||
), | ||
late_link_args: vec!( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -232,6 +232,7 @@ pub mod eabi { | |
} | ||
} | ||
|
||
// See docs in the `unwind` module. | ||
#[cfg(all(target_os="windows", target_arch = "x86", target_env="gnu", not(test)))] | ||
#[lang = "eh_unwind_resume"] | ||
#[unwind] | ||
|
@@ -241,6 +242,10 @@ unsafe extern fn rust_eh_unwind_resume(panic_ctx: *mut u8) -> ! { | |
|
||
#[cfg(all(target_os="windows", target_arch = "x86", target_env="gnu"))] | ||
pub mod eh_frame_registry { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you be sure to add a comment here pointing to a location which documents what this all is? |
||
// The implementation of stack unwinding is (for now) deferred to libgcc_eh, however Rust | ||
// crates use these Rust-specific entry points to avoid potential clashes with GCC runtime. | ||
// See also: rtbegin.rs, `unwind` module. | ||
|
||
#[link(name = "gcc_eh")] | ||
extern { | ||
fn __register_frame_info(eh_frame_begin: *const u8, object: *mut u8); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,8 +8,21 @@ | |
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah ok, so this is about the location that it'd be awesome to have a nice long doc block explaining what this is all doing. Could you add some docs here basically describing the whole scheme for why this works and such? Things like:
etc |
||
// rsbegin.o and rsend.o are the so called "compiler runtime startup objects". | ||
// They contain code needed to correctly initialize the compiler runtime. | ||
// | ||
// When an executable or dylib image is linked, all user code and libraries are | ||
// "sandwiched" between these two object files, so code or data from rsbegin.o | ||
// become first in the respective sections of the image, whereas code and data | ||
// from rsend.o become the last ones. This effect can be used to place symbols | ||
// at the beginning or at the end of a section, as well as to insert any required | ||
// headers or footers. | ||
// | ||
// Note that the actual module entry point is located in the C runtime startup | ||
// object (usually called `crtX.o), which then invokes initialization callbacks | ||
// of other runtime components (registered via yet another special image section). | ||
|
||
#![feature(no_std)] | ||
#![feature(linkage)] | ||
|
||
#![crate_type="rlib"] | ||
#![no_std] | ||
|
@@ -20,27 +33,33 @@ pub mod eh_frames | |
{ | ||
#[no_mangle] | ||
#[link_section = ".eh_frame"] | ||
// Marks beginning of the stack frame unwind info section | ||
pub static __EH_FRAME_BEGIN__: [u8; 0] = []; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So just to clarify, this works because:
Does that sound right? Also out of curiosity, what is the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that's my understanding of how this works.
It's used to support the weight of eh_frame section, thus the extra wide base. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm ok, and by "weight" and "extra wide base" do you mean how There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ...the other reason is that you can't have a static variable (the zero footer) without a name (at least that I know of). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. By extra wide base I meant the underscores :) just kidding :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh dear it looks like my ignorance is leaking, a zero footer makes sense to me! |
||
|
||
// Scratch space for unwinder's internal book-keeping. | ||
// This is defined as `struct object` in $GCC/libgcc/unwind-dw2-fde.h. | ||
static mut obj: [isize; 6] = [0; 6]; | ||
|
||
// Unwind info registration/deregistration routines. | ||
// See the docs of `unwind` module in libstd. | ||
extern { | ||
fn rust_eh_register_frames(eh_frame_begin: *const u8, object: *mut u8); | ||
fn rust_eh_unregister_frames(eh_frame_begin: *const u8, object: *mut u8); | ||
} | ||
|
||
unsafe fn init() { | ||
// register unwind info on module startup | ||
rust_eh_register_frames(&__EH_FRAME_BEGIN__ as *const u8, | ||
&mut obj as *mut _ as *mut u8); | ||
} | ||
|
||
unsafe fn uninit() { | ||
// unregister on shutdown | ||
rust_eh_unregister_frames(&__EH_FRAME_BEGIN__ as *const u8, | ||
&mut obj as *mut _ as *mut u8); | ||
} | ||
|
||
// MSVC-specific init/uninit routine registration | ||
pub mod ms_init | ||
{ | ||
// .CRT$X?? sections are roughly analogous to ELF's .init_array and .fini_array, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this necessary? I thought that
-nodefaultlibs
would do what this comment indicates, and the man pages at least indicate that-nostdlib
means that only the directories on the command line will be searched (e.g. doesn't mention anything about startup files or objects).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My man page's section for
-nostdlib
begins with this exact sentence . I could have used-nostartfiles
since we are also passing-nodefaultlibs
, but just to make sure...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh wait I was looking at the man page for
ld
notgcc
, nevermind!