mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-11-15 17:02:14 +03:00
arch ____ Fixes: arm-openwrt-linux-muslgnueabi-gcc: error: unrecognized -march target: armv7a arm-openwrt-linux-muslgnueabi-gcc: note: valid arguments are: armv4 armv4t armv5t armv5te armv5tej armv6 armv6j armv6k armv6z armv6kz armv6zk armv6t2 armv6-m armv6s-m armv7 armv7-a armv7ve armv7-r armv7-m armv7e-m armv8-a armv8.1-a armv8.2-a armv8.3-a armv8.4-a armv8.5-a armv8.6-a armv8-m.base armv8-m.main armv8-r armv8.1-m.main armv9-a iwmmxt iwmmxt2; did you mean 'armv7'? arm-openwrt-linux-muslgnueabi-gcc: error: missing argument to '-march=' Reference in Linux kernel for the same change: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/arch/arm/Makefile?h=v6.17-rc7&id=76ebc6a429ec2becc2fa738c85ab9688ea4b9006 flag ---- generic flag for armv7-a does not exist Fixes: 2025-09-26T08:57:44.2958982Z cc1: error: unrecognized -mtune target: generic 2025-09-26T08:57:44.2965968Z cc1: note: valid arguments are: arm8 arm810 strongarm strongarm110 fa526 fa626 arm7tdmi arm7tdmi-s arm710t arm720t arm740t arm9 arm9tdmi arm920t arm920 arm922t arm940t ep9312 arm10tdmi arm1020t arm9e arm946e-s arm966e-s arm968e-s arm10e arm1020e arm1022e xscale iwmmxt iwmmxt2 fa606te fa626te fmp626 fa726te arm926ej-s arm1026ej-s arm1136j-s arm1136jf-s arm1176jz-s arm1176jzf-s mpcorenovfp mpcore arm1156t2-s arm1156t2f-s cortex-m1 cortex-m0 cortex-m0plus cortex-m1.small-multiply cortex-m0.small-multiply cortex-m0plus.small-multiply generic-armv7-a cortex-a5 cortex-a7 cortex-a8 cortex-a9 cortex-a12 cortex-a15 cortex-a17 cortex-r4 cortex-r4f cortex-r5 cortex-r7 cortex-r8 cortex-m7 cortex-m4 cortex-m3 marvell-pj4 cortex-a15.cortex-a7 cortex-a17.cortex-a7 cortex-a32 cortex-a35 cortex-a53 cortex-a57 cortex-a72 cortex-a73 exynos-m1 xgene1 cortex-a57.cortex-a53 cortex-a72.cortex-a53 cortex-a73.cortex-a35 cortex-a73.cortex-a53 cortex-a55 cortex-a75 cortex-a76 cortex-a76ae cortex-a77 cortex-a78 cortex-a78ae cortex-a78c cortex-a710 cortex-x1 cortex-x1c neoverse-n1 cortex-a75.cortex-a55 cortex-a76.cortex-a55 neoverse-v1 neoverse-n2 cortex-m23 cortex-m33 cortex-m35p cortex-m52 cortex-m55 star-mc1 cortex-m85 cortex-r52 cortex-r52plus
125 lines
4.7 KiB
CMake
125 lines
4.7 KiB
CMake
if (USE_CPU_NATIVE)
|
|
# Detect best GNUCC_ARCH to tune for
|
|
if (CMAKE_COMPILER_IS_GNUCC)
|
|
message(STATUS "gcc version ${CMAKE_C_COMPILER_VERSION}")
|
|
|
|
# If gcc doesn't recognise the host cpu, then mtune=native becomes
|
|
# generic, which isn't very good in some cases. march=native looks at
|
|
# cpuid info and then chooses the best microarch it can (and replaces
|
|
# the flag), so use that for tune.
|
|
|
|
set(TUNE_FLAG "mtune")
|
|
|
|
# set the default fallback values for the arch and tune to native, in case we can't parse them properly later
|
|
set(GNUCC_ARCH "native")
|
|
set(GNUCC_TUNE "native")
|
|
message(STATUS "ARCH_FLAG '${ARCH_FLAG}' '${GNUCC_ARCH}', TUNE_FLAG '${TUNE_FLAG}' '${GNUCC_TUNE}' ")
|
|
|
|
# arg1 might exist if using ccache
|
|
string (STRIP "${CMAKE_C_COMPILER_ARG1}" CC_ARG1)
|
|
set (EXEC_ARGS ${CC_ARG1} -c -Q --help=target -${ARCH_FLAG}=${GNUCC_ARCH} -${TUNE_FLAG}=${GNUCC_TUNE})
|
|
execute_process(COMMAND ${CMAKE_C_COMPILER} ${EXEC_ARGS}
|
|
OUTPUT_VARIABLE _GCC_OUTPUT)
|
|
set(_GCC_OUTPUT_TUNE ${_GCC_OUTPUT})
|
|
string(FIND "${_GCC_OUTPUT}" "${ARCH_FLAG}=" POS)
|
|
string(SUBSTRING "${_GCC_OUTPUT}" ${POS} -1 _GCC_OUTPUT)
|
|
string(REGEX REPLACE "${ARCH_FLAG}=[ \t]*([^ \n]*)[ \n].*" "\\1" _GNUCC_ARCH "${_GCC_OUTPUT}")
|
|
|
|
# Only overwrite arch if non-empty
|
|
if(NOT _GNUCC_ARCH STREQUAL "")
|
|
set(GNUCC_ARCH ${_GNUCC_ARCH})
|
|
endif()
|
|
|
|
string(FIND "${_GCC_OUTPUT_TUNE}" "${TUNE_FLAG}=" POS_TUNE)
|
|
string(SUBSTRING "${_GCC_OUTPUT_TUNE}" ${POS_TUNE} -1 _GCC_OUTPUT_TUNE)
|
|
string(REGEX REPLACE "${TUNE_FLAG}=[ \t]*([^ \n]*)[ \n].*" "\\1" _GNUCC_TUNE "${_GCC_OUTPUT_TUNE}")
|
|
|
|
# Only overwrite tune if non-empty
|
|
if (NOT _GNUCC_TUNE STREQUAL "")
|
|
set(GNUCC_TUNE ${_GNUCC_TUNE})
|
|
endif()
|
|
|
|
message(STATUS "ARCH_FLAG '${ARCH_FLAG}' '${GNUCC_ARCH}', TUNE_FLAG '${TUNE_FLAG}' '${GNUCC_TUNE}' ")
|
|
|
|
# test the parsed flag
|
|
set (EXEC_ARGS ${CC_ARG1} -E - -${ARCH_FLAG}=${GNUCC_ARCH} -${TUNE_FLAG}=${GNUCC_TUNE})
|
|
execute_process(COMMAND ${CMAKE_C_COMPILER} ${EXEC_ARGS}
|
|
OUTPUT_QUIET ERROR_QUIET
|
|
INPUT_FILE /dev/null
|
|
RESULT_VARIABLE GNUCC_TUNE_TEST)
|
|
|
|
if (NOT GNUCC_TUNE_TEST EQUAL 0)
|
|
message(WARNING "Something went wrong determining gcc tune: -mtune=${GNUCC_TUNE} not valid, falling back to -mtune=native")
|
|
set(GNUCC_TUNE native)
|
|
else()
|
|
set(GNUCC_TUNE ${GNUCC_TUNE})
|
|
message(STATUS "gcc will tune for ${GNUCC_ARCH}, ${GNUCC_TUNE}")
|
|
endif()
|
|
elseif (CMAKE_COMPILER_IS_CLANG)
|
|
if (ARCH_IA32 OR ARCH_X86_64)
|
|
set(GNUCC_ARCH x86-64-v2)
|
|
set(TUNE_FLAG generic)
|
|
elseif(ARCH_AARCH64)
|
|
if (BUILD_SVE2_BITPERM)
|
|
set(GNUCC_ARCH ${SVE2_BITPERM_ARCH})
|
|
elseif (BUILD_SVE2)
|
|
set(GNUCC_ARCH ${SVE2_ARCH})
|
|
elseif (BUILD_SVE)
|
|
set(GNUCC_ARCH ${SVE_ARCH})
|
|
else ()
|
|
set(GNUCC_ARCH ${ARMV8_ARCH})
|
|
endif()
|
|
set(TUNE_FLAG generic)
|
|
elseif(ARCH_ARM32)
|
|
set(GNUCC_ARCH armv7-a)
|
|
set(TUNE_FLAG generic-armv7-a)
|
|
else()
|
|
set(GNUCC_ARCH native)
|
|
set(TUNE_FLAG generic)
|
|
endif()
|
|
message(STATUS "clang will tune for ${GNUCC_ARCH}, ${TUNE_FLAG}")
|
|
endif()
|
|
else()
|
|
if (SIMDE_BACKEND)
|
|
if (ARCH_IA32 OR ARCH_X86_64)
|
|
set(GNUCC_ARCH x86-64-v2)
|
|
set(TUNE_FLAG generic)
|
|
elseif(ARCH_AARCH64)
|
|
set(GNUCC_ARCH armv8-a)
|
|
set(TUNE_FLAG generic)
|
|
elseif(ARCH_ARM32)
|
|
set(GNUCC_ARCH armv7-a)
|
|
set(TUNE_FLAG generic-armv7-a)
|
|
elseif(ARCH_PPC64EL)
|
|
set(GNUCC_ARCH power8)
|
|
set(TUNE_FLAG power8)
|
|
else()
|
|
set(GNUCC_ARCH x86-64-v2)
|
|
set(TUNE_FLAG generic)
|
|
endif()
|
|
elseif (ARCH_IA32 OR ARCH_X86_64)
|
|
set(GNUCC_ARCH ${X86_ARCH})
|
|
set(TUNE_FLAG generic)
|
|
elseif(ARCH_AARCH64)
|
|
if (BUILD_SVE2_BITPERM)
|
|
set(GNUCC_ARCH ${SVE2_BITPERM_ARCH})
|
|
elseif (BUILD_SVE2)
|
|
set(GNUCC_ARCH ${SVE2_ARCH})
|
|
elseif (BUILD_SVE)
|
|
set(GNUCC_ARCH ${SVE_ARCH})
|
|
else ()
|
|
set(GNUCC_ARCH ${ARMV8_ARCH})
|
|
endif()
|
|
set(TUNE_FLAG generic)
|
|
elseif(ARCH_ARM32)
|
|
set(GNUCC_ARCH armv7-a)
|
|
set(TUNE_FLAG generic-armv7-a)
|
|
elseif(ARCH_PPC64EL)
|
|
set(GNUCC_ARCH power8)
|
|
set(TUNE_FLAG power8)
|
|
else()
|
|
set(GNUCC_ARCH native)
|
|
set(TUNE_FLAG native)
|
|
endif()
|
|
endif()
|