Skip to content

add crt-static for android - #2848

Merged
bors merged 2 commits into
rust-lang:masterfrom
Bryanskiy:android-crt-static
Aug 9, 2022
Merged

add crt-static for android#2848
bors merged 2 commits into
rust-lang:masterfrom
Bryanskiy:android-crt-static

Conversation

@Bryanskiy

Copy link
Copy Markdown
Contributor

No description provided.

@rust-highfive

Copy link
Copy Markdown

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Amanieu (or someone else) soon.

Please see the contribution instructions for more information.

@JohnTitor JohnTitor left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Also, it'd be helpful to provide the context/reason for this change.

Comment thread src/lib.rs
Comment on lines -29 to -32
#![cfg_attr(
feature = "rustc-dep-of-std",
feature(native_link_modifiers, native_link_modifiers_bundle)
)]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you explain why this change is necessary?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

native_link_modifiers and native_link_modifiers_bundle are already stable, so these features produce #[warn(stable_features)] in rustc-dep-of-std mode (which turns into an error when building standard library in rust-lang/rust).

@petrochenkov

Copy link
Copy Markdown
Contributor

Also, it'd be helpful to provide the context/reason for this change.

This is the libc part of supporting statically linked executables on Android, the rustc part is rust-lang/rust#99421.

@Amanieu

Amanieu commented Jul 30, 2022

Copy link
Copy Markdown
Member

@bors r+

@bors

bors commented Jul 30, 2022

Copy link
Copy Markdown
Contributor

📌 Commit 64d47e8 has been approved by Amanieu

It is now in the queue for this repository.

@bors

bors commented Jul 30, 2022

Copy link
Copy Markdown
Contributor

⌛ Testing commit 64d47e8 with merge 09afbfb...

bors added a commit that referenced this pull request Jul 30, 2022
@bors

bors commented Jul 30, 2022

Copy link
Copy Markdown
Contributor

💔 Test failed - checks-actions

@Amanieu

Amanieu commented Jul 30, 2022

Copy link
Copy Markdown
Member
  = note: /android/ndk-arm/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: cannot find -lrt
          /android/ndk-arm/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: cannot find -lpthread

Comment thread src/unix/mod.rs
} else if #[cfg(any(target_os = "macos",
target_os = "ios",
target_os = "watchos",
target_os = "android",

@petrochenkov petrochenkov Jul 30, 2022

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

With these changes as is the case of Android without rustc-dep-of-std is never covered, so this line needs to be kept.
Sorry, didn't notice this previously.

@petrochenkov

Copy link
Copy Markdown
Contributor

Does anybody know why libc on musl and redox doesn't link anything at all in regular no-std mode (without rustc-dep-of-std)?
It looks like a bug but people apparently lived with this for years?

@petrochenkov

Copy link
Copy Markdown
Contributor

Implementation for glibc is also incorrect, but in a different way - in regular no-std mode the libraries are linked dynamically even if crt-static is enabled.

@petrochenkov

Copy link
Copy Markdown
Contributor

Ah, I see, all of this is indeed incorrect but cannot be properly fixed on stable version of libc because link time cfg is unstable.
(But unstable features can be used in feature = "rustc-dep-of-std" mode.)

Anyway, this PR is about Android and the least bad thing to do for this target would be to follow what glibc does (i.e. #2848 (comment)).

@Amanieu

Amanieu commented Aug 9, 2022

Copy link
Copy Markdown
Member

@bors r+

@bors

bors commented Aug 9, 2022

Copy link
Copy Markdown
Contributor

📌 Commit d6d7bfd has been approved by Amanieu

It is now in the queue for this repository.

@bors

bors commented Aug 9, 2022

Copy link
Copy Markdown
Contributor

⌛ Testing commit d6d7bfd with merge 4b7908f...

@bors

bors commented Aug 9, 2022

Copy link
Copy Markdown
Contributor

☀️ Test successful - checks-actions, checks-cirrus-freebsd-12, checks-cirrus-freebsd-13, checks-cirrus-freebsd-14
Approved by: Amanieu
Pushing 4b7908f to master...

@bors
bors merged commit 4b7908f into rust-lang:master Aug 9, 2022
@petrochenkov

Copy link
Copy Markdown
Contributor

@Amanieu
Could you make a release?
It's needed to pull this into rust-lang/rust.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants