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

uclibc/mips: fixed SA_* mismatched types #3211

Merged
merged 1 commit into from
Nov 20, 2024
Merged

Conversation

cppcoffee
Copy link
Contributor

@cppcoffee cppcoffee commented Apr 21, 2023

use ulong type uniformly.

@rustbot
Copy link
Collaborator

rustbot commented Apr 21, 2023

r? @JohnTitor

(rustbot has picked a reviewer for you, use r? to override)

@cppcoffee
Copy link
Contributor Author

cppcoffee commented Apr 21, 2023

The following error occurs when compiling nix crate on the uclibc/mips platform:

error[E0308]: mismatched types
   --> /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/nix-0.24.3/src/macros.rs:70:35
    |
70  |                       const $Flag = libc::$Flag $(as $cast)*;
    |                                     ^^^^^^^^^^^ expected `u32`, found `i32`
    |
   ::: /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/nix-0.24.3/src/sys/signal.rs:436:1
    |
436 | / libc_bitflags!{
437 | |     /// Controls the behavior of a [`SigAction`]
438 | |     #[cfg_attr(docsrs, doc(cfg(feature = "signal")))]
439 | |     pub struct SaFlags: SaFlags_t {
...   |
461 | |     }
462 | | }
    | |_- in this macro invocation
    |
    = note: this error originates in the macro `libc_bitflags` (in Nightly builds, run with -Z macro-backtrace for more info)

I found the uclibc/arm definition of SA_* using the ulong type: https://github.com/rust-lang/libc/blob/master/src/unix/linux_like/linux/uclibc/arm/mod.rs#L472-L478

Modified to use ulong type uniformly, can compile nix now.

Please review it.

@JohnTitor
Copy link
Member

JohnTitor commented Apr 21, 2023

This is a breaking change and I'd recommend deprecating them first to inform users. Read our policy: https://github.com/rust-lang/libc/blob/master/CONTRIBUTING.md#breaking-change-policy

@cppcoffee
Copy link
Contributor Author

Hi @JohnTitor , deprecated attribute has been added, please review it.

@JohnTitor
Copy link
Member

Please do not change their types, also it'd be great if could squash commits into one once it's done!

@cppcoffee
Copy link
Contributor Author

Hi @JohnTitor , Does that mean adding only the deprecated attribute?

@JohnTitor
Copy link
Member

Yes, we should inform users that we're going to introduce a breaking change before actually doing so. By this users can prepare that change and we can prevent their code from being broken.

@cppcoffee
Copy link
Contributor Author

Hi @JohnTitor , Add deprecated attribute only, please review.

@cppcoffee
Copy link
Contributor Author

Hi @JohnTitor , change label status to S-waiting-to-review please.

@JohnTitor
Copy link
Member

JohnTitor commented Nov 2, 2023

Sorry for the absence!
I am considering adding a Cargo feature to cfg breaking changes so that we no longer have to misuse the deprecation attribute. Give me some time to make it.
Meanwhile, could you do a rebase instead of merging?

@cppcoffee
Copy link
Contributor Author

OK, I'll take care of it when I can rebase it.

@tgross35
Copy link
Contributor

@cppcoffee could you squash this so it drops the merge commits? Looks like this

# Assuming this repo (rust-lang, not your fork) is called `upstream`
git fetch upstream

git rebase -i upstream/main
# This command opens an editor. For everything EXCEPT the first line,
# replace `pick` with `f` or `fixup`.
#
# There might not actually be any lines besides the first here, if not
# just close it.
#
# When you close the editor, it will have combined the commits.

# Resolve conflicts if needed, follow the instructions it gives

# Push to this branch with the new history
git push --force-with-lease

Also a couple different ways to do it here https://stackoverflow.com/questions/5189560/how-do-i-squash-my-last-n-commits-together


I will backport only this PR (to target stable, 0.2) but as soon as it merges, you can create a new PR doing the actual fix (which will be in 1.0 when that happens). I opened #3887 to make sure we don't forget this.

@rustbot label +stable-nominated

@rustbot rustbot added the stable-nominated This PR should be considered for cherry-pick to libc's stable release branch label Aug 29, 2024
@tgross35
Copy link
Contributor

Hey @cppcoffee, thank you for updating but this needs a rebase and squash - not merge (no merge commits policy). Could you try to follow the instructions from my comment? If that doesn't work then let me know and I can help you figure it out (or worst case I can do it for you, but I think you should be able to get it working).

@cppcoffee
Copy link
Contributor Author

cppcoffee commented Aug 30, 2024

PR rebase done.

@tgross35
Copy link
Contributor

tgross35 commented Aug 30, 2024

@cppcoffee thank you for getting this up to date. Unfortunately after some digging, it seems like this wouldn't be correct - see #3887 (comment).

What would be correct is to change all the SA_* constants to be ::c_uint on mips ulibc. And then open an issue/PR to nix to do the same. If this sounds right, could you update this PR to do that?

You can just do the actual change without deprecation notices, it just won't get released until 1.0.

@cppcoffee
Copy link
Contributor Author

Oh, it looks like nix is using the wrong type.

@cppcoffee
Copy link
Contributor Author

cppcoffee commented Sep 15, 2024

Hi @tgross35, Use the c_uint type for SA_*, changed now.

@tgross35
Copy link
Contributor

tgross35 commented Sep 17, 2024

LGTM, but please rebase and squash (and update the title/description).

Comment @rustbot review once that is done so it gets back into my queue.

@tgross35
Copy link
Contributor

@cppcoffee could you rebase and squash as mentioned above?

@cppcoffee
Copy link
Contributor Author

rebase and squash done.

@tgross35
Copy link
Contributor

Thanks! There are some CI issues but it's not related to your changes.

@tgross35 tgross35 enabled auto-merge November 20, 2024 09:06
@tgross35 tgross35 added this pull request to the merge queue Nov 20, 2024
Merged via the queue into rust-lang:main with commit 78598d2 Nov 20, 2024
45 checks passed
tgross35 pushed a commit to tgross35/rust-libc that referenced this pull request Nov 21, 2024
Signed-off-by: Xiaobo Liu <[email protected]>

(backport <rust-lang#3211>)
(cherry picked from commit e8f54bb)
@tgross35 tgross35 mentioned this pull request Nov 21, 2024
@tgross35 tgross35 added stable-applied This PR has been cherry-picked to libc's stable release branch and removed stable-nominated This PR should be considered for cherry-pick to libc's stable release branch labels Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
O-linux O-mips O-unix S-waiting-on-ci stable-applied This PR has been cherry-picked to libc's stable release branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants