Support needed for a build with profiling features

I’m trying to get a custom build of x265 with profiling features, but with no luck.

My latest attempt stopped at cmake, which I fed with custom options:


Now the blocking point is the simple build of a test file by cmake itself, which ends with failure:

-- The C compiler identification is GNU 11.2.0
-- The CXX compiler identification is GNU 11.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: /bin/cc
-- Check for working C compiler: /bin/cc - broken
CMake Error at /boot/system/data/cmake/Modules/CMakeTestCCompiler.cmake:69 (message):
  The C compiler


  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: /boot/home/Desktop/x265_git/source/CMakeFiles/CMakeTmp
    Run Build Command(s):/bin/make -f Makefile cmTC_8ca14/fast && /bin/make  -f CMakeFiles/cmTC_8ca14.dir/build.make CMakeFiles/cmTC_8ca14.dir/build
    make[1]: Entering directory '/boot/home/Desktop/x265_git/source/CMakeFiles/CMakeTmp'
    Building C object CMakeFiles/cmTC_8ca14.dir/testCCompiler.c.o
    /bin/cc   -pg  -o CMakeFiles/cmTC_8ca14.dir/testCCompiler.c.o -c /boot/home/Desktop/x265_git/source/CMakeFiles/CMakeTmp/testCCompiler.c
    Linking C executable cmTC_8ca14
    /boot/system/bin/cmake -E cmake_link_script CMakeFiles/cmTC_8ca14.dir/link.txt --verbose=1
    /bin/cc -pg  CMakeFiles/cmTC_8ca14.dir/testCCompiler.c.o -o cmTC_8ca14 
    /boot/system/develop/tools/bin/../lib/gcc/x86_64-unknown-haiku/11.2.0/../../../../x86_64-unknown-haiku/bin/ld: CMakeFiles/cmTC_8ca14.dir/testCCompiler.c.o: in function `main':
    testCCompiler.c:(.text+0xa): undefined reference to `_mcount'
    collect2: error: ld returned 1 exit status
    CMakeFiles/cmTC_8ca14.dir/build.make:98: recipe for target 'cmTC_8ca14' failed
    make[1]: *** [cmTC_8ca14] Error 1
    make[1]: Leaving directory '/boot/home/Desktop/x265_git/source/CMakeFiles/CMakeTmp'
    Makefile:127: recipe for target 'cmTC_8ca14/fast' failed
    make: *** [cmTC_8ca14/fast] Error 2


  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:19 (project)

-- Configuring incomplete, errors occurred!
See also "/boot/home/Desktop/x265_git/source/CMakeFiles/CMakeOutput.log".
See also "/boot/home/Desktop/x265_git/source/CMakeFiles/CMakeError.log".

I think the compiler (gcc? g++?) should provide that “_mcount” routine code, assuming the same operation goes smooth on linux, should it?
What am I missing?

A shot in the dark, but do you have haiku_devel installed?

Yes I do, it is into /system/packages/

Profiling requires some support in the C library which we didn’t implement yet in Haiku. So in the current state, this will not work.

Some explanations of the mcount function is available here: Implementation (GNU gprof)

We need to add this function to our C library before profiling can be used.