minio / c2goasm

C to Go Assembly
Apache License 2.0
1.31k stars 110 forks source link

companion '.go' file is missing #2

Closed leonklingele closed 7 years ago

leonklingele commented 7 years ago

Steps to reproduce:

$ cat <<EOF > hello.c
#include <stdio.h>

int main()
{
    printf("Hello World!\n");
    return 0;
}
EOF
$ gcc -S hello.c # produces hello.s
$ c2goasm hello.s hello-go.s
error: companion '.go' file is missing for hello-go.s
$ touch hello-go.go # doesn't help

How to create this companion file and why is it required?

fwessels commented 7 years ago

There is a "wrapping" Go file necessary that will be the interface to call into the assembly version listing the arguments etc. Ie if you look at the example in the README file it is like this:

//go:noescape
func _MultiplyAndAdd(vec1, vec2, vec3, result unsafe.Pointer)

func MultiplyAndAdd(someObj Object) {

    _MultiplyAndAdd(someObj.GetVec1(), someObj.GetVec2(), someObj.GetVec3(), someObj.GetResult()))
}

So the assembly should go to main_amd64.s and the go file should be named `main_amd64.go'.

See also for more examples https://github.com/minio/c2goasm/tree/master/test