-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Use platform dependent mcount function #59506
Conversation
|
||
// The function name varies on platforms. | ||
// See test/CodeGen/mcount.c in clang. | ||
let mcount_name = if cfg!(target_os = "netbsd") { |
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.
cfg
is wrong here, because it will be checking for the host (the computer running the compiler) rather than for the target (whatever is intended to run the final executable).
You should be checking for stuff in sess().target
or, even better, make this name a part of target definitions and use that value directly.
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.
make this name a part of target definitions and use that value directly.
The targets are defined in src/librustc_target/spec/
(e.g. like this)? If so, I should add target_mcount
or something in Ok(Target {..})
, right?
https://github.com/rust-lang/rust/blob/master/src/librustc_target/spec/aarch64_unknown_netbsd.rs
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.
If so, I should add target_mcount or something in Ok(Target {..}), right?
Yeah.
use std::ffi::CStr; | ||
let target_mcount = format!("{}{}", | ||
&cx.sess().target.target.options.target_mcount, "\0"); | ||
let mcount_name = CStr::from_bytes_with_nul(target_mcount.as_bytes()).unwrap(); |
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.
@nagisa I couldn't deal with concat!
, so didn't use const_cstr!
. Could you give me advice?
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.
I think you just need to use a CString
here.
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.
Okay, I pushed the change.
r=me on the imeplementation. I think the test is likely to fail if sent to bors now, but I’m fine with sending it if proven otherwise. |
@bors r+ |
📌 Commit aec518a has been approved by |
Use platform dependent mcount function close rust-lang#59097 This pull-request is based on rust-lang#57244 and [here](https://github.com/llvm-mirror/clang/search?q=MCountName&unscoped_MCountName). r? @nagisa
Use platform dependent mcount function close #59097 This pull-request is based on #57244 and [here](https://github.com/llvm-mirror/clang/search?q=MCountName&unscoped_MCountName). r? @nagisa
💔 Test failed - checks-travis |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
@bors r+
…On Sun, Mar 31, 2019, 17:18 Yuki OKUSHI ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In src/librustc_target/spec/x86_64_apple_darwin.rs
<#59506 (comment)>:
> @@ -19,6 +19,9 @@ pub fn target() -> TargetResult {
target_env: String::new(),
target_vendor: "apple".to_string(),
linker_flavor: LinkerFlavor::Gcc,
- options: base,
+ options: TargetOptions {
+ target_mcount: "\01mcount".to_string(),
Okay, I fixed them.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#59506 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AApc0jIPR5Ruc5XqNnyBoVRgnvb_-7K4ks5vcMPMgaJpZM4cRNbz>
.
|
📌 Commit 7b26a43 has been approved by |
Use platform dependent mcount function close rust-lang#59097 This pull-request is based on rust-lang#57244 and [here](https://github.com/llvm-mirror/clang/search?q=MCountName&unscoped_MCountName). r? @nagisa
Rollup of 7 pull requests Successful merges: - #58805 (Lint for redundant imports) - #59506 (Use platform dependent mcount function) - #59519 (rustc_target: factor out common fields of non-Single Variants.) - #59580 (Allow closure to unsafe fn coercion) - #59581 (Stabilize refcell_replace_swap feature) - #59583 (match match match match match) - #59587 (Remove #[doc(hidden)] from Error::type_id) Failed merges: r? @ghost
close #59097
This pull-request is based on #57244 and here.
r? @nagisa