Cross compilation of CGO stuff requires a lot of faff. I spend several years doing embedded development, and messing about with GCC build-chains. So I was absolutely astounded that the Go build tools do everything with two env vars.
Once you branch out to CGO, you are back in the hairy world of GCC cross compilation tool chains. I say turn back if you can! My advice, if you need sqlite, is to switch to https://gitlab.com/cznic/sqlite which is a pure Go version. I haven't tried it. But if it spared people the pain of CGO, then it is worth its weight in gold. On Monday, 7 September 2020 20:27:39 UTC+1, Ian Lance Taylor wrote: > > On Sun, Sep 6, 2020 at 1:53 PM 'Hubert Hirtz' via golang-nuts > <[email protected] <javascript:>> wrote: > > > > I am trying to cross-compile a project that depends on sqlite3 on a > > amd64 machine (host) for an armhf machine (target), using clang with the > > appropriate "--target" flag. > > > > The build fails on runtime/cgo with the following errors: > > > > ``` > > # runtime/cgo > > In file included from gcc_libinit.c:8: > > /usr/include/pthread.h:672:6: error: 'regparm' is not valid on this > platform > > /usr/include/bits/pthreadtypes-arch.h:52:50: note: expanded from macro > > '__cleanup_fct_attribute' > > In file included from gcc_libinit.c:8: > > /usr/include/pthread.h:684:3: error: 'regparm' is not valid on this > platform > > /usr/include/bits/pthreadtypes-arch.h:52:50: note: expanded from macro > > '__cleanup_fct_attribute' > > In file included from gcc_libinit.c:8: > > /usr/include/pthread.h:725:6: error: 'regparm' is not valid on this > platform > > /usr/include/bits/pthreadtypes-arch.h:52:50: note: expanded from macro > > '__cleanup_fct_attribute' > > ``` > > > > Here is the `go env` and the full build output (run with `-x`): > > <https://paste.sr.ht/~taiite/b6b47c78cc399d41b398f1076f55a5a1cc75526e> > > > > Do you have any idea why it fails or if I missed something? > > In order to cross-compile a Go program that uses cgo, you need a > complete C cross-compiler. In this case your C cross-compiler appears > to be using the native header files, which can't work. It needs to > use the cross-compiler header files. > > Ian > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/4400a583-de03-402e-a7f3-b1d2cc8eb0feo%40googlegroups.com.
