1# Copyright (c) 2021-2022 Huawei Device Co., Ltd. 2# Licensed under the Apache License, Version 2.0 (the "License"); 3# you may not use this file except in compliance with the License. 4# You may obtain a copy of the License at 5# 6# http://www.apache.org/licenses/LICENSE-2.0 7# 8# Unless required by applicable law or agreed to in writing, software 9# distributed under the License is distributed on an "AS IS" BASIS, 10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11# See the License for the specific language governing permissions and 12# limitations under the License. 13 14function(panda_set_flag flag) 15 set(${flag} 1 PARENT_SCOPE) 16 add_definitions("-D${flag}") 17endfunction() 18 19# For each CMake variable name, add a corresponding preprocessor definition 20# if variable evaluates to True. 21function(panda_promote_to_definitions) 22 foreach(var_name ${ARGV}) 23 if(${var_name}) 24 add_definitions("-D${var_name}") 25 endif() 26 endforeach() 27endfunction() 28 29set(CMAKE_BUILD_RPATH_USE_ORIGIN TRUE) 30 31if(CMAKE_SYSTEM_NAME STREQUAL "Linux") 32 panda_set_flag(PANDA_TARGET_LINUX) 33 panda_set_flag(PANDA_TARGET_UNIX) 34 if (NOT PANDA_ENABLE_ADDRESS_SANITIZER) 35 panda_set_flag(PANDA_USE_FUTEX) 36 endif() 37elseif(CMAKE_SYSTEM_NAME STREQUAL "OHOS") 38 panda_set_flag(PANDA_TARGET_OHOS) 39 panda_set_flag(PANDA_TARGET_UNIX) 40elseif(CMAKE_SYSTEM_NAME STREQUAL "Android") 41 panda_set_flag(PANDA_TARGET_MOBILE) 42 panda_set_flag(PANDA_TARGET_UNIX) 43 if (NOT PANDA_ENABLE_ADDRESS_SANITIZER) 44 panda_set_flag(PANDA_USE_FUTEX) 45 endif() 46elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows") 47 panda_set_flag(PANDA_TARGET_WINDOWS) 48elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin") 49 panda_set_flag(PANDA_TARGET_MACOS) 50 panda_set_flag(PANDA_TARGET_UNIX) 51else() 52 message(FATAL_ERROR "Platform ${CMAKE_SYSTEM_NAME} is not supported") 53endif() 54 55if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64") 56 if(NOT PANDA_CROSS_AMD64_X86) 57 panda_set_flag(PANDA_TARGET_AMD64) 58 else() 59 panda_set_flag(PANDA_TARGET_X86) 60 endif() 61elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "i[356]86") 62 panda_set_flag(PANDA_TARGET_X86) 63elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64") 64 panda_set_flag(PANDA_TARGET_ARM64) 65elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "arm") 66 panda_set_flag(PANDA_TARGET_ARM32) 67 panda_promote_to_definitions( 68 PANDA_TARGET_ARM32_ABI_SOFT 69 PANDA_TARGET_ARM32_ABI_SOFTFP 70 PANDA_TARGET_ARM32_ABI_HARD 71 ) 72 if((PANDA_TARGET_ARM32_ABI_SOFT AND (PANDA_TARGET_ARM32_ABI_SOFTFP OR PANDA_TARGET_ARM32_ABI_HARD)) OR 73 (PANDA_TARGET_ARM32_ABI_SOFTFP AND (PANDA_TARGET_ARM32_ABI_SOFT OR PANDA_TARGET_ARM32_ABI_HARD)) OR 74 (PANDA_TARGET_ARM32_ABI_HARD AND (PANDA_TARGET_ARM32_ABI_SOFT OR PANDA_TARGET_ARM32_ABI_SOFTFP))) 75 message(FATAL_ERROR "Only one PANDA_TARGET_ARM32_ABI_* should be set. 76 PANDA_TARGET_ARM32_ABI_SOFT = ${PANDA_TARGET_ARM32_ABI_SOFT} 77 PANDA_TARGET_ARM32_ABI_SOFTFP = ${PANDA_TARGET_ARM32_ABI_SOFTFP} 78 PANDA_TARGET_ARM32_ABI_HARD = ${PANDA_TARGET_ARM32_ABI_HARD}") 79 elseif(NOT (PANDA_TARGET_ARM32_ABI_SOFT OR PANDA_TARGET_ARM32_ABI_SOFTFP OR PANDA_TARGET_ARM32_ABI_HARD)) 80 message(FATAL_ERROR "PANDA_TARGET_ARM32_ABI_* is not set") 81 endif() 82else() 83 message(FATAL_ERROR "Processor ${CMAKE_SYSTEM_PROCESSOR} is not supported") 84endif() 85 86if(PANDA_TARGET_AMD64 OR PANDA_TARGET_ARM64) 87 panda_set_flag(PANDA_TARGET_64) 88elseif(PANDA_TARGET_X86 OR PANDA_TARGET_ARM32) 89 panda_set_flag(PANDA_TARGET_32) 90else() 91 message(FATAL_ERROR "Unknown bitness of the target platform") 92endif() 93 94if (PANDA_TRACK_INTERNAL_ALLOCATIONS) 95 message(STATUS "Track internal allocations") 96 add_definitions(-DTRACK_INTERNAL_ALLOCATIONS=${PANDA_TRACK_INTERNAL_ALLOCATIONS}) 97endif() 98 99if (PANDA_TARGET_ARM64 AND NOT PANDA_CI_TESTING_MODE STREQUAL "Nightly") 100 if (PANDA_ENABLE_ADDRESS_SANITIZER OR PANDA_ENABLE_THREAD_SANITIZER) 101 panda_set_flag(PANDA_ARM64_TESTS_WITH_SANITIZER) 102 endif() 103endif() 104 105 106# Enable global register variables usage only for clang >= 9.0.0 and gcc >= 8.0.0. 107# Clang 8.0.0 doesn't support all necessary options -ffixed-<reg>. Gcc 7.5.0 freezes 108# when compiling release interpreter. 109# 110# Also calling conventions of functions that use global register variables are different: 111# clang stores and restores registers that are used for global variables in the prolog 112# and epilog of such functions and gcc doesn't do it. So it's necessary to inline all 113# function that refers to global register variables to interpreter loop. 114 115# For this reason we disable global register variables usage for clang debug builds as 116# ALWAYS_INLINE macro expands to nothing in this mode and we cannot guarantee that all 117# necessary function will be inlined. 118# 119if(PANDA_TARGET_ARM64 AND ((CMAKE_CXX_COMPILER_ID STREQUAL "Clang" 120 AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0.0 121 AND CMAKE_BUILD_TYPE MATCHES Release) 122 OR 123 (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" 124 AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.0.0))) 125 panda_set_flag(PANDA_ENABLE_GLOBAL_REGISTER_VARIABLES) 126endif() 127 128if(CMAKE_BUILD_TYPE MATCHES Debug) 129 # Additional debug information about fp in each frame 130 add_compile_options(-fno-omit-frame-pointer) 131endif() 132 133# for correct work with gdb-9 134# See https://discourse.llvm.org/t/gdb-10-1-cant-read-clangs-dwarf-v5/6035 135if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 14) 136 if ("${CMAKE_BUILD_TYPE}" MATCHES "^(RelWithDebInfo|FastVerify|Debug|DebugDetailed)$") 137 add_compile_options(-gdwarf-4) 138 endif() 139endif() 140 141# Enable LTO only for Android aarch64 due to bug for Android armv7: 142# https://github.com/android/ndk/issues/721 143if (PANDA_TARGET_MOBILE AND PANDA_TARGET_ARM64) 144 set(PANDA_ENABLE_LTO true) 145 set(PANDA_LLVM_REGALLOC pbqp) 146endif() 147 148if (PANDA_PGO_INSTRUMENT OR PANDA_PGO_OPTIMIZE) 149 if (NOT PANDA_TARGET_MOBILE OR NOT PANDA_TARGET_ARM64) 150 message(FATAL_ERROR "PGO supported only for Android aarch64") 151 endif() 152 153 set(PANDA_ENABLE_LTO true) 154endif() 155 156# TODO(v.cherkashi): Remove PANDA_TARGET_MOBILE_WITH_MANAGED_LIBS when the managed libs are separated form the Panda 157if(PANDA_TARGET_MOBILE_WITH_MANAGED_LIBS) 158 add_definitions(-DPANDA_TARGET_MOBILE_WITH_MANAGED_LIBS=1) 159 if(PANDA_TARGET_MOBILE) 160 panda_set_flag(PANDA_TARGET_MOBILE_WITH_NATIVE_LIBS) 161 endif() 162else() 163 add_definitions(-DPANDA_TARGET_MOBILE_WITH_MANAGED_LIBS=0) 164endif() 165 166if(PANDA_TARGET_MOBILE_WITH_NATIVE_LIBS) 167 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-gnu-statement-expression") 168 if(MOBILE_NATIVE_LIBS_SOURCE_PATH) 169 include_directories(${MOBILE_NATIVE_LIBS_SOURCE_PATH}/libc) 170 else() 171 message(FATAL_ERROR "MOBILE_NATIVE_LIBS_SOURCE_PATH is not set") 172 endif() 173endif() 174 175if(PANDA_TARGET_64) 176 panda_set_flag(PANDA_USE_32_BIT_POINTER) 177endif() 178 179if(PANDA_TARGET_LINUX) 180 execute_process(COMMAND grep PRETTY_NAME= /etc/os-release 181 OUTPUT_VARIABLE PANDA_TARGET_LINUX_DISTRO 182 OUTPUT_STRIP_TRAILING_WHITESPACE 183 ) 184 if(PANDA_TARGET_LINUX_DISTRO MATCHES "Ubuntu") 185 panda_set_flag(PANDA_TARGET_LINUX_UBUNTU) 186 endif() 187 188 if(PANDA_TARGET_LINUX_DISTRO MATCHES "Ubuntu 18\\.04") 189 panda_set_flag(PANDA_TARGET_LINUX_UBUNTU_18_04) 190 elseif(PANDA_TARGET_LINUX_DISTRO MATCHES "Ubuntu 20\\.04") 191 panda_set_flag(PANDA_TARGET_LINUX_UBUNTU_20_04) 192 elseif(PANDA_TARGET_LINUX_DISTRO MATCHES "Ubuntu 22\\.04") 193 panda_set_flag(PANDA_TARGET_LINUX_UBUNTU_22_04) 194 endif() 195 execute_process(COMMAND uname -a 196 OUTPUT_VARIABLE PANDA_TARGET_WSL_DISTRO 197 OUTPUT_STRIP_TRAILING_WHITESPACE 198 ) 199 if(PANDA_TARGET_WSL_DISTRO MATCHES "Microsoft") 200 panda_set_flag(PANDA_TARGET_WSL) 201 endif() 202 if(PANDA_TARGET_WSL_DISTRO MATCHES "WSL") 203 panda_set_flag(PANDA_TARGET_GENERAL_WSL) 204 endif() 205endif() 206 207set(PANDA_WITH_RUNTIME true) 208set(PANDA_WITH_COMPILER true) 209set(PANDA_WITH_TOOLCHAIN true) 210if (NOT DEFINED PANDA_WITH_BENCHMARKS) 211 set(PANDA_WITH_BENCHMARKS true) 212endif() 213set(PANDA_DEFAULT_LIB_TYPE "SHARED") 214 215option(PANDA_WITH_TESTS "Enable test targets" true) 216option(PANDA_WITH_BYTECODE_OPTIMIZER "Enable bytecode optimizer" true) 217option(PANDA_COMPILER_DEBUG_INFO "Support DWARF debug information in Compiler (JIT/AOT/IRtoC)" OFF) 218option(PANDA_ENABLE_RELAYOUT_PROFILE "Enable relayout profile" OFF) 219option(PANDA_ENABLE_CCACHE "Enable ccache" true) 220if (NOT DEFINED ES2PANDA_PATH) 221 set(ES2PANDA_PATH ${PANDA_ROOT}/tools/es2panda) 222endif() 223 224if(PANDA_TARGET_WINDOWS) 225 set(PANDA_WITH_BENCHMARKS false) 226 set(PANDA_DEFAULT_LIB_TYPE "STATIC") 227 # introduced for GetDynamicTimeZoneInformation 228 add_definitions(-D_WIN32_WINNT=0x600) 229endif() 230 231if(PANDA_TARGET_MACOS) 232 set(PANDA_DEFAULT_LIB_TYPE "STATIC") 233 #introduced for "std::filesystem::create_directories" 234 add_compile_options(-mmacosx-version-min=10.15) 235endif() 236 237if(PANDA_TARGET_OHOS) 238 set(PANDA_WITH_BENCHMARKS false) 239 add_definitions(-D__MUSL__) 240 241 if(PANDA_TARGET_ARM64) 242 # WORKAROUND: 243 # Disable '-Wunused-command-line-argument' error to avoid compilation error: 244 # clang++: error: argument unused during compilation: '--gcc-toolchain=<path/to/toolchain>/llvm' [-Werror,-Wunused-command-line-argument] 245 add_compile_options(-Wno-unused-command-line-argument) 246 247 # -Wno-deprecated-declarations needs for third_parties and ecmascript plugin 248 add_compile_options(-Wno-deprecated-declarations) 249 endif() 250endif() 251 252if(CMAKE_BUILD_TYPE STREQUAL Debug) 253 add_definitions(-DPANDA_ENABLE_SLOW_DEBUG) 254 add_definitions(-D_GLIBCXX_ASSERTIONS) 255endif() 256 257if(CMAKE_BUILD_TYPE STREQUAL FastVerify) 258 add_definitions(-DPANDA_FAST_VERIFY) 259 add_definitions(-D_GLIBCXX_ASSERTIONS) 260endif() 261 262# The define is set for the build which will be delivered to customers. 263# Currently this build doesn't contain dependencies to debug libraries 264# (like libdwarf.so) 265option(PANDA_PRODUCT_BUILD "Build which will be delivered to customers" false) 266 267if(PANDA_PRODUCT_BUILD AND NOT (CMAKE_BUILD_TYPE STREQUAL "Release")) 268 message(FATAL_ERROR "PANDA_PRODUCT_BUILD must be run with the Release build type only!") 269endif() 270 271if(NOT PANDA_PRODUCT_BUILD AND PANDA_WITH_HIDDEN_SYMBOLS) 272 message(FATAL_ERROR "PANDA_WITH_HIDDEN_SYMBOLS must be run with PANDA_PRODUCT_BUILD only!") 273endif() 274 275option(PANDA_WITH_HIDDEN_SYMBOLS "Build with -fvisibility=hidden options for some libraries" ${PANDA_PRODUCT_BUILD}) 276 277if (("${CMAKE_BUILD_TYPE}" STREQUAL "Debug" OR 278 "${CMAKE_BUILD_TYPE}" STREQUAL "DebugDetailed" OR 279 "${CMAKE_BUILD_TYPE}" STREQUAL "FastVerify" OR 280 "${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo") AND 281 (NOT PANDA_TARGET_WINDOWS) AND 282 (NOT PANDA_ENABLE_ADDRESS_SANITIZER) AND 283 (NOT PANDA_ENABLE_UNDEFINED_BEHAVIOR_SANITIZER) AND 284 (NOT PANDA_ENABLE_THREAD_SANITIZER)) 285 # Windows do not have elf and dwarf libraries 286 # Sanitizers do not work properly with gdb 287 set(PANDA_COMPILER_DEBUG_INFO ON) 288endif() 289 290# libdwarf-dev lib (version: 20180129-1) in Ubuntu 18.04 has memory leaks 291# TODO(asidorov): delete the workaround when the problem is fixed 292if (PANDA_ENABLE_ADDRESS_SANITIZER AND PANDA_TARGET_LINUX_UBUNTU_18_04) 293 set(PANDA_COMPILER_DEBUG_INFO OFF) 294endif() 295 296# TODO: Ensure libdwarf is available when building with OHOS toolchain 297if (PANDA_TARGET_OHOS) 298 set(PANDA_COMPILER_DEBUG_INFO OFF) 299endif() 300 301if (PANDA_PRODUCT_BUILD) 302 set(PANDA_COMPILER_DEBUG_INFO OFF) 303endif() 304 305if ((NOT DEFINED PANDA_MINIMAL_VIXL) AND PANDA_PRODUCT_BUILD) 306 # VIXL aarch64 with Encoder only (with no Decoder or Simulator provided) 307 set(PANDA_MINIMAL_VIXL true) 308endif() 309 310panda_promote_to_definitions( 311 PANDA_PRODUCT_BUILD 312 PANDA_WITH_COMPILER 313 PANDA_WITH_BYTECODE_OPTIMIZER 314 PANDA_COMPILER_DEBUG_INFO 315 PANDA_MINIMAL_VIXL 316 INTRUSIVE_TESTING 317) 318 319option(PANDA_CROSS_COMPILER "Enable compiler cross-compilation support" ON) 320option(PANDA_COMPILER_TARGET_X86 "Build x86-backend") 321option(PANDA_COMPILER_TARGET_X86_64 "Build x86_64-backend" ON) 322option(PANDA_COMPILER_TARGET_AARCH32 "Build aarch32-backend" ON) 323option(PANDA_COMPILER_TARGET_AARCH64 "Build aarch64-backend" ON) 324# User-specified cross-toolchains: 325option(PANDA_CROSS_X86_64_TOOLCHAIN_FILE "Absolute path to X86_64 target toolchain" OFF) 326option(PANDA_CROSS_AARCH64_TOOLCHAIN_FILE "Absolute path to AARCH64 target toolchain" OFF) 327option(PANDA_CROSS_AARCH32_TOOLCHAIN_FILE "Absolute path to AARCH32 target toolchain" OFF) 328 329# true if current target supports JIT/AOT native compilation 330# TODO (asidorov, runtime): replace all uses of this option by PANDA_WITH_COMPILER 331set(PANDA_COMPILER_ENABLE TRUE) 332 333if (PANDA_TARGET_AMD64) 334 if (PANDA_CROSS_COMPILER) 335 if (HOST_TOOLS) 336 # For host-tools build support only single-target backend (with the same toolchain): 337 message(STATUS "set ${PANDA_HOST_TOOLS_TARGET_ARCH}") 338 set(PANDA_COMPILER_TARGET_${PANDA_HOST_TOOLS_TARGET_ARCH} ON) 339 else() 340 set(PANDA_COMPILER_TARGET_X86_64 ON) 341 # If `PANDA_CROSS_${arch}_TOOLCHAIN_FILE` wasn't specified, gcc-toolchain is used: 342 find_program(GCC_AARCH64_CXX "aarch64-linux-gnu-g++") 343 find_program(GCC_ARM_CXX "arm-linux-gnueabi-g++") 344 345 # The option is ON by default; this 'if' allows to check if the target wasn't turned off explicitly: 346 if (PANDA_COMPILER_TARGET_AARCH64) 347 if (PANDA_CROSS_AARCH64_TOOLCHAIN_FILE) 348 message(STATUS "Specified AARCH64 toolchain: ${PANDA_CROSS_AARCH64_TOOLCHAIN_FILE}") 349 elseif (GCC_AARCH64_CXX) 350 message(STATUS "Detected default AARCH64 toolchain") 351 else() 352 set(PANDA_COMPILER_TARGET_AARCH64 OFF) 353 message(STATUS "No AARCH64 toolchain found") 354 endif() 355 endif() 356 357 # The option is ON by default; this 'if' allows to check if the target wasn't turned off explicitly: 358 if (PANDA_COMPILER_TARGET_AARCH32) 359 if (PANDA_CROSS_AARCH32_TOOLCHAIN_FILE) 360 message(STATUS "Specified AARCH32 toolchain: ${PANDA_CROSS_AARCH32_TOOLCHAIN_FILE}") 361 elseif (GCC_ARM_CXX) 362 message(STATUS "Detected default AARCH32 toolchain") 363 else() 364 set(PANDA_COMPILER_TARGET_AARCH32 OFF) 365 message(STATUS "No AARCH32 toolchain found") 366 endif() 367 endif() 368 # TODO(dkofanov): cross-values do not support x86 369 set(PANDA_COMPILER_TARGET_X86 OFF) 370 endif() 371 else() 372 set(PANDA_COMPILER_TARGET_X86 OFF) 373 set(PANDA_COMPILER_TARGET_X86_64 ON) 374 set(PANDA_COMPILER_TARGET_AARCH32 OFF) 375 set(PANDA_COMPILER_TARGET_AARCH64 OFF) 376 endif() 377endif() 378 379if (PANDA_TARGET_X86) 380 set(PANDA_COMPILER_TARGET_X86 ON) 381 set(PANDA_COMPILER_TARGET_X86_64 OFF) 382 set(PANDA_COMPILER_TARGET_AARCH32 OFF) 383 set(PANDA_COMPILER_TARGET_AARCH64 OFF) 384endif() 385 386if (PANDA_TARGET_ARM32) 387 if(PANDA_TARGET_ARM32_ABI_SOFT) 388 set(PANDA_COMPILER_ENABLE FALSE) 389 set(PANDA_COMPILER_TARGET_X86 OFF) 390 set(PANDA_COMPILER_TARGET_X86_64 OFF) 391 set(PANDA_COMPILER_TARGET_AARCH32 OFF) 392 set(PANDA_COMPILER_TARGET_AARCH64 OFF) 393 else() 394 set(PANDA_COMPILER_TARGET_X86 OFF) 395 set(PANDA_COMPILER_TARGET_X86_64 OFF) 396 set(PANDA_COMPILER_TARGET_AARCH32 ON) 397 set(PANDA_COMPILER_TARGET_AARCH64 OFF) 398 endif() 399endif() 400 401if (PANDA_TARGET_ARM64) 402 set(PANDA_COMPILER_TARGET_X86 OFF) 403 set(PANDA_COMPILER_TARGET_X86_64 OFF) 404 set(PANDA_COMPILER_TARGET_AARCH32 OFF) 405 set(PANDA_COMPILER_TARGET_AARCH64 ON) 406endif() 407 408if ((NOT PANDA_TARGET_WINDOWS) AND (NOT PANDA_ENABLE_ADDRESS_SANITIZER) AND (NOT PANDA_ENABLE_THREAD_SANITIZER)) 409 panda_set_flag(PANDA_USE_CUSTOM_SIGNAL_STACK) 410endif() 411 412option(PANDA_LLVM_BACKEND "Enable LLVM backend for Ark compiler" OFF) 413 414if (NOT PANDA_LLVM_BACKEND) 415 if (PANDA_LLVM_INTERPRETER) 416 message(FATAL_ERROR "PANDA_LLVM_INTERPRETER can't be enabled without PANDA_LLVM_BACKEND") 417 endif() 418 419 if (PANDA_LLVM_FASTPATH) 420 message(FATAL_ERROR "PANDA_LLVM_FASTPATH can't be enabled without PANDA_LLVM_BACKEND") 421 endif() 422 423 if (PANDA_LLVM_AOT) 424 message(FATAL_ERROR "PANDA_LLVM_AOT is temporarily disabled") 425 endif() 426endif() 427 428if (NOT (PANDA_TARGET_AMD64 OR PANDA_TARGET_ARM64)) 429 set(PANDA_LLVM_BACKEND false) 430endif() 431 432# NB: LLVM_AOT option now relates only to '--paoc-mode=llvm' and is temporarily disabled 433# One have to enable the option below to get `--interpreter-mode=llvm` working 434if (PANDA_LLVM_BACKEND) 435 # Enabling PANDA_LLVM_BACKEND enables IRTOC code compilation functions, 436 # including FastPaths and Interpreter handlers. 437 # Examples: 438 # cmake -DPANDA_LLVM_BACKEND=ON => both FastPaths and Interpreter are ON 439 # cmake -DPANDA_LLVM_BACKEND=ON -DPANDA_LLVM_FASTPATH=OFF => only Interpreter handlers compiled 440 # cmake -DPANDA_LLVM_INTERPRETER=ON => error, please enable the BACKEND option too 441 if (NOT DEFINED PANDA_LLVM_FASTPATH) 442 set(PANDA_LLVM_FASTPATH ON) 443 endif() 444 if (NOT DEFINED PANDA_LLVM_INTERPRETER) 445 set(PANDA_LLVM_INTERPRETER ON) 446 endif() 447 # ======= LLVM_AOT functionality is temporarily disabled ========= 448 set(PANDA_LLVM_AOT OFF) 449 450 # Internal flag, merged from irtoc: FASTPATH and INTERPRETER 451 if (PANDA_LLVM_FASTPATH OR PANDA_LLVM_INTERPRETER) 452 panda_set_flag(PANDA_LLVM_IRTOC) 453 endif() 454 455 # PANDA_LLVM_AOT means either: 456 # 1. We're in cross-build, and llvm aot support is requested for the cross-build target. 457 # For example, host is amd64, and cross target is aarch64, then we'll add llvm aot 458 # support for the ark_aot compiled for aarch64. 459 # 2. We're in non cross-build, and llvm aot support is requested 460 # 461 # PANDA_LLVM_IRTOC AND NOT CMAKE_CROSS_COMPILING covers two scenarios: 462 # 1. Non cross-build, IRTOC support is requested 463 # 2. Cross-build, IRTOC support is requested but we'll require LLVM only for HOST_TOOLS 464 if (PANDA_LLVM_AOT OR (PANDA_LLVM_IRTOC AND NOT CMAKE_CROSSCOMPILING)) 465 panda_set_flag(PANDA_BUILD_LLVM_BACKEND) 466 endif() 467endif() 468 469panda_promote_to_definitions( 470 PANDA_COMPILER_TARGET_X86 471 PANDA_COMPILER_TARGET_X86_64 472 PANDA_COMPILER_TARGET_AARCH32 473 PANDA_COMPILER_TARGET_AARCH64 474 PANDA_COMPILER_ENABLE 475 PANDA_QEMU_BUILD 476 PANDA_LLVM_BACKEND 477 PANDA_LLVM_FASTPATH 478 PANDA_LLVM_INTERPRETER 479 PANDA_LLVM_AOT 480) 481 482if (PANDA_USE_PREBUILT_TARGETS) 483 set(CMAKE_NO_SYSTEM_FROM_IMPORTED ON) 484endif() 485 486if (PANDA_ETS_INTEROP_JS) 487 panda_set_flag(PANDA_ETS_INTEROP_JS) 488endif() 489 490message(STATUS "PANDA_TARGET_MOBILE_WITH_MANAGED_LIBS = ${PANDA_TARGET_MOBILE_WITH_MANAGED_LIBS}") 491message(STATUS "PANDA_TARGET_UNIX = ${PANDA_TARGET_UNIX}") 492message(STATUS "PANDA_TARGET_LINUX = ${PANDA_TARGET_LINUX}") 493message(STATUS "PANDA_TARGET_MOBILE = ${PANDA_TARGET_MOBILE}") 494message(STATUS "PANDA_USE_FUTEX = ${PANDA_USE_FUTEX}") 495message(STATUS "PANDA_TARGET_WINDOWS = ${PANDA_TARGET_WINDOWS}") 496message(STATUS "PANDA_TARGET_OHOS = ${PANDA_TARGET_OHOS}") 497message(STATUS "PANDA_TARGET_MACOS = ${PANDA_TARGET_MACOS}") 498message(STATUS "PANDA_CROSS_COMPILER = ${PANDA_CROSS_COMPILER}") 499message(STATUS "PANDA_CROSS_AMD64_X86 = ${PANDA_CROSS_AMD64_X86}") 500message(STATUS "PANDA_TARGET_AMD64 = ${PANDA_TARGET_AMD64}") 501message(STATUS "PANDA_TARGET_X86 = ${PANDA_TARGET_X86}") 502message(STATUS "PANDA_TARGET_ARM64 = ${PANDA_TARGET_ARM64}") 503message(STATUS "PANDA_TARGET_ARM32 = ${PANDA_TARGET_ARM32}") 504if(PANDA_TARGET_ARM32) 505message(STATUS "PANDA_TARGET_ARM32_ABI_SOFT = ${PANDA_TARGET_ARM32_ABI_SOFT}") 506message(STATUS "PANDA_TARGET_ARM32_ABI_SOFTFP = ${PANDA_TARGET_ARM32_ABI_SOFTFP}") 507message(STATUS "PANDA_TARGET_ARM32_ABI_HARD = ${PANDA_TARGET_ARM32_ABI_HARD}") 508endif() 509message(STATUS "PANDA_TARGET_64 = ${PANDA_TARGET_64}") 510message(STATUS "PANDA_TARGET_32 = ${PANDA_TARGET_32}") 511message(STATUS "PANDA_ENABLE_GLOBAL_REGISTER_VARIABLES = ${PANDA_ENABLE_GLOBAL_REGISTER_VARIABLES}") 512message(STATUS "PANDA_ENABLE_LTO = ${PANDA_ENABLE_LTO}") 513if(PANDA_TARGET_MOBILE) 514message(STATUS "PANDA_LLVM_REGALLOC = ${PANDA_LLVM_REGALLOC}") 515endif() 516if(PANDA_TARGET_MOBILE_WITH_NATIVE_LIBS) 517message(STATUS "PANDA_TARGET_MOBILE_WITH_NATIVE_LIBS = ${PANDA_TARGET_MOBILE_WITH_NATIVE_LIBS}") 518endif() 519message(STATUS "PANDA_WITH_RUNTIME = ${PANDA_WITH_RUNTIME}") 520message(STATUS "PANDA_WITH_COMPILER = ${PANDA_WITH_COMPILER}") 521message(STATUS "PANDA_COMPILER_ENABLE = ${PANDA_COMPILER_ENABLE}") 522message(STATUS "PANDA_WITH_TOOLCHAIN = ${PANDA_WITH_TOOLCHAIN}") 523message(STATUS "PANDA_WITH_TESTS = ${PANDA_WITH_TESTS}") 524message(STATUS "PANDA_WITH_BENCHMARKS = ${PANDA_WITH_BENCHMARKS}") 525message(STATUS "PANDA_WITH_BYTECODE_OPTIMIZER = ${PANDA_WITH_BYTECODE_OPTIMIZER}") 526message(STATUS "PANDA_PGO_INSTRUMENT = ${PANDA_PGO_INSTRUMENT}") 527message(STATUS "PANDA_PGO_OPTIMIZE = ${PANDA_PGO_OPTIMIZE}") 528message(STATUS "PANDA_PRODUCT_BUILD = ${PANDA_PRODUCT_BUILD}") 529message(STATUS "PANDA_ENABLE_RELAYOUT_PROFILE = ${PANDA_ENABLE_RELAYOUT_PROFILE}") 530message(STATUS "PANDA_QEMU_BUILD = ${PANDA_QEMU_BUILD}") 531message(STATUS "PANDA_LLVM_BACKEND = ${PANDA_LLVM_BACKEND}") 532message(STATUS "PANDA_LLVM_INTERPRETER = ${PANDA_LLVM_INTERPRETER}") 533message(STATUS "PANDA_LLVM_FASTPATH = ${PANDA_LLVM_FASTPATH}") 534message(STATUS "PANDA_LLVM_AOT = ${PANDA_LLVM_AOT}") 535message(STATUS "PANDA_ENABLE_CCACHE = ${PANDA_ENABLE_CCACHE}") 536message(STATUS "PANDA_USE_CUSTOM_SIGNAL_STACK = ${PANDA_USE_CUSTOM_SIGNAL_STACK}") 537message(STATUS "PANDA_USE_PREBUILT_TARGETS = ${PANDA_USE_PREBUILT_TARGETS}") 538message(STATUS "CMAKE_NO_SYSTEM_FROM_IMPORTED = ${CMAKE_NO_SYSTEM_FROM_IMPORTED}") 539message(STATUS "ES2PANDA_PATH = ${ES2PANDA_PATH}") 540