herumi
March 27, 2020, 11:10am
1
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?
herumi
March 27, 2020, 7:15pm
3
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.
herumi
March 27, 2020, 11:08pm
5
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.
herumi
March 30, 2020, 1:56am
6
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