Skip to content

Support platforms without 64-bit atomic types#12

Merged
nicoburns merged 1 commit intoservo:mainfrom
cjwatson:platforms-without-atomic-64
Aug 25, 2025
Merged

Support platforms without 64-bit atomic types#12
nicoburns merged 1 commit intoservo:mainfrom
cjwatson:platforms-without-atomic-64

Conversation

@cjwatson
Copy link
Contributor

@cjwatson cjwatson commented Aug 21, 2025

As explained in https://doc.rust-lang.org/std/sync/atomic/#portability, some platforms don't have 64-bit atomic types. As a result of smallvec being used by pydantic-core, this crate is involved in some dependency chains in Debian where we currently support the armel and powerpc architectures, neither of which have these types.

Since the malloc_size_of_is_0! macro just implements a trait on the types it's called with, it should be fine to skip types that don't exist on the target platform.

Bumps MSRV to 1.60 for #[cfg(target_has_atomic = "...")].

Copy link
Collaborator

@nicoburns nicoburns left a comment

Choose a reason for hiding this comment

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

Makes sense!

@cjwatson cjwatson force-pushed the platforms-without-atomic-64 branch from 496b37d to 70d1eaf Compare August 21, 2025 23:13
@cjwatson
Copy link
Contributor Author

cjwatson commented Aug 21, 2025

Are you OK with MSRV on this? I think #[cfg(target_has_atomic = "...")] was only stabilized in Rust 1.60.0, and your Cargo.toml declares rust-version = "1.56". But the check in .github/workflows/main.yml has toolchain: 1.68, so I'm not entirely sure what's going on there.

@cjwatson
Copy link
Contributor Author

cjwatson commented Aug 21, 2025

Looking through https://crates.io/crates/malloc-size-of/reverse_dependencies, it seems that thin-vec, smallbitvec, and app_units have MSRVs below 1.60. So does this need a major version bump?

(Except I just noticed that the Cargo Book recommends treating MSRV bumps as a minor change, i.e. just a patch version bump for a 0.x crate. Sorry, I'm a bit of a Rust novice.)

As explained in https://doc.rust-lang.org/std/sync/atomic/#portability,
some platforms don't have 64-bit atomic types.  As a result of
`smallvec` being used by `pydantic-core`, this crate is involved in some
dependency chains in Debian where we currently support the armel and
powerpc architectures, neither of which have these types.

Since the `malloc_size_of_is_0!` macro just implements a trait on the
types it's called with, it should be fine to skip types that don't exist
on the target platform.

Bumps MSRV to 1.60 for `#[cfg(target_has_atomic = "...")]`.

Signed-off-by: Colin Watson <cjwatson@debian.org>
@cjwatson cjwatson force-pushed the platforms-without-atomic-64 branch from 70d1eaf to 2aa5096 Compare August 21, 2025 23:29
@nicoburns
Copy link
Collaborator

nicoburns commented Aug 22, 2025

I just noticed that the Cargo Book recommends treating MSRV bumps as a minor change, i.e. just a patch version bump for a 0.x crate

That's still somewhat controversial in the Rust community. And some of our dependent crates do care about MSRV. However, I think we're ok because this MSRV should only kick in for crates enabling the malloc_size_of feature (which should only be Servo/Firefox, neither of which have strict MSRV requirements).

I think I'm going to merge/release this next week though. So I'm around just in case there are fires that need to be put out.

should only kick in for crates enabling the malloc_size_of feature

FYI, I'd expect you to not need to package this crate for the same reason.

@jdm
Copy link
Member

jdm commented Aug 22, 2025

FYI, I'd expect you to not need to package this crate for the same reason.

Yeah, I was struck by this as well. The dependency is disabled by default in smallvec; it would be worth your time to figure out why it's enabled in your case.

@nicoburns nicoburns added this pull request to the merge queue Aug 25, 2025
Merged via the queue into servo:main with commit 7ab6938 Aug 25, 2025
8 checks passed
@cjwatson cjwatson deleted the platforms-without-atomic-64 branch September 2, 2025 23:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants