I have some go sources that are exclusively built for mips. I'm trying to get them to compile on x86 so as to run select, non-architecture-specific code on x86 as well. My sources are organized as below:
ipmi.go: # Only builds on mips.
package main
import (
"foo"
"bar"
)
/*
#cgo LDFLAGS: -lfreeipmi
#define FOO 1
some c code
*/
import C
// go code
func gofunc1() {
}
func gofunc2() {
}
// more go code
hardware.go: # All go code
package main
import (
"lots"
"of"
"libs"
)
func main() {
// some go code
ret1 = gofunc1()
ret2 = gofunc1()
// Use ret1 and ret2 to do something else.
// more go code
}
What's the best way to enable building these sources on x86?
I added the following to ipmi.go to restrict the arch on which it is built:
// +build linux,mips,cgo
hardware.go still fails to compile since it calls gofunc1()
and gofunc2()
. Since hardware.go will always need to call gofunc1()
and gofunc2()
, I can't think
of any way to conditionally compile these sources for x86. Any inisghts will be helpful.
Thanks