A tiny Go code fails only on Travis CI for Linux

I have a strange behavior of Travis CI for Linux.
https://github.com/herumi/test-travis-release is a sample of it.
make test runs well in my local environments such as Ubuntu 18.04.4 LTS + go1.13.4(14.1) and macOS 10.14.
But it fails only on Travis CI for Linux (It runs well on Travis CI for macOS).
https://travis-ci.org/github/herumi/test-travis-release/builds/667614744

bls/bls.go:15:105: cannot use (*[8]_Ctype_char)(unsafe.Pointer(&buf[0])) (type *[8]_Ctype_char) as type unsafe.Pointer in argument to func literal

I think that it would cause an error in every environment if it is a syntax error.
Could you give me some advice?

At the very least

  • you are using language: cpp rather than language: go for some reason and Xenial rather than Bionic
  • preinstalled Go version is 1.11.1, not 1.13.4
  • it likely uses GCC in Linux and CLang in OSX

Thank you for the advice.
I tried many combinations but the results were the same.


https://travis-ci.org/github/herumi/test-travis-release/builds/667846719

The strangest thing for me is that it works well locally but not on travis, even if using the same version of Go.

If something works locally but not in Travis, there are differences between your local environment and Travis.

Find out what this error message means and dig from there – only that can tell what the cause is and point to the discrepancy.

The code I pointed out is minimized from my large projects.
It is https://github.com/herumi/test-travis-release/blob/master/bls/bls.go

package bls

/*
#cgo LDFLAGS:-lbls
#cgo linux,amd64 LDFLAGS:-L${SRCDIR}/lib/linux/amd64
#cgo darwin,amd64 LDFLAGS:-L${SRCDIR}/lib/darwin/amd64
void blsFunc(const char buf[][8]);
*/
import "C"
import (
	"unsafe"
)

func BlsFunc(buf []byte) {
	C.blsFunc((*[8]C.char)(unsafe.Pointer(&buf[0])))
}

travis says:
bls/bls.go:15:105: cannot use (*[8]_Ctype_char)(unsafe.Pointer(&buf[0])) (type *[8]_Ctype_char) as type unsafe.Pointer in argument to func literal

But my all environments (Ubuntu/CentOS/Windows mingw/macOS + Go 1.12.10, 1.13.4, 1.14.1 and travis with macOS) say nothing.

I asked this problem at go forum and got the answer that this Go code has no problem.
By checking of the result of go tool bls.go, I found that there are difference between Travis-mac-go and Travis-linux-go.

I think that this causes an error, but I don’t know why Travis-go puts it.

bls/bls.go:13:118: cannot use _cgo0 (type *[8]_Ctype_char) as type unsafe.Pointer in argument to _Cfunc_blsFunc

travis-linux-go

//go:cgo_unsafe_args

func _Cfunc_blsFunc(p0 unsafe.Pointer) (r1 _Ctype_void) {
    _cgo_runtime_cgocall(_cgo_e2f56382bf64_Cfunc_blsFunc, uintptr(unsafe.Pointer(&p0)))
    if _Cgo_always_false {
        _Cgo_use(p0)
    }
    return
}

travis-mac-go and all my local environments (linux/mac/mingw)

//go:cgo_unsafe_args

func _Cfunc_blsFunc(p0 *[8]_Ctype_char) (r1 _Ctype_void) {
    _cgo_runtime_cgocall(_cgo_e2f56382bf64_Cfunc_blsFunc, uintptr(unsafe.Pointer(&p0)))
    if _Cgo_always_false {
        _Cgo_use(p0)
    }
    return
}
1 Like
Imprint