zeek / zeek

Zeek is a powerful network analysis framework that is much different from the typical IDS you may know.
https://www.zeek.org
Other
6.45k stars 1.22k forks source link

link error in arm64 #2330

Open jiamo opened 2 years ago

jiamo commented 2 years ago

With latest code in arm64 build got 100% but link error:

[100%] Building CXX object src/CMakeFiles/zeek.dir/main.cc.o
[100%] Linking CXX executable zeek
/usr/lib/aarch64-linux-gnu/libresolv.a(res_comp.o): in function `__res_hnok':
(.text+0x120): relocation truncated to fit: R_AARCH64_LD64_GOTPAGE_LO15 against symbol `__stack_chk_guard@@GLIBC_2.17' defined in .data.rel.ro section in /lib/ld-linux-aarch64.so.1
/usr/bin/ld: (.text+0x120): warning: too many GOT entries for -fpic, please recompile with -fPIC
collect2: error: ld returned 1 exit status
make[3]: *** [src/CMakeFiles/zeek.dir/build.make:1597: src/zeek] Error 1
make[3]: Leaving directory '/src/zeek-master/build'
make[2]: *** [CMakeFiles/Makefile2:5912: src/CMakeFiles/zeek.dir/all] Error 2
make[1]: *** [Makefile:166: all] Error 2
make: *** [Makefile:15: all] Error 2
make[2]: Leaving directory '/src/zeek-ma

build two times it can rehappened.

The build process is simple

git clone --recursive https://github.com/zeek/zeek
./configure --prefix=/usr 
make
0xxon commented 2 years ago

Thank you very much for the report.

Could you please add a bit more context, specifically:

would be helpful.

jiamo commented 2 years ago

uname

Linux arm1 5.15.0-1013-oracle #17~20.04.1-Ubuntu SMP Mon Jul 4 05:29:46 UTC 2022 aarch64 aarch64 aarch64 GNU/Linux

Docker version

Client: Docker Engine - Community
 Version:           20.10.17
 API version:       1.41

Dockerfile

FROM debian:bookworm-slim AS builder

The default g++11

0xxon commented 2 years ago

Interesting. Would it be easy for you to check if this happens with bullseye too? Bookworm is not yet on our list of supported platforms. This does not mean that we won't fix problems - I am just curious if it is specific to the distribution.

jiamo commented 2 years ago

bullseye is the same error.

timwoj commented 2 years ago

As a data point, I spun up an arm64 AWS instance and was able to build without any issues.

uname:

Linux ip-snip 5.15.0-1009-aws #11-Ubuntu SMP Thu May 26 19:39:49 UTC 2022 aarch64 aarch64 aarch64 GNU/Linux

debian_version:

bookworm/sid
awelzel commented 1 year ago

This seems to be happening for the aarch64 build for Debian_11 build on OBS, actually:

[ 5253s] [100%] Building CXX object src/CMakeFiles/zeek_objs.dir/script_opt/ZAM/ZOp.cc.o
[ 5256s] make[4]: Leaving directory '/usr/src/packages/BUILD/build'
[ 5256s] [100%] Built target zeek_objs
[ 5256s] make[4]: Entering directory '/usr/src/packages/BUILD/build'
[ 5256s] Scanning dependencies of target zeek
[ 5256s] make[4]: Leaving directory '/usr/src/packages/BUILD/build'
[ 5256s] make[4]: Entering directory '/usr/src/packages/BUILD/build'
[ 5256s] [100%] Building CXX object src/CMakeFiles/zeek.dir/main.cc.o
[ 5258s] [100%] Linking CXX executable zeek
[ 5263s] /usr/lib/aarch64-linux-gnu/libresolv.a(res_comp.o): in function `__res_hnok':
[ 5263s] (.text+0x120): relocation truncated to fit: R_AARCH64_LD64_GOTPAGE_LO15 against symbol `__stack_chk_guard@@GLIBC_2.17' defined in .data.rel.ro section in /lib/ld-linux-aarch64.so.1
[ 5263s] /usr/bin/ld: (.text+0x120): warning: too many GOT entries for -fpic, please recompile with -fPIC
[ 5263s] collect2: error: ld returned 1 exit status
[ 5263s] make[4]: *** [src/CMakeFiles/zeek.dir/build.make:1599: src/zeek] Error 1

https://build.opensuse.org/package/live_build_log/security:zeek/zeek/Debian_11/aarch64

cc - @perkinjo tried using the binary builds on M1 with Debian 11.

ckreibich commented 1 year ago

Not sure this helps, but I diffed the OBS build configs for Zeek 5.1.1 (which fails) vs the nightly build (which runs through). The Spicy config indicates the Gold linker is used for the former, not the latter:

@@ -185,7 +185,7 @@
  -- Looking for backtrace - found
  -- backtrace facility detected in default set of libraries
  -- Found Backtrace: /usr/include
- -- Using Gold linker
+ -- Gold linker usage disabled
  -- Check if compiler accepts -pthread
  -- Check if compiler accepts -pthread - yes
  -- Found BISON: /usr/bin/bison
@@ -213,7 +213,9 @@
  -- Performing Test CMU_HAVE_WARN_DATE_TIME
  -- Performing Test CMU_HAVE_WARN_DATE_TIME - Success
  -- Performing Test CMU_HAVE_LD_lld
- -- Performing Test CMU_HAVE_LD_lld - Success
+ -- Performing Test CMU_HAVE_LD_lld - Failed
+ -- Performing Test CMU_HAVE_LD_gold
+ -- Performing Test CMU_HAVE_LD_gold - Success
  -- Performing Test CMU_HAVE_STACK_PROTECTOR_STRONG
  -- Performing Test CMU_HAVE_STACK_PROTECTOR_STRONG - Success
  -- Performing Test CMU_HAVE_STACK_CLASH_PROTECTION
@@ -221,21 +223,21 @@

  ====================|  Spicy Build Summary  |====================

- Version:               1.5.2
+ Version:               1.6.0

  Build type:            Release
  Build directory:       /usr/src/packages/BUILD/build/auxil/spicy/spicy
- Install prefix:        /opt/zeek
+ Install prefix:        /opt/zeek-nightly
  Build shared libs:     OFF

- Host system:           Linux 5.14.21-150400.24.28-default (aarch64)
+ Host system:           Linux 5.14.21-150400.24.38-default (aarch64)
  C compiler:            /usr/bin/cc (GNU 10.2.1)
  C++ compiler:          /usr/bin/c++ (GNU 10.2.1)

  Building toolchain:    yes

  Use ccache:            no
- Use gold linker:       yes
+ Use gold linker:       no
  Use sanitizers:
  Use backtrace:         yes
awelzel commented 1 year ago

Oh, that's great! So with the upcoming Spicy 1.5.x release once it's bumped in release/5.1 branch that might sort itself out. The unconditional usage of gold has been disabled in spicy and @bbannier picked it up for backporting into 1.5.

https://github.com/zeek/spicy/pull/1308

awelzel commented 1 year ago

@jiamo - we believe this may be fixed in the master branch as well as in the current release/5.1 and release/5.0 branches. I'm going to close the ticket, but feel free to re-open if you find it's not working on master.

timwoj commented 1 year ago

This is happening again for release/5.0 builds on OBS with Debian 11/aarch64: https://build.opensuse.org/build/security:zeek/Debian_11/aarch64/zeek-5.0/_log

[ 6222s] [100%] Linking CXX executable zeek
[ 6230s] /usr/lib/aarch64-linux-gnu/libresolv.a(res_comp.o): in function `__res_hnok':
[ 6230s] (.text+0x120): relocation truncated to fit: R_AARCH64_LD64_GOTPAGE_LO15 against symbol `__stack_chk_guard@@GLIBC_2.17' defined in .data.rel.ro section in /lib/ld-linux-aarch64.so.1
[ 6230s] /usr/bin/ld: (.text+0x120): warning: too many GOT entries for -fpic, please recompile with -fPIC
[ 6230s] collect2: error: ld returned 1 exit status
[ 6230s] make[4]: *** [src/CMakeFiles/zeek.dir/build.make:1605: src/zeek] Error 1

The configure log indicates we're not using the gold linker still though, so there's something else happening here. I also reproduced this locally in a Debian 11 docker instance on an M1 Mac.

Debian 12/aarch64 builds for both release/5.0 and release/6.0 complete without errors.