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

Getting undefined reference errors when trying to build with make fuzz #9608

Open
personnumber3377 opened this issue Dec 10, 2024 · 5 comments

Comments

@personnumber3377
Copy link

Hi!

When I try to run make fuzz , I get these errors during the build:


/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libunbound.a(ub_event_pluggable.o): in function `my_event_new':
(.text+0x162): undefined reference to `event_set'
/usr/bin/ld: (.text+0x16e): undefined reference to `event_base_set'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libunbound.a(ub_event_pluggable.o): in function `my_timer_add':
(.text+0x1ef): undefined reference to `event_set'
/usr/bin/ld: (.text+0x1fc): undefined reference to `event_base_set'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libunbound.a(ub_event_pluggable.o): in function `my_event_base_free':
(.text+0x275): undefined reference to `event_base_free'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libunbound.a(ub_event_pluggable.o): in function `ub_default_event_base':
(.text+0x2f5): undefined reference to `event_base_new'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libunbound.a(ub_event_pluggable.o): in function `ub_get_event_sys':
(.text+0x3c7): undefined reference to `event_get_version'
/usr/bin/ld: (.text+0x3dd): undefined reference to `event_base_get_method'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libunbound.a(ub_event_pluggable.o): in function `my_event_del':
(.text+0x1b9): undefined reference to `event_del'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libunbound.a(ub_event_pluggable.o): in function `my_timer_add':
(.text+0x215): undefined reference to `event_add'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libunbound.a(ub_event_pluggable.o): in function `my_event_add':
(.text+0x239): undefined reference to `event_add'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libunbound.a(ub_event_pluggable.o): in function `my_event_base_loopexit':
(.text+0x249): undefined reference to `event_base_loopexit'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libunbound.a(ub_event_pluggable.o): in function `my_event_base_dispatch':
(.text+0x259): undefined reference to `event_base_dispatch'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libunbound.a(ub_event_pluggable.o): in function `my_signal_del':
(.text+0x299): undefined reference to `event_del'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libunbound.a(ub_event_pluggable.o): in function `my_timer_del':
(.text+0x2a9): undefined reference to `event_del'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libunbound.a(ub_event_pluggable.o): in function `my_signal_add':
(.text+0x2b9): undefined reference to `event_add'
collect2: error: ld returned 1 exit status
make[3]: *** [src/wallet/CMakeFiles/wallet_rpc_server.dir/build.make:153: bin/monero-wallet-rpc] Error 1
make[3]: Leaving directory '/home/oof/monero/build/Linux/master/fuzz'
make[2]: *** [CMakeFiles/Makefile2:3159: src/wallet/CMakeFiles/wallet_rpc_server.dir/all] Error 2
make[2]: Leaving directory '/home/oof/monero/build/Linux/master/fuzz'
make[1]: *** [Makefile:146: all] Error 2
make[1]: Leaving directory '/home/oof/monero/build/Linux/master/fuzz'
make: *** [Makefile:163: fuzz] Error 2


anyone know a good solution?

@personnumber3377
Copy link
Author

Maybe this here: NLnetLabs/unbound#299 is somehow related?

@personnumber3377
Copy link
Author

I think the culprit is the -D STATIC=ON in the Makefile. It specifies that a static binary should be built, but something goes wrong in the link process.

@personnumber3377
Copy link
Author

personnumber3377 commented Dec 10, 2024

This bug I think is something to do with the compiler. If I run this:



release-static-linux-x86_64:
	mkdir -p $(builddir)/release
	cd $(builddir)/release && cmake -D STATIC=ON -D CMAKE_C_COMPILER=afl-gcc -D CMAKE_CXX_COMPILER=afl-g++ -D ARCH="x86-64" -D BUILD_64=ON -D CMAKE_BUILD_TYPE=fuzz -D BUILD_TAG="linux-x64" $(topdir) && $(MAKE)

then I get this error:

-- Looking for -Wl,--no-undefined linker flag
-- Looking for -Wl,--no-undefined linker flag - found
-- Looking for -Wl,-undefined,error linker flag
-- Looking for -Wl,-undefined,error linker flag - found
CMake Error at CMakeLists.txt:247 (message):
  Undefined symbols test failure: expect(FALSE), success(TRUE)
Call Stack (most recent call first):
  CMakeLists.txt:253 (forbid_undefined_symbols)


-- Configuring incomplete, errors occurred!
make: *** [Makefile:139: release-static-linux-x86_64] Error 1

but if we set the compiler to cc and c++, then the compilation continues normally, therefore this has something to do with the compiler:

like so:

release-static-linux-x86_64:
	mkdir -p $(builddir)/release
	cd $(builddir)/release && cmake -D STATIC=ON -D CMAKE_C_COMPILER=cc -D CMAKE_CXX_COMPILER=c++ -D ARCH="x86-64" -D BUILD_64=ON -D CMAKE_BUILD_TYPE=fuzz -D BUILD_TAG="linux-x64" $(topdir) && $(MAKE)

that continues to compiling normally.

@selsta
Copy link
Collaborator

selsta commented Dec 13, 2024

Does #9463 help?

@personnumber3377
Copy link
Author

Hi!

Thanks for the response. I tried to compile with this in the Makefile:

fuzz:
        mkdir -p $(builddir)/fuzz
        cd $(builddir)/fuzz && cmake -D STATIC=ON -D OSSFUZZ=ON -D SANITIZE=ON -D BUILD_TESTS=ON -D USE_LTO=OFF -D CMAKE_C_COMPILER=afl-gcc -D CMAKE_CXX_COMPILER=afl-g++ -D ARCH="x86-64" -D CMAKE_BUILD_TYPE=fuzz -D BUILD_TAG="linux-x64" $(topdir) && $(MAKE)

and I am still getting the same error:

[!] WARNING: You are using outdated instrumentation, install LLVM and/or gcc-plugin and use afl-clang-fast/afl-clang-lto/afl-gcc-fast instead!
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libunbound.a(ub_event_pluggable.o): in function `my_signal_new':
(.text+0xbe): undefined reference to `event_set'
/usr/bin/ld: (.text+0xcb): undefined reference to `event_base_set'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libunbound.a(ub_event_pluggable.o): in function `my_event_new':
(.text+0x162): undefined reference to `event_set'
/usr/bin/ld: (.text+0x16e): undefined reference to `event_base_set'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libunbound.a(ub_event_pluggable.o): in function `my_timer_add':
(.text+0x1ef): undefined reference to `event_set'
/usr/bin/ld: (.text+0x1fc): undefined reference to `event_base_set'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libunbound.a(ub_event_pluggable.o): in function `my_event_base_free':
(.text+0x275): undefined reference to `event_base_free'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libunbound.a(ub_event_pluggable.o): in function `ub_default_event_base':
(.text+0x2f5): undefined reference to `event_base_new'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libunbound.a(ub_event_pluggable.o): in function `ub_get_event_sys':
(.text+0x3c7): undefined reference to `event_get_version'
/usr/bin/ld: (.text+0x3dd): undefined reference to `event_base_get_method'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libunbound.a(ub_event_pluggable.o): in function `my_event_del':
(.text+0x1b9): undefined reference to `event_del'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libunbound.a(ub_event_pluggable.o): in function `my_timer_add':
(.text+0x215): undefined reference to `event_add'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libunbound.a(ub_event_pluggable.o): in function `my_event_add':
(.text+0x239): undefined reference to `event_add'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libunbound.a(ub_event_pluggable.o): in function `my_event_base_loopexit':
(.text+0x249): undefined reference to `event_base_loopexit'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libunbound.a(ub_event_pluggable.o): in function `my_event_base_dispatch':
(.text+0x259): undefined reference to `event_base_dispatch'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libunbound.a(ub_event_pluggable.o): in function `my_signal_del':
(.text+0x299): undefined reference to `event_del'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libunbound.a(ub_event_pluggable.o): in function `my_timer_del':
(.text+0x2a9): undefined reference to `event_del'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libunbound.a(ub_event_pluggable.o): in function `my_signal_add':
(.text+0x2b9): undefined reference to `event_add'
collect2: error: ld returned 1 exit status

It works if I change the afl compiler to the normal gcc and g++ so I think it may have something to do with the specific compiler version I am using.

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

No branches or pull requests

2 participants