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.:

Signed-off-by: Benoît Canet <ben...@scylladb.com>
---
 core/app.cc | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/core/app.cc b/core/app.cc
index 1e9fddb..a1e8035 100644
--- a/core/app.cc
+++ b/core/app.cc
@@ -186,6 +186,9 @@ application::application(const std::string& command,
 
     _main = _lib->lookup<int (int, char**)>("main");
     if (!_main) {
+        _entry_point = _lib->lookup<void ()>("GoMain");
+    }
+    if (!_main && !_entry_point) {
         _entry_point = reinterpret_cast<void(*)()>(_lib->entry_point());
     }
     if (!_entry_point && !_main) {
-- 
2.7.4

-- 
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