weaveworks / scope

Monitoring, visualisation & management for Docker & Kubernetes
https://www.weave.works/oss/scope/
Apache License 2.0
5.85k stars 709 forks source link

question about build #3799

Open luomoyisheng opened 4 years ago

luomoyisheng commented 4 years ago

github.com/iovisor/gobpf/elf github.com/iovisor/gobpf/elf vendor/github.com/iovisor/gobpf/elf/module.go: In function 'bpf_attach_socket': vendor/github.com/iovisor/gobpf/elf/module.go:83:38: error: 'SO_ATTACH_BPF' undeclared (first use in this function) return setsockopt(sock, SOL_SOCKET, SO_ATTACH_BPF, &fd, sizeof(fd)); ^ vendor/github.com/iovisor/gobpf/elf/module.go:83:38: note: each undeclared identifier is reported only once for each function it appears in vendor/github.com/iovisor/gobpf/elf/module.go: In function 'bpf_detach_socket': vendor/github.com/iovisor/gobpf/elf/module.go:88:38: error: 'SO_DETACH_BPF' undeclared (first use in this function) return setsockopt(sock, SOL_SOCKET, SO_DETACH_BPF, &fd, sizeof(fd));

bboreham commented 4 years ago

That’s a little terse. Can you do a differential diagnosis against the CI build which is working fine?

Are you building inside the build container? (Eg by running make)

luomoyisheng commented 4 years ago

I don't want to run in a container, I just want to run on the host, so I just need to compile a binary program

luomoyisheng commented 4 years ago

Moreover, I need to compile binary programs of other architectures after X86 compilation, which is my requirement.

bboreham commented 4 years ago

Suggest you take a look at what is installed by the build container, as a guide to what you’ll need on your host.

bboreham commented 4 years ago

Note make prog/scope will give you the plain binary, built by a container.

luomoyisheng commented 4 years ago

OK, I'll try

luomoyisheng commented 4 years ago

Can't I build binaries directly from makefiles? Can only be built from containers? I have some packages that can't be downloaded eg: package golang.org/x/lint/golint: unrecognized import path "golang.org/x/lint/golint" (https fetch: Get https://golang.org/x/lint/golint?go-get=1: dial tcp 216.239.37.1:443: connect: connection refused)

bboreham commented 4 years ago

If you install all dependencies on the host then make prog/scope BUILD_IN_CONTAINER=false.

luomoyisheng commented 4 years ago

OK,I'm a little busy this afternoon. I haven't replied to you. Thank you very much for your help

luomoyisheng commented 4 years ago

make prog/scope BUILD_IN_CONTAINER=false report errors: mkdir -p prog/staticui esc -o prog/staticui/staticui.go -pkg staticui -prefix client/build client/build make: esc:command not found make: *** [prog/staticui/staticui.go] error This esc doesn't look like a system command

bboreham commented 4 years ago

esc is a dependency of the build. For the provided build process it is installed here: https://github.com/weaveworks/scope/blob/e6faa2ba4bf842bb81993a64232554c281ced644/backend/Dockerfile#L25

luomoyisheng commented 4 years ago

Ok, I thought it was a linux system command, so I yum install esc.

luomoyisheng commented 4 years ago

The container is compiled, but I want to compile other architectures, such as mips64le, how do I modify the Makefile and perform compilation command

bboreham commented 4 years ago

We do a couple of cross-platform builds in CI to check it doesn't break: https://github.com/weaveworks/scope/blob/e6faa2ba4bf842bb81993a64232554c281ced644/.circleci/config.yml#L116

Some features are stubbed out but I think that's based on OS rather than CPU.

luomoyisheng commented 4 years ago

Ok, thanks, I don’t have an arm system. I know that the go code can be cross-compiled. I want to cross-compile the arm architecture on x86_64. Is this feasible?

luomoyisheng commented 4 years ago

I execute:GOARCH=mips64le make BUILD_IN_CONTAINER=false GO_BUILD_INSTALL_DEPS= prog/scope output:time env GOGC=off CGO_ENABLED=1 CC=/opt/gcc-4.4-gnu/bin/mipsel-linux-gcc go build -mod vendor -ldflags "-extldflags \"-static\" -X main.version=2f9ccdc -s -w" -tags 'netgo unsafe' -o prog/scope ./prog

github.com/docker/docker/pkg/system

vendor/github.com/docker/docker/pkg/system/stat_linux.go:11:3: cannot use s.Rdev (type uint32) as type uint64 in field value

runtime/cgo

collect2: ld terminated with signal 11 [Segmentation fault] /opt/gcc-4.4-gnu/bin/../lib/gcc/mipsel-linux/4.4.0/../../../../mipsel-linux/bin/ld: $WORK/b286/_cgo_main.o: ABI is incompatible with that of the selected emulation /opt/gcc-4.4-gnu/bin/../lib/gcc/mipsel-linux/4.4.0/../../../../mipsel-linux/bin/ld: failed to merge target specific data of file $WORK/b286/_cgo_main.o /opt/gcc-4.4-gnu/bin/../lib/gcc/mipsel-linux/4.4.0/../../../../mipsel-linux/bin/ld: $WORK/b286/_x001.o: ABI is incompatible with that of the selected emulation /opt/gcc-4.4-gnu/bin/../lib/gcc/mipsel-linux/4.4.0/../../../../mipsel-linux/bin/ld: failed to merge target specific data of file $WORK/b286/_x001.o /opt/gcc-4.4-gnu/bin/../lib/gcc/mipsel-linux/4.4.0/../../../../mipsel-linux/bin/ld: $WORK/b286/_x002.o: ABI is incompatible with that of the selected emulation /opt/gcc-4.4-gnu/bin/../lib/gcc/mipsel-linux/4.4.0/../../../../mipsel-linux/bin/ld: failed to merge target specific data of file $WORK/b286/_x002.o /opt/gcc-4.4-gnu/bin/../lib/gcc/mipsel-linux/4.4.0/../../../../mipsel-linux/bin/ld: $WORK/b286/_x003.o: ABI is incompatible with that of the selected emulation /opt/gcc-4.4-gnu/bin/../lib/gcc/mipsel-linux/4.4.0/../../../../mipsel-linux/bin/ld: failed to merge target specific data of file $WORK/b286/_x003.o /opt/gcc-4.4-gnu/bin/../lib/gcc/mipsel-linux/4.4.0/../../../../mipsel-linux/bin/ld: $WORK/b286/_x004.o: ABI is incompatible with that of the selected emulation /opt/gcc-4.4-gnu/bin/../lib/gcc/mipsel-linux/4.4.0/../../../../mipsel-linux/bin/ld: failed to merge target specific data of file $WORK/b286/_x004.o /opt/gcc-4.4-gnu/bin/../lib/gcc/mipsel-linux/4.4.0/../../../../mipsel-linux/bin/ld: $WORK/b286/_x005.o: ABI is incompatible with that of the selected emulation /opt/gcc-4.4-gnu/bin/../lib/gcc/mipsel-linux/4.4.0/../../../../mipsel-linux/bin/ld: failed to merge target specific data of file $WORK/b286/_x005.o /opt/gcc-4.4-gnu/bin/../lib/gcc/mipsel-linux/4.4.0/../../../../mipsel-linux/bin/ld: $WORK/b286/_x006.o: ABI is incompatible with that of the selected emulation /opt/gcc-4.4-gnu/bin/../lib/gcc/mipsel-linux/4.4.0/../../../../mipsel-linux/bin/ld: failed to merge target specific data of file $WORK/b286/_x006.o /opt/gcc-4.4-gnu/bin/../lib/gcc/mipsel-linux/4.4.0/../../../../mipsel-linux/bin/ld: $WORK/b286/_x007.o: ABI is incompatible with that of the selected emulation /opt/gcc-4.4-gnu/bin/../lib/gcc/mipsel-linux/4.4.0/../../../../mipsel-linux/bin/ld: failed to merge target specific data of file $WORK/b286/_x007.o /opt/gcc-4.4-gnu/bin/../lib/gcc/mipsel-linux/4.4.0/../../../../mipsel-linux/bin/ld: $WORK/b286/_x008.o: ABI is incompatible with that of the selected emulation /opt/gcc-4.4-gnu/bin/../lib/gcc/mipsel-linux/4.4.0/../../../../mipsel-linux/bin/ld: failed to merge target specific data of file $WORK/b286/_x008.o /opt/gcc-4.4-gnu/bin/../lib/gcc/mipsel-linux/4.4.0/../../../../mipsel-linux/bin/ld: $WORK/b286/_x009.o: ABI is incompatible with that of the selected emulation /opt/gcc-4.4-gnu/bin/../lib/gcc/mipsel-linux/4.4.0/../../../../mipsel-linux/bin/ld: failed to merge target specific data of file $WORK/b286/_x009.o /opt/gcc-4.4-gnu/bin/../lib/gcc/mipsel-linux/4.4.0/../../../../mipsel-linux/bin/ld: $WORK/b286/_x010.o: ABI is incompatible with that of the selected emulation /opt/gcc-4.4-gnu/bin/../lib/gcc/mipsel-linux/4.4.0/../../../../mipsel-linux/bin/ld: failed to merge target specific data of file $WORK/b286/_x010.o /tmp/go-build590877641/b286/_x003.o: In function _cgo_release_context': /usr/lib/golang/src/runtime/cgo/gcc_context.c:14: relocation truncated to fit: R_MIPS_CALL16 against_cgo_get_context_function'

real 0m0.773s user 0m0.941s sys 0m0.391s make: *** [prog/scope] Error 2

I made the gcc toolchain of mips64 on x86_64, and executed the compilation but the above problem still occurred

bboreham commented 4 years ago

I want to cross-compile the arm architecture on x86_64. Is this feasible?

The line I gave you does exactly that.

vendor/github.com/docker/docker/pkg/system/stat_linux.go:11:3: cannot use s.Rdev (type uint32) as type uint64 in field value

Possibly a newer version of the Docker code would work, but updating that may need changes elsewhere to fit with different interfaces.

collect2: ld terminated with signal 11 [Segmentation fault]

This is a bug in the linker.

luomoyisheng commented 4 years ago

Ok, thanks, let me try

luomoyisheng commented 4 years ago

go get github.com/docker/docker/pkg/system

output:go: github.com/docker/libcontainer@v2.2.2-0.20150701164209-83a102cc68a0+incompatible: invalid pseudo-version: git fetch --unshallow -f https://github.com/docker/libcontainer in /root/go/pkg/mod/cache/vcs/64bebe9f90303f9d2c71fa74be10602c56b1856196b58f28075dffdbe7d0b953: exit status 128: fatal: git fetch-pack: expected shallow list

I am eager to compile a program with mips64le architecture, but I feel I can do nothing. You have communication software, can I add you? In order to solve the problem, I can pay a little money to thank you for your help.