-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Labels
area-vmUse area-vm for VM related issues, including code coverage, and the AOT and JIT backends.Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends.library-ffi
Description
Given a dart file
@FfiNative<Int64 Function(Int64, Int64)>("FfiNative_Sum", isLeaf:true)
external int sum(int a, int b);
main(){
print(sum(40, 2));
}
And a C file:
#include <stdint.h>
uint64_t FfiNative_Sum(uint64_t a, uint64_t b) { return a + b; }
It should be possible to compile this to a pc relative call if we use the native linker.
- Compile the dart program to a (a) an assembly file with a
call FfiNative_Sum
or (b) to an ELF file with relocation records (a static library in ELF format rather than a dynamic library in ELF format). - Compile the C program to a relocatable file (static library or object file).
- Link them together with the native linker to a dynamic library in ELF format.
- Run with dartaotruntime passing in the dynamic library or appending it.
There is a huge design space.
For example we should add asset
tags to disambiguate native symbols.
And we could use the same syntax for dynamic linking using these assets.
I will not write these up here, but wanted to have a bug to point to.
simc, GZGavinZhao, TimWhiting, safasofuoglu, GregoryConrad and 13 more
Metadata
Metadata
Assignees
Labels
area-vmUse area-vm for VM related issues, including code coverage, and the AOT and JIT backends.Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends.library-ffi