ipfs / kubo

An IPFS implementation in Go
https://docs.ipfs.tech/how-to/command-line-quick-start/
Other
15.9k stars 2.98k forks source link

RISC-V Support #8398

Open agsstaff opened 2 years ago

agsstaff commented 2 years ago

Checklist

Installation method

built from source

Version

make install
go version go1.16.2 linux/riscv64
bin/check_go_version 1.15.2
plugin/loader/preload.sh > plugin/loader/preload.go
go fmt plugin/loader/preload.go >/dev/null
go install "-asmflags=all='-trimpath='" "-gcflags=all='-trimpath='" -ldflags="-X "github.com/ipfs/go-ipfs".CurrentCommit=c9cc09f6f" ./cmd/ipfs
# github.com/marten-seemann/tcp
../go/pkg/mod/github.com/marten-seemann/tcp@v0.0.0-20210406111302-dfbc87cc63fd/sys_linux.go:8:19: undefined: sysSIOCINQ
../go/pkg/mod/github.com/marten-seemann/tcp@v0.0.0-20210406111302-dfbc87cc63fd/sys_linux.go:9:19: undefined: sysSIOCOUTQ
# go.opencensus.io/plugin/ocgrpc
../go/pkg/mod/go.opencensus.io@v0.23.0/plugin/ocgrpc/stats_common.go:33:2: import /root/.cache/go-build/83/83d97274d45d808884ccc773b7985950d23f98e85f42fb667e3464023918e527-d: not a go object file: pkg/mod/google.golang.org/protobuf@v1.27.1/internal/impl/validate.gogofile../root/go/pkg/mod/google.golang.org/protobuf@v1.27.1/internal/impl/message_reflect_gen.gogofile../root/go/pkg/mod/google.golang.org/protobuf@v1.27.1/internal/impl/codec_message.gogofile../root/go/pkg/mod/google.golang.org/protobuf@v1.27.1/internal/impl/checkinit.gogofile../root/go/pkg/mod/google.golang.org/protobuf@v1.27.1/internal/impl/codec_field.gogofile../root/go/pkg/mod/google.golang.org/protobuf@v1.27.1/types/known/anypb/any.pb.gogofile../root/go/pkg/mod/google.golang.org/protobuf@v1.27.1/runtime/protoiface/legacy.gogofile..$GOROOT/src/fmt/print.gogofile..$GOROOT/src/context/context.gogofile../root/go/pkg/mod/github.com/golang/protobuf@v1.5.2/proto/proto.gogofile../root/go/pkg/mod/google.golang.org/protobuf@v1.27.1/runtime/protoimpl/impl.gogofile../root/go/pkg/mod/google.golang.org/protobuf@v1.27.1/internal/impl/api_export.gogofile../root/go/pkg/mod/google.golang.org/protobuf@v1.27.1/internal/impl/legacy_export.gogofile../root/go/pkg/mod/google.golang.org/protobuf@v1.27.1/encoding/prototext/encode.gogofile../root/go/pkg/mod/google.golang.org/protobuf@v1.27.1/reflect/protoregistry/registry.gogofile..$GOROOT/src/strings/strings.god▒Z▒▒a▒▒▒k▒)▒▒h0n▒▒)▒o2?W▒_^~*▒*▒V&▒ʨ]▒Xd&▒0nk ▒-▒d▒
                                                            `▒OKR▒U▒`AZ▒V▒XQW▒X X&xdI▒U▒W< Z▒ X▒ ]E!&▒!!-▒"▒▒#▒,$8l(▒X'C        ▒'▒
H&F▒L[Qny▒\ U|!▒T▒#F$iX▒Y▒V>_▒`▒YS[▒Z^ab▒[!Q|\▒Y)S▒K▒Y OyO▒I
make: *** [cmd/ipfs/Rules.mk:37: cmd/ipfs-install] Error 2

Config

make install
go version go1.16.2 linux/riscv64
bin/check_go_version 1.15.2
plugin/loader/preload.sh > plugin/loader/preload.go
go fmt plugin/loader/preload.go >/dev/null
go install "-asmflags=all='-trimpath='" "-gcflags=all='-trimpath='" -ldflags="-X "github.com/ipfs/go-ipfs".CurrentCommit=c9cc09f6f" ./cmd/ipfs
# github.com/marten-seemann/tcp
../go/pkg/mod/github.com/marten-seemann/tcp@v0.0.0-20210406111302-dfbc87cc63fd/sys_linux.go:8:19: undefined: sysSIOCINQ
../go/pkg/mod/github.com/marten-seemann/tcp@v0.0.0-20210406111302-dfbc87cc63fd/sys_linux.go:9:19: undefined: sysSIOCOUTQ
# go.opencensus.io/plugin/ocgrpc
../go/pkg/mod/go.opencensus.io@v0.23.0/plugin/ocgrpc/stats_common.go:33:2: import /root/.cache/go-build/83/83d97274d45d808884ccc773b7985950d23f98e85f42fb667e3464023918e527-d: not a go object file: pkg/mod/google.golang.org/protobuf@v1.27.1/internal/impl/validate.gogofile../root/go/pkg/mod/google.golang.org/protobuf@v1.27.1/internal/impl/message_reflect_gen.gogofile../root/go/pkg/mod/google.golang.org/protobuf@v1.27.1/internal/impl/codec_message.gogofile../root/go/pkg/mod/google.golang.org/protobuf@v1.27.1/internal/impl/checkinit.gogofile../root/go/pkg/mod/google.golang.org/protobuf@v1.27.1/internal/impl/codec_field.gogofile../root/go/pkg/mod/google.golang.org/protobuf@v1.27.1/types/known/anypb/any.pb.gogofile../root/go/pkg/mod/google.golang.org/protobuf@v1.27.1/runtime/protoiface/legacy.gogofile..$GOROOT/src/fmt/print.gogofile..$GOROOT/src/context/context.gogofile../root/go/pkg/mod/github.com/golang/protobuf@v1.5.2/proto/proto.gogofile../root/go/pkg/mod/google.golang.org/protobuf@v1.27.1/runtime/protoimpl/impl.gogofile../root/go/pkg/mod/google.golang.org/protobuf@v1.27.1/internal/impl/api_export.gogofile../root/go/pkg/mod/google.golang.org/protobuf@v1.27.1/internal/impl/legacy_export.gogofile../root/go/pkg/mod/google.golang.org/protobuf@v1.27.1/encoding/prototext/encode.gogofile../root/go/pkg/mod/google.golang.org/protobuf@v1.27.1/reflect/protoregistry/registry.gogofile..$GOROOT/src/strings/strings.god▒Z▒▒a▒▒▒k▒)▒▒h0n▒▒)▒o2?W▒_^~*▒*▒V&▒ʨ]▒Xd&▒0nk ▒-▒d▒
                                                            `▒OKR▒U▒`AZ▒V▒XQW▒X X&xdI▒U▒W< Z▒ X▒ ]E!&▒!!-▒"▒▒#▒,$8l(▒X'C        ▒'▒
H&F▒L[Qny▒\ U|!▒T▒#F$iX▒Y▒V>_▒`▒YS[▒Z^ab▒[!Q|\▒Y)S▒K▒Y OyO▒I
make: *** [cmd/ipfs/Rules.mk:37: cmd/ipfs-install] Error 2

Description

Error trying to compile on RISC-V SiFIVE SOC from git clone

welcome[bot] commented 2 years ago

Thank you for submitting your first issue to this repository! A maintainer will be here shortly to triage and review. In the meantime, please double-check that you have provided all the necessary information to make this process easy! Any information that can help save additional round trips is useful! We currently aim to give initial feedback within two business days. If this does not happen, feel free to leave a comment. Please keep an eye on how this issue will be labeled, as labels give an overview of priorities, assignments and additional actions requested by the maintainers:

Finally, remember to use https://discuss.ipfs.io if you just need general support.

Stebalien commented 2 years ago

RISC-V is not a supported architecture at the moment.

agsstaff commented 2 years ago

Hello Steven.. understood We would like to help support IPFS on RISC-V hardware I'm working with the SiFive Unmatched RV64 dev board and just built BTC from source without any compile issues. Currently downloading the full block-chain too.

Our company has applied to several Tachyon Accelerator rounds without being accepted.. Currently.. The EOG hardware we are proposing to build for IPFS is based on ARM.. ARM tech has become very difficult to support because of China.

The Open RISC-V ISA and Hardware mfg like SiFive could resolve this "bottleneck" IMO.

I'm interested in helping move IPFS forward on to RISC-V.. Please let me know how we can help..

Doug

On Mon, Sep 6, 2021 at 7:29 AM Steven Allen @.***> wrote:

RISC-V is not a supported architecture at the moment.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ipfs/go-ipfs/issues/8398#issuecomment-913574803, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIDJX3OCF2BOMZ7BRDPN2DLUASQ27ANCNFSM5DCSFJ7Q . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

Stebalien commented 2 years ago

I can't guarantee we'll be able to maintain support due to lack of testing, but I'm happy to review patches to add support. You'd need to start by making https://github.com/marten-seemann/tcp build on RISC V.

agsstaff commented 2 years ago

Thank you for your response. I'm following marten seemann on github... will try contacting him for guidance and let you best regards, Doug

On Mon, Sep 6, 2021 at 8:31 AM Steven Allen @.***> wrote:

I can't guarantee we'll be able to maintain support due to lack of testing, but I'm happy to review patches to add support. You'd need to start by making https://github.com/marten-seemann/tcp build on RISC V.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ipfs/go-ipfs/issues/8398#issuecomment-913612624, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIDJX3LDESK3T3VO4WCEFIDUASYCNANCNFSM5DCSFJ7Q . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

Stebalien commented 2 years ago

Just so you know, he's very busy right now. I'm sure he'll accept patches (assuming they're reasonably easy to review), but he's probably not going to have much time to help.

agsstaff commented 2 years ago

Ok, thanks for the update. Looks like TCP was forked from https://github.com/mikioh.. no updates since 2018.. I see other dev's worked on the CPU patches too.. Doug

On Mon, Sep 6, 2021 at 9:06 AM Steven Allen @.***> wrote:

Just so you know, he's very busy right now. I'm sure he'll accept patches (assuming they're reasonably easy to review), but he's probably not going to have much time to help.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ipfs/go-ipfs/issues/8398#issuecomment-913635432, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIDJX3LWUWQHFNSUEMUSOWTUAS4DXANCNFSM5DCSFJ7Q . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

agsstaff commented 2 years ago

Hi Steven.. I may have resolved the TCP error by copying sys_linux_amd64.go to a new file sys_linux_riscv64.go $go env shows GOARCH="riscv64" Maybe Marten could verify the two values are correct ?

sysSIOCINQ = 0x541b sysSIOCOUTQ = 0x5411

best regards, Doug

On Mon, Sep 6, 2021 at 9:48 AM AGS Staff @.***> wrote:

Ok, thanks for the update. Looks like TCP was forked from https://github.com/mikioh.. no updates since 2018.. I see other dev's worked on the CPU patches too.. Doug

On Mon, Sep 6, 2021 at 9:06 AM Steven Allen @.***> wrote:

Just so you know, he's very busy right now. I'm sure he'll accept patches (assuming they're reasonably easy to review), but he's probably not going to have much time to help.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ipfs/go-ipfs/issues/8398#issuecomment-913635432, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIDJX3LWUWQHFNSUEMUSOWTUAS4DXANCNFSM5DCSFJ7Q . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

Stebalien commented 2 years ago

Unfortunately this is very much a "patches welcome" situation. You'll have to do the research here (read the relevent man pages, etc.). None of us use RISC V so we have no more idea what the correct values are than you do.

marten-seemann commented 2 years ago

Maybe we can get around patching https://github.com/mikioh/tcp (or the fork I'm maintaining). We only need this package to collect TCP metrics, and I assume you could live without TCP metrics (at least for now). It would probably be not too hard to extend https://github.com/libp2p/go-tcp-transport/pull/93/ to disable metrics collection on RISC V as well. Maybe you try that out, @agsstaff, and send a PR if it works.

agsstaff commented 2 years ago

Ok, I'll do that. Thank you for the info and direction.. Best regards, Doug

On Mon, Sep 6, 2021 at 11:05 AM Marten Seemann @.***> wrote:

Maybe we can get around patching https://github.com/mikioh/tcp (or the fork I'm maintaining). We only need this package to collect TCP metrics, and I assume you could live without TCP metrics (at least for now). It would probably be not too hard to extend libp2p/go-tcp-transport#93 https://github.com/libp2p/go-tcp-transport/pull/93 to disable metrics collection on RISC V as well. Maybe you try that out, @agsstaff https://github.com/agsstaff, and send a PR if it works.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ipfs/go-ipfs/issues/8398#issuecomment-913714364, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIDJX3IXNNYVKEHUOOB2V3DUATKEBANCNFSM5DCSFJ7Q . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

agsstaff commented 2 years ago

correction on my post... I used source file sys_linux_arm64.go not sys_linux_amd64.go

On Mon, Sep 6, 2021 at 10:53 AM AGS Staff @.***> wrote:

Hi Steven.. I may have resolved the TCP error by copying sys_linux_amd64.go to a new file sys_linux_riscv64.go $go env shows GOARCH="riscv64" Maybe Marten could verify the two values are correct ?

sysSIOCINQ = 0x541b sysSIOCOUTQ = 0x5411

best regards, Doug

On Mon, Sep 6, 2021 at 9:48 AM AGS Staff @.***> wrote:

Ok, thanks for the update. Looks like TCP was forked from https://github.com/mikioh.. no updates since 2018.. I see other dev's worked on the CPU patches too.. Doug

On Mon, Sep 6, 2021 at 9:06 AM Steven Allen @.***> wrote:

Just so you know, he's very busy right now. I'm sure he'll accept patches (assuming they're reasonably easy to review), but he's probably not going to have much time to help.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ipfs/go-ipfs/issues/8398#issuecomment-913635432, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIDJX3LWUWQHFNSUEMUSOWTUAS4DXANCNFSM5DCSFJ7Q . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

agsstaff commented 2 years ago

Thank you again for your help.. I think the compile error was do to a broken Golang version from the distro package in Ubuntu 21.04 ./go version go version go1.16.2 linux/riscv64

I was able to locate a newer bootstrap version Go 1.16.6 and that worked !

./go version go version go1.16.6 linux/riscv64

IPFS Compiles binary $file ipfs ipfs: ELF 64-bit LSB executable, UCB RISC-V, version 1 (SYSV), statically linked, Go BuildID=q9xSpd11Pi6VzoylpW-6/dpznK-iC8VFMtQlNhZzd/J3shovvtwxI3yoR5bJ1H/FAPEK2eX6FMld4HczN4c, not stripped

@.***:~$ ipfs daemon Initializing daemon... go-ipfs version: 0.11.0-dev-65d570c6c Repo version: 11 System version: riscv64/linux Golang version: go1.16.6

I did notice this buffer size message..will check for a fix 2021/09/07 11:21:39 failed to sufficiently increase receive buffer size (was: 208 kiB, wanted: 2048 kiB, got: 416 kiB). See https://github.com/lucas-clemente/quic-go/wiki/UDP-Receive-Buffer-Size for details.

Swarm listening on /ip4/127.0.0.1/tcp/4001 Swarm listening on /ip4/127.0.0.1/udp/4001/quic Swarm listening on /ip4/192.168.1.126/tcp/4001 Swarm listening on /ip4/192.168.1.126/udp/4001/quic Swarm listening on /ip6/::1/tcp/4001 Swarm listening on /ip6/::1/udp/4001/quic Swarm listening on /p2p-circuit Swarm announcing /ip4/127.0.0.1/tcp/4001 Swarm announcing /ip4/127.0.0.1/udp/4001/quic Swarm announcing /ip4/192.168.1.126/tcp/4001 Swarm announcing /ip4/192.168.1.126/udp/4001/quic Swarm announcing /ip4/75.131.26.156/udp/4001/quic Swarm announcing /ip6/::1/tcp/4001 Swarm announcing /ip6/::1/udp/4001/quic API server listening on /ip4/127.0.0.1/tcp/5001 WebUI: http://127.0.0.1:5001/webui Gateway (readonly) server listening on /ip4/127.0.0.1/tcp/8080 Daemon is ready

Best regards, Doug

On Mon, Sep 6, 2021 at 11:05 AM Marten Seemann @.***> wrote:

Maybe we can get around patching https://github.com/mikioh/tcp (or the fork I'm maintaining). We only need this package to collect TCP metrics, and I assume you could live without TCP metrics (at least for now). It would probably be not too hard to extend libp2p/go-tcp-transport#93 https://github.com/libp2p/go-tcp-transport/pull/93 to disable metrics collection on RISC V as well. Maybe you try that out, @agsstaff https://github.com/agsstaff, and send a PR if it works.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ipfs/go-ipfs/issues/8398#issuecomment-913714364, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIDJX3IXNNYVKEHUOOB2V3DUATKEBANCNFSM5DCSFJ7Q . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

agsstaff commented 2 years ago

running this command fixed the UDP buffer issue..

sysctl -w net.core.rmem_max=2500000

On Tue, Sep 7, 2021 at 11:44 AM AGS Staff @.***> wrote:

Thank you again for your help.. I think the compile error was do to a broken Golang version from the distro package in Ubuntu 21.04 ./go version go version go1.16.2 linux/riscv64

I was able to locate a newer bootstrap version Go 1.16.6 and that worked !

./go version go version go1.16.6 linux/riscv64

IPFS Compiles binary $file ipfs ipfs: ELF 64-bit LSB executable, UCB RISC-V, version 1 (SYSV), statically linked, Go BuildID=q9xSpd11Pi6VzoylpW-6/dpznK-iC8VFMtQlNhZzd/J3shovvtwxI3yoR5bJ1H/FAPEK2eX6FMld4HczN4c, not stripped

@.***:~$ ipfs daemon Initializing daemon... go-ipfs version: 0.11.0-dev-65d570c6c Repo version: 11 System version: riscv64/linux Golang version: go1.16.6

I did notice this buffer size message..will check for a fix 2021/09/07 11:21:39 failed to sufficiently increase receive buffer size (was: 208 kiB, wanted: 2048 kiB, got: 416 kiB). See https://github.com/lucas-clemente/quic-go/wiki/UDP-Receive-Buffer-Size for details.

Swarm listening on /ip4/127.0.0.1/tcp/4001 Swarm listening on /ip4/127.0.0.1/udp/4001/quic Swarm listening on /ip4/192.168.1.126/tcp/4001 Swarm listening on /ip4/192.168.1.126/udp/4001/quic Swarm listening on /ip6/::1/tcp/4001 Swarm listening on /ip6/::1/udp/4001/quic Swarm listening on /p2p-circuit Swarm announcing /ip4/127.0.0.1/tcp/4001 Swarm announcing /ip4/127.0.0.1/udp/4001/quic Swarm announcing /ip4/192.168.1.126/tcp/4001 Swarm announcing /ip4/192.168.1.126/udp/4001/quic Swarm announcing /ip4/75.131.26.156/udp/4001/quic Swarm announcing /ip6/::1/tcp/4001 Swarm announcing /ip6/::1/udp/4001/quic API server listening on /ip4/127.0.0.1/tcp/5001 WebUI: http://127.0.0.1:5001/webui Gateway (readonly) server listening on /ip4/127.0.0.1/tcp/8080 Daemon is ready

Best regards, Doug

On Mon, Sep 6, 2021 at 11:05 AM Marten Seemann @.***> wrote:

Maybe we can get around patching https://github.com/mikioh/tcp (or the fork I'm maintaining). We only need this package to collect TCP metrics, and I assume you could live without TCP metrics (at least for now). It would probably be not too hard to extend libp2p/go-tcp-transport#93 https://github.com/libp2p/go-tcp-transport/pull/93 to disable metrics collection on RISC V as well. Maybe you try that out, @agsstaff https://github.com/agsstaff, and send a PR if it works.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ipfs/go-ipfs/issues/8398#issuecomment-913714364, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIDJX3IXNNYVKEHUOOB2V3DUATKEBANCNFSM5DCSFJ7Q . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

DavidBurela commented 2 years ago

@agsstaff you might want to rename the issue to RISC-V compile issues This issue with the TCP library not compiling is a brand new regression.

IPFS on RISC-V was building fine last year. There was a single bug in the golang core libraries which was fixed in later versions https://blog.davidburela.com/2020/11/16/ipfs-on-risc-v/ and I was tracking it in #7781

I just tried it on go1.17.4 and I am getting the same compile issues as you mentioned in the original post

> make build
...
# github.com/marten-seemann/tcp
../go/pkg/mod/github.com/marten-seemann/tcp@v0.0.0-20210406111302-dfbc87cc63fd/sys_linux.go:8:19: undefined: sysSIOCINQ
../go/pkg/mod/github.com/marten-seemann/tcp@v0.0.0-20210406111302-dfbc87cc63fd/sys_linux.go:9:19: undefined: sysSIOCOUTQ
agsstaff commented 2 years ago

Hello David, Thank you for the email.. I was able to fix the Golang compile error with go version go1.17 linux/riscv64.

As for the IPFS TCP error.. here is my fix but has not been verified the author

I created a new file in the TCP folder called sys_linux_riscv64.go and copied the two values from sys_linux_arm64.go.

cat sys_linux_riscv64.go // Copyright 2017 Mikio Hara. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file.

package tcp

const ( sysSIOCINQ = 0x541b sysSIOCOUTQ = 0x5411 )

This buffer size error comes up at launch.. 2021/12/06 09:46:58 failed to sufficiently increase receive buffer size (was: 208 kiB, wanted: 2048 kiB, got: 416 kiB). See https://github.com/lucas-clemente/quic-go/wiki/UDP-Receive-Buffer-Size for details.

So running sysctl -w net.core.rmem_max=2500000 fixed the buffer error.

The RISC-V hardware is the SiFIVE Unmatched board running Risc-V 64 21.10 (Impish Indri)

Please let me know if you have a better fix for the compile and buffer errors

Best regards, Doug

https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=icon Virus-free. www.avast.com https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=link <#m_-2496260210117685770_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Mon, Dec 6, 2021 at 5:47 AM David Burela @.***> wrote:

@agsstaff https://github.com/agsstaff you might want to rename the issue to RISC-V compile issues This issue with the TCP library not compiling is a brand new regression.

IPFS on RISC-V was building fine last year. There was a single bug in the golang core libraries which was fixed in later versions https://blog.davidburela.com/2020/11/16/ipfs-on-risc-v/ and I was tracking it in #7781 https://github.com/ipfs/go-ipfs/issues/7781

I just tried it on go1.17.4 and I am getting the same compile issues as you mentioned in the original post

make build ...

github.com/marten-seemann/tcp

..@./sys_linux.go:8:19: undefined: sysSIOCINQ ..@./sys_linux.go:9:19: undefined: sysSIOCOUTQ

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ipfs/go-ipfs/issues/8398#issuecomment-986657105, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIDJX3PR6NWZUUZUHAN6BJTUPSIFBANCNFSM5DCSFJ7Q . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=icon Virus-free. www.avast.com https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=link <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

Jorropo commented 2 years ago

Note to @marten-seemann about github.com/marten-seemann/tcp. You could add a fallback and set your constants by loading them from the libc headers (using CGO), the RISC V (or whatever arch) guys already worked on copy pasting the right info at the right place, might as well use that. I'm confident most of the code is exactly the same everywhere (for linux at least) and only constants need to be updated.

I might get around doing that.

marten-seemann commented 2 years ago

@Jorropo I won't have the bandwidth to dive into the tcp library. The only reason I forked it is because we needed to add this function: https://github.com/marten-seemann/tcp/commit/dfbc87cc63fd003b9a070c76d605769fa3e2e3b2. I'm happy to review a PR though.

ifsheldon commented 1 year ago

I think I got the same error on my M1 Mac and my RISC-V board. Both Go versions are 1.19.5. I was compiling Kubo natively on my board and also cross-compiling it on my Mac with make build GOOS=linux GOARCH=riscv64. I guess you can easily reproduce this error with cross compilation.

The error msg is a bit different as below:

# omit downloading a bunch of go modules
go: downloading github.com/golang/snappy v0.0.4
go version go1.19.5 darwin/arm64
bin/check_go_version 1.18
plugin/loader/preload.sh > plugin/loader/preload.go
go fmt plugin/loader/preload.go >/dev/null
go: downloading github.com/klauspost/compress v1.15.12
go: downloading golang.org/x/text v0.5.0
go: downloading google.golang.org/genproto v0.0.0-20211118181313-81c1377c94b1
go build  "-trimpath" -ldflags="-X "github.com/ipfs/kubo".CurrentCommit=644f0ae22" -o "cmd/ipfs/ipfs" "github.com/ipfs/kubo/cmd/ipfs"
go: downloading github.com/coreos/go-systemd/v22 v22.5.0
# github.com/marten-seemann/tcp
../../../go/pkg/mod/github.com/marten-seemann/tcp@v0.0.0-20210406111302-dfbc87cc63fd/sys_linux.go:8:19: undefined: sysSIOCINQ
../../../go/pkg/mod/github.com/marten-seemann/tcp@v0.0.0-20210406111302-dfbc87cc63fd/sys_linux.go:9:19: undefined: sysSIOCOUTQ
make: *** [cmd/ipfs/ipfs] Error 2

After a long research, I found this post. We can grep the values of SIOCINQ and SIOCOUTQ with their aliases.

Here are my logs:

user@starfive ~> grep SIOCINQ /usr/include/*/* 
/usr/include/linux/sockios.h:#define SIOCINQ            FIONREAD

user@starfive ~ [2]> grep FIONREAD /usr/include/*/*
/usr/include/asm-generic/ioctls.h:#define FIONREAD      0x541B

user@starfive ~> grep SIOCOUTQ /usr/include/*/*
/usr/include/linux/sockios.h:#define SIOCOUTQ   TIOCOUTQ        /* output queue size (not sent + not acked) */

user@starfive ~ [2]> grep TIOCOUTQ /usr/include/*/*
/usr/include/asm-generic/ioctls.h:#define TIOCOUTQ      0x5411

So here we have the constants and it's kind of annoying to me the original author of tcp hardcoded these constants when the kernel has these to offer.

Jorropo commented 1 year ago

So here we have the constants and it's kind of annoying to me the original author of tcp hardcoded these constants when the kernel has these to offer.

I wanted to do this, however not everyone have /usr/include/*/* needed for cross compilation (the constants change on each arch). I think just adding more constants for each arch is the easiests solution here. Maybe codegen them but that seems overkill.