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

Apple: Do not specify an SDK version in rlib object files #131016

Merged
merged 3 commits into from
Oct 2, 2024

Conversation

madsmtm
Copy link
Contributor

@madsmtm madsmtm commented Sep 29, 2024

This was added in #114114, but is unnecessary, since it ends up being overwritten when linking anyhow, and it feels wrong to embed some arbitrary SDK version in here. The object files produced by LLVM also do not set this, and the tooling shows n/a when it's 0, so it seems to genuinely be optional in object files.

I've also added a test for the different places the SDK version shows up, and documented a bit more in the code how SDK versions work.

See #129432 for the bigger picture.

Tested with (excludes the same few targets as in #130435):

./x test tests/run-make/apple-sdk-version --target aarch64-apple-darwin,aarch64-apple-ios,aarch64-apple-ios-macabi,aarch64-apple-ios-sim,aarch64-apple-tvos,aarch64-apple-tvos-sim,aarch64-apple-visionos,aarch64-apple-visionos-sim,aarch64-apple-watchos,aarch64-apple-watchos-sim,arm64_32-apple-watchos,armv7k-apple-watchos,armv7s-apple-ios,x86_64-apple-darwin,x86_64-apple-ios,x86_64-apple-ios-macabi,x86_64-apple-tvos,x86_64-apple-watchos-sim,x86_64h-apple-darwin
IPHONEOS_DEPLOYMENT_TARGET=10.0 ./x test tests/run-make/apple-sdk-version --target=i386-apple-ios

CC @BlackHoleFox, you originally commented on these values.

@rustbot label O-apple

@rustbot
Copy link
Collaborator

rustbot commented Sep 29, 2024

r? @jieyouxu

rustbot has assigned @jieyouxu.
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 A-run-make Area: port run-make Makefiles to rmake.rs O-apple Operating system: Apple (macOS, iOS, tvOS, visionOS, watchOS) S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 29, 2024
@rustbot
Copy link
Collaborator

rustbot commented Sep 29, 2024

This PR modifies tests/run-make/. If this PR is trying to port a Makefile
run-make test to use rmake.rs, please update the
run-make port tracking issue
so we can track our progress. You can either modify the tracking issue
directly, or you can comment on the tracking issue and link this PR.

cc @jieyouxu

These commits modify compiler targets.
(See the Target Tier Policy.)

This is unnecessary, since it ends up being overwritten when linking
anyhow, and it feels wrong to embed some arbitrary SDK version in here.
Copy link
Member

@jieyouxu jieyouxu left a comment

Choose a reason for hiding this comment

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

Thanks, the changes look reasonable to me but I'll wait for other apple target maintainers to double-check. I have one question regarding the test.

Comment on lines +70 to +75
// Test with clang
let file_name = format!("foo_cc{file_ext}");
rustc()
.target(target())
.crate_type("bin")
.arg("-Clinker-flavor=gcc")
Copy link
Member

Choose a reason for hiding this comment

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

Question: is this comment or arg accurate, the comment says clang, but linker-flavor is gcc?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The comment is mostly accurate, it tests with cc, which is basically always Clang on Apple platforms, it's just how the linker-flavor option works.

@jieyouxu
Copy link
Member

Should this get relnotes? Even if it doesn't technically change how object file SDK version is treated if I understand this correctly.

@madsmtm
Copy link
Contributor Author

madsmtm commented Sep 29, 2024

Thanks, the changes look reasonable to me but I'll wait for other apple target maintainers to double-check. I have one question regarding the test.

I'll tag @thomcc as well then.

Should this get relnotes? Even if it doesn't technically change how object file SDK version is treated if I understand this correctly.

This is only used inside create_object_file, and that, in turn, is only used for constructing rlibs. So no, it doesn't make sense to relnote, the difference is only observable if you manually unarchive the rlib (and the format of that is explicitly unspecified).

@madsmtm madsmtm changed the title Apple: Do not specify an SDK version in object files Apple: Do not specify an SDK version in rlib object files Sep 29, 2024
Copy link
Contributor

@BlackHoleFox BlackHoleFox left a comment

Choose a reason for hiding this comment

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

Nice PR, everything looks fine to me and more test coverage too.

I did indeed comment on the original values because Magic Numbers are odd, but it was harmless in removing a linker warning with no actual cost beyond a strangeness factor. I didn't dig in very far (should have looked at LLVM like you did). Since it turns out the SDK version is actually optional at this stage of linking, there doesn't appear to be any good reason left for rustc to carry that added strange.

@jieyouxu
Copy link
Member

jieyouxu commented Oct 2, 2024

Thanks @BlackHoleFox . In that case,

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Oct 2, 2024

📌 Commit 6b06ceb has been approved by jieyouxu

It is now in the queue for this repository.

@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 Oct 2, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 2, 2024
…iaskrgr

Rollup of 7 pull requests

Successful merges:

 - rust-lang#130863 (Relax a debug assertion for dyn principal *equality* in codegen)
 - rust-lang#131016 (Apple: Do not specify an SDK version in `rlib` object files)
 - rust-lang#131140 (Handle `rustc_hir_analysis` cases of `potential_query_instability` lint)
 - rust-lang#131141 (mpmc doctest: make sure main thread waits for child threads)
 - rust-lang#131150 (only query `params_in_repr` if def kind is adt)
 - rust-lang#131151 (Replace zero-width whitespace with a visible `\` in the PR template)
 - rust-lang#131152 (Improve const traits diagnostics for new desugaring)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 5fd6218 into rust-lang:master Oct 2, 2024
6 checks passed
@rustbot rustbot added this to the 1.83.0 milestone Oct 2, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Oct 2, 2024
Rollup merge of rust-lang#131016 - madsmtm:no-sdk-version-in-object, r=jieyouxu

Apple: Do not specify an SDK version in `rlib` object files

This was added in rust-lang#114114, but is unnecessary, since it ends up being overwritten when linking anyhow, and it feels wrong to embed some arbitrary SDK version in here. The object files produced by LLVM also do not set this, and the tooling shows `n/a` when it's `0`, so it seems to genuinely be optional in object files.

I've also added a test for the different places the SDK version shows up, and documented a bit more in the code how SDK versions work.

See rust-lang#129432 for the bigger picture.

Tested with (excludes the same few targets as in rust-lang#130435):
```console
./x test tests/run-make/apple-sdk-version --target aarch64-apple-darwin,aarch64-apple-ios,aarch64-apple-ios-macabi,aarch64-apple-ios-sim,aarch64-apple-tvos,aarch64-apple-tvos-sim,aarch64-apple-visionos,aarch64-apple-visionos-sim,aarch64-apple-watchos,aarch64-apple-watchos-sim,arm64_32-apple-watchos,armv7k-apple-watchos,armv7s-apple-ios,x86_64-apple-darwin,x86_64-apple-ios,x86_64-apple-ios-macabi,x86_64-apple-tvos,x86_64-apple-watchos-sim,x86_64h-apple-darwin
IPHONEOS_DEPLOYMENT_TARGET=10.0 ./x test tests/run-make/apple-sdk-version --target=i386-apple-ios
```

CC `@BlackHoleFox,` you [originally commented on these values](rust-lang#114114 (comment)).

`@rustbot` label O-apple
@madsmtm madsmtm deleted the no-sdk-version-in-object branch October 2, 2024 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-run-make Area: port run-make Makefiles to rmake.rs O-apple Operating system: Apple (macOS, iOS, tvOS, visionOS, watchOS) S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

5 participants