ported version of Aram's basic cgo build patch