1b1994897Sopenharmony_ci# Copyright (c) 2021-2022 Huawei Device Co., Ltd. 2b1994897Sopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License"); 3b1994897Sopenharmony_ci# you may not use this file except in compliance with the License. 4b1994897Sopenharmony_ci# You may obtain a copy of the License at 5b1994897Sopenharmony_ci# 6b1994897Sopenharmony_ci# http://www.apache.org/licenses/LICENSE-2.0 7b1994897Sopenharmony_ci# 8b1994897Sopenharmony_ci# Unless required by applicable law or agreed to in writing, software 9b1994897Sopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS, 10b1994897Sopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11b1994897Sopenharmony_ci# See the License for the specific language governing permissions and 12b1994897Sopenharmony_ci# limitations under the License. 13b1994897Sopenharmony_ci 14b1994897Sopenharmony_cifunction(panda_set_flag flag) 15b1994897Sopenharmony_ci set(${flag} 1 PARENT_SCOPE) 16b1994897Sopenharmony_ci add_definitions("-D${flag}") 17b1994897Sopenharmony_ciendfunction() 18b1994897Sopenharmony_ci 19b1994897Sopenharmony_ci# For each CMake variable name, add a corresponding preprocessor definition 20b1994897Sopenharmony_ci# if variable evaluates to True. 21b1994897Sopenharmony_cifunction(panda_promote_to_definitions) 22b1994897Sopenharmony_ci foreach(var_name ${ARGV}) 23b1994897Sopenharmony_ci if(${var_name}) 24b1994897Sopenharmony_ci add_definitions("-D${var_name}") 25b1994897Sopenharmony_ci endif() 26b1994897Sopenharmony_ci endforeach() 27b1994897Sopenharmony_ciendfunction() 28b1994897Sopenharmony_ci 29b1994897Sopenharmony_ciif(CMAKE_SYSTEM_NAME STREQUAL Linux) 30b1994897Sopenharmony_ci panda_set_flag(PANDA_TARGET_LINUX) 31b1994897Sopenharmony_ci panda_set_flag(PANDA_TARGET_UNIX) 32b1994897Sopenharmony_ci if (NOT PANDA_ENABLE_ADDRESS_SANITIZER) 33b1994897Sopenharmony_ci panda_set_flag(PANDA_USE_FUTEX) 34b1994897Sopenharmony_ci endif() 35b1994897Sopenharmony_cielseif(CMAKE_SYSTEM_NAME STREQUAL OHOS) 36b1994897Sopenharmony_ci panda_set_flag(PANDA_TARGET_OHOS) 37b1994897Sopenharmony_ci panda_set_flag(PANDA_TARGET_UNIX) 38b1994897Sopenharmony_cielseif(CMAKE_SYSTEM_NAME STREQUAL Windows) 39b1994897Sopenharmony_ci panda_set_flag(PANDA_TARGET_WINDOWS) 40b1994897Sopenharmony_cielseif(CMAKE_SYSTEM_NAME STREQUAL Darwin) 41b1994897Sopenharmony_ci panda_set_flag(PANDA_TARGET_MACOS) 42b1994897Sopenharmony_ci panda_set_flag(PANDA_TARGET_UNIX) 43b1994897Sopenharmony_cielse() 44b1994897Sopenharmony_ci message(FATAL_ERROR "Platform ${CMAKE_SYSTEM_NAME} is not supported") 45b1994897Sopenharmony_ciendif() 46b1994897Sopenharmony_ci 47b1994897Sopenharmony_ciif(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64") 48b1994897Sopenharmony_ci if(NOT PANDA_CROSS_AMD64_X86) 49b1994897Sopenharmony_ci panda_set_flag(PANDA_TARGET_AMD64) 50b1994897Sopenharmony_ci else() 51b1994897Sopenharmony_ci panda_set_flag(PANDA_TARGET_X86) 52b1994897Sopenharmony_ci endif() 53b1994897Sopenharmony_cielseif(CMAKE_SYSTEM_PROCESSOR MATCHES "i[356]86") 54b1994897Sopenharmony_ci panda_set_flag(PANDA_TARGET_X86) 55b1994897Sopenharmony_cielseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64") 56b1994897Sopenharmony_ci panda_set_flag(PANDA_TARGET_ARM64) 57b1994897Sopenharmony_cielseif(CMAKE_SYSTEM_PROCESSOR MATCHES "arm") 58b1994897Sopenharmony_ci panda_set_flag(PANDA_TARGET_ARM32) 59b1994897Sopenharmony_ci panda_promote_to_definitions( 60b1994897Sopenharmony_ci PANDA_TARGET_ARM32_ABI_SOFT 61b1994897Sopenharmony_ci PANDA_TARGET_ARM32_ABI_SOFTFP 62b1994897Sopenharmony_ci PANDA_TARGET_ARM32_ABI_HARD 63b1994897Sopenharmony_ci ) 64b1994897Sopenharmony_ci if((PANDA_TARGET_ARM32_ABI_SOFT AND (PANDA_TARGET_ARM32_ABI_SOFTFP OR PANDA_TARGET_ARM32_ABI_HARD)) OR 65b1994897Sopenharmony_ci (PANDA_TARGET_ARM32_ABI_SOFTFP AND (PANDA_TARGET_ARM32_ABI_SOFT OR PANDA_TARGET_ARM32_ABI_HARD)) OR 66b1994897Sopenharmony_ci (PANDA_TARGET_ARM32_ABI_HARD AND (PANDA_TARGET_ARM32_ABI_SOFT OR PANDA_TARGET_ARM32_ABI_SOFTFP))) 67b1994897Sopenharmony_ci message(FATAL_ERROR "Only one PANDA_TARGET_ARM32_ABI_* should be set. 68b1994897Sopenharmony_ci PANDA_TARGET_ARM32_ABI_SOFT = ${PANDA_TARGET_ARM32_ABI_SOFT} 69b1994897Sopenharmony_ci PANDA_TARGET_ARM32_ABI_SOFTFP = ${PANDA_TARGET_ARM32_ABI_SOFTFP} 70b1994897Sopenharmony_ci PANDA_TARGET_ARM32_ABI_HARD = ${PANDA_TARGET_ARM32_ABI_HARD}") 71b1994897Sopenharmony_ci elseif(NOT (PANDA_TARGET_ARM32_ABI_SOFT OR PANDA_TARGET_ARM32_ABI_SOFTFP OR PANDA_TARGET_ARM32_ABI_HARD)) 72b1994897Sopenharmony_ci message(FATAL_ERROR "PANDA_TARGET_ARM32_ABI_* is not set") 73b1994897Sopenharmony_ci endif() 74b1994897Sopenharmony_cielse() 75b1994897Sopenharmony_ci message(FATAL_ERROR "Processor ${CMAKE_SYSTEM_PROCESSOR} is not supported") 76b1994897Sopenharmony_ciendif() 77b1994897Sopenharmony_ci 78b1994897Sopenharmony_ciif(PANDA_TARGET_AMD64 OR PANDA_TARGET_ARM64) 79b1994897Sopenharmony_ci panda_set_flag(PANDA_TARGET_64) 80b1994897Sopenharmony_cielseif(PANDA_TARGET_X86 OR PANDA_TARGET_ARM32) 81b1994897Sopenharmony_ci panda_set_flag(PANDA_TARGET_32) 82b1994897Sopenharmony_cielse() 83b1994897Sopenharmony_ci message(FATAL_ERROR "Unknown bitness of the target platform") 84b1994897Sopenharmony_ciendif() 85b1994897Sopenharmony_ci 86b1994897Sopenharmony_ciif (PANDA_TRACK_INTERNAL_ALLOCATIONS) 87b1994897Sopenharmony_ci message(STATUS "Track internal allocations") 88b1994897Sopenharmony_ci add_definitions(-DTRACK_INTERNAL_ALLOCATIONS=${PANDA_TRACK_INTERNAL_ALLOCATIONS}) 89b1994897Sopenharmony_ciendif() 90b1994897Sopenharmony_ci 91b1994897Sopenharmony_ci# Enable global register variables usage only for clang >= 9.0.0 and gcc >= 8.0.0. 92b1994897Sopenharmony_ci# Clang 8.0.0 doesn't support all necessary options -ffixed-<reg>. Gcc 7.5.0 freezes 93b1994897Sopenharmony_ci# when compiling release interpreter. 94b1994897Sopenharmony_ci# 95b1994897Sopenharmony_ci# Also calling conventions of functions that use global register variables are different: 96b1994897Sopenharmony_ci# clang stores and restores registers that are used for global variables in the prolog 97b1994897Sopenharmony_ci# and epilog of such functions and gcc doesn't do it. So it's necessary to inline all 98b1994897Sopenharmony_ci# function that refers to global register variables to interpreter loop. 99b1994897Sopenharmony_ci 100b1994897Sopenharmony_ci# For this reason we disable global register variables usage for clang debug builds as 101b1994897Sopenharmony_ci# ALWAYS_INLINE macro expands to nothing in this mode and we cannot guarantee that all 102b1994897Sopenharmony_ci# necessary function will be inlined. 103b1994897Sopenharmony_ci# 104b1994897Sopenharmony_ciif(PANDA_TARGET_ARM64 AND ((CMAKE_CXX_COMPILER_ID STREQUAL "Clang" 105b1994897Sopenharmony_ci AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0.0 106b1994897Sopenharmony_ci AND CMAKE_BUILD_TYPE MATCHES Release) 107b1994897Sopenharmony_ci OR 108b1994897Sopenharmony_ci (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" 109b1994897Sopenharmony_ci AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.0.0))) 110b1994897Sopenharmony_ci panda_set_flag(PANDA_ENABLE_GLOBAL_REGISTER_VARIABLES) 111b1994897Sopenharmony_ciendif() 112b1994897Sopenharmony_ci 113b1994897Sopenharmony_ciif(CMAKE_BUILD_TYPE MATCHES Debug) 114b1994897Sopenharmony_ci # Additional debug information about fp in each frame 115b1994897Sopenharmony_ci add_compile_options(-fno-omit-frame-pointer) 116b1994897Sopenharmony_ciendif() 117b1994897Sopenharmony_ci 118b1994897Sopenharmony_ciif (PANDA_TARGET_MOBILE AND PANDA_TARGET_ARM64) 119b1994897Sopenharmony_ci set(PANDA_ENABLE_LTO true) 120b1994897Sopenharmony_ci set(PANDA_LLVM_REGALLOC pbqp) 121b1994897Sopenharmony_ciendif() 122b1994897Sopenharmony_ci 123b1994897Sopenharmony_ciif (PANDA_PGO_INSTRUMENT OR PANDA_PGO_OPTIMIZE) 124b1994897Sopenharmony_ci if (NOT PANDA_TARGET_MOBILE OR NOT PANDA_TARGET_ARM64) 125b1994897Sopenharmony_ci message(FATAL_ERROR "PGO supported only for aarch64") 126b1994897Sopenharmony_ci endif() 127b1994897Sopenharmony_ci 128b1994897Sopenharmony_ci set(PANDA_ENABLE_LTO true) 129b1994897Sopenharmony_ciendif() 130b1994897Sopenharmony_ci 131b1994897Sopenharmony_ci# TODO(v.cherkashi): Remove PANDA_TARGET_MOBILE_WITH_MANAGED_LIBS when the managed libs are separated form the Panda 132b1994897Sopenharmony_ciif(PANDA_TARGET_MOBILE_WITH_MANAGED_LIBS) 133b1994897Sopenharmony_ci add_definitions(-DPANDA_TARGET_MOBILE_WITH_MANAGED_LIBS=1) 134b1994897Sopenharmony_ci if(PANDA_TARGET_MOBILE) 135b1994897Sopenharmony_ci panda_set_flag(PANDA_TARGET_MOBILE_WITH_NATIVE_LIBS) 136b1994897Sopenharmony_ci endif() 137b1994897Sopenharmony_cielse() 138b1994897Sopenharmony_ci add_definitions(-DPANDA_TARGET_MOBILE_WITH_MANAGED_LIBS=0) 139b1994897Sopenharmony_ciendif() 140b1994897Sopenharmony_ci 141b1994897Sopenharmony_ciif(PANDA_TARGET_MOBILE_WITH_NATIVE_LIBS) 142b1994897Sopenharmony_ci set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-gnu-statement-expression") 143b1994897Sopenharmony_ci if(MOBILE_NATIVE_LIBS_SOURCE_PATH) 144b1994897Sopenharmony_ci include_directories(${MOBILE_NATIVE_LIBS_SOURCE_PATH}/libc) 145b1994897Sopenharmony_ci else() 146b1994897Sopenharmony_ci message(FATAL_ERROR "MOBILE_NATIVE_LIBS_SOURCE_PATH is not set") 147b1994897Sopenharmony_ci endif() 148b1994897Sopenharmony_ciendif() 149b1994897Sopenharmony_ci 150b1994897Sopenharmony_ciif(PANDA_TARGET_64) 151b1994897Sopenharmony_ci panda_set_flag(PANDA_USE_32_BIT_POINTER) 152b1994897Sopenharmony_ciendif() 153b1994897Sopenharmony_ci 154b1994897Sopenharmony_ciif(PANDA_TARGET_LINUX) 155b1994897Sopenharmony_ci execute_process(COMMAND grep PRETTY_NAME= /etc/os-release 156b1994897Sopenharmony_ci OUTPUT_VARIABLE PANDA_TARGET_LINUX_DISTRO 157b1994897Sopenharmony_ci OUTPUT_STRIP_TRAILING_WHITESPACE 158b1994897Sopenharmony_ci ) 159b1994897Sopenharmony_ci if(PANDA_TARGET_LINUX_DISTRO MATCHES "Ubuntu") 160b1994897Sopenharmony_ci panda_set_flag(PANDA_TARGET_LINUX_UBUNTU) 161b1994897Sopenharmony_ci endif() 162b1994897Sopenharmony_ci 163b1994897Sopenharmony_ci if(PANDA_TARGET_LINUX_DISTRO MATCHES "Ubuntu 18\\.04") 164b1994897Sopenharmony_ci panda_set_flag(PANDA_TARGET_LINUX_UBUNTU_18_04) 165b1994897Sopenharmony_ci elseif(PANDA_TARGET_LINUX_DISTRO MATCHES "Ubuntu 20\\.04") 166b1994897Sopenharmony_ci panda_set_flag(PANDA_TARGET_LINUX_UBUNTU_20_04) 167b1994897Sopenharmony_ci endif() 168b1994897Sopenharmony_ciendif() 169b1994897Sopenharmony_ci 170b1994897Sopenharmony_ciset(PANDA_WITH_RUNTIME true) 171b1994897Sopenharmony_ciset(PANDA_WITH_COMPILER true) 172b1994897Sopenharmony_ciset(PANDA_WITH_TOOLCHAIN true) 173b1994897Sopenharmony_ciif (NOT DEFINED PANDA_WITH_BENCHMARKS) 174b1994897Sopenharmony_ci set(PANDA_WITH_BENCHMARKS true) 175b1994897Sopenharmony_ciendif() 176b1994897Sopenharmony_ciset(PANDA_DEFAULT_LIB_TYPE "SHARED") 177b1994897Sopenharmony_ci 178b1994897Sopenharmony_cioption(PANDA_WITH_TESTS "Enable test targets" true) 179b1994897Sopenharmony_cioption(PANDA_WITH_BYTECODE_OPTIMIZER "Enable bytecode optimizer" true) 180b1994897Sopenharmony_cioption(PANDA_WITH_JAVA "Enable java plugin" ON) 181b1994897Sopenharmony_cioption(PANDA_WITH_ECMASCRIPT "Enable ecmascript plugin" ON) 182b1994897Sopenharmony_cioption(PANDA_WITH_ACCORD "Enable accord plugin" ON) 183b1994897Sopenharmony_cioption(PANDA_WITH_CANGJIE "Enable cangjie plugin" ON) 184b1994897Sopenharmony_cioption(PANDA_COMPILER_CFI "Support CFI information") 185b1994897Sopenharmony_cioption(PANDA_ENABLE_RELAYOUT_PROFILE "Enable relayout profile" OFF) 186b1994897Sopenharmony_ci 187b1994897Sopenharmony_ciif(PANDA_TARGET_WINDOWS) 188b1994897Sopenharmony_ci set(PANDA_WITH_BENCHMARKS false) 189b1994897Sopenharmony_ci set(PANDA_DEFAULT_LIB_TYPE "STATIC") 190b1994897Sopenharmony_ci # Need to fix windows build for ecmascript. 191b1994897Sopenharmony_ci set(PANDA_WITH_ECMASCRIPT false) 192b1994897Sopenharmony_ciendif() 193b1994897Sopenharmony_ci 194b1994897Sopenharmony_ciif(PANDA_TARGET_MACOS) 195b1994897Sopenharmony_ci set(PANDA_DEFAULT_LIB_TYPE "STATIC") 196b1994897Sopenharmony_ci #introduced for "std::filesystem::create_directories" 197b1994897Sopenharmony_ci add_compile_options(-mmacosx-version-min=10.15) 198b1994897Sopenharmony_ciendif() 199b1994897Sopenharmony_ci 200b1994897Sopenharmony_ciif(PANDA_TARGET_OHOS) 201b1994897Sopenharmony_ci set(PANDA_WITH_BENCHMARKS false) 202b1994897Sopenharmony_ciendif() 203b1994897Sopenharmony_ci 204b1994897Sopenharmony_ciif(CMAKE_BUILD_TYPE STREQUAL Debug) 205b1994897Sopenharmony_ci add_definitions(-DPANDA_ENABLE_SLOW_DEBUG) 206b1994897Sopenharmony_ciendif() 207b1994897Sopenharmony_ci 208b1994897Sopenharmony_ciif(CMAKE_BUILD_TYPE STREQUAL FastVerify) 209b1994897Sopenharmony_ci add_definitions(-DPANDA_FAST_VERIFY) 210b1994897Sopenharmony_ciendif() 211b1994897Sopenharmony_ci 212b1994897Sopenharmony_ci# The define is set for the build which will be delivered to customers. 213b1994897Sopenharmony_ci# Currently this build doesn't contain dependencies to debug libraries 214b1994897Sopenharmony_ci# (like libdwarf.so) 215b1994897Sopenharmony_cioption(PANDA_PRODUCT_BUILD "Build which will be delivered to customers" false) 216b1994897Sopenharmony_ci 217b1994897Sopenharmony_ci# TODO: merge with PANDA_PRODUCT_BUILD 218b1994897Sopenharmony_ci# PANDA_RELEASE_BUILD should set all relevant flags for benchmarking 219b1994897Sopenharmony_cioption(PANDA_RELEASE_BUILD "Build for benchmarking. Must be run with CMAKE_BUILD_TYPE=Release" false) 220b1994897Sopenharmony_ci 221b1994897Sopenharmony_ciif(PANDA_RELEASE_BUILD AND NOT (CMAKE_BUILD_TYPE STREQUAL "Release")) 222b1994897Sopenharmony_ci message(FATAL_ERROR "PANDA_RELEASE_BUILD must be run with the Release build type only!") 223b1994897Sopenharmony_ciendif() 224b1994897Sopenharmony_ci 225b1994897Sopenharmony_ciif (PANDA_RELEASE_BUILD) 226b1994897Sopenharmony_ci set(PANDA_WITH_JAVA ON) 227b1994897Sopenharmony_ci set(PANDA_WITH_ECMASCRIPT ON) 228b1994897Sopenharmony_ci set(PANDA_WITH_ACCORD OFF) 229b1994897Sopenharmony_ci set(PANDA_WITH_CANGJIE OFF) 230b1994897Sopenharmony_ciendif() 231b1994897Sopenharmony_ci 232b1994897Sopenharmony_ciif (PANDA_PRODUCT_BUILD OR PANDA_RELEASE_BUILD) 233b1994897Sopenharmony_ci # VIXL aarch64 with Encoder only (with no Decoder or Simulator provided) 234b1994897Sopenharmony_ci set(PANDA_MINIMAL_VIXL true) 235b1994897Sopenharmony_ciendif() 236b1994897Sopenharmony_ci 237b1994897Sopenharmony_cipanda_promote_to_definitions( 238b1994897Sopenharmony_ci PANDA_PRODUCT_BUILD 239b1994897Sopenharmony_ci PANDA_WITH_COMPILER 240b1994897Sopenharmony_ci PANDA_WITH_BYTECODE_OPTIMIZER 241b1994897Sopenharmony_ci PANDA_MINIMAL_VIXL 242b1994897Sopenharmony_ci) 243b1994897Sopenharmony_ci 244b1994897Sopenharmony_ciif (("${CMAKE_BUILD_TYPE}" STREQUAL "Debug" OR 245b1994897Sopenharmony_ci "${CMAKE_BUILD_TYPE}" STREQUAL "DebugDetailed" OR 246b1994897Sopenharmony_ci "${CMAKE_BUILD_TYPE}" STREQUAL "FastVerify" OR 247b1994897Sopenharmony_ci "${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo") AND 248b1994897Sopenharmony_ci (NOT PANDA_TARGET_WINDOWS) AND 249b1994897Sopenharmony_ci (NOT PANDA_ENABLE_ADDRESS_SANITIZER) AND 250b1994897Sopenharmony_ci (NOT PANDA_ENABLE_UNDEFINED_BEHAVIOR_SANITIZER) AND 251b1994897Sopenharmony_ci (NOT PANDA_ENABLE_THREAD_SANITIZER)) 252b1994897Sopenharmony_ci # Windows do not have elf and dwarf libraries 253b1994897Sopenharmony_ci # Sanitizers do not work properly with gdb 254b1994897Sopenharmony_ci set(PANDA_COMPILER_CFI ON) 255b1994897Sopenharmony_ciendif() 256b1994897Sopenharmony_ci 257b1994897Sopenharmony_ci# libdwarf-dev lib (version: 20180129-1) in Ubuntu 18.04 has memory leaks 258b1994897Sopenharmony_ci# TODO(asidorov): delete the workaround when the problem is fixed 259b1994897Sopenharmony_ciif (PANDA_ENABLE_ADDRESS_SANITIZER AND PANDA_TARGET_LINUX_UBUNTU_18_04) 260b1994897Sopenharmony_ci set(PANDA_COMPILER_CFI OFF) 261b1994897Sopenharmony_ciendif() 262b1994897Sopenharmony_ci 263b1994897Sopenharmony_ci# TODO: Ensure libdwarf is available when building with OHOS toolchain 264b1994897Sopenharmony_ciif (PANDA_TARGET_OHOS) 265b1994897Sopenharmony_ci set(PANDA_COMPILER_CFI OFF) 266b1994897Sopenharmony_ciendif() 267b1994897Sopenharmony_ci 268b1994897Sopenharmony_ciif (PANDA_PRODUCT_BUILD) 269b1994897Sopenharmony_ci set(PANDA_COMPILER_CFI OFF) 270b1994897Sopenharmony_ciendif() 271b1994897Sopenharmony_ci 272b1994897Sopenharmony_ciif (PANDA_COMPILER_CFI) 273b1994897Sopenharmony_ci add_definitions(-DPANDA_COMPILER_CFI) 274b1994897Sopenharmony_ciendif() 275b1994897Sopenharmony_ci 276b1994897Sopenharmony_cioption(PANDA_CROSS_COMPILER "Enable compiler cross-compilation support" ON) 277b1994897Sopenharmony_cioption(PANDA_COMPILER_TARGET_X86 "Build x86-backend") 278b1994897Sopenharmony_cioption(PANDA_COMPILER_TARGET_X86_64 "Build x86_64-backend") 279b1994897Sopenharmony_cioption(PANDA_COMPILER_TARGET_AARCH32 "Build aarch32-backend") 280b1994897Sopenharmony_cioption(PANDA_COMPILER_TARGET_AARCH64 "Build aarch64-backend") 281b1994897Sopenharmony_ci# User-specified cross-toolchains: 282b1994897Sopenharmony_cioption(PANDA_CROSS_X86_64_TOOLCHAIN_FILE "Absolute path to X86_64 target toolchain" OFF) 283b1994897Sopenharmony_cioption(PANDA_CROSS_AARCH64_TOOLCHAIN_FILE "Absolute path to AARCH64 target toolchain" OFF) 284b1994897Sopenharmony_cioption(PANDA_CROSS_AARCH32_TOOLCHAIN_FILE "Absolute path to AARCH32 target toolchain" OFF) 285b1994897Sopenharmony_ci 286b1994897Sopenharmony_ci# true if current target supports JIT/AOT native compilation 287b1994897Sopenharmony_ci# TODO (asidorov, runtime): replace all uses of this option by PANDA_WITH_COMPILER 288b1994897Sopenharmony_ciset(PANDA_COMPILER_ENABLE TRUE) 289b1994897Sopenharmony_ci 290b1994897Sopenharmony_ciif (PANDA_TARGET_AMD64) 291b1994897Sopenharmony_ci if (PANDA_CROSS_COMPILER) 292b1994897Sopenharmony_ci if (HOST_TOOLS) 293b1994897Sopenharmony_ci # For host-tools build support only single-target backend (with the same toolchain): 294b1994897Sopenharmony_ci message(STATUS "set ${PANDA_HOST_TOOLS_TARGET_ARCH}") 295b1994897Sopenharmony_ci set(PANDA_COMPILER_TARGET_${PANDA_HOST_TOOLS_TARGET_ARCH} ON) 296b1994897Sopenharmony_ci else() 297b1994897Sopenharmony_ci set(PANDA_COMPILER_TARGET_X86_64 ON) 298b1994897Sopenharmony_ci # If `PANDA_CROSS_${arch}_TOOLCHAIN_FILE` wasn't specified, gcc-toolchain is used: 299b1994897Sopenharmony_ci find_program(GCC_AARCH64_CXX "aarch64-linux-gnu-g++") 300b1994897Sopenharmony_ci find_program(GCC_ARM_CXX "arm-linux-gnueabi-g++") 301b1994897Sopenharmony_ci 302b1994897Sopenharmony_ci if (PANDA_CROSS_AARCH64_TOOLCHAIN_FILE) 303b1994897Sopenharmony_ci set(PANDA_COMPILER_TARGET_AARCH64 ON) 304b1994897Sopenharmony_ci message(STATUS "Specified AARCH64 toolchain: ${PANDA_CROSS_AARCH64_TOOLCHAIN_FILE}") 305b1994897Sopenharmony_ci elseif (GCC_AARCH64_CXX) 306b1994897Sopenharmony_ci set(PANDA_COMPILER_TARGET_AARCH64 ON) 307b1994897Sopenharmony_ci message(STATUS "Detected default AARCH64 toolchain") 308b1994897Sopenharmony_ci else() 309b1994897Sopenharmony_ci message(STATUS "No AARCH64 toolchain found") 310b1994897Sopenharmony_ci endif() 311b1994897Sopenharmony_ci 312b1994897Sopenharmony_ci if (PANDA_CROSS_AARCH32_TOOLCHAIN_FILE) 313b1994897Sopenharmony_ci set(PANDA_COMPILER_TARGET_AARCH32 ON) 314b1994897Sopenharmony_ci message(STATUS "Specified AARCH32 toolchain: ${PANDA_CROSS_AARCH32_TOOLCHAIN_FILE}") 315b1994897Sopenharmony_ci elseif (GCC_ARM_CXX) 316b1994897Sopenharmony_ci set(PANDA_COMPILER_TARGET_AARCH32 ON) 317b1994897Sopenharmony_ci message(STATUS "Detected default AARCH32 toolchain") 318b1994897Sopenharmony_ci else() 319b1994897Sopenharmony_ci message(STATUS "No AARCH32 toolchain found") 320b1994897Sopenharmony_ci endif() 321b1994897Sopenharmony_ci # TODO(dkofanov): cross-values do not support x86 322b1994897Sopenharmony_ci set(PANDA_COMPILER_TARGET_X86 OFF) 323b1994897Sopenharmony_ci endif() 324b1994897Sopenharmony_ci else() 325b1994897Sopenharmony_ci set(PANDA_COMPILER_TARGET_X86_64 ON) 326b1994897Sopenharmony_ci endif() 327b1994897Sopenharmony_ciendif() 328b1994897Sopenharmony_ci 329b1994897Sopenharmony_ciif (PANDA_TARGET_X86) 330b1994897Sopenharmony_ci set(PANDA_COMPILER_TARGET_X86 ON) 331b1994897Sopenharmony_ciendif() 332b1994897Sopenharmony_ci 333b1994897Sopenharmony_ciif (PANDA_TARGET_ARM32) 334b1994897Sopenharmony_ci if(PANDA_TARGET_ARM32_ABI_SOFT) 335b1994897Sopenharmony_ci set(PANDA_COMPILER_ENABLE FALSE) 336b1994897Sopenharmony_ci else() 337b1994897Sopenharmony_ci set(PANDA_COMPILER_TARGET_AARCH32 ON) 338b1994897Sopenharmony_ci endif() 339b1994897Sopenharmony_ciendif() 340b1994897Sopenharmony_ci 341b1994897Sopenharmony_ciif (PANDA_TARGET_ARM64) 342b1994897Sopenharmony_ci set(PANDA_COMPILER_TARGET_AARCH64 ON) 343b1994897Sopenharmony_ciendif() 344b1994897Sopenharmony_ci 345b1994897Sopenharmony_cipanda_promote_to_definitions( 346b1994897Sopenharmony_ci PANDA_COMPILER_TARGET_X86 347b1994897Sopenharmony_ci PANDA_COMPILER_TARGET_X86_64 348b1994897Sopenharmony_ci PANDA_COMPILER_TARGET_AARCH32 349b1994897Sopenharmony_ci PANDA_COMPILER_TARGET_AARCH64 350b1994897Sopenharmony_ci PANDA_COMPILER_ENABLE 351b1994897Sopenharmony_ci) 352b1994897Sopenharmony_ci 353b1994897Sopenharmony_cimessage(STATUS "PANDA_TARGET_MOBILE_WITH_MANAGED_LIBS = ${PANDA_TARGET_MOBILE_WITH_MANAGED_LIBS}") 354b1994897Sopenharmony_cimessage(STATUS "PANDA_TARGET_UNIX = ${PANDA_TARGET_UNIX}") 355b1994897Sopenharmony_cimessage(STATUS "PANDA_TARGET_LINUX = ${PANDA_TARGET_LINUX}") 356b1994897Sopenharmony_cimessage(STATUS "PANDA_TARGET_MOBILE = ${PANDA_TARGET_MOBILE}") 357b1994897Sopenharmony_cimessage(STATUS "PANDA_USE_FUTEX = ${PANDA_USE_FUTEX}") 358b1994897Sopenharmony_cimessage(STATUS "PANDA_TARGET_WINDOWS = ${PANDA_TARGET_WINDOWS}") 359b1994897Sopenharmony_cimessage(STATUS "PANDA_TARGET_OHOS = ${PANDA_TARGET_OHOS}") 360b1994897Sopenharmony_cimessage(STATUS "PANDA_TARGET_MACOS = ${PANDA_TARGET_MACOS}") 361b1994897Sopenharmony_cimessage(STATUS "PANDA_CROSS_COMPILER = ${PANDA_CROSS_COMPILER}") 362b1994897Sopenharmony_cimessage(STATUS "PANDA_CROSS_AMD64_X86 = ${PANDA_CROSS_AMD64_X86}") 363b1994897Sopenharmony_cimessage(STATUS "PANDA_TARGET_AMD64 = ${PANDA_TARGET_AMD64}") 364b1994897Sopenharmony_cimessage(STATUS "PANDA_TARGET_X86 = ${PANDA_TARGET_X86}") 365b1994897Sopenharmony_cimessage(STATUS "PANDA_TARGET_ARM64 = ${PANDA_TARGET_ARM64}") 366b1994897Sopenharmony_cimessage(STATUS "PANDA_TARGET_ARM32 = ${PANDA_TARGET_ARM32}") 367b1994897Sopenharmony_ciif(PANDA_TARGET_ARM32) 368b1994897Sopenharmony_cimessage(STATUS "PANDA_TARGET_ARM32_ABI_SOFT = ${PANDA_TARGET_ARM32_ABI_SOFT}") 369b1994897Sopenharmony_cimessage(STATUS "PANDA_TARGET_ARM32_ABI_SOFTFP = ${PANDA_TARGET_ARM32_ABI_SOFTFP}") 370b1994897Sopenharmony_cimessage(STATUS "PANDA_TARGET_ARM32_ABI_HARD = ${PANDA_TARGET_ARM32_ABI_HARD}") 371b1994897Sopenharmony_ciendif() 372b1994897Sopenharmony_cimessage(STATUS "PANDA_TARGET_64 = ${PANDA_TARGET_64}") 373b1994897Sopenharmony_cimessage(STATUS "PANDA_TARGET_32 = ${PANDA_TARGET_32}") 374b1994897Sopenharmony_cimessage(STATUS "PANDA_ENABLE_GLOBAL_REGISTER_VARIABLES = ${PANDA_ENABLE_GLOBAL_REGISTER_VARIABLES}") 375b1994897Sopenharmony_cimessage(STATUS "PANDA_ENABLE_LTO = ${PANDA_ENABLE_LTO}") 376b1994897Sopenharmony_ciif(PANDA_TARGET_MOBILE) 377b1994897Sopenharmony_cimessage(STATUS "PANDA_LLVM_REGALLOC = ${PANDA_LLVM_REGALLOC}") 378b1994897Sopenharmony_ciendif() 379b1994897Sopenharmony_ciif(PANDA_TARGET_MOBILE_WITH_NATIVE_LIBS) 380b1994897Sopenharmony_cimessage(STATUS "PANDA_TARGET_MOBILE_WITH_NATIVE_LIBS = ${PANDA_TARGET_MOBILE_WITH_NATIVE_LIBS}") 381b1994897Sopenharmony_ciendif() 382b1994897Sopenharmony_cimessage(STATUS "PANDA_WITH_RUNTIME = ${PANDA_WITH_RUNTIME}") 383b1994897Sopenharmony_cimessage(STATUS "PANDA_WITH_COMPILER = ${PANDA_WITH_COMPILER}") 384b1994897Sopenharmony_cimessage(STATUS "PANDA_COMPILER_ENABLE = ${PANDA_COMPILER_ENABLE}") 385b1994897Sopenharmony_cimessage(STATUS "PANDA_WITH_TOOLCHAIN = ${PANDA_WITH_TOOLCHAIN}") 386b1994897Sopenharmony_cimessage(STATUS "PANDA_WITH_TESTS = ${PANDA_WITH_TESTS}") 387b1994897Sopenharmony_cimessage(STATUS "PANDA_WITH_BENCHMARKS = ${PANDA_WITH_BENCHMARKS}") 388b1994897Sopenharmony_cimessage(STATUS "PANDA_WITH_BYTECODE_OPTIMIZER = ${PANDA_WITH_BYTECODE_OPTIMIZER}") 389b1994897Sopenharmony_cimessage(STATUS "PANDA_PGO_INSTRUMENT = ${PANDA_PGO_INSTRUMENT}") 390b1994897Sopenharmony_cimessage(STATUS "PANDA_PGO_OPTIMIZE = ${PANDA_PGO_OPTIMIZE}") 391b1994897Sopenharmony_cimessage(STATUS "PANDA_PRODUCT_BUILD = ${PANDA_PRODUCT_BUILD}") 392b1994897Sopenharmony_cimessage(STATUS "PANDA_WITH_JAVA = ${PANDA_WITH_JAVA}") 393b1994897Sopenharmony_cimessage(STATUS "PANDA_WITH_ECMASCRIPT = ${PANDA_WITH_ECMASCRIPT}") 394b1994897Sopenharmony_cimessage(STATUS "PANDA_WITH_ACCORD = ${PANDA_WITH_ACCORD}") 395b1994897Sopenharmony_cimessage(STATUS "PANDA_WITH_CANGJIE = ${PANDA_WITH_CANGJIE}") 396b1994897Sopenharmony_cimessage(STATUS "PANDA_ENABLE_RELAYOUT_PROFILE = ${PANDA_ENABLE_RELAYOUT_PROFILE}") 397