Skip to content

C abi compatability #10

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

Closed
5 of 7 tasks
bjorn3 opened this issue Aug 11, 2018 · 4 comments · Fixed by #1131
Closed
5 of 7 tasks

C abi compatability #10

bjorn3 opened this issue Aug 11, 2018 · 4 comments · Fixed by #1131
Labels
A-abi Area: ABI handling C-enhancement Category: An issue proposing an enhancement or a PR with one. help wanted Extra attention is needed
Milestone

Comments

@bjorn3
Copy link
Member

bjorn3 commented Aug 11, 2018

  • Don't pass return pointer for unit return type (419cbcb)
  • Make sure every type has the correct PassMode
    • Return !
    • Option<fn(..)>
    • layout.abi = Abi::ByValPair (3f15b0a)
    • Abi::ScalarPair + non rust abis
  • Find out correct way of passing Abi::ByRef values. (ptr or stack offset)
@bjorn3 bjorn3 added this to the MVP milestone Aug 11, 2018
@bjorn3

This comment has been minimized.

@bjorn3 bjorn3 added the C-enhancement Category: An issue proposing an enhancement or a PR with one. label Aug 20, 2019
@bjorn3
Copy link
Member Author

bjorn3 commented Aug 20, 2019

@bjorn3
Copy link
Member Author

bjorn3 commented Aug 20, 2019

Find out correct way of passing Abi::ByRef values. (ptr or stack offset)

It needs to be stored at a certain stack offset.

@bjorn3 bjorn3 added the A-abi Area: ABI handling label Aug 21, 2019
@bjorn3
Copy link
Member Author

bjorn3 commented Aug 21, 2019

Found another problem:

use std::os::raw::*;

#[repr(C)]
pub struct Sel {
    ptr: *const c_void,
}

extern {
    pub fn sel_registerName(name: *const c_char) -> Sel;
}

pub unsafe fn call_register_name(res: &mut Sel) {
    *res = sel_registerName(0 as *const _)
}

Uses a return pointer to return Sel instead of returning it in a register.

Expected:

playground::call_register_name:
	pushq	%rbx
	movq	%rdi, %rbx
	xorl	%edi, %edi
	callq	*sel_registerName@GOTPCREL(%rip)
	movq	%rax, (%rbx)
	popq	%rbx
	retq

This causes the objc crate to misbehave.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-abi Area: ABI handling C-enhancement Category: An issue proposing an enhancement or a PR with one. help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant