Skip to content
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

Add --enable-debug flag to musl CI build script #49849

Merged
merged 1 commit into from
Apr 12, 2018
Merged

Add --enable-debug flag to musl CI build script #49849

merged 1 commit into from
Apr 12, 2018

Conversation

alecmocatta
Copy link
Contributor

Building for x86_64-unknown-linux-musl currently results in an executable lacking debug information for musl libc itself. If you request a backtrace in GDB while control flow is within musl – including sycalls made by musl – the result looks like:

#0  0x0000000000434b46 in __cp_end ()
#1  0x0000000000432dbd in __syscall_cp_c ()
#2  0x0000000000000000 in ?? ()

i.e. not very helpful. Adding --enable-debug resolves this, and --enable-optimize re-enables optimisations which default to off given the previous flag.

Building for x86_64-unknown-linux-musl currently results in an executable lacking debug information for musl libc itself. If you request a backtrace in GDB while control flow is within musl – including sycalls made by musl – the result looks like:

#0  0x0000000000434b46 in __cp_end ()
#1  0x0000000000432dbd in __syscall_cp_c ()
#2  0x0000000000000000 in ?? ()

i.e. not very helpful. Adding --enable-debug resolves this, and --enable-optimize re-enables optimisations which default to off given the previous flag.
@pietroalbini
Copy link
Member

Thanks for this PR! The triage team will periodically check in to make sure this PR is reviewed.

r? @alexcrichton

@pietroalbini pietroalbini added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 10, 2018
@alexcrichton
Copy link
Member

Thanks for this! To confirm, you've tested the resulting binaries and they're optimized correctly and have debug information?

Also are there other settings that this implies? I'd just wanna make sure that things like malloc and memcpy don't tank in performance by accident

@alecmocatta
Copy link
Contributor Author

Yes I have indeed been running the resulting binaries, and they do indeed have debug info and are optimised:

(gdb) bt
#0  __syscall () at src/internal/x86_64/syscall.s:13
#1  0x000000000045e3f8 in nanosleep (req=<optimized out>, rem=<optimized out>) at src/time/nanosleep.c:7
#2  0x0000000000445833 in std::sys::unix::thread::Thread::sleep::h5a6a14352632043c ()
#3  0x000000000040032b in x::main::h33e0397ddc129856 ()
#4  0x0000000000400403 in std::rt::lang_start::_$u7b$$u7b$closure$u7d$$u7d$::h7e9e7f9d5763a160 ()
#5  0x000000000043f6f3 in std::panicking::try::do_call::h652c91b274df4c69 ()
#6  0x000000000045017a in __rust_maybe_catch_panic ()
#7  0x000000000043e5d7 in std::rt::lang_start_internal::h2e87c2c21b125ac0 ()
#8  0x00000000004003e7 in std::rt::lang_start::h57093f2887229336 ()
#9  0x000000000040034e in main ()

@alecmocatta
Copy link
Contributor Author

alecmocatta commented Apr 11, 2018

I also just sanity checked memcpy performance against apt-installed x86_64-unknown-linux-gnu, and it is indeed comparable:

$ rustc --target x86_64-unknown-linux-gnu -C opt-level=3 ./x.rs && ./x
Duration { secs: 2, nanos: 8780924 }

$ rustc --target x86_64-unknown-linux-musl -C opt-level=3 ./x.rs && ./x
Duration { secs: 2, nanos: 364127222 }
fn main() {
	let mut x: Vec<u8> = Vec::with_capacity(1_000_000_000);
	let mut y: Vec<u8> = Vec::with_capacity(x.capacity()); unsafe{y.set_len(x.capacity())};
	let time = std::time::Instant::now();
	for i in 0..x.capacity() {
		x.push(i as u8);
	}
	unsafe{memcpy(&mut x[0], &y[0], x.capacity())};
	println!("{:?}", time.elapsed());
}

@alexcrichton
Copy link
Member

@bors: r+

Ok great, thanks for verifying!

@bors
Copy link
Contributor

bors commented Apr 11, 2018

📌 Commit 18e9532 has been approved by alexcrichton

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 11, 2018
kennytm added a commit to kennytm/rust that referenced this pull request Apr 11, 2018
Add --enable-debug flag to musl CI build script

Building for x86_64-unknown-linux-musl currently results in an executable lacking debug information for musl libc itself. If you request a backtrace in GDB while control flow is within musl – including sycalls made by musl – the result looks like:

```
#0  0x0000000000434b46 in __cp_end ()
#1  0x0000000000432dbd in __syscall_cp_c ()
rust-lang#2  0x0000000000000000 in ?? ()
```

i.e. not very helpful. Adding --enable-debug resolves this, and --enable-optimize re-enables optimisations which default to off given the previous flag.
bors added a commit that referenced this pull request Apr 11, 2018
Rollup of 14 pull requests

Successful merges:

 - #49525 (Use sort_by_cached_key where appropriate)
 - #49575 (Stabilize `Option::filter`.)
 - #49614 (in which the non-shorthand patterns lint keeps its own counsel in macros)
 - #49665 (Small nits to make couple of tests pass on mips targets.)
 - #49781 (add regression test for #16223 (NLL): use of collaterally moved value)
 - #49795 (Properly look for uninhabitedness of variants in niche-filling check)
 - #49809 (Stop emitting color codes on TERM=dumb)
 - #49856 (Do not uppercase-lint #[no_mangle] statics)
 - #49863 (fixed typo)
 - #49857 (Fix "fp" target feature for AArch64)
 - #49849 (Add --enable-debug flag to musl CI build script)
 - #49734 (proc_macro: Generalize `FromIterator` impl)
 - #49730 (Fix ICE with impl Trait)
 - #48270 (Replace `structurally_resolved_type` in casts check.)

Failed merges:
@bors bors merged commit 18e9532 into rust-lang:master Apr 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants