Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loongarch64支持 #173

Open
donmor opened this issue Sep 18, 2022 · 3 comments · May be fixed by #174
Open

Loongarch64支持 #173

donmor opened this issue Sep 18, 2022 · 3 comments · May be fixed by #174

Comments

@donmor
Copy link

donmor commented Sep 18, 2022

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

@ZenithalHourlyRate
Copy link
Contributor

使用 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/sys@v0.0.0-20210426230700-d19ff857e887/unix/affinity_linux.go:14:35: undefined: _NCPUBITS
../../../G/pkg/mod/golang.org/x/sys@v0.0.0-20210426230700-d19ff857e887/unix/affinity_linux.go:17:25: undefined: cpuMask
../../../G/pkg/mod/golang.org/x/sys@v0.0.0-20210426230700-d19ff857e887/unix/affinity_linux.go:50:27: undefined: cpuMask
../../../G/pkg/mod/golang.org/x/sys@v0.0.0-20210426230700-d19ff857e887/unix/sockcmsg_unix.go:34:9: undefined: Cmsghdr
../../../G/pkg/mod/golang.org/x/sys@v0.0.0-20210426230700-d19ff857e887/unix/ztypes_linux.go:23:11: undefined: Timespec
../../../G/pkg/mod/golang.org/x/sys@v0.0.0-20210426230700-d19ff857e887/unix/ztypes_linux.go:24:11: undefined: Timespec
../../../G/pkg/mod/golang.org/x/sys@v0.0.0-20210426230700-d19ff857e887/unix/ztypes_linux.go:1132:12: undefined: SockaddrStorage
../../../G/pkg/mod/golang.org/x/sys@v0.0.0-20210426230700-d19ff857e887/unix/ztypes_linux.go:2313:8: undefined: Timespec
../../../G/pkg/mod/golang.org/x/sys@v0.0.0-20210426230700-d19ff857e887/unix/ztypes_linux.go:2806:8: undefined: TIPCSubscr
../../../G/pkg/mod/golang.org/x/sys@v0.0.0-20210426230700-d19ff857e887/unix/ztypes_linux.go:3214:10: undefined: PPSKInfo
../../../G/pkg/mod/golang.org/x/sys@v0.0.0-20210426230700-d19ff857e887/unix/affinity_linux.go:50:27: too many errors
# github.com/boltdb/bolt
../../../G/pkg/mod/github.com/boltdb/bolt@v1.3.1/db.go:101:13: undeclared name maxMapSize for array length
../../../G/pkg/mod/github.com/boltdb/bolt@v1.3.1/db.go:317:12: undefined: maxMapSize
../../../G/pkg/mod/github.com/boltdb/bolt@v1.3.1/db.go:335:10: undefined: maxMapSize
../../../G/pkg/mod/github.com/boltdb/bolt@v1.3.1/db.go:336:8: undefined: maxMapSize
../../../G/pkg/mod/github.com/boltdb/bolt@v1.3.1/db.go:795:2: pos declared but not used
../../../G/pkg/mod/github.com/boltdb/bolt@v1.3.1/bolt_unix.go:62:15: undeclared name maxMapSize for array length
../../../G/pkg/mod/github.com/boltdb/bolt@v1.3.1/bucket.go:135:15: undefined: brokenUnaligned
../../../G/pkg/mod/github.com/boltdb/bolt@v1.3.1/freelist.go:166:2: idx declared but not used
../../../G/pkg/mod/github.com/boltdb/bolt@v1.3.1/freelist.go:169:19: undeclared name maxAllocSize for array length
../../../G/pkg/mod/github.com/boltdb/bolt@v1.3.1/freelist.go:176:14: undeclared name maxAllocSize for array length
../../../G/pkg/mod/github.com/boltdb/bolt@v1.3.1/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,不知道是否能用,参考
hashicorp/nomad#11775
felixonmars/archriscv-packages#376 (为 riscv 编译 tunasync 也会出现 bolt 错误)

@ZenithalHourlyRate
Copy link
Contributor

$ go mod edit -replace github.com/boltdb/bolt@v1.3.1=go.etcd.io/bbolt@v1.3.6 后,loong64 依然不能编译,不过 riscv64 可以在简单修改后编译了

应该需要对 bbolt 发个 PR 增加相应支持,参考 etcd-io/bbolt#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/bbolt@v1.3.6/db.go:133:13: undeclared name maxMapSize for array length
../../../G/pkg/mod/go.etcd.io/bbolt@v1.3.6/db.go:422:12: undefined: maxMapSize
../../../G/pkg/mod/go.etcd.io/bbolt@v1.3.6/db.go:440:10: undefined: maxMapSize
../../../G/pkg/mod/go.etcd.io/bbolt@v1.3.6/db.go:441:8: undefined: maxMapSize
../../../G/pkg/mod/go.etcd.io/bbolt@v1.3.6/db.go:932:2: pos declared but not used
../../../G/pkg/mod/go.etcd.io/bbolt@v1.3.6/bolt_unix.go:68:15: undeclared name maxMapSize for array length
../../../G/pkg/mod/go.etcd.io/bbolt@v1.3.6/tx.go:532:12: undefined: maxAllocSize
../../../G/pkg/mod/go.etcd.io/bbolt@v1.3.6/tx.go:533:10: undefined: maxAllocSize
../../../G/pkg/mod/go.etcd.io/bbolt@v1.3.6/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
Copy link
Contributor

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

已经有了……在指向 7d9f2ecba (etcd-io/bbolt#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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants