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

codegen: Use target pointer size consistently for layout calculations #1289

Merged
merged 8 commits into from Apr 3, 2018

Conversation

emilio
Copy link
Contributor

@emilio emilio commented Mar 31, 2018

Assuming new enough libclang, this PR makes cross-compilation do layout calculations properly.

Fixes #1284

@highfive
Copy link

warning Warning warning

  • These commits modify unsafe code. Please review it carefully!

@emilio
Copy link
Contributor Author

emilio commented Mar 31, 2018

r? @fitzgen or @pepyakin

@emilio emilio force-pushed the target-stuff branch 3 times, most recently from e7d8082 to b69ecbf Compare March 31, 2018 12:43
Copy link
Member

@fitzgen fitzgen left a comment

Choose a reason for hiding this comment

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

Nice!

let triple;
let pointer_width;
unsafe {
let ti = clang_getTranslationUnitTargetInfo(tu.x);
Copy link
Member

Choose a reason for hiding this comment

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

Oh, nice -- this is the API you sent patches upstream to add, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right :)

len;
field_layout.align = mem::size_of::<*mut ()>();
// access, since they won't be properly aligned, but there's not too
// much we can do about it.
Copy link
Member

Choose a reason for hiding this comment

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

For posterity, we can use #[repr(align(..))] to fix this ultra hack now (given a new enough target rust).

@@ -1,36 +1,60 @@
set -ex
set -e
Copy link
Member

Choose a reason for hiding this comment

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

I think having -x is useful for debugging CI runs -- is there a particular reason you removed it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not really, the script was taken from clang-sys, and they removed it upstream. But I'll re-add.

@emilio
Copy link
Contributor Author

emilio commented Apr 3, 2018

@bors-servo r=fitzgen

@bors-servo
Copy link

📌 Commit de0d850 has been approved by fitzgen

@bors-servo
Copy link

⌛ Testing commit de0d850 with merge 0166f4a...

bors-servo pushed a commit that referenced this pull request Apr 3, 2018
codegen: Use target pointer size consistently for layout calculations

Assuming new enough libclang, this PR makes cross-compilation do layout calculations properly.

Fixes #1284
@bors-servo
Copy link

☀️ Test successful - status-travis
Approved by: fitzgen
Pushing 0166f4a to master...

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.

None yet

4 participants