mattn/go-sqlite3

cross-compile mattn/go-sqlite3 --targets=linux/arm

zeevikal opened this issue · 6 comments

Im trying to compile mattn/go-sqlite3 to linux/arm.
I run:
sudo docker run karalabe/xgo-latest github.com/mattn/go-sqlite3 --targets=linux/arm
I get:

Fetching main repository github.com/mattn/go-sqlite3...
github.com/mattn/go-sqlite3 (download)
Fetching https://golang.org/x/net/context?go-get=1
Parsing meta tags from https://golang.org/x/net/context?go-get=1 (status code 200)
get "golang.org/x/net/context": found meta tag main.metaImport{Prefix:"golang.org/x/net", VCS:"git", RepoRoot:"https://go.googlesource.com/net"} at https://golang.org/x/net/context?go-get=1
get "golang.org/x/net/context": verifying non-authoritative meta tag
Fetching https://golang.org/x/net?go-get=1
Parsing meta tags from https://golang.org/x/net?go-get=1 (status code 200)
golang.org/x/net (download)
Assembling toolchain for android-16/arm...
Bootstrapping android-16/arm...
Compiling for android-16/arm...
Assembling toolchain for android-16/386...
Bootstrapping android-16/386...
Compiling for android-16/386...
/tmp/tmp.izDbZRL94v/go-sqlite3.i:1: Error: Syntax error in input(1).

what am I doing wrong? thanks

mattn commented

go-sqlite3 doesn't use swig (file extension .i). may be it is not an issue of go-sqlite3.

can you advise me please, what should I do?
I want to compile github.com/mattn/go-sqlite3 to Arm6.
thank you

mattn commented

Sorry, I don't have arm6 and not well to know karalabe/xgo-latest.

I just have a test and it's okay to use xgo build linux/arm. My go env is

go env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/Eveee/Storage/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/w4/75xgx41n2bb7mm3m0dxbp0d40000gn/T/go-build381488672=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"

and build process log

github.com/mattn/go-sqlite3  master ✗                                                                                                                                     56d ⚑ ◒  ⍉
▶ xgo --targets=linux/arm  .
Checking docker installation...
Client:
 Version:      17.09.1-ce
 API version:  1.32
 Go version:   go1.8.3
 Git commit:   19e2cf6
 Built:        Thu Dec  7 22:22:25 2017
 OS/Arch:      darwin/amd64

Server:
 Version:      17.09.1-ce
 API version:  1.32 (minimum version 1.12)
 Go version:   go1.8.3
 Git commit:   19e2cf6
 Built:        Thu Dec  7 22:28:28 2017
 OS/Arch:      linux/amd64
 Experimental: true

Checking for required docker image karalabe/xgo-latest... found.
Cross compiling github.com/mattn/go-sqlite3...
Building locally github.com/mattn/go-sqlite3...
Bootstrapping linux/arm-5...
Compiling for linux/arm-5...
Cleaning up Go runtime for linux/arm-5...
Cleaning up build environment...```

@zeevikal Current master has no problem with cross-compile

To compile for ARM6 use:

GOARM=6 GOARCH=arm go build -a -v .

Verification:

gtimmert@Aeris:~/Projects/go/src/go-sqlite3$ GOARM=6 GOARCH=arm go build -a -v .
errors
internal/race
runtime/internal/sys
unicode/utf8
sync/atomic
runtime/internal/atomic
math
unicode
internal/testlog
runtime
strconv
sync
io
reflect
syscall
time
internal/poll
os
sort
fmt
context
database/sql/driver
database/sql
go-sqlite3
gtimmer@Aeris:~/Projects/go/src/go-sqlite3$

I ran into this problem on a separate project and found a solution.

/tmp/tmp.izDbZRL94v/go-sqlite3.i:1: Error: Syntax error in input(1).

Here is what xgo generates

%module go-sqlite3
%{
#include "go-sqlite3.h"
%}
%pragma(java) jniclasscode=%{
static {
System.loadLibrary("go-sqlite3");
}
%}
%include "go-sqlite3.h"

The problem is the dash in %module go-sqlite3

The solution is to rename the project or add -out projectwithoutdash to xgo