Skip to content

Documentation: Remove warning that nonstandard primitive type sizes may reveal LLVM bugs #58262

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

Merged
merged 1 commit into from
May 13, 2025

Conversation

PatrickHaecker
Copy link
Contributor

Only primitive types which are a multiple of 8 bits in size can be constructed. Therefore, the documentation should not speculate about possible bugs in other non-reachable cases.

Additionally, it's not clear whether these LLVM bugs still exist now that C allows all integers sizes.

Only primitive types which are a multiple of 8 bits in size can be constructed. Therefore, the documentation should not speculate about possible bugs in other non-reachable cases.

Additionally, it's not clear whether these LLVM bugs still exist now that C allows all integers sizes.
@oscardssmith
Copy link
Member

It would be pretty nice if we could enable support for arbitrary size primitive types. LLVM should be able to do so now that C Rust and Zig all support it.

@PatrickHaecker
Copy link
Contributor Author

PatrickHaecker commented Apr 29, 2025

Yes, this would be nice, but unfortunately out-of-scope for this PR.

Arbitrary bit sized primitives need at least two large changes to be really useful (each worth at least one separate PR):

  • switching all the size logic to not only account bytes, but allow for accounting bits – this is not only a huge change, but might make things slower and/or remove support for very large sizes
  • packing fields closer than what C does, because otherwise padding typically makes all potential space savings void, e.g. a struct consisting of an Int24 and an Int8 results in a 64 bit field with the C memory layout which Julia follows.

I am currently working on two packages which would mostly circumvent these issues. However, I need to clarify whether we'll open-source them.

@inkydragon inkydragon added docs This change adds or pertains to documentation types and dispatch Types, subtyping and method dispatch labels Apr 29, 2025
Copy link
Member

@LilithHafner LilithHafner left a comment

Choose a reason for hiding this comment

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

"Sizes used above" refers to 2 .^ (3:7), so the clause this PR removes isn't about multiples of 8 bits but about sizes that are larger or not powers of 2.

An accurate title for this PR would be "Remove warning that nonstandard primitive type sizes may reveal LLVM bugs"

@PatrickHaecker
Copy link
Contributor Author

Yes, this would be nice, but unfortunately out-of-scope for this PR.

Maybe I was too fast. Supporting arbitrary sized primitives which have a byte-sized sizeof might actually be possible within the scope of this PR (I have not evaluated this). It would mean that there would be no space savings at all and all we would get would be the modular arithmetic.

It would open a can of worms for discussions about how widen should work and whether all the types need to be defined by the user and what to do about signed when only the unsigned type is defined, but at least it would be a step in the direction of implementing them in Base. Would that be seen as useful?

This could make one of the two mentioned packages obsolete in the long run.

@PatrickHaecker PatrickHaecker changed the title Documentation: primitive type needs multiple of 8 bits Documentation: Remove warning that nonstandard primitive type sizes may reveal LLVM bugs Apr 29, 2025
@LilithHafner
Copy link
Member

Is this not already supported?

julia> primitive type T 24 end

julia> sizeof(T)
3

@oscardssmith
Copy link
Member

What we're talking about here is primitive type T 23 end

Copy link
Member

@rfourquet rfourquet left a comment

Choose a reason for hiding this comment

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

The deleted comment used to be true, but I'm not aware of current LLVM (or Julia) bugs with these primitive types.

@LilithHafner LilithHafner merged commit 3fc2a15 into JuliaLang:master May 13, 2025
8 of 10 checks passed
@oscardssmith oscardssmith added the revert This reverts a previously merged PR. label May 16, 2025
@oscardssmith
Copy link
Member

well that was quick. Turns out there are still plenty of bugs here.

@LilithHafner
Copy link
Member

The label for this is "reverted" but not yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs This change adds or pertains to documentation types and dispatch Types, subtyping and method dispatch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants