DEV Community

Jainta Paul
Jainta Paul

Posted on

Golang Building from Source

#go

I have been working on a research project which involves Garbage collection mechanism in Golang. We have successfully built Golang from source code. Now, we are trying to add minor modifications in the source code and see if build succeeds or not. As a starter, we have added a log print in mgc.go file in function gcinit at the very beginning

func gcinit() {
log.Print("In Function GCINT ")
....................................................................................................................
}

After adding the log print, the build fails with the following error:
In Function GCINIT
In Function GCINIT shift.go:12:6: (i8 + 1) (8 bits) too small for shift of 8
FAIL
FAIL cmd/vet 9.460s
FAIL
go tool dist: Failed: exit status 1

We have tried to use fmt.printf but no luck so far. We will be happy if someone can help

Top comments (1)

Collapse
 
mugabe profile image
mugabe

I don't think that's possible. You need already initialized GC for log.Print or other high-level functions, so it's not possible to call them here.
You can write your own low-level function for output to stdout, but i'm pretty sure it will also affect many Go tools which are widely used in compilation process, but now they will output unexpected data, so build will fail again.