-
Notifications
You must be signed in to change notification settings - Fork 179
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
Changed compiler to clang. #282
Changed compiler to clang. #282
Conversation
Signed-off-by: Devidas Jadhav <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your PR!
This https://github.com/cilium/pwru/blob/main/local-release.sh needs to be changed too.
Modified compiler to clang keeping in line with bpf. Signed-off-by: Devidas Jadhav <[email protected]>
Added and verified local-release.sh.
|
Thanks. The last bit is to replace gcc with clang for arm64 in |
clang build for arm64 failing when clang replaced by gcc.
I had only changed gcc to clan in arm64. |
Found root cause of issue.
also found similar issue. trying to figure out clang compiler and compiling using aarch64 clang binary. as well as I will check if there is any repo hosting these clang. @brb any pointers about this ? |
just realized is not cross-compiler rather its clang for aarch64. |
Could we use a clang cross-compiler for arm64? https://clang.llvm.org/docs/CrossCompilation.html |
I am able to cross compile libpcap. @brb any pointers ? |
Is it GCC or Clang? |
It was typo. |
In order to cross compile with Clang, you need to set |
Yes Now I can compile. CC=clang CGO_CFLAGS="--target=aarch64-unknown-linux" GOARCH=arm64 CGO_ENABLED=1 go build \
-ldflags "-w -s \
-X 'github.com/cilium/pwru/internal/pwru.Version=2f22f3f'"
# github.com/cilium/pwru
/usr/local/go/pkg/tool/linux_386/link: running clang failed: exit status 1
/usr/bin/ld: /tmp/go-link-1420334561/go.o: Relocations in generic ELF (EM: 183)
/usr/bin/ld: /tmp/go-link-1420334561/go.o: Relocations in generic ELF (EM: 183)
/usr/bin/ld: /tmp/go-link-1420334561/go.o: Relocations in generic ELF (EM: 183)
/usr/bin/ld: /tmp/go-link-1420334561/go.o: Relocations in generic ELF (EM: 183)
/usr/bin/ld: /tmp/go-link-1420334561/go.o: Relocations in generic ELF (EM: 183)
/usr/bin/ld: /tmp/go-link-1420334561/go.o: Relocations in generic ELF (EM: 183)
/usr/bin/ld: /tmp/go-link-1420334561/go.o: Relocations in generic ELF (EM: 183)
/usr/bin/ld: /tmp/go-link-1420334561/go.o: Relocations in generic ELF (EM: 183)
/usr/bin/ld: /tmp/go-link-1420334561/go.o: Relocations in generic ELF (EM: 183)
/usr/bin/ld: /tmp/go-link-1420334561/go.o: error adding symbols: file in wrong format
clang: error: linker command failed with exit code 1 (use -v to see invocation) trying to add linker using i.e. /usr/local/go/pkg/tool/linux_386/link -I aarch64-linux-gnu-ld |
here is execsnoop output.
Which means target flag is not used by go build i.e. cgo is not compiling for arm64. |
Maybe try this hack |
@devidasjadhav 👋 any update on this PR? |
@devidasjadhav I'm closing this PR due to inactivity. Please let me know if I need to reopen. |
Closes #221
I have tested this on vm.
Test:
verified binary is executable and running as expected.
Removed LIBPCAP_CC. As it indicates we are using different compilers.
I can revert it if needed.