tunasync icon indicating copy to clipboard operation
tunasync copied to clipboard

Loongarch64支持

Open donmor opened this issue 3 years ago • 3 comments

tunasync能否在la64(3a5000等)架构上编译?如果不能,原因是否是依赖的库中使用了不支持的c库或者存在内联汇编? 如果支持编译,可否通过交叉编译等方式构建la64的二进制发布到release页?

donmor avatar Sep 18 '22 05:09 donmor

使用 go 1.19 和 loong64 构建时出现一些问题,这些依赖库似乎未迁移

# zenithal @ Sun in ~/C/tuna/tunasync on git:master o [17:27:55]  { go_1_19 }
$ make ARCH=linux-loong64 all
mkdir -p build-linux-loong64
GOOS=linux GOARCH=loong64 go get ./cmd/tunasync
GOOS=linux GOARCH=loong64 go build -o build-linux-loong64/tunasync -ldflags "-X main.buildstamp=`date -u '+%s'` -X main.githash=`git rev-parse HEAD`" github.com/tuna/tunasync/cmd/tunasync
# golang.org/x/sys/unix
../../../G/pkg/mod/golang.org/x/[email protected]/unix/affinity_linux.go:14:35: undefined: _NCPUBITS
../../../G/pkg/mod/golang.org/x/[email protected]/unix/affinity_linux.go:17:25: undefined: cpuMask
../../../G/pkg/mod/golang.org/x/[email protected]/unix/affinity_linux.go:50:27: undefined: cpuMask
../../../G/pkg/mod/golang.org/x/[email protected]/unix/sockcmsg_unix.go:34:9: undefined: Cmsghdr
../../../G/pkg/mod/golang.org/x/[email protected]/unix/ztypes_linux.go:23:11: undefined: Timespec
../../../G/pkg/mod/golang.org/x/[email protected]/unix/ztypes_linux.go:24:11: undefined: Timespec
../../../G/pkg/mod/golang.org/x/[email protected]/unix/ztypes_linux.go:1132:12: undefined: SockaddrStorage
../../../G/pkg/mod/golang.org/x/[email protected]/unix/ztypes_linux.go:2313:8: undefined: Timespec
../../../G/pkg/mod/golang.org/x/[email protected]/unix/ztypes_linux.go:2806:8: undefined: TIPCSubscr
../../../G/pkg/mod/golang.org/x/[email protected]/unix/ztypes_linux.go:3214:10: undefined: PPSKInfo
../../../G/pkg/mod/golang.org/x/[email protected]/unix/affinity_linux.go:50:27: too many errors
# github.com/boltdb/bolt
../../../G/pkg/mod/github.com/boltdb/[email protected]/db.go:101:13: undeclared name maxMapSize for array length
../../../G/pkg/mod/github.com/boltdb/[email protected]/db.go:317:12: undefined: maxMapSize
../../../G/pkg/mod/github.com/boltdb/[email protected]/db.go:335:10: undefined: maxMapSize
../../../G/pkg/mod/github.com/boltdb/[email protected]/db.go:336:8: undefined: maxMapSize
../../../G/pkg/mod/github.com/boltdb/[email protected]/db.go:795:2: pos declared but not used
../../../G/pkg/mod/github.com/boltdb/[email protected]/bolt_unix.go:62:15: undeclared name maxMapSize for array length
../../../G/pkg/mod/github.com/boltdb/[email protected]/bucket.go:135:15: undefined: brokenUnaligned
../../../G/pkg/mod/github.com/boltdb/[email protected]/freelist.go:166:2: idx declared but not used
../../../G/pkg/mod/github.com/boltdb/[email protected]/freelist.go:169:19: undeclared name maxAllocSize for array length
../../../G/pkg/mod/github.com/boltdb/[email protected]/freelist.go:176:14: undeclared name maxAllocSize for array length
../../../G/pkg/mod/github.com/boltdb/[email protected]/freelist.go:166:2: too many errors
make: *** [Makefile:17: build-linux-loong64/tunasync] Error 2

升级 golang.org/x/sys 后可以正常编译 x/sys,但 bolt 已经不再更新,错误依旧存在

一些实现将 bolt 替换成了 bbolt,不知道是否能用,参考 https://github.com/hashicorp/nomad/issues/11775 https://github.com/felixonmars/archriscv-packages/pull/376 (为 riscv 编译 tunasync 也会出现 bolt 错误)

ZenithalHourlyRate avatar Sep 18 '22 09:09 ZenithalHourlyRate

$ go mod edit -replace github.com/boltdb/[email protected]=go.etcd.io/[email protected] 后,loong64 依然不能编译,不过 riscv64 可以在简单修改后编译了

应该需要对 bbolt 发个 PR 增加相应支持,参考 https://github.com/etcd-io/bbolt/pull/159

$ make ARCH=linux-loong64 all                                               
GOOS=linux GOARCH=loong64 go get ./cmd/tunasync
go: downloading go.etcd.io/bbolt v1.3.6
GOOS=linux GOARCH=loong64 go build -o build-linux-loong64/tunasync -ldflags "-X main.buildstamp=`date -u '+%s'` -X main.githash=`git rev-parse HEAD`" github.com/tuna/tunasync/cmd/tunasync
# github.com/boltdb/bolt
../../../G/pkg/mod/go.etcd.io/[email protected]/db.go:133:13: undeclared name maxMapSize for array length
../../../G/pkg/mod/go.etcd.io/[email protected]/db.go:422:12: undefined: maxMapSize
../../../G/pkg/mod/go.etcd.io/[email protected]/db.go:440:10: undefined: maxMapSize
../../../G/pkg/mod/go.etcd.io/[email protected]/db.go:441:8: undefined: maxMapSize
../../../G/pkg/mod/go.etcd.io/[email protected]/db.go:932:2: pos declared but not used
../../../G/pkg/mod/go.etcd.io/[email protected]/bolt_unix.go:68:15: undeclared name maxMapSize for array length
../../../G/pkg/mod/go.etcd.io/[email protected]/tx.go:532:12: undefined: maxAllocSize
../../../G/pkg/mod/go.etcd.io/[email protected]/tx.go:533:10: undefined: maxAllocSize
../../../G/pkg/mod/go.etcd.io/[email protected]/unsafe.go:27:12: undeclared name maxAllocSize for array length
make: *** [Makefile:17: build-linux-loong64/tunasync] Error 2

# zenithal @ Sun in ~/C/tuna/tunasync on git:master x [17:52:03] C:2 { go_1_19 }
$ make ARCH=linux-riscv64 all
GOOS=linux GOARCH=riscv64 go get ./cmd/tunasync
GOOS=linux GOARCH=riscv64 go build -o build-linux-riscv64/tunasync -ldflags "-X main.buildstamp=`date -u '+%s'` -X main.githash=`git rev-parse HEAD`" github.com/tuna/tunasync/cmd/tunasync
# github.com/tuna/tunasync/manager
manager/db_bolt.go:6:2: imported and not used: "github.com/boltdb/bolt" as bbolt
manager/db_bolt.go:11:6: undefined: bolt
manager/db_bolt.go:15:30: undefined: bolt
manager/db_bolt.go:25:27: undefined: bolt
manager/db_bolt.go:34:27: undefined: bolt
manager/db_bolt.go:47:30: undefined: bolt
manager/db_bolt.go:56:30: undefined: bolt
manager/db.go:9:2: imported and not used: "github.com/boltdb/bolt" as bbolt
manager/db.go:50:19: undefined: bolt
make: *** [Makefile:17: build-linux-riscv64/tunasync] Error 2

# zenithal @ Sun in ~/C/tuna/tunasync on git:master x [17:52:13] C:2 { go_1_19 }
$ vim manager/db.go

# zenithal @ Sun in ~/C/tuna/tunasync on git:master x [17:54:25]  { go_1_19 }
$ vim manager/db_bolt.go 

# zenithal @ Sun in ~/C/tuna/tunasync on git:master x [17:54:34]  { go_1_19 }
$ make ARCH=linux-riscv64 all
GOOS=linux GOARCH=riscv64 go get ./cmd/tunasync
GOOS=linux GOARCH=riscv64 go build -o build-linux-riscv64/tunasync -ldflags "-X main.buildstamp=`date -u '+%s'` -X main.githash=`git rev-parse HEAD`" github.com/tuna/tunasync/cmd/tunasync
GOOS=linux GOARCH=riscv64 go get ./cmd/tunasynctl
GOOS=linux GOARCH=riscv64 go build -o build-linux-riscv64/tunasynctl -ldflags "-X main.buildstamp=`date -u '+%s'` -X main.githash=`git rev-parse HEAD`" github.com/tuna/tunasync/cmd/tunasynctl

ZenithalHourlyRate avatar Sep 18 '22 09:09 ZenithalHourlyRate

应该需要对 bbolt 发个 PR 增加相应支持,参考 etcd-io/bbolt#159

已经有了……在指向 7d9f2ecba (https://github.com/etcd-io/bbolt/pull/303) 后可以构建成功

$ make ARCH=linux-loong64 all
GOOS=linux GOARCH=loong64 go get ./cmd/tunasync
go: downloading go.etcd.io/bbolt v1.3.7-0.20220129023850-7d9f2ecba159
GOOS=linux GOARCH=loong64 go build -o build-linux-loong64/tunasync -ldflags "-X main.buildstamp=`date -u '+%s'` -X main.githash=`git rev-parse HEAD`" github.com/tuna/tunasync/cmd/tunasync
GOOS=linux GOARCH=loong64 go get ./cmd/tunasynctl
GOOS=linux GOARCH=loong64 go build -o build-linux-loong64/tunasynctl -ldflags "-X main.buildstamp=`date -u '+%s'` -X main.githash=`git rev-parse HEAD`" github.com/tuna/tunasync/cmd/tunasynctl

ZenithalHourlyRate avatar Sep 18 '22 10:09 ZenithalHourlyRate