UnitTestBot / UTBotCpp

Tool that generates unit test by C/C++ source code, trying to reach all branches and maximize code coverage
Apache License 2.0
158 stars 27 forks source link

Generated tests cannot be run when PIE flag is present in compile_commands.json #618

Closed IDKWNTCMF closed 1 year ago

IDKWNTCMF commented 1 year ago

Description We often want to compile object files with PIC flag, so we add it to corresponding compile commands. However it can be overriden if PIE flag is used in source compile commands.

To Reproduce Steps to reproduce the behavior:

  1. Open the libyang project in IDE
  2. Use plugin to generate tests *2.1 Remove initialization of thread-local variables in log_wrapper.c if #616 is not resolved yet
  3. Run generated tests

Expected behavior Tests are supposed to be executed successfully.

Actual behavior Linker error.

Visual proofs (screenshots, logs)

error: /home/utbot/libyang/utbot_tests/makefiles/src/../../../build/utbot_files/utbot_build/recompiled/tests/style/CMakeFiles/cpp_compat.dir/cpp_compat.c.o: requires dynamic R_X86_64_PC32 reloc against 'main__' which may overflow at runtime; recompile with -fPIC
clang-10: error: linker command failed with exit code 1 (use -v to see invocation)