undefined reference to `x265_cpu_neon_test' & `x265_cpu_fast_neon_mrc_test'

Issue #489 new
Vaishnav Sivadas created an issue

I am trying to build the cross compiler for arm and this is the error which I get for the make command. It seems similar to this issue here: Issue #155 https://bitbucket.org/multicoreware/x265/issues/155/undefined-reference-to-x265_cpu_neon_test , but it seems to be an old thread. Any fix for this one?

Here's the output of the make command:

[ 30%] Built target encoder [ 80%] Built target common [ 81%] Built target x265-static [ 83%] Built target x265-shared [ 85%] Linking CXX executable x265 libx265.so.173: undefined reference to x265_cpu_neon_test' libx265.so.173: undefined reference tox265_cpu_fast_neon_mrc_test' collect2: error: ld returned 1 exit status CMakeFiles/cli.dir/build.make:303: recipe for target 'x265' failed make[2]: [x265] Error 1 CMakeFiles/Makefile2:207: recipe for target 'CMakeFiles/cli.dir/all' failed make[1]: [CMakeFiles/cli.dir/all] Error 2 Makefile:129: recipe for target 'all' failed make: *** [all] Error 2

Comments (1)

  1. Lukas Fellechner

    Hi, I have just run into the same issue. When compiling for ARM64, then ARM assembly code does not work. When I disable assembly code, then this error comes.

    The problem is with this code in primitives.cpp:

    #if ENABLE_ASSEMBLY && X265_ARCH_X86
    /* these functions are implemented in assembly. When assembly is not being
     * compiled, they are unnecessary and can be NOPs */
    #else
    extern "C" {
    int PFX(cpu_cpuid_test)(void) { return 0; }
    void PFX(cpu_emms)(void) {}
    void PFX(cpu_cpuid)(uint32_t, uint32_t *eax, uint32_t *, uint32_t *, uint32_t *) { *eax = 0; }
    void PFX(cpu_xgetbv)(uint32_t, uint32_t *, uint32_t *) {}
    
    #if X265_ARCH_ARM == 0
    void PFX(cpu_neon_test)(void) {}
    int PFX(cpu_fast_neon_mrc_test)(void) { return 0; }
    #endif // X265_ARCH_ARM
    }
    #endif
    

    The two functions cpu_neon_test and cpu_fast_neon_mrc_test are only implemented in assembly code (cpu-a.S). When assembly code is disabled, then we need those two dummy implementations. The code works when change it like this:

    #if X265_ARCH_ARM == 0 || ENABLE_ASSEMBLY == 0
    void PFX(cpu_neon_test)(void) {}
    int PFX(cpu_fast_neon_mrc_test)(void) { return 0; }
    #endif // X265_ARCH_ARM
    }
    #endif
    

    Now the dummy implementation is available on ARM when assembly code is disabled. When no assembly code is used, we do not need any NEON checks, so things should be fine.

  2. Log in to comment