Skip to content
This repository has been archived by the owner on Jan 24, 2022. It is now read-only.

do not KEEP the .stack_sizes section #186

Merged
merged 1 commit into from
Apr 2, 2019
Merged

do not KEEP the .stack_sizes section #186

merged 1 commit into from
Apr 2, 2019

Conversation

japaric
Copy link
Member

@japaric japaric commented Mar 24, 2019

this undoes PR #118

I found a problem with keeping this section. Turns out that the input
.stack_sizes sections contain references to all functions compiled with -Z emit-stack-sizes (the section contains the addresses of all those functions
after all) so keeping those section prevents the linker from removing any of
those functions. This is not a problem today because -Z emit-stack-sizes is
opt-in and only used to analyze a program.

However, I am proposing a rust-lang/rust PR to build the compiler-builtins
crate with -Z emit-stack-sizes. That change will cause all the functions in
that crate to be kept in binaries that link to cortex-m-rt, regardless of
whether the crate author uses -Z emit-stack-sizes or not, leading a increase
in binary size of about 14 KB (.text section).

To prevent issues with that rust-lang/rust PR I propose we undo PR #118. On the
bright side, the tools that were depending on this (cargo-stack-sizes and
cargo-call-stack) no longer do so in their latest releases so nothing is lost
on the tooling front with this change.

r? @rust-embedded/cortex-m

this undoes PR #118

I found a problem with keeping this section. Turns out that the input
`.stack_sizes` sections contain references to all functions compiled with `-Z
emit-stack-sizes` (the section contains the addresses of all those functions
after all) so keeping those section prevents the linker from removing *any* of
those functions. This is not a problem today because `-Z emit-stack-sizes` is
*opt-in* and only used to analyze a program.

However, I am proposing a rust-lang/rust PR to build the `compiler-builtins`
crate with `-Z emit-stack-sizes`. That change will cause *all* the functions in
that crate to be kept in binaries that link to `cortex-m-rt`, regardless of
whether the crate author uses `-Z emit-stack-sizes` or not, leading a increase
in binary size of about 14 KB (`.text` section).

To prevent issues with that rust-lang/rust PR I propose we undo PR #118. On the
bright side, the tools that were depending on this (`cargo-stack-sizes` and
`cargo-call-stack`) no longer do so in their latest releases so nothing is lost
on the tooling front with this change.
@japaric
Copy link
Member Author

japaric commented Mar 24, 2019

However, I am proposing a rust-lang/rust PR

PR in question: rust-lang/rust#59401

Copy link
Contributor

@therealprof therealprof left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@therealprof
Copy link
Contributor

bors r+

bors bot added a commit that referenced this pull request Mar 24, 2019
186: do not KEEP the .stack_sizes section r=therealprof a=japaric

this undoes PR #118

I found a problem with keeping this section. Turns out that the input
`.stack_sizes` sections contain references to all functions compiled with `-Z
emit-stack-sizes` (the section contains the addresses of all those functions
after all) so keeping those section prevents the linker from removing *any* of
those functions. This is not a problem today because `-Z emit-stack-sizes` is
*opt-in* and only used to analyze a program.

However, I am proposing a rust-lang/rust PR to build the `compiler-builtins`
crate with `-Z emit-stack-sizes`. That change will cause *all* the functions in
that crate to be kept in binaries that link to `cortex-m-rt`, regardless of
whether the crate author uses `-Z emit-stack-sizes` or not, leading a increase
in binary size of about 14 KB (`.text` section).

To prevent issues with that rust-lang/rust PR I propose we undo PR #118. On the
bright side, the tools that were depending on this (`cargo-stack-sizes` and
`cargo-call-stack`) no longer do so in their latest releases so nothing is lost
on the tooling front with this change.

r? @rust-embedded/cortex-m

Co-authored-by: Jorge Aparicio <jorge@japaric.io>
@bors
Copy link
Contributor

bors bot commented Mar 24, 2019

Build failed

@japaric
Copy link
Member Author

japaric commented Mar 25, 2019

compiletest v0.3.19 doesn't compile with the latest nightly. We can either wait or mark the nightly build as allow_fail: true

@therealprof
Copy link
Contributor

@japaric I'm feeling that is the only right thing to do. Using CI on nightly is a total gamble and waste of time.

Centril added a commit to Centril/rust that referenced this pull request Mar 29, 2019
…es, r=alexcrichton

bootstrap: build crates under libtest with -Z emit-stack-sizes

Please see the comment in the diff for the rationale.

This change adds a `.stack_sizes` linker section to `libcompiler_builtins.rlib`
but this section is discarded by the linker by default so it won't affect the
binary size of most programs. It will, however, negatively affect the binary
size of programs that link to a recent release of the `cortex-m-rt` crate
because of the linker script that crate provides, but I have proposed a PR
(rust-embedded/cortex-m-rt#186) to solve the problem (which I originally
introduced :-)).

This change does increase the size of the `libcompiler_builtins.rlib` artifact we
distribute but the increase is in the order of (a few) KBs.

r? @alexcrichton
@korken89
Copy link
Contributor

korken89 commented Apr 2, 2019

@japaric Rebase with master to get CI to pass

@japaric
Copy link
Member Author

japaric commented Apr 2, 2019

@korken89 there are no merge conflicts; bors should work

bors r=therealprof

bors bot added a commit that referenced this pull request Apr 2, 2019
186: do not KEEP the .stack_sizes section r=therealprof a=japaric

this undoes PR #118

I found a problem with keeping this section. Turns out that the input
`.stack_sizes` sections contain references to all functions compiled with `-Z
emit-stack-sizes` (the section contains the addresses of all those functions
after all) so keeping those section prevents the linker from removing *any* of
those functions. This is not a problem today because `-Z emit-stack-sizes` is
*opt-in* and only used to analyze a program.

However, I am proposing a rust-lang/rust PR to build the `compiler-builtins`
crate with `-Z emit-stack-sizes`. That change will cause *all* the functions in
that crate to be kept in binaries that link to `cortex-m-rt`, regardless of
whether the crate author uses `-Z emit-stack-sizes` or not, leading a increase
in binary size of about 14 KB (`.text` section).

To prevent issues with that rust-lang/rust PR I propose we undo PR #118. On the
bright side, the tools that were depending on this (`cargo-stack-sizes` and
`cargo-call-stack`) no longer do so in their latest releases so nothing is lost
on the tooling front with this change.

r? @rust-embedded/cortex-m

Co-authored-by: Jorge Aparicio <jorge@japaric.io>
@bors
Copy link
Contributor

bors bot commented Apr 2, 2019

Build succeeded

@bors bors bot merged commit 8ff305b into master Apr 2, 2019
@bors bors bot deleted the dont-keep-stack-sizes branch April 2, 2019 21:18
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants