Wow, that is really awesome, thank you!

---
gapfruit AG
Baarerstrasse 135
6300 Zug
+41 762 444 560
sergey.platonov@gapfruit.com


On 17.12.2021 12:01, Alexander Tormasov via users wrote:

I have a progress in porting of golang from gcc 10.3 to genode 21.11.
Seems that now it suitable for external testing.

More details in
https://github.com/tor-m6/genode-world/blob/21.11/src/test/go_app/README.golang

In particular, it is possible to run most of the golang programs, including tcp network (http server from net/http package) in SMP mode (tested on 4 cpu) on genode for nova, foc and linux, run inside qemu (or on linux), for x86_64. May be some other platforms works as well (except sel4- see below).

To run you need 2 repos:
https://github.com/tor-m6/genode.git
Need to checkout 21.11 branch - while it have only one commit introducing .go as a target for compilation.

support code is in repos/world (don’t forget to uncomment it)
https://github.com/tor-m6/genode-world.git
(Need to checkout 21.11 branch)

I successfully run some tests with channels/async goroutines - some of them (Like Hanoi towers or barber serving) inside
https://github.com/tor-m6/genode-world/blob/21.11/src/test/go_app/main.go

also you can run network code like this:

package main

import (
    "fmt"
    "log"
    "net/http"
)

func main() {

    http.HandleFunc("/", HelloServer)
    fmt.Println("Server started at port 80")
    log.Fatal(http.ListenAndServe(":80", nil))
}

func HelloServer(w http.ResponseWriter, r *http.Request) {
    fmt.Fprintf(w, "Hello, %s!\n", r.URL.Path[1:])
}


Future plan:
- add arm64 support
- check sel4 problem
- add automated generation of part of run file (all shared libs/binaries need to appears in appropriate places to unwind process works correctly)
- check performance problems on sel4 and foc (probably timeouts/timer, waits too long in the very beginning)
- try to integrate it in native mode to create workable «go build» code inside genode as native compilation.

Note1: currently it can’t run on x86_64 sel4 because during initial golang stack unwind process it touch stack guard page, deeply inside _Unwind_Backtrace libgcc function (not sure why - probably this is compiler flags/optimisation issue). Once I have workable version with different debug options…

Note2: May be it worth to add patch below permanently to main genode?

diff --git a/repos/base/mk/generic.mk b/repos/base/mk/generic.mk
index 66e5c309c..aea75e342 100644
--- a/repos/base/mk/generic.mk
+++ b/repos/base/mk/generic.mk
@@ -7,7 +7,7 @@
 # Collect object files and avoid duplicates (by using 'sort')
 #
 SRC_O  += $(addprefix binary_,$(addsuffix .o,$(notdir $(SRC_BIN))))
-SRC     = $(sort $(SRC_C) $(SRC_CC) $(SRC_ADB) $(SRC_ADS) $(SRC_RS) $(SRC_S) $(SRC_O))
+SRC     = $(sort $(SRC_C) $(SRC_CC) $(SRC_ADB) $(SRC_ADS) $(SRC_RS) $(SRC_S) $(SRC_O) $(SRC_GO))
 OBJECTS = $(addsuffix .o,$(basename $(SRC)))

 #
@@ -69,6 +69,16 @@ endif
        $(MSG_ASSEM)$@
        $(VERBOSE)$(CC) $(CC_DEF) $(CC_C_OPT) $(INCLUDES) -c $< -o $@

+#
+# Compiling Go sources
+#
+%.o: %.go
+       $(MSG_COMP)$@
+       $(VERBOSE)$(GOLANG) $(CUSTOM_GO_FLAGS) -c -o $@ $<
+
+CUSTOM_GO      ?= $(CROSS_DEV_PREFIX)gccgo
+GOLANG   = $(CUSTOM_GO)
+
 #
 # Compiling Ada source codes
 #

_______________________________________________
Genode users mailing list
users@lists.genode.org
https://lists.genode.org/listinfo/users