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.gol...
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 #
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.gol...
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
Hi Alexander,
congratulations for this great achievement, and thank you for sharing your work!
Even though I'm unable to give meaningful feedback regarding Go, I'm very happy that you found ways to avoid patching Genode's main repository. Thank you for having taken our earlier feedback wrt to the libc to heart.
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.
Hats off for your perseverance and for your further planning.
The initial delay of the seL4 version possibly depends on the amount of physical memory used. At boot time, physical memory gets converted into seL4 kernel objects in [1] (if I remember right). To see the effect, you may try tweaking the Qemu's -m argument.
[1] https://github.com/genodelabs/genode/blob/master/repos/base-sel4/src/core/pl...
Note2: May be it worth to add patch below permanently to main genode?
Yes, this patch would be welcome.
Cheers Norman
The initial delay of the seL4 version possibly depends on the amount of physical memory used. At boot time, physical memory gets converted into seL4 kernel objects in [1] (if I remember right). To see the effect, you may try tweaking the Qemu's -m argument.
not sure - delay time too big. Initially I think that it related to probe of big ranges of addresses used by attach_at() during allocator arena initialisation (I already send a letter with question about difference between seL4 and NOVA memory and receive answer, thanks). Anyway, I found that this part run relatively fast, so, not a case (while I need to remove error messages about failed allocation attempt).
Now start of sel4 golang code requires literally 2-3 minutes even for 512M ram for qemu, while for the same qemu and same code NOVA run in seconds. I don’t able to check this with current version - seems that this is specifics golang runtime. Still suspect timers/etc. Anyway, this could be a combination of timer and genode scheduler which is not that tailored for such workload, as I suspect. Will continue check after finalising of porting for arm64, most of it done.
For aarch64 it is not clear for me what to do with so called aarch64 extensions which handled differently in libc sources [2] (has traditional structure ucontext for generic registers and floating point ones), and for glibc aarch64 [1] which have somehow similar structure for generic registers and just additional page attached to context where it put some magic and additional fields and fill by other FP registers. I choose to move closer to libc structure to minimise changes in related structures while have some doubts about different dialects of ARM64 supported. I run it only inside qemu.
[1] https://github.com/bminor/glibc/blob/master/sysdeps/unix/sysv/linux/aarch64/... [2] https://github.com/freebsd/freebsd-src/blob/master/sys/arm64/include/ucontex...
added support for ARM64 (V8A). tested on single platform - foc where rpi3 is available. all info see below in README.golang
Now you need only one repo - https://github.com/tor-m6/genode-world.git
while temporary patch which allow .go compilation is inside staging of main genode, soon should be available in master, still please apply manually from here https://github.com/genodelabs/genode/commit/e6231794f36a481afc9edb058df342f0...
Note: here I can’t try go_http because drivers_nic package not available for rpi3 Any ideas where I can check that network works using arm64 in qemu with it?
not sure which other ARM platforms need to be supported - if you have any idea just email me.
Alexander
17 дек. 2021 г., в 14:01, Alexander Tormasov via users users@lists.genode.org написал(а):
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.gol...
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