noloader / cryptopp-cmake

CMake files for Crypto++ project
BSD 3-Clause "New" or "Revised" License
92 stars 67 forks source link

Build fails on i.MX6 (error: inlining failed) #72

Closed D-r-P-3-p-p-3-r closed 2 years ago

D-r-P-3-p-p-3-r commented 3 years ago

Build fails with errors like this one (cross-compile on an x86_64 Linux for a Linux running on an i.MX6 with g++ 9.2.1):

error: inlining failed in call to always_inline 'void vst1q_u8(uint8_t*, uint8x16_t)': target specific option mismatch

Cause: The platform is not detected correctly. Thus incorrect compiler options are inferred:

-- Platform: x86_64

Changing the else branch of

function(DumpMachine output pattern)

  if (MSVC)

    # CMake does not provide a generic shell/terminal mechanism
    #  and Microsoft environments don't know what 'sh' is.
    set(${output} 0 PARENT_SCOPE)

  else ()
      if(CMAKE_SYSTEM_PROCESSOR MATCHES ${pattern})
          set(${output} TRUE PARENT_SCOPE)
      endif()
  endif()

endfunction(DumpMachine)

back to the old version from 8.2.0

function(DumpMachine output pattern)

  if (MSVC)

    # CMake does not provide a generic shell/terminal mechanism
    #  and Microsoft environments don't know what 'sh' is.
    set(${output} 0 PARENT_SCOPE)

  else ()
    execute_process(
      COMMAND sh -c "${CMAKE_CXX_COMPILER} -dumpmachine 2>&1"
      COMMAND ${GREP_CMD} -i -c -E "${pattern}"
      OUTPUT_VARIABLE ${output}
      OUTPUT_STRIP_TRAILING_WHITESPACE)
    set(${output} "${${output}}" PARENT_SCOPE)
  endif()

endfunction(DumpMachine)

in CMakeLists.txt fixes the problem.

noloader commented 2 years ago

Done. I never liked that change. But I did not understand it, either.

Also see Commit c57ba8f63495.