Skip to content

Add rudimentary support for __float128 #233

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
Nov 11, 2016

Conversation

fitzgen
Copy link
Member

@fitzgen fitzgen commented Nov 10, 2016

This adds __float128 as a builtin type, and generates an opaque array
of 16 u8s to represent it in the generated bindings since Rust doesn't
have an f128 type.

Context and motivation: Somehow __float128 is getting pulled into
SpiderMonkey headers from somewhere, and the lack of __float128
support was causing bindgen to hard fail in bindings generation.

r? @emilio

#[test]
fn bindgen_test_layout_A() {
assert_eq!(::std::mem::size_of::<A>() , 16usize);
assert_eq!(::std::mem::align_of::<A>() , 16usize);
Copy link
Member Author

Choose a reason for hiding this comment

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

Hmmm.... It seems that this alignment check is failing on Travis CI, but it is working locally. Any ideas, @emilio?

Copy link
Contributor

Choose a reason for hiding this comment

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

I doubt a lot the alignment of f128 is 16. The same happens with complex types and i128 and friends. Land the test commented with a FIXME and with empty expectations, since there's no way of getting a 128-bit aligned value in rust as of right now.

Also, note that layout tests now don't run by default in regen (probably should be changed? I don't know, makes most of the use cases faster), and you need to run cargo test -p tests_expectations.

@jimblandy
Copy link
Contributor

Would it make sense to introduce a fake Rust f128_standin newtype, so that if people come across this, they might be less mystified to find [u8; 16]?

@fitzgen
Copy link
Member Author

fitzgen commented Nov 10, 2016

Would it make sense ...

Perhaps! Depends how easy it is to add newtypes to a prelude before the generated bindings are created. I am least familiar with codegen of all of bindgen's phases so far, so I will let @emilio fill in the gaps (and point me in the right direction if we want to do this).

Copy link
Contributor

@emilio emilio left a comment

Choose a reason for hiding this comment

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

r=me with the constants changed, and the test commented with a FIXME.

I don't think adding a new type for this is necessary given the unlikelyhood of this...

@@ -394,6 +394,7 @@ pub const CXType_ObjCClass: c_uint = 28;
pub const CXType_ObjCSel: c_uint = 29;
pub const CXType_FirstBuiltin: c_uint = 2;
pub const CXType_LastBuiltin: c_uint = 29;
pub const CXType_Float128: c_uint = 30;
Copy link
Contributor

Choose a reason for hiding this comment

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

Please move this before FirstBuiltin and make LastBuiltin 30.

#[test]
fn bindgen_test_layout_A() {
assert_eq!(::std::mem::size_of::<A>() , 16usize);
assert_eq!(::std::mem::align_of::<A>() , 16usize);
Copy link
Contributor

Choose a reason for hiding this comment

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

I doubt a lot the alignment of f128 is 16. The same happens with complex types and i128 and friends. Land the test commented with a FIXME and with empty expectations, since there's no way of getting a 128-bit aligned value in rust as of right now.

Also, note that layout tests now don't run by default in regen (probably should be changed? I don't know, makes most of the use cases faster), and you need to run cargo test -p tests_expectations.

@fitzgen
Copy link
Member Author

fitzgen commented Nov 10, 2016

@emilio fixed per the review comments.

@emilio
Copy link
Contributor

emilio commented Nov 10, 2016

Well, the LastBuiltin value isn't changed, but we don't use it so I don't think it matters a lot. Thanks for doing this! :)

@emilio
Copy link
Contributor

emilio commented Nov 10, 2016

@bors-servo r+

@bors-servo
Copy link

📌 Commit 5e67ceb has been approved by emilio

@bors-servo
Copy link

⌛ Testing commit 5e67ceb with merge 6a2ee60...

bors-servo pushed a commit that referenced this pull request Nov 10, 2016
Add rudimentary support for `__float128`

This adds `__float128` as a builtin type, and generates an opaque array
of 16 `u8`s to represent it in the generated bindings since Rust doesn't
have an `f128` type.

Context and motivation: Somehow `__float128` is getting pulled into
SpiderMonkey headers from somewhere, and the lack of `__float128`
support was causing bindgen to hard fail in bindings generation.

r? @emilio
@fitzgen
Copy link
Member Author

fitzgen commented Nov 10, 2016

Well, the LastBuiltin value isn't changed, but we don't use it so I don't think it matters a lot. Thanks for doing this! :)

That is for loops iterating over all types, and is supposed to be the same as CXType_Float128. I suspect CXType_Float128 just got hidden by CXType_LastBuiltin when clangll.rs was originally generated, since we didn't support overlapping enum variants back than.

//
// struct A {
// __float128 f;
// };
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it make sense to have a global constant __float128 gloablaFloat to test it a bit.
This does not generate layout tests, I think.

Copy link
Contributor

Choose a reason for hiding this comment

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

That struct would generate layout tests, but would fail them.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh I see what you mean, yeah that'd be neat.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good idea, thanks.

@emilio
Copy link
Contributor

emilio commented Nov 10, 2016

@bors-servo r-

Could you do that @fitzgen? Should be a minute. Also, maybe using two u64 instead of multiple u16? not a big deal, but would be closer to the real alignment.

@emilio
Copy link
Contributor

emilio commented Nov 10, 2016

@bors-servo delegate+

@bors-servo
Copy link

✌️ @fitzgen can now approve this pull request

@fitzgen
Copy link
Member Author

fitzgen commented Nov 10, 2016

Also, maybe using two u64 instead of multiple u16? not a big deal, but would be closer to the real alignment.

I originally had it like this, but decided it wasn't actually any better.

@fitzgen
Copy link
Member Author

fitzgen commented Nov 10, 2016

@bors-servo r=emilio

@bors-servo
Copy link

📌 Commit 5e67ceb has been approved by emilio

@emilio
Copy link
Contributor

emilio commented Nov 11, 2016

Bors seems dead, let's try again.

@emilio emilio closed this Nov 11, 2016
@emilio emilio reopened this Nov 11, 2016
@emilio
Copy link
Contributor

emilio commented Nov 11, 2016

@bors-servo r+

@bors-servo
Copy link

📌 Commit db8dc9a has been approved by emilio

@bors-servo
Copy link

⌛ Testing commit db8dc9a with merge e8096ec...

bors-servo pushed a commit that referenced this pull request Nov 11, 2016
Add rudimentary support for `__float128`

This adds `__float128` as a builtin type, and generates an opaque array
of 16 `u8`s to represent it in the generated bindings since Rust doesn't
have an `f128` type.

Context and motivation: Somehow `__float128` is getting pulled into
SpiderMonkey headers from somewhere, and the lack of `__float128`
support was causing bindgen to hard fail in bindings generation.

r? @emilio
@bors-servo
Copy link

💔 Test failed - status-travis

@fitzgen
Copy link
Member Author

fitzgen commented Nov 11, 2016

Looks like CXType_Float128 is llvm 3.9 only. I'll fix and re-push in a few minutes.

@fitzgen
Copy link
Member Author

fitzgen commented Nov 11, 2016

Hmm... So this still builds fine when --features llvm_stable because we just won't ever get a Clang type of kind CXType_Float128 so we have some branches that will never be reached in that case. However, it means that we get (I presume) a CXType_Unexposed or something for the __float128 and the best we can do for it is generate a c_int.

Ideally, we would be able to run certain tests only if we are not --features llvm_stable, but we don't have that infrastructure right now. Nor is adding it economical: we are moving towards the removal of that feature.

Therefore, I'm going to comment the whole test out, and add a FIXME comment for when we remove the llvm_stable feature.

This adds `__float128` as a builtin type, and generates an opaque array
of 16 `u8`s to represent it in the generated bindings since Rust doesn't
have an `f128` type.

Context and motivation: Somehow `__float128` is getting pulled into
SpiderMonkey headers from somewhere, and the lack of `__float128`
support was causing bindgen to hard fail in bindings generation.
@fitzgen
Copy link
Member Author

fitzgen commented Nov 11, 2016

@bors-servo r=emilio

@bors-servo
Copy link

📌 Commit 53f7a50 has been approved by emilio

@bors-servo
Copy link

⌛ Testing commit 53f7a50 with merge c2e7f46...

bors-servo pushed a commit that referenced this pull request Nov 11, 2016
Add rudimentary support for `__float128`

This adds `__float128` as a builtin type, and generates an opaque array
of 16 `u8`s to represent it in the generated bindings since Rust doesn't
have an `f128` type.

Context and motivation: Somehow `__float128` is getting pulled into
SpiderMonkey headers from somewhere, and the lack of `__float128`
support was causing bindgen to hard fail in bindings generation.

r? @emilio
@bors-servo
Copy link

☀️ Test successful - status-travis

@bors-servo bors-servo merged commit 53f7a50 into rust-lang:master Nov 11, 2016
@fitzgen fitzgen deleted the float128 branch November 11, 2016 20:40
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.

6 participants