On Thu, Oct 27, 2016 at 3:06 PM, Benoît Canet <
benoit.canet.cont...@gmail.com> wrote:

> Go c-shared library main() get ignored by the
> Go runtime at init. main() cannot be //export since the
> c-go .c file already have a main. Fact is that if main()
> is exported in a Go "C" module the C compiler will complain
> that two main are presents.
>
> So this patch declare GoMain as the official OSv go main()
> entry point.

Since the go library init already took argc and
> argv as parameters GoMain does not need to bother with them
> and hence is specific to Go.:
>

I wouldn't say that this is "specific to go".... Sorry for the
resistance... It's just an entry point function to run without arguments
(assuming you get the arguments from somewhere else, or don't need them at
all). You're in fact reusing the concept of "entry_point" which already
existed in the code. So couldn't we just call this function entry_point(),
or osv_entry_point() or something, instead of GoMain? We can have a comment
that this is useful for Go - but it might be used in the future in other
circumstances.

Also, since what you end up doing is setting _entry_point, I wonder if we
really need this patch to choose a fixed name for the entry point, given
that I think the user can choose the entry point when linking the shared
object: with the linker's "-e" option (entry point), we can define which
function (in your case GoMain) is the entry point.  Perhaps something like

      go build -buildmode=c-shared  -ldflags="-extldflags '-e GoMain'"
hello.go

would work? (I didn't test).

-- 
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to osv-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to