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

Compilation Error #134

Open
rakim-0 opened this issue Apr 30, 2024 · 2 comments
Open

Compilation Error #134

rakim-0 opened this issue Apr 30, 2024 · 2 comments

Comments

@rakim-0
Copy link

rakim-0 commented Apr 30, 2024

Hi, I am not able to compile the library because of -Wstrict-prototypes. I could add the prototypes but just wanted to know if this is due to a newer version of clang. (or just skill issue ;-;)

I'm on Fedora 39 and here's the output for clang --version

❯ clang --version
clang version 17.0.6 (Fedora 17.0.6-2.fc39)
Target: x86_64-redhat-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

make output:

~/programming_stuff/repos_ext/syscall_intercept
❯ make                     
[  0%] Built target check_whitespace
[  0%] Building CXX object CMakeFiles/cpp_test.dir/src/cpp_compile_test.cc.o
[  1%] Building C object CMakeFiles/cpp_test.dir/src/cpp_compile_mock.c.o
[  2%] Linking CXX executable cpp_test
[  2%] Built target cpp_test
[  2%] Built target cstyle
[  2%] Building C object CMakeFiles/syscall_intercept_base_c.dir/src/disasm_wrapper.c.o
/home/rakim/programming_stuff/repos_ext/syscall_intercept/repo/src/disasm_wrapper.c:66:14: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
   66 | nop_vsnprintf()
      |              ^
      |               void
1 error generated.
make[2]: *** [CMakeFiles/syscall_intercept_base_c.dir/build.make:76: CMakeFiles/syscall_intercept_base_c.dir/src/disasm_wrapper.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:300: CMakeFiles/syscall_intercept_base_c.dir/all] Error 2
make: *** [Makefile:146: all] Error 2

cmake output:

~/programming_stuff/repos_ext/syscall_intercept
❯ cmake repo -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=clang
CMake Deprecation Warning at CMakeLists.txt:32 (cmake_minimum_required):
  Compatibility with CMake < 3.5 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


-- The C compiler identification is Clang 17.0.6
-- The ASM compiler identification is Clang with GNU-like command-line
-- Found assembler: /usr/lib64/ccache/clang
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/lib64/ccache/clang - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Performing Test HAS_WERROR
-- Performing Test HAS_WERROR - Success
-- Performing Test HAS_WALL
-- Performing Test HAS_WALL - Success
-- Performing Test HAS_WEXTRA
-- Performing Test HAS_WEXTRA - Success
-- Performing Test HAS_PEDANTIC
-- Performing Test HAS_PEDANTIC - Success
-- Performing Test HAS_NOMFI
-- Performing Test HAS_NOMFI - Success
-- Performing Test HAS_NO9099
-- Performing Test HAS_NO9099 - Failed
-- Performing Test LINKER_HAS_NOSTDLIB
-- Performing Test LINKER_HAS_NOSTDLIB - Success
-- Performing Test HAS_WLFATAL
-- Performing Test HAS_WLFATAL - Success
-- Performing Test HAS_NOUNUSEDARG
-- Performing Test HAS_NOUNUSEDARG - Success
-- Performing Test HAS_ARG_PIE
-- Performing Test HAS_ARG_PIE - Success
-- Performing Test HAS_ARG_NOPIE
-- Performing Test HAS_ARG_NOPIE - Success
-- Performing Test HAS_ARG_NO_PIE
-- Performing Test HAS_ARG_NO_PIE - Success
-- Performing Test HAS_GCC_ATTR_CONSTR
-- Performing Test HAS_GCC_ATTR_CONSTR - Success
-- Performing Test HAS_GCC_PRAGMA_SYSH
-- Performing Test HAS_GCC_PRAGMA_SYSH - Success
-- Looking for include file elf.h
-- Looking for include file elf.h - found
-- Looking for dladdr
-- Looking for dladdr - found
-- Looking for a CXX compiler
-- Looking for a CXX compiler - /usr/lib64/ccache/c++
-- The CXX compiler identification is GNU 13.2.1
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/lib64/ccache/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Perl: /usr/bin/perl (found version "5.38.2") 
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE  
-- Configuring done (2.8s)
-- Generating done (0.1s)
-- Build files have been written to: /home/rakim/programming_stuff/repos_ext/syscall_intercept
@GBuella
Copy link
Contributor

GBuella commented May 1, 2024

Good catch! It is not your skill issue, it should be something:

static int
nop_vsnprintf(char *str, size_t size, const char *format, va_list ap)

See the definition in capstone:
https://github.com/capstone-engine/capstone/blob/8f9a337dfaad6bddec3fb8dc1cccae17a3736b93/include/capstone/capstone.h#L243

@rakim-0
Copy link
Author

rakim-0 commented May 9, 2024

Ah so to compile it for now, I just changed the function to the definition given below.
Just used printf/vfprintf to get rid of the unused parameters error (it seems very hacky so am curious how to deal with that error in a dummy function?).

I also had to change main() -> main(void) in two different files: /test/test_clone_thread.c and /test/filter_test.c

and finally it compiles ^^

static int
nop_vsnprintf(char *str, size_t size, const char *format, va_list ap)
{
	printf("%s %lu %s", str, size, format);
	vfprintf(stderr, format, ap);
	return 0;
}

P.S. Sorry for responding so late, just got done with finals week.

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