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

bootstrap/codegen_ssa: ship llvm-strip and use it for -Cstrip #131405

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

davidtwco
Copy link
Member

Fixes #131206.

  • Includes llvm-strip (a symlink to llvm-objcopy) in the compiler dist artifact so that it can be used for -Cstrip instead of the system tooling.
  • Uses llvm-strip instead of /usr/bin/strip for macOS. macOS needs a specific linker and the system one is preferred, hence Fix up setting strip = true in Cargo.toml makes build scripts fail in… #130781 but that doesn't work when cross-compiling, so use the llvm-strip utility instead.

cc #123151

@rustbot
Copy link
Collaborator

rustbot commented Oct 8, 2024

r? @albertlarsan68

rustbot has assigned @albertlarsan68.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 8, 2024
@davidtwco
Copy link
Member Author

We could make this same change to the illumos and AIX targets which also hardcode a path to a strip binary. Pinging relevant people for those targets to see if this would be desirable.

@ecnelises @bzEq (listed as target maintainers for powerpc64-ibm-aix
@jclulow (we have no target maintainers for the illumos targets in the documentation, but I've seen @jclulow in the issue tracker and I know is involved in illumos)

@rust-log-analyzer

This comment was marked as resolved.

@@ -1151,6 +1151,11 @@ impl<'a> Builder<'a> {
self.ensure(compile::Sysroot::new(compiler))
}

/// Returns the bindir for a compiler's sysroot.
Copy link
Member

Choose a reason for hiding this comment

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

Probably t-bootstrap will have opinions here, because there are 2 "bin" directories 😓

@workingjubilee
Copy link
Member

Thank you for posting this. I tried twice and couldn't even figure out where to start.

@taiki-e
Copy link
Member

taiki-e commented Oct 8, 2024

illumos

AFAIK some change is needed for illumos too because using the default strip binary of Linux host causes a problem (oxidecomputer/helios#147).
However, I have not actually tested to see if using LLVM strip would solve the problem. (This comment may indicate that anything other than native strip utility would not work.)

cc @sunshowers

Comment on lines +1152 to +1162
let mut new_path = sess.get_tools_search_paths(false);
if let Some(path) = env::var_os("PATH") {
new_path.extend(env::split_paths(&path));
}
cmd.env("PATH", env::join_paths(new_path).unwrap());
Copy link
Member

@lqd lqd Oct 8, 2024

Choose a reason for hiding this comment

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

also: it's probably safer to look for rust-objcopy in the tools search path and launch w/ the absolute path cmd rather than overriding the $PATH?

Copy link
Member Author

Choose a reason for hiding this comment

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

It probably is but we override the PATH for rust-lld so I'll keep it this way and we can change both together later.

@jclulow
Copy link
Contributor

jclulow commented Oct 8, 2024

@jclulow (we have no target maintainers for the illumos targets in the documentation, but I've seen @jclulow in the issue tracker and I know is involved in illumos)

Hey, with my apologies, someone pointed this out to me recently and I owe a PR to fix the docs and list some maintainers there.

We could make this same change to the illumos and AIX targets which also hardcode a path to a strip binary. Pinging relevant people for those targets to see if this would be desirable.

When we're running on an illumos host and compiling for an illumos target, we definitely want to use the system strip binary explicitly. If we're cross compiling, either on an illumos host for a non-illumos target, or on a non-illumos host, I don't have a particular preference and we should do whatever is tested to work there.

Does that make sense?

@bzEq
Copy link
Contributor

bzEq commented Oct 8, 2024

Thanks for headsup. On AIX, we are still using /usr/bin/strip. llvm-strip is not compatible with AIX's system strip utility.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Oct 10, 2024
…nnethercote

Fix hardcoded strip path when cross-compiling from Linux to Darwin

Fixes rust-lang#131206.

I fear that rust-lang#131405 might end up taking some time, so opening this PR to resolve the regression.

`@rustbot` label O-apple
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Oct 10, 2024
Rollup merge of rust-lang#131480 - madsmtm:macos-fix-strip-binary, r=nnethercote

Fix hardcoded strip path when cross-compiling from Linux to Darwin

Fixes rust-lang#131206.

I fear that rust-lang#131405 might end up taking some time, so opening this PR to resolve the regression.

`@rustbot` label O-apple
@bors

This comment was marked as resolved.

@davidtwco
Copy link
Member Author

Thanks for headsup. On AIX, we are still using /usr/bin/strip. llvm-strip is not compatible with AIX's system strip utility.

Okay, I've kept AIX's logic as it is, but I have added a warning when cross-compiling that whatever is in /usr/bin/strip may not work because it isn't AIX's system strip.

When we're running on an illumos host and compiling for an illumos target, we definitely want to use the system strip binary explicitly. If we're cross compiling, either on an illumos host for a non-illumos target, or on a non-illumos host, I don't have a particular preference and we should do whatever is tested to work there.

Does that make sense?

That makes sense. I've kept /usr/bin/strip if not cross-compiling, and we'll now use llvm-strip instead of /usr/bin/strip when cross-compiling (that seems more likely to work reliably than relying on whatever /usr/bin/strip could be). I also changed the condition we used here from target.os == "illumos" to target.is_like_solaris, since that's why we have is_like_solaris in the first place. Let me know if that's not correct and there is some difference with stripping between illumos and solaris in general.

Copy link
Member

@albertlarsan68 albertlarsan68 left a comment

Choose a reason for hiding this comment

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

LGTM for the technical side in bootstrap

@albertlarsan68
Copy link
Member

r? t-compiler for the compiler side of things

@rustbot rustbot assigned cjgillot and unassigned albertlarsan68 Oct 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hard-coded strip path breaks Linux -> Darwin builds