@@ -81,21 +81,7 @@ if(CMAKE_SYSTEM_NAME MATCHES "Linux|Darwin")
8181 # Enable a baseline of features for the compiler to support everywhere
8282 # Assumes that the compiler will not emit crypto instructions as a result of normal C code
8383 set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=armv8-a+simd+crypto" )
84-
85- if (SYMCRYPT_TARGET_ENV MATCHES "OPTEE" )
86- # TA DEV KIT is require for OPTEE TA compilation
87- if (DEFINED TA_DEV_KIT_INC)
88- # Get the compiler toolchain include
89- execute_process (COMMAND ${CMAKE_C_COMPILER} -print-file-name =include OUTPUT_VARIABLE TOOLCHAIN_INCLUDE)
90- string (STRIP "${TOOLCHAIN_INCLUDE} " TOOLCHAIN_INCLUDE)
91- # OPTEE env has a different stdlib and doesn't support atomic operations or multithreading.
92- add_compile_options (-mno-outline-atomics -nostdinc -isystem ${TOOLCHAIN_INCLUDE} )
93- include_directories (${TA_DEV_KIT_INC} )
94- else ()
95- message (FATAL_ERROR "TA_DEV_KIT_INC must be defined for OPTEE build" )
96- endif ()
97- endif ()
98-
84+
9985 # GCC complains about implicit casting between ASIMD registers (i.e. uint8x16_t -> uint64x2_t) by default,
10086 # whereas clang and MSVC do not. Setting -flax-vector-conversions to build Arm64 intrinsics code with GCC.
10187 set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -flax-vector-conversions" )
@@ -107,6 +93,27 @@ if(CMAKE_SYSTEM_NAME MATCHES "Linux|Darwin")
10793 link_libraries (c)
10894 link_libraries (gcc)
10995 endif ()
96+
97+ # OPTEE specific compilation options
98+ if (SYMCRYPT_TARGET_ENV MATCHES "OPTEE" )
99+ # TA DEV KIT is require for OPTEE TA compilation
100+ if (DEFINED TA_DEV_KIT_INC)
101+ # Get the compiler toolchain include
102+ execute_process (COMMAND ${CMAKE_C_COMPILER} -print-file-name =include OUTPUT_VARIABLE TOOLCHAIN_INCLUDE)
103+ string (STRIP "${TOOLCHAIN_INCLUDE} " TOOLCHAIN_INCLUDE)
104+
105+ if (SYMCRYPT_TARGET_ARCH MATCHES "ARM64" )
106+ # OPTEE env on Arm64 does not support atomic operations
107+ add_compile_options (-mno-outline-atomics)
108+ endif ()
109+
110+ # OPTEE env has a different stdlib
111+ add_compile_options (-nostdinc -isystem ${TOOLCHAIN_INCLUDE} )
112+ include_directories (${TA_DEV_KIT_INC} )
113+ else ()
114+ message (FATAL_ERROR "TA_DEV_KIT_INC must be defined for OPTEE build" )
115+ endif ()
116+ endif ()
110117
111118 # add_compile_options(-Wall)
112119 add_compile_options (-Wno-unknown-pragmas)
0 commit comments