From 33ced5913e5a775202eb96c520d4e1154b6b2ea0 Mon Sep 17 00:00:00 2001 From: Aregtech Date: Mon, 11 Nov 2024 21:44:21 +0100 Subject: [PATCH] Fixed cross-compiling of AREG SDK. binaries. Updated documents. --- README.md | 20 ++- areg-sdk.sln | 2 + conf/cmake/common.cmake | 24 ++- conf/cmake/functions.cmake | 85 ++++++++-- conf/cmake/gnu.cmake | 18 ++- conf/cmake/msvc.cmake | 8 +- conf/cmake/user.cmake | 145 +++++++++-------- conf/exports/config.cmake.in | 19 ++- docs/wiki/01b-cmake-build.md | 111 +++++++++++++ docs/wiki/01d-wsl-build.md | 103 ++++++++++-- docs/wiki/02a-cmake-config.md | 150 +++++++++++------- docs/wiki/02b-cmake-functions.md | 26 +++ docs/wiki/07a-troubleshooting-wsl-update.md | 41 +++++ .../07b-troubleshooting-cmake-linux-builds.md | 38 +++++ docs/wiki/README.md | 4 + framework/areg/base/GETypes.h | 26 ++- .../base/private/posix/SynchLockAndWaitIX.cpp | 8 +- .../base/private/posix/SynchLockAndWaitIX.hpp | 6 +- framework/areg/component/private/Watchdog.hpp | 6 +- tests/CMakeLists.txt | 5 + 20 files changed, 643 insertions(+), 202 deletions(-) create mode 100644 docs/wiki/07a-troubleshooting-wsl-update.md create mode 100644 docs/wiki/07b-troubleshooting-cmake-linux-builds.md diff --git a/README.md b/README.md index 0125f13e..eefe098a 100644 --- a/README.md +++ b/README.md @@ -148,17 +148,14 @@ git clone https://github.com/aregtech/areg-sdk.git ### Build Instructions -The **AREG SDK** is written in **C++17** and supports multiple platforms and compilers: -- **Supported platforms:** Linux, Windows, Cygwin and macOS. -- **Supported compilers:** GNU, Clang, MSVC and Cygwin GNU. -- **Supported CPU:** x86, x86_64, arm, and aarch64. +The **AREG SDK** is written in **C++17**, supports multiple platforms, processors and compilers: -The following build tools are supported: - -| Tool | Solution | Platforms | API | Quick actions to compile | -|-------------|------------------|------------------------|--------------|------------------------------------| -| **CMake** | `CMakeLists.txt` | Linux, Windows, Cygwin | POSIX, Win32 | Build with CMake, VSCode, or MSVS. | -| **MSBuild** | `areg-sdk.sln` | Windows | Win32 | Build with MSBuild or MSVS. | +| Compiler | Platforms | Tools | API | CPU Architecture | +|-----------|---------------|---------------|---------------|---------------------------| +| GNU | Linux, macOS | CMake | POSIX | x86, x86_64, ARM, AARCH64 | +| Clang | Linux, Windows| CMake, MSVS | POSIX, Win32 | x86, x86_64 | +| MSVC | Windows | CMake, MSVS | Win32 | x86, x86_64 | +| Cygwin GNU| Windows | CMake | POSIX | x86, x86_64 | For detailed build instructions, check the **[Building AREG SDK with CMake](./docs/wiki/01b-cmake-build.md)** or **[Building the AREG SDK with Microsoft Visual Studio and MSBuild](./docs/wiki/01c-msvc-build.md)** pages. @@ -175,7 +172,8 @@ cmake -B ./build cmake --build ./build -j 20 ``` -For custom builds, pass the options via the command line or configure the options listed in **[user.cmake](./docs/wiki/02a-cmake-config.md)** in CMake script. +> [!TIP] +> For **custom builds and cross-compiling** see **[Building AREG SDK with CMake](./docs/wiki/01b-cmake-build.md)**. #### Build with Microsoft Visual Studio diff --git a/areg-sdk.sln b/areg-sdk.sln index e84b15d6..7982e1c7 100644 --- a/areg-sdk.sln +++ b/areg-sdk.sln @@ -705,6 +705,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "wiki", "wiki", "{C33D0DF1-A docs\wiki\04d-logcollector.md = docs\wiki\04d-logcollector.md docs\wiki\05a-mcrouter.md = docs\wiki\05a-mcrouter.md docs\wiki\06a-persistence-syntax.md = docs\wiki\06a-persistence-syntax.md + docs\wiki\07a-troubleshooting-wsl-update.md = docs\wiki\07a-troubleshooting-wsl-update.md + docs\wiki\07b-troubleshooting-cmake-linux-builds.md = docs\wiki\07b-troubleshooting-cmake-linux-builds.md docs\wiki\README.md = docs\wiki\README.md EndProjectSection EndProject diff --git a/conf/cmake/common.cmake b/conf/cmake/common.cmake index 03f49d6a..7b369626 100644 --- a/conf/cmake/common.cmake +++ b/conf/cmake/common.cmake @@ -12,7 +12,7 @@ endif() # Identify compiler short name if ("${AREG_COMPILER_FAMILY}" STREQUAL "") - macro_setup_compilers_data("${CMAKE_CXX_COMPILER}" AREG_COMPILER_FAMILY AREG_COMPILER_SHORT AREG_CXX_COMPILER AREG_C_COMPILER _compiler_found) + macro_setup_compilers_data("${CMAKE_CXX_COMPILER}" AREG_COMPILER_FAMILY AREG_COMPILER_SHORT AREG_CXX_COMPILER AREG_C_COMPILER AREG_PROCESSOR AREG_BITNESS _compiler_found) if (_compiler_found) message(STATUS "AREG: >>> Use system default settings:") message(STATUS "AREG: ... Compiler family = \'${AREG_COMPILER_FAMILY}\'") @@ -24,14 +24,16 @@ if ("${AREG_COMPILER_FAMILY}" STREQUAL "") elseif("${AREG_COMPILER_SHORT}" STREQUAL "") - message(FATAL_ERROR "AREG: >>> The cmake file \'${AREG_CMAKE_CONFIG_DIR}/setup.cmake\' should be included before \'common.cmake\', fix it and retry again.") + message(FATAL_ERROR "AREG: >>> The file \'${AREG_CMAKE_CONFIG_DIR}/setup.cmake\' should be included before \'common.cmake\', fix it and retry again.") endif() # Identify the OS set(AREG_OS ${CMAKE_SYSTEM_NAME}) # Identify CPU platform -set(AREG_PROCESSOR ${CMAKE_SYSTEM_PROCESSOR}) +if ("${AREG_PROCESSOR}" STREQUAL "") + set(AREG_PROCESSOR ${CMAKE_SYSTEM_PROCESSOR}) +endif() # ----------------------------------------------------- # areg specific internal variable settings @@ -63,11 +65,21 @@ option(AREG_GTEST_FOUND "GTest package found flag" FALSE) add_definitions(-DUNICODE -D_UNICODE) remove_definitions(-D_MBCS -DMBCS) +# ######################################################## +# Warnings to disable +# ######################################################## + +# Disable common warnings for all projects set(AREG_OPT_DISABLE_WARN_COMMON) +# Disable warnings only for areg framework set(AREG_OPT_DISABLE_WARN_FRAMEWORK) +# Disable warnings only for tools set(AREG_OPT_DISABLE_WARN_TOOLS) +# Disable warnings only for examples set(AREG_OPT_DISABLE_WARN_EXAMPLES) +# Disable warnings only for generated codes set(AREG_OPT_DISABLE_WARN_CODEGEN) +# Disable warnings only for thirdparty projects set(AREG_OPT_DISABLE_WARN_THIRDPARTY) # Checking Compiler for adding corresponded tweaks and flags @@ -106,6 +118,12 @@ else() add_definitions(-DAREG_LOGS=0) endif() +if (AREG_BITNESS EQUAL 32) + add_definitions(-DBIT32) +else() + add_definitions(-DBIT64) +endif() + # ------------------------------------------------------- # Setup product paths # ------------------------------------------------------- diff --git a/conf/cmake/functions.cmake b/conf/cmake/functions.cmake index 108a5a60..8f11967a 100644 --- a/conf/cmake/functions.cmake +++ b/conf/cmake/functions.cmake @@ -166,6 +166,51 @@ macro(macro_parse_arguments res_sources res_libs res_resources) endforeach() endmacro(macro_parse_arguments) +# --------------------------------------------------------------------------- +# Macro ......: macro_guess_processor_architecture +# Purpose ....: Tries to guess the CPU architecture and bitness from the given cross-compiler. +# For example, if cross-compiler has "arm" in the name, it could mean that +# it targets 32-bit ARM processor. +# Parameters .: ${compiler_path} [in] -- Path of the cross-compiler. +# ${target_processor} [out] -- Name of variable to store the CPU type. +# ${target_bitness} [out] -- Name of variable to store bitness. +# +# Usage ......: macro_guess_processor_architecture( ) +# Example ....: macro_guess_processor_architecture("arm-linux-gnueabihf-g++" cpu_architect cpu_bitness) +# --------------------------------------------------------------------------- +macro(macro_guess_processor_architecture compiler_path target_processor target_bitness) + foreach(_proc "arm;32;arm" "aarch64;64;arm64") + list(GET _proc 0 _arch) + list(GET _proc 1 _bits) + list(GET _proc 2 _name) + string(FIND "${compiler_path}" ${_arch} _proc_pos) + if (_proc_pos GREATER -1) + set(${target_processor} ${_name}) + set(${target_bitness} ${_bits}) + break() + endif() + endforeach() +endmacro(macro_guess_processor_architecture) + +# --------------------------------------------------------------------------- +# Macro ......: macro_system_bitness +# Purpose ....: Extracts the system default bitness. +# Parameters : ${var_bitness} -- The name of variable to set the bitness. +# Usage ......: macro_system_bitness() +# Example ....: macro_system_bitness(_sys_bitness) +# --------------------------------------------------------------------------- +macro(macro_system_bitness var_bitness) + # Detect and set bitness here + # 8 bytes ==> 64-bits (x64) and 4 bytes ==> 32-nit (x86) + if(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(${var_bitness} 64) + elseif(CMAKE_SIZEOF_VOID_P EQUAL 4) + set(${var_bitness} 32) + else() + set(${var_bitness} 0) + endif() +endmacro(macro_system_bitness) + # --------------------------------------------------------------------------- # Macro ......: macro_setup_compilers_data # Purpose ....: Identifies and configures compiler family, short names, and paths. @@ -181,13 +226,21 @@ endmacro(macro_parse_arguments) # AREG_COMPILER_FAMILY # AREG_COMPILER_SHORT # AREG_CXX_COMPILER -# AREG_C_COMPILER +# AREG_C_COMPILER +# AREG_PROCESSOR +# AREG_BITNESS # _compiler_supports # ) # --------------------------------------------------------------------------- -macro(macro_setup_compilers_data compiler_path compiler_family compiler_short compiler_cxx compiler_c is_identified) +macro(macro_setup_compilers_data compiler_path compiler_family compiler_short compiler_cxx compiler_c sys_platform sys_bitness is_identified) set(${is_identified} FALSE) + if (DEFINED AREG_PROCESSOR) + set(${sys_platform} AREG_PROCESSOR) + endif() + if (DEFINED AREG_BITNESS) + set(${sys_bitness} AREG_BITNESS) + endif() # Iterate over known compilers to identify the compiler type foreach(_entry "clang-cl;llvm;clang-cl" "clang++;llvm;clang" "clang;llvm;clang" "g++;gnu;gcc" "gcc;gnu;gcc" "c++;gnu;cc" "cc;gnu;cc" "cl;msvc;cl") @@ -196,11 +249,15 @@ macro(macro_setup_compilers_data compiler_path compiler_family compiler_short co list(GET _entry 2 _c_compiler) # Check if the provided compiler matches the known C++ compiler - string(FIND "${compiler_path}" "${_cxx_compiler}" _found_pos REVERSE) + string(TOLOWER "${compiler_path}" _comp_path) + string(FIND "${_comp_path}" "${_cxx_compiler}" _found_pos REVERSE) if (_found_pos GREATER -1) # Handle special case for CYGWIN and GNU family compilers if (CYGWIN AND ("${_family}" STREQUAL "gnu")) set(${compiler_family} "cygwin") + elseif("${_family}" STREQUAL "gnu") + macro_guess_processor_architecture("${_comp_path}" ${sys_platform} ${sys_bitness}) + set(${compiler_family} "${_family}") else() set(${compiler_family} "${_family}") endif() @@ -234,7 +291,7 @@ endmacro(macro_setup_compilers_data) # - ${compiler_cxx} -- Output: Variable to hold the C++ compiler name. # - ${compiler_c} -- Output: Variable to hold the corresponding C compiler name. # - ${is_identified} -- Output: Name of variable to hold Boolean indicating successful identification.. -# Usage ......: macro_setup_compilers_data( ) +# Usage ......: macro_setup_compilers_data_by_family( ) # Example ....: macro_setup_compilers_data_by_family("gnu" # AREG_COMPILER_SHORT # AREG_CXX_COMPILER @@ -258,6 +315,14 @@ macro(macro_setup_compilers_data_by_family compiler_family compiler_short compil set(${compiler_short} "clang-cl") set(${compiler_cxx} "clang-cl") set(${compiler_c} "clang-cl") + elseif (AREG_PROCESSOR STREQUAL "arm" AND "${_family}" STREQUAL "gnu") + set(${compiler_short} "g++") + set(${compiler_cxx} "arm-linux-gnueabihf-g++") + set(${compiler_c} "arm-linux-gnueabihf-gcc") + elseif (AREG_PROCESSOR STREQUAL "aarch64" AND "${_family}" STREQUAL "gnu") + set(${compiler_short} "g++") + set(${compiler_cxx} "aarch64-linux-gnu-g++") + set(${compiler_c} "aarch64-linux-gnu-gcc") else() set(${compiler_short} "${_compiler}") set(${compiler_cxx} "${_compiler}") @@ -840,15 +905,3 @@ function(printAregConfigStatus var_make_print var_prefix var_header var_footer) message(STATUS "=======================================================================================") endfunction(printAregConfigStatus) - -macro(macro_system_bitness var_bitness) - # Detect and set bitness here - # 8 bytes ==> 64-bits (x64) and 4 bytes ==> 32-nit (x86) - if(CMAKE_SIZEOF_VOID_P EQUAL 8) - set(${var_bitness} 64) - elseif(CMAKE_SIZEOF_VOID_P EQUAL 4) - set(${var_bitness} 32) - else() - set(${var_bitness} 0) - endif() -endmacro(macro_system_bitness) diff --git a/conf/cmake/gnu.cmake b/conf/cmake/gnu.cmake index ee91c42e..1accd476 100644 --- a/conf/cmake/gnu.cmake +++ b/conf/cmake/gnu.cmake @@ -29,12 +29,14 @@ else() list(APPEND AREG_COMPILER_OPTIONS -O0 -g3) endif() -if(${AREG_BITNESS} EQUAL 32) - list(APPEND AREG_COMPILER_OPTIONS -m32) - list(APPEND AREG_LDFLAGS -m32) -else() - list(APPEND AREG_COMPILER_OPTIONS -m64) - list(APPEND AREG_LDFLAGS -m64) +if (NOT ${AREG_PROCESSOR} STREQUAL "arm" AND NOT ${AREG_PROCESSOR} STREQUAL "aarch64") + if(${AREG_BITNESS} EQUAL 32) + list(APPEND AREG_COMPILER_OPTIONS -m32) + list(APPEND AREG_LDFLAGS -m32) + else() + list(APPEND AREG_COMPILER_OPTIONS -m64) + list(APPEND AREG_LDFLAGS -m64) + endif() endif() # Linker flags (-l is not necessary) @@ -46,3 +48,7 @@ list(APPEND AREG_OPT_DISABLE_WARN_THIRDPARTY -Wno-everything -Wno-unused-function ) + +list(APPEND AREG_OPT_DISABLE_WARN_COMMON + -Wno-psabi +) \ No newline at end of file diff --git a/conf/cmake/msvc.cmake b/conf/cmake/msvc.cmake index 5157a29e..d9a5d53b 100644 --- a/conf/cmake/msvc.cmake +++ b/conf/cmake/msvc.cmake @@ -7,16 +7,16 @@ message(STATUS "AREG: >>> Preparing settings for MSVC compiler under \'${AREG_OS # Visual Studio C++, Windows / Win32 API set(AREG_DEVELOP_ENV "Win32") + add_definitions(-DWINDOWS -D_WINDOWS -DWIN32 -D_WIN32) +if (${AREG_BITNESS} EQUAL 64) + add_definitions(-DWIN64 -D_WIN64) +endif() if(NOT CMAKE_BUILD_TYPE MATCHES Release) list(APPEND AREG_COMPILER_OPTIONS -Od -RTC1 -c) endif() -if (${AREG_BITNESS} EQUAL 64) - add_definitions(-DWIN64 -D_WIN64) -endif() - # Linker flags (-l is not necessary) list(APPEND AREG_LDFLAGS advapi32 psapi shell32 ws2_32) set(AREG_LDFLAGS_STR "-ladvapi32 -lpsapi -lshell32 -lws2_32") diff --git a/conf/cmake/user.cmake b/conf/cmake/user.cmake index e16a4d06..9ad4cb0c 100644 --- a/conf/cmake/user.cmake +++ b/conf/cmake/user.cmake @@ -10,48 +10,48 @@ # Available Options: # 1. AREG_COMPILER_FAMILY -- A quick way to set the C++ and C compilers (CMAKE_CXX_COMPILER and CMAKE_C_COMPILER). # 2. AREG_COMPILER -- Sets a specific compiler for both C++ and C projects. -# 3. AREG_BINARY -- Specifies the library type for the AREG Framework ('shared' or 'static'). Defaults to 'shared'. -# 4. AREG_LOGGER_LIB -- Specifies the type of the Log Observer API library ('shared' or 'static'). Defaults to 'shared'. -# 5. AREG_BUILD_TYPE -- Specifies the build configuration ('Debug' or 'Release'). -# 6. AREG_BUILD_TESTS -- Enables or disables building unit tests for the AREG Framework. -# 7. AREG_BUILD_EXAMPLES -- Enables or disables building examples for the AREG Framework. -# 8. AREG_EXTENDED -- Enables or disables extended AREG Framework features. May require additional dependencies. -# 9. AREG_LOGS -- Enables or disables logging during compilation. Defaults to 'enabled'. -# 10. AREG_USE_PACKAGES -- Enables or disables using installed packages. Controls other package options like SQLite and GTest. -# 11. AREG_SQLITE_PACKAGE -- Determines if the system's SQLite3 package should be used or compiled from source. -# 12. AREG_GTEST_PACKAGE -- Determines if the system's GTest package should be used or compiled from source. -# 13. AREG_ENABLE_OUTPUTS -- If disabled, output directories will match the CMake binary directory. -# 14. AREG_BUILD_ROOT -- Specifies the root directory for build files. Defaults to './product' within the AREG SDK root. -# 15. AREG_OUTPUT_DIR -- Directory where build outputs are placed. -# 16. AREG_OUTPUT_BIN -- Directory for output binaries (executables and shared libraries). -# 17. AREG_OUTPUT_LIB -- Directory for output static libraries. -# 18. AREG_PACKAGES -- Location for fetching third-party packages such as GTest. -# 19. AREG_INSTALL -- Enables or disables the installation of the AREG SDK binaries and headers, including dependent libraries like 'sqlite3' and 'ncurses'. -# 20. AREG_INSTALL_PATH -- Location where AREG SDK binaries, headers, and tools are installed. Defaults to the user's home directory. -# 21. AREG_BITNESS -- The bitness of the compiled applications. It can be either 32- or 64-bits. +# 3. AREG_PROCESSOR -- The processor architect. Ignore if need to use system default. +# 4. AREG_BINARY -- Specifies the library type for the AREG Framework ('shared' or 'static'). Defaults to 'shared'. +# 5. AREG_LOGGER_LIB -- Specifies the type of the Log Observer API library ('shared' or 'static'). Defaults to 'shared'. +# 6. AREG_BUILD_TYPE -- Specifies the build configuration ('Debug' or 'Release'). +# 7. AREG_BUILD_TESTS -- Enables or disables building unit tests for the AREG Framework. +# 8. AREG_BUILD_EXAMPLES -- Enables or disables building examples for the AREG Framework. +# 9. AREG_EXTENDED -- Enables or disables extended AREG Framework features. May require additional dependencies. +# 10. AREG_LOGS -- Enables or disables logging during compilation. Defaults to 'enabled'. +# 11. AREG_USE_PACKAGES -- Enables or disables using installed packages. Controls other package options like SQLite and GTest. +# 12. AREG_SQLITE_PACKAGE -- Determines if the system's SQLite3 package should be used or compiled from source. +# 13. AREG_GTEST_PACKAGE -- Determines if the system's GTest package should be used or compiled from source. +# 14. AREG_ENABLE_OUTPUTS -- If disabled, output directories will match the CMake binary directory. +# 15. AREG_BUILD_ROOT -- Specifies the root directory for build files. Defaults to './product' within the AREG SDK root. +# 16. AREG_OUTPUT_DIR -- Directory where build outputs are placed. +# 17. AREG_OUTPUT_BIN -- Directory for output binaries (executables and shared libraries). +# 18. AREG_OUTPUT_LIB -- Directory for output static libraries. +# 19. AREG_PACKAGES -- Location for fetching third-party packages such as GTest. +# 20. AREG_INSTALL -- Enables or disables installation of AREG SDK binaries, headers and dependencies like 'sqlite3' and 'ncurses'. +# 21. AREG_INSTALL_PATH -- Location where AREG SDK binaries, headers, and tools are installed. Defaults to the user's home directory. # # Default Values: # 1. AREG_COMPILER_FAMILY = (possible values: gnu, cygwin, llvm, msvc) # 2. AREG_COMPILER = (possible values: g++, gcc, c++, cc, clang++, clang, clang-cl, cl) -# 3. AREG_BINARY = shared (possible values: shared, static) -# 4. AREG_LOGGER_LIB = shared (possible values: shared, static) -# 5. AREG_BUILD_TYPE = Release (possible values: Release, Debug) -# 6. AREG_BUILD_TESTS = ON (possible values: ON, OFF) -# 7. AREG_BUILD_EXAMPLES = ON (possible values: ON, OFF) -# 8. AREG_EXTENDED = OFF (possible values: ON, OFF) -# 9. AREG_LOGS = ON (possible values: ON, OFF) -# 10. AREG_USE_PACKAGES = ON (possible values: ON, OFF) -# 11. AREG_SQLITE_PACKAGE = ON (possible values: ON, OFF) -# 12. AREG_GTEST_PACKAGE = ON (possible values: ON, OFF) -# 13. AREG_ENABLE_OUTPUTS = ON (possible values: ON, OFF) -# 14. AREG_BUILD_ROOT = '/product' (path for output and generated files) -# 15. AREG_OUTPUT_DIR = '/product/build//---release-' -# 16. AREG_OUTPUT_BIN = '/product/build//---release-/bin' -# 17. AREG_OUTPUT_LIB = '/product/build//---release-/lib' -# 18. AREG_PACKAGES = '${AREG_BUILD_ROOT}/packages' -# 19. AREG_INSTALL = ON (possible values: ON, OFF) -# 20. AREG_INSTALL_PATH = '${HOME}/areg-sdk' (or '${USERPROFILE}' on Windows, defaults to current directory if unset) -# 21. AREG_BITNESS = System (possible values: 32, 64) +# 3. AREG_PROCESSOR = System (possible values: x86, x64 (x86_64, amd64), arm (arm32), aarch64 (arm64)) +# 4. AREG_BINARY = shared (possible values: shared, static) +# 5. AREG_LOGGER_LIB = shared (possible values: shared, static) +# 6. AREG_BUILD_TYPE = Release (possible values: Release, Debug) +# 7. AREG_BUILD_TESTS = ON (possible values: ON, OFF) +# 8. AREG_BUILD_EXAMPLES = ON (possible values: ON, OFF) +# 9. AREG_EXTENDED = OFF (possible values: ON, OFF) +# 10. AREG_LOGS = ON (possible values: ON, OFF) +# 11. AREG_USE_PACKAGES = ON (possible values: ON, OFF) +# 12. AREG_SQLITE_PACKAGE = ON (possible values: ON, OFF) +# 13. AREG_GTEST_PACKAGE = ON (possible values: ON, OFF) +# 14. AREG_ENABLE_OUTPUTS = ON (possible values: ON, OFF) +# 15. AREG_BUILD_ROOT = '/product' (path for output and generated files) +# 16. AREG_OUTPUT_DIR = '/product/build//---release-' +# 17. AREG_OUTPUT_BIN = '/product/build//---release-/bin' +# 18. AREG_OUTPUT_LIB = '/product/build//---release-/lib' +# 19. AREG_PACKAGES = '${AREG_BUILD_ROOT}/packages' +# 20. AREG_INSTALL = ON (possible values: ON, OFF) +# 21. AREG_INSTALL_PATH = '${HOME}/areg-sdk' (or '${USERPROFILE}' on Windows, defaults to current directory if unset) # # Hints: # - AREG_COMPILER_FAMILY is an easy way to set compilers: @@ -78,6 +78,33 @@ set(AREG_CXX_COMPILER) set(AREG_C_COMPILER) set(AREG_COMPILER_SHORT) +# Specify CPU platform here, the system CPU platform is detected in 'commmon.cmake' +if (DEFINED AREG_PROCESSOR) + if (AREG_PROCESSOR STREQUAL "x86") + set(CMAKE_SYSTEM_PROCESSOR x86) + set(AREG_BITNESS 32) + elseif(AREG_PROCESSOR STREQUAL "x64" OR AREG_PROCESSOR STREQUAL "x86_64" OR AREG_PROCESSOR STREQUAL "amd64") + set(CMAKE_SYSTEM_PROCESSOR x86_64) + set(AREG_PROCESSOR x64) + set(AREG_BITNESS 64) + elseif (AREG_PROCESSOR STREQUAL "arm" OR AREG_PROCESSOR STREQUAL "arm32") + set(CMAKE_SYSTEM_PROCESSOR ARM) + set(AREG_PROCESSOR arm) + set(AREG_BITNESS 32) + elseif (AREG_PROCESSOR STREQUAL "aarch64" OR AREG_PROCESSOR STREQUAL "arm64") + set(CMAKE_SYSTEM_PROCESSOR AARCH64) + set(AREG_PROCESSOR aarch64) + set(AREG_BITNESS 64) + else() + set(CMAKE_SYSTEM_PROCESSOR ${AREG_PROCESSOR}) + if (NOT DEFINED AREG_BITNESS) + macro_system_bitness(AREG_BITNESS) + endif() + endif() +elseif(NOT DEFINED AREG_BITNESS) + macro_system_bitness(AREG_BITNESS) +endif() + # If CMake compilers are specified, use them if ((DEFINED CMAKE_CXX_COMPILER OR DEFINED CMAKE_C_COMPILER) AND (NOT "${CMAKE_CXX_COMPILER}" STREQUAL "" OR NOT "${CMAKE_C_COMPILER}" STREQUAL "")) @@ -91,7 +118,7 @@ if ((DEFINED CMAKE_CXX_COMPILER OR DEFINED CMAKE_C_COMPILER) AND (NOT "${CMAKE_C message(STATUS "AREG: >>> Using CMake specified C++ compiler '${_sys_compiler}'") # Setup compiler details based on the identified system compiler - macro_setup_compilers_data("${_sys_compiler}" _compiler_family _compiler_short _cxx_compiler _c_compiler _compiler_found) + macro_setup_compilers_data("${_sys_compiler}" _compiler_family _compiler_short _cxx_compiler _c_compiler _sys_process _sys_bitness _compiler_found) if (_compiler_found) # Check for existing compiler family or specific compiler and issue warnings if necessary @@ -113,11 +140,18 @@ if ((DEFINED CMAKE_CXX_COMPILER OR DEFINED CMAKE_C_COMPILER) AND (NOT "${CMAKE_C set(AREG_COMPILER_SHORT "${_compiler_short}") set(AREG_CXX_COMPILER "${_sys_compiler}") set(AREG_C_COMPILER "${_c_compiler}") + if (NOT "${_sys_process}" STREQUAL "") + set(AREG_PROCESSOR ${_sys_process}) + set(AREG_BITNESS ${_sys_bitness}) + set(CMAKE_SYSTEM_PROCESSOR ${AREG_PROCESSOR}) + endif() else() message(WARNING "AREG: Unknown C++ compiler '${_sys_compiler}'; results may be unpredictable") endif() unset(_sys_compiler) + unset(_sys_process) + unset(_sys_bitness) # If a specific compiler family is set, use that to determine compilers elseif (DEFINED AREG_COMPILER_FAMILY AND NOT "${AREG_COMPILER_FAMILY}" STREQUAL "") @@ -140,7 +174,7 @@ elseif (DEFINED AREG_COMPILER AND NOT "${AREG_COMPILER}" STREQUAL "") message(STATUS "AREG: >>> Using user-specified C/C++ compiler '${AREG_COMPILER}'") # Set both C and C++ compilers based on AREG_COMPILER - macro_setup_compilers_data("${AREG_COMPILER}" _compiler_family _compiler_short _cxx_compiler _c_compiler _compiler_found) + macro_setup_compilers_data("${AREG_COMPILER}" _compiler_family _compiler_short _cxx_compiler _c_compiler _sys_process _sys_bitness _compiler_found) if (_compiler_found) # Set the relevant variables for the chosen compiler @@ -148,10 +182,19 @@ elseif (DEFINED AREG_COMPILER AND NOT "${AREG_COMPILER}" STREQUAL "") set(AREG_COMPILER_SHORT "${_compiler_short}") set(AREG_CXX_COMPILER "${_cxx_compiler}") set(AREG_C_COMPILER "${_c_compiler}") + if (NOT "${_sys_process}" STREQUAL "") + set(AREG_PROCESSOR ${_sys_process}) + set(AREG_BITNESS ${_sys_bitness}) + set(CMAKE_SYSTEM_PROCESSOR ${AREG_PROCESSOR}) + endif() else() message(WARNING "AREG: Unknown compiler '${AREG_COMPILER}'; results may be unpredictable") endif() + unset(_sys_compiler) + unset(_sys_process) + unset(_sys_bitness) + # If no specific compiler or family is set, use the system default else() message(STATUS "AREG: >>> No compiler specified; using system default compilers.") @@ -225,28 +268,6 @@ endif() # CPP standard for the projects set(AREG_CXX_STANDARD 17) -# Check and specify bitness -macro_system_bitness(_sys_bitness) -if (DEFINED AREG_BITNESS) - if (NOT AREG_BITNESS EQUAL 32 AND NOT AREG_BITNESS EQUAL 64) - if (NOT _sys_bitness EQUAL 0) - set(AREG_BITNESS ${_sys_bitness}) - else() - message(WARNING "AREG: >>> Undefined Bitness, use default!") - endif() - endif() -elseif (NOT _sys_bitness EQUAL 0) - set(AREG_BITNESS ${_sys_bitness}) -else() - message(WARNING "AREG: >>> Undefined System Bitness, use default!") - set(AREG_BITNESS 64) -endif() -unset(_sys_bitness) - -# Specify CPU platform here, the system CPU platform is detected in 'commmon.cmake' -set(AREG_PROCESSOR x86_64) - - if (NOT DEFINED AREG_ENABLE_OUTPUTS OR AREG_ENABLE_OUTPUTS) option(AREG_ENABLE_OUTPUTS "Enable changing output directories" TRUE) # Set the areg-sdk build root folder to output files. diff --git a/conf/exports/config.cmake.in b/conf/exports/config.cmake.in index fa64b370..16f1dac3 100644 --- a/conf/exports/config.cmake.in +++ b/conf/exports/config.cmake.in @@ -8,7 +8,7 @@ include(CMakeFindDependencyMacro) # Root folder of the SDK set(AREG_SDK_ROOT "@CMAKE_INSTALL_PREFIX@") # Location of 'areg', 'aregextend' and 'areglogger' header files -set(AREG_FRAMEWORK "@CMAKE_INSTALL_FULL_INCLUDEDIR@") +set(AREG_FRAMEWORK "@CMAKE_INSTALL_FULL_INCLUDEDIR@") # Location of configuration, initialization and other shared files of AREG SDK set(AREG_SHARE_DIR "@CMAKE_INSTALL_PREFIX@/share/@AREG_PACKAGE_NAME@") # Location of initialization file to copy as a template in the processes @@ -23,16 +23,17 @@ set(AREG_TOOL_CODEGEN "${AREG_SDK_TOOLS}/codegen.jar") set(AREG_CMAKE_EXPORTS "${AREG_CMAKE_CONFIG_DIR}/areg.cmake") # The build type of AREG libraries. -set(AREG_BUILD_TYPE "@AREG_BUILD_TYPE@") +set(AREG_BUILD_TYPE @AREG_BUILD_TYPE@) # The library type of 'areg'. Static or dynamic -set(AREG_BINARY "@AREG_BINARY@") +set(AREG_BINARY @AREG_BINARY@) # The library type of 'areglogger'. Static or dynamic. -set(AREG_LOGGER_LIB "@AREG_LOGGER_LIB@") +set(AREG_LOGGER_LIB @AREG_LOGGER_LIB@) # set platform specific variables. -set(AREG_OS "@AREG_OS@") -set(AREG_DEVELOP_ENV "@AREG_DEVELOP_ENV@") +set(AREG_OS @AREG_OS@) +set(AREG_DEVELOP_ENV @AREG_DEVELOP_ENV@) set(AREG_BITNESS @AREG_BITNESS@) +set(AREG_PROCESSOR @AREG_PROCESSOR@) # Specify whether 'aregextend' is compiled with enabled extended objects flag option(AREG_EXTENDED "AREG Extended object flag" @AREG_EXTENDED@) @@ -105,3 +106,9 @@ if (AREG_DEVELOP_ENV STREQUAL "Win32") else() add_definitions(-DPOSIX) endif() + +if (AREG_BITNESS EQUAL 32) + add_definitions(-DBIT32) +else() + add_definitions(-DBIT64) +endif() diff --git a/docs/wiki/01b-cmake-build.md b/docs/wiki/01b-cmake-build.md index b3fbecc1..6baa0743 100644 --- a/docs/wiki/01b-cmake-build.md +++ b/docs/wiki/01b-cmake-build.md @@ -18,6 +18,10 @@ This guide provides step-by-step instructions for building the **AREG SDK** on L - [Step 5: Running Tests and Installing](#step-5-running-tests-and-installing) - [Run Unit Tests:](#run-unit-tests) - [Install AREG SDK:](#install-areg-sdk) +- [Cross-Compiling AREG SDK](#crosscompiling-areg-sdk) + - [Cross-Compiling for 32-bit Systems](#crosscompiling-for-32bit-systems) + - [Cross-Compiling for ARM Processors](#crosscompiling-for-arm-processors) + - [Cross-Compiling for AARCH64 (64-bit ARM)](#crosscompilingfor-aarch64-64bit-arm) - [Additional IDE Configurations](#additional-ide-configurations) --- @@ -134,6 +138,113 @@ Install AREG SDK binaries and headers to develop multithreaded and multiprocessi --- +## Cross-Compiling AREG SDK + +Cross-compiling allows building applications for architectures different from the native environment. Here are instructions for configuring AREG SDK to compile for 32-bit systems, as well as ARM and AARCH64 (64-bit ARM) processors. + +**Supported Compilers, Platforms and Architectures** +| Compiler | Platform |API | CPU Architecture | +|-----------|---------------|---------------|---------------------------| +| GNU | Linux, macOS | POSIX | x86, x86_64, arm, aarch64 | +| Clang | Linux, Windows| POSIX, Win32 | x86, x86_64 | +| MSVC | Windows | Win32 | x86, x86_64 | +| Cygwin GNU| Windows | POSIX | x86, x86_64 | + + +### Cross-Compiling for 32-bit Systems + +To compile AREG SDK for a 32-bit system, you need to specify the target bitness and ensure you have the correct 32-bit libraries installed. + +**Steps** + +1. **Install Required Libraries** + ```bash + sudo apt-get install -y gcc-multilib g++-multilib + ``` +2. **Configure CMake for 32-bit x86 Architecture** + Optionally select compiler (here it is `clang++`) + ```bash + cmake -B ./build -DAREG_PROCESSOR=x86 -DAREG_COMPILER_FAMILY=llvm + ``` +3. **Build AREG SDK** + ```bash + cmake --build ./build -j 20 + ``` + +To verify that a binary is 32-bit, navigate to the build directory and run: +```bash +file ./mcrouter.out +``` +This command should output something like: +> ./mcrouter.out: ELF **32-bit** LSB pie executable, **Intel 80386**, version 1 (GNU/Linux), dynamically linked, interpreter /lib/ld-linux.so.2, BuildID[sha1]=3df1d5e3d1b90b9533b93a906cece6ff95fa816c, for GNU/Linux 3.2.0, not stripped + +Alternatively, you can run: +```bash +od -t x1 -t c ./mcrouter | head -n 2 +``` +In the ELF Header, the 5th byte `001` indicates a 32-bit executable, while `002` indicates 64-bit. +> ```plaintext +> 0000000 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 +> 177 E L F 001 001 001 \0 \0 \0 \0 \0 \0 \0 \0 \0 +> ``` +For further details, refer to the **[ELF Header](https://en.wikipedia.org/wiki/Executable_and_Linkable_Format#File_header)** Wikipedia page. + +### Cross-Compiling for ARM Processors + +Cross-compiling for ARM processors requires an ARM-compatible toolchain and configuring CMake for ARM architecture. + +**Steps** + +1. **Install ARM Toolchain** + ```bash + sudo apt-get install -y gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf binutils-arm-linux-gnueabihf + ``` + > [!NOTE] + > For most 32-bit modern ARM processors, `gcc-arm-linux-gnueabihf` is recommended over `gcc-arm-linux-gnueab`. + +2. **Configure CMake for ARM Architecture** + ```bash + cmake -B ./build -DAREG_PROCESSOR=arm -DAREG_COMPILER_FAMILY=gnu + ``` +3. **Build AREG SDK** + ```bash + cmake --build ./build -j 20 + ``` + +Verify the architecture of the compiled binary with: +```bash +file ./mcrouter.out +``` +This should output message `ELF 32-bit LSB executable, ARM, ...`. + +### Cross-Compiling for AARCH64 (64-bit ARM) + +For AARCH64 architecture, install the 64-bit ARM toolchain and configure CMake accordingly. + +**Steps** +1. **Install AARCH64 Toolchain** + ```bash + sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu binutils-aarch64-linux-gnu + ``` + +2. **Configure CMake for AARCH64 Architecture** + ```bash + cmake -B ./build -DAREG_PROCESSOR=aarch64 -DAREG_COMPILER_FAMILY=gnu + ``` + +3. **Build AREG SDK** + ```bash + cmake --build ./build -j 20 + ``` + +Verify the binary architecture: +```bash +file ./mcrouter.out +``` +This should output message `ELF 64-bit LSB executable, ARM aarch64, ...`. + +--- + ## Additional IDE Configurations For **Microsoft Visual Studio** or **Visual Studio Code**: diff --git a/docs/wiki/01d-wsl-build.md b/docs/wiki/01d-wsl-build.md index cfdcded4..4d241f25 100644 --- a/docs/wiki/01d-wsl-build.md +++ b/docs/wiki/01d-wsl-build.md @@ -9,6 +9,11 @@ Following these steps will guide you through setting up, troubleshooting, and ru 4. [Installing Build Tools](#installing-build-tools) 5. [Cloning AREG SDK in WSL](#cloning-areg-sdk-in-wsl) 6. [Compiling AREG SDK](#compiling-areg-sdk) + - [CMake with Clang](#cmake-with-clang) + - [CMake with GCC](#cmake-with-gcc) + - [CMake for 32-bit Build with Clang](#cmake-for-32bit-build-with-clang) + - [CMake for 32-bit ARM Build with GNU](#cmake-for-32bit-arm-build-with-gnu) + - [CMake for 64-bit ARM Build with GNU](#cmake-for-64bit-arm-build-with-gnu) 7. [Running Applications](#running-applications) --- @@ -69,6 +74,11 @@ Install the essential tools and libraries to compile AREG SDK: sudo apt-get install -y git cmake build-essential clang libncurses-dev openjdk-17-jre ``` +You would need additional tools if you want to compile for 32-bit system: +```bash +sudo apt-get install -y gcc-multilib g++-multilib +``` + For package specifics, consult your Linux distribution's package list, such as [Ubuntu Packages](https://packages.ubuntu.com/).
Refer to the **System Requirements** for Linux platforms in the [Building AREG SDK with CMake](./01b-cmake-build.md) document. @@ -100,21 +110,90 @@ cd /mnt/c/projects/areg-sdk/ ## 5. Compiling AREG SDK -Example commands to build AREG SDK with CMake: +This section provides example commands for compiling AREG SDK using CMake in different configurations. -- **CMake with Clang (Release):** - ```bash - cmake -B ./build -DAREG_COMPILER_FAMILY=llvm -DAREG_BUILD_TYPE=Release -DAREG_EXTENDED:BOOL=ON - cmake --build ./build -j - ``` +### CMake with Clang +To configure and build binaries with the `clang++` compiler in `Release` mode: +```bash +cmake -B ./build -DAREG_COMPILER_FAMILY=llvm -DAREG_BUILD_TYPE=Release +cmake --build ./build -j +``` -- **CMake with GCC (Debug):** - ```bash - cmake -B ./build -DAREG_COMPILER_FAMILY=gnu -DAREG_BUILD_TYPE=Debug -DAREG_EXTENDED:BOOL=ON - cmake --build ./build -j - ``` +### CMake with GCC +To configure and build binaries with the `g++` compiler in `Debug` mode: +```bash +cmake -B ./build -DAREG_COMPILER_FAMILY=gnu -DAREG_BUILD_TYPE=Debug +cmake --build ./build -j +``` + +### CMake for 32-bit Build with Clang +To compile for a 32-bit system, first install the required libraries: +```bash +sudo apt-get install -y gcc-multilib g++-multilib +``` +Configure and build binaries with `clang++` for a 32-bit system: +```bash +cmake -B ./build -DAREG_PROCESSOR=x86 -DAREG_COMPILER_FAMILY=llvm +cmake --build ./build -j +``` + +> [!TIP] +> To verify if an application is compiled for a 32-bit system, navigate to the build binary directory and use: +> ```bash +> file ./mcrouter.out +> ``` +> This command shows the binary's architecture. Example output for a 32-bit `mcrouter` binary: +> > ./mcrouter.out: ELF **32-bit** LSB pie executable, **Intel 80386**, version 1 (GNU/Linux), dynamically linked, interpreter /lib/ld-linux.so.2, BuildID[sha1]=3df1d5e3d1b90b9533b93a906cece6ff95fa816c, for GNU/Linux 3.2.0, not stripped +> +> Alternatively, run: +> ```bash +> od -t x1 -t c ./mcrouter | head -n 2 +> ``` +> Here, the 5th byte of the **ELF Header** should be `001` for a 32-bit executable and `002` for a 64-bit. +> ```plaintext +> 0000000 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 +> 177 E L F 001 001 001 \0 \0 \0 \0 \0 \0 \0 \0 \0 +> ``` +> For more details, see the **[ELF Header](https://en.wikipedia.org/wiki/Executable_and_Linkable_Format#File_header)** documentation. + +> [!IMPORTANT] +> **Troubleshooting**: If you encounter a "could not find ``" error, resolve it by creating a symbolic link: +> ```bash +> sudo ln -s /usr/include/asm-generic/ /usr/include/asm +> ``` + +### CMake for 32-bit ARM Build with GNU +To compile for a 32-bit ARM system, first install the required toolchain: +```bash +sudo apt-get install -y gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf binutils-arm-linux-gnueabihf +``` + +> [!NOTE] +> Make sure that `gcc-arm-linux-gnueabihf` is better solution than `gcc-arm-linux-gnueab` for your device. By default, for ARM processors AREG compiles with `gcc-arm-linux-gnueabihf`. + + +Then configure and build AREG SDK binaries: +```bash +cmake -B ./build -DAREG_PROCESSOR=arm -DAREG_COMPILER_FAMILY=gnu +cmake --build ./build -j +``` +Check the binary with `file ./mcrouter.out`. If successful, you’ll see output like: +> ./mcrouter.out: ELF **32-bit** LSB executable, **ARM**, EABI5 version 1 (GNU/Linux), dynamically linked, interpreter /lib/ld-linux.so.3, BuildID[sha1]=c606ea5ce7be9cb1175fd87587b5975e235c084e, for GNU/Linux 3.2.0, not stripped + +### CMake for 64-bit ARM Build with GNU +To compile for a 64-bit ARM system, install the appropriate toolchain: +```bash +sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu binutils-aarch64-linux-gnu +``` +Then configure and build AREG SDK binaries: +```bash +cmake -B ./build -DAREG_PROCESSOR=aarch64 -DAREG_COMPILER_FAMILY=gnu +cmake --build ./build -j +``` +Check the binary with `file ./mcrouter.out`. Successful output will look like: +> ./mcrouter.out: ELF **64-bit** LSB pie executable, **ARM aarch64**, version 1 (GNU/Linux), dynamically linked, interpreter /lib/ld-linux-aarch64.so.1, BuildID[sha1]=bcf786a8c893b950868addecbc347d24518a25cd, for GNU/Linux 3.7.0, not stripped -Refer to the **[AREG SDK build](./01b-cmake-build.md)** document for further details. +For more information, refer to the **[AREG SDK Build Guide](./01b-cmake-build.md)**. --- diff --git a/docs/wiki/02a-cmake-config.md b/docs/wiki/02a-cmake-config.md index 182632cb..3be93583 100644 --- a/docs/wiki/02a-cmake-config.md +++ b/docs/wiki/02a-cmake-config.md @@ -15,76 +15,78 @@ The following is the list of AREG SDK specific options that needs to be set befo 1. [AREG_COMPILER_FAMILY](#1-areg_compiler_family) 2. [AREG_COMPILER](#2-areg_compiler) -3. [AREG_BINARY](#3-areg_binary) -4. [AREG_LOGGER_LIB](#4-areg_logger_lib) -5. [AREG_BUILD_TYPE](#5-areg_build_type) -6. [AREG_BUILD_TESTS](#6-areg_build_tests) -7. [AREG_BUILD_EXAMPLES](#7-areg_build_examples) -8. [AREG_EXTENDED](#8-areg_extended) -9. [AREG_LOGS](#9-areg_logs) -10. [AREG_USE_PACKAGES](#10-areg_use_packages) -11. [AREG_SQLITE_PACKAGE](#11-areg_sqlite_package) -12. [AREG_GTEST_PACKAGE](#12-areg_gtest_package) -13. [AREG_ENABLE_OUTPUTS](#13-areg_enable_outputs) -14. [AREG_BUILD_ROOT](#14-areg_build_root) -15. [AREG_OUTPUT_DIR](#15-areg_output_dir) -16. [AREG_OUTPUT_BIN](#16-areg_output_bin) -17. [AREG_OUTPUT_LIB](#17-areg_output_lib) -18. [AREG_PACKAGES](#18-areg_packages) -19. [AREG_INSTALL](#19-areg_install) -20. [AREG_INSTALL_PATH](#20-areg_install_path) +3. [AREG_PROCESSOR](#3-areg_processor) +4. [AREG_BINARY](#3-areg_binary) +5. [AREG_LOGGER_LIB](#4-areg_logger_lib) +6. [AREG_BUILD_TYPE](#5-areg_build_type) +7. [AREG_BUILD_TESTS](#6-areg_build_tests) +8. [AREG_BUILD_EXAMPLES](#7-areg_build_examples) +9. [AREG_EXTENDED](#8-areg_extended) +10.[AREG_LOGS](#9-areg_logs) +11. [AREG_USE_PACKAGES](#10-areg_use_packages) +12. [AREG_SQLITE_PACKAGE](#11-areg_sqlite_package) +13. [AREG_GTEST_PACKAGE](#12-areg_gtest_package) +14. [AREG_ENABLE_OUTPUTS](#13-areg_enable_outputs) +15. [AREG_BUILD_ROOT](#14-areg_build_root) +16. [AREG_OUTPUT_DIR](#15-areg_output_dir) +17. [AREG_OUTPUT_BIN](#16-areg_output_bin) +18. [AREG_OUTPUT_LIB](#17-areg_output_lib) +19. [AREG_PACKAGES](#18-areg_packages) +20. [AREG_INSTALL](#19-areg_install) +21. [AREG_INSTALL_PATH](#20-areg_install_path) For the quick orientation, here are the lists of AREG SDK specific options grouped by categories. See description for details. -### Options for Compiler +### Options for Compiler and Processor The following is the list of options to select compiler: | Options | Short description | |-------------------------------------------------------|---------------------------------------------------| -| 1. [AREG_COMPILER_FAMILY](#1-areg_compiler_family) | Select C++ compiler by family. | -| 2. [AREG_COMPILER](#2-areg_compiler) | Select C++ compiler by name. | - +| 1. [AREG_COMPILER_FAMILY](#1-areg_compiler_family) | Select C++ compiler by family. | +| 2. [AREG_COMPILER](#2-areg_compiler) | Select C++ compiler by name. | +| 3. [AREG_PROCESSOR](#21-areg_processor) | Select processor and bitness of target application| + ### Options to Build Binaries The following is the list of options that have impact on the build: | Options | Short description | |-------------------------------------------------------|---------------------------------------------------| -| 3. [AREG_BINARY](#3-areg_binary) | `areg` framework shared or static library. | -| 4. [AREG_LOGGER_LIB](#4-areg_logger_lib) | `areglogger` library shared or static library. | -| 5. [AREG_BUILD_TYPE](#5-areg_build_type) | `Debug` or `Release` build. | -| 6. [AREG_BUILD_TESTS](#6-areg_build_tests) | Build or escape unit tests. | -| 7. [AREG_BUILD_EXAMPLES](#7-areg_build_examples) | Build or escape example. | -| 8. [AREG_EXTENDED](#8-areg_extended) | Build `aregextend` library with extended objects. | -| 9. [AREG_LOGS](#9-areg_logs) | Build binaries with logs. +| 4. [AREG_BINARY](#3-areg_binary) | `areg` framework shared or static library. | +| 5. [AREG_LOGGER_LIB](#4-areg_logger_lib) | `areglogger` library shared or static library. | +| 6. [AREG_BUILD_TYPE](#5-areg_build_type) | `Debug` or `Release` build. | +| 7. [AREG_BUILD_TESTS](#6-areg_build_tests) | Build or escape unit tests. | +| 8. [AREG_BUILD_EXAMPLES](#7-areg_build_examples) | Build or escape example. | +| 9. [AREG_EXTENDED](#8-areg_extended) | Build `aregextend` library with extended objects. | +| 10. [AREG_LOGS](#9-areg_logs) | Build binaries with logs. ### Options to Use Packages | Options | Short description | |-------------------------------------------------------|---------------------------------------------------| -| 10. [AREG_USE_PACKAGES](#10-areg_use_packages) | Use installed packages whenever possible. | -| 11. [AREG_SQLITE_PACKAGE](#11-areg_sqlite_package) | Try using installed `SQLite3` package. | -| 12. [AREG_GTEST_PACKAGE](#12-areg_gtest_package) | Try using installed `GTest` package. | +| 11. [AREG_USE_PACKAGES](#10-areg_use_packages) | Use installed packages whenever possible. | +| 12. [AREG_SQLITE_PACKAGE](#11-areg_sqlite_package) | Try using installed `SQLite3` package. | +| 13. [AREG_GTEST_PACKAGE](#12-areg_gtest_package) | Try using installed `GTest` package. | ### Options to Change Output Directories | Options | Short description | |-------------------------------------------------------|---------------------------------------------------| -| 13. [AREG_ENABLE_OUTPUTS](#13-areg_enable_outputs) | Allow AREG specific output directories. | -| 14. [AREG_BUILD_ROOT](#14-areg_build_root) | Build directory path (binaries, packages). | -| 15. [AREG_OUTPUT_DIR](#15-areg_output_dir) | Output directory path for binaries. | -| 16. [AREG_OUTPUT_BIN](#16-areg_output_bin) | Output directory path for executables. | -| 17. [AREG_OUTPUT_LIB](#17-areg_output_lib) | Output directory path for static libraries. | -| 18. [AREG_PACKAGES](#18-areg_packages) | Directory to fetch packages (like `Google Test`). | +| 14. [AREG_ENABLE_OUTPUTS](#13-areg_enable_outputs) | Allow AREG specific output directories. | +| 15. [AREG_BUILD_ROOT](#14-areg_build_root) | Build directory path (binaries, packages). | +| 16. [AREG_OUTPUT_DIR](#15-areg_output_dir) | Output directory path for binaries. | +| 17. [AREG_OUTPUT_BIN](#16-areg_output_bin) | Output directory path for executables. | +| 18. [AREG_OUTPUT_LIB](#17-areg_output_lib) | Output directory path for static libraries. | +| 19. [AREG_PACKAGES](#18-areg_packages) | Directory to fetch packages (like `Google Test`). | ### Options to Install AREG Binaries | Options | Short description | |-------------------------------------------------------|---------------------------------------------------| -| 19. [AREG_INSTALL](#19-areg_install) | Enable install (call `cmake --install`). | -| 20. [AREG_INSTALL_PATH](#20-areg_install_path) | Location to install AREG binaries. | +| 20. [AREG_INSTALL](#19-areg_install) | Enable install (call `cmake --install`). | +| 21. [AREG_INSTALL_PATH](#20-areg_install_path) | Location to install AREG binaries. | --- @@ -116,7 +118,37 @@ The following are the available CMake options to configure the AREG SDK build. O --- -### 3. **AREG_BINARY** +### 3. **AREG_PROCESSOR** + + - **Description**: Specifies the target processor architecture and bitness for the compiled application. By default, it uses the system’s processor architecture and bitness. + - **Possible Values**: `x86`, `x64` (`x86_x64`, `amd64`), `arm` (`arm32`), `aarch64` (`arm64`) + - **Default**: *System-Defined* + - **Example**: `cmake -B ./build -DAREG_PROCESSOR=x86` + +> [!TIP] +> To check if an application has been compiled for a 32-bit or 64-bit system, navigate to the build binary directory and run: +> ```bash +> file ./mcrouter.out +> ``` +> This command displays the binary's architecture. For example, the output for a 32-bit `mcrouter` binary may appear as: +> > ./mcrouter.out: ELF **32-bit** LSB pie executable, **Intel 80386**, version 1 (GNU/Linux), dynamically linked, interpreter /lib/ld-linux.so.2, BuildID[sha1]=3df1d5e3d1b90b9533b93a906cece6ff95fa816c, for GNU/Linux 3.2.0, not stripped + +> Alternatively, use the following command to check specific details in the ELF header: +> ```bash +> od -t x1 -t c ./mcrouter | head -n 2 +> ``` +> In the ELF header output, the 5th byte indicates the bitness: `001` represents a 32-bit executable, while `002` indicates a 64-bit executable. +> ```plaintext +> 0000000 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 +> 177 E L F 001 001 001 \0 \0 \0 \0 \0 \0 \0 \0 \0 +> ``` +> For more information, refer to the **[ELF Header documentation](https://en.wikipedia.org/wiki/Executable_and_Linkable_Format#File_header)**. + + + +--- + +### 4. **AREG_BINARY** - **Description**: Specifies the type of library for the AREG Framework. - **Possible Values**: `shared`, `static` - **Default**: `shared` @@ -126,7 +158,7 @@ The following are the available CMake options to configure the AREG SDK build. O --- -### 4. **AREG_LOGGER_LIB** +### 5. **AREG_LOGGER_LIB** - **Description**: Sets the library type for the Log Observer API. - **Possible Values**: `shared`, `static` - **Default**: `shared` @@ -136,7 +168,7 @@ The following are the available CMake options to configure the AREG SDK build. O --- -### 5. **AREG_BUILD_TYPE** +### 6. **AREG_BUILD_TYPE** - **Description**: Defines the build configuration type, equivalent to the CMake option `CMAKE_BUILD_TYPE`. If `AREG_BUILD_TYPE` is set, it will override `CMAKE_BUILD_TYPE`. Otherwise, it takes the value of `CMAKE_BUILD_TYPE` if set, or `Release` if not set. - **Possible Values**: `Release`, `Debug` - **Default**: `Release` @@ -146,7 +178,7 @@ The following are the available CMake options to configure the AREG SDK build. O --- -### 6. **AREG_BUILD_TESTS** +### 7. **AREG_BUILD_TESTS** - **Description**: Enables or disables building unit tests for the AREG SDK. If enabled (`ON`), the tests build will require an additional dependency on `GTest`. - **Possible Values**: `ON`, `OFF` - **Default**: `ON` @@ -156,7 +188,7 @@ The following are the available CMake options to configure the AREG SDK build. O --- -### 7. **AREG_BUILD_EXAMPLES** +### 8. **AREG_BUILD_EXAMPLES** - **Description**: Controls whether to build example applications for the AREG SDK. Enabling this option (`ON`) may require additional dependencies, such as MFC (Microsoft Foundation Classes) for GUI projects on Windows. - **Possible Values**: `ON`, `OFF` - **Default**: `ON` @@ -166,7 +198,7 @@ The following are the available CMake options to configure the AREG SDK build. O --- -### 8. **AREG_EXTENDED** +### 9. **AREG_EXTENDED** - **Description**: Specifies if `aregextend` additional library should be build with extended features, adding specialized library support for advanced functionality. Enabling this option (`ON`) may introduce dependencies such as `ncurses` on Linux or Cygwin platforms, which are required to support these features. - **Possible Values**: `ON`, `OFF` - **Default**: `OFF` @@ -176,7 +208,7 @@ The following are the available CMake options to configure the AREG SDK build. O --- -### 9. **AREG_LOGS** +### 10. **AREG_LOGS** - **Description**: Controls whether the AREG Framework is compiled with logging capabilities. Disabling logging (`OFF`) prevents applications from generating log messages, which may be useful for reducing overhead in production builds. - **Possible Values**: `ON`, `OFF` - **Default**: `ON` @@ -186,7 +218,7 @@ The following are the available CMake options to configure the AREG SDK build. O --- -### 10. **AREG_USE_PACKAGES** +### 11. **AREG_USE_PACKAGES** - **Description**: Enables the use of pre-installed third-party packages, such as **Google Test** or **SQLite3**. If disabled (`OFF`), the build process will download or compile the required third-party libraries from source. - **Possible Values**: `ON`, `OFF` - **Default**: `ON` @@ -196,7 +228,7 @@ The following are the available CMake options to configure the AREG SDK build. O --- -### 11. **AREG_SQLITE_PACKAGE** +### 12. **AREG_SQLITE_PACKAGE** - **Description**: Controls whether the build uses a system-installed SQLite3 package or compiles SQLite3 from the `thirdparty` directory. If set to `ON`, it first attempts to locate a system installation; if not found, it falls back to compiling from source. - **Possible Values**: `ON`, `OFF` - **Default**: `ON` @@ -206,7 +238,7 @@ The following are the available CMake options to configure the AREG SDK build. O --- -### 12. **AREG_GTEST_PACKAGE** +### 13. **AREG_GTEST_PACKAGE** - **Description**: Determines whether the system-installed Google Test package is used or fetched and compiled directly from the Google repository. If enabled (`ON`), it will attempt to use the system package; otherwise, it fetches from the repository if the package isn't found. - **Possible Values**: `ON`, `OFF` - **Default**: `ON` @@ -216,7 +248,7 @@ The following are the available CMake options to configure the AREG SDK build. O --- -### 23. **AREG_ENABLE_OUTPUTS** +### 14. **AREG_ENABLE_OUTPUTS** - **Description**: Controls whether output directories use the CMake binary directory or AREG SDK-specific defaults. When disabled (`OFF`), AREG-specific settings are ignored in favor of CMake's default outputs, useful when integrating AREG into third-party builds. - **Possible Values**: `ON`, `OFF` - **Default**: `ON` @@ -226,7 +258,7 @@ The following are the available CMake options to configure the AREG SDK build. O --- -### 14. **AREG_BUILD_ROOT** +### 15. **AREG_BUILD_ROOT** - - **Description**: Defines the main directory for all build binary files, which also manages third-party dependencies and generated code files. This directory with the content can be safely deleted as needed without affecting codes. - **Default**: `/product` - **Example**: `cmake -B ./build -DAREG_BUILD_ROOT=/path/to/custom/build` @@ -235,7 +267,7 @@ The following are the available CMake options to configure the AREG SDK build. O --- -### 15. **AREG_OUTPUT_DIR** +### 16. **AREG_OUTPUT_DIR** - **Description**: Sets the directory for all build outputs, including binaries and libraries. The subdirectories `bin` and `lib` are used for runtime binaries and libraries, respectively. - **Default**: `'{AREG_BUILD_ROOT}/build//---'` - **Example**: `cmake -B ./build -DAREG_OUTPUT_DIR=/custom/output` @@ -244,7 +276,7 @@ The following are the available CMake options to configure the AREG SDK build. O --- -### 16. **AREG_OUTPUT_BIN** +### 17. **AREG_OUTPUT_BIN** - **Description**: Defines the output directory for runtime binaries and shared libraries, aligning with CMake's `CMAKE_RUNTIME_OUTPUT_DIRECTORY` and `CMAKE_LIBRARY_OUTPUT_DIRECTORY`. - **Default**: `{AREG_OUTPUT_DIR}/bin` - **Example**: `cmake -B ./build -DAREG_OUTPUT_BIN=/custom/output/bin` @@ -253,7 +285,7 @@ The following are the available CMake options to configure the AREG SDK build. O --- -### 17. **AREG_OUTPUT_LIB** +### 18. **AREG_OUTPUT_LIB** - **Description**: Specifies the output directory for static libraries, corresponding to the CMake setting `CMAKE_ARCHIVE_OUTPUT_DIRECTORY`. - **Default**: `{AREG_OUTPUT_DIR}/lib` - **Example**: `cmake -B ./build -DAREG_OUTPUT_LIB=/custom/output/lib` @@ -262,7 +294,7 @@ The following are the available CMake options to configure the AREG SDK build. O --- -### 18. **AREG_PACKAGES** +### 19. **AREG_PACKAGES** - **Description**: Defines where third-party packages are stored. By default, this is set to a `packages` subdirectory within `AREG_BUILD_ROOT`. - **Default**: `{AREG_BUILD_ROOT}/packages` - **Example**: `cmake -B ./build -DAREG_PACKAGES=/path/to/packages` @@ -271,7 +303,7 @@ The following are the available CMake options to configure the AREG SDK build. O --- -### 19. **AREG_INSTALL** +### 20. **AREG_INSTALL** - **Description**: Specifies if the SDK installation process should be enabled. When set to `ON`, all necessary components will be prepared for installation on the specified system. - **Possible Values**: `ON`, `OFF` - **Default**: `ON` @@ -281,7 +313,7 @@ The following are the available CMake options to configure the AREG SDK build. O --- -### 20. **AREG_INSTALL_PATH** +### 21. **AREG_INSTALL_PATH** - **Description**: Specifies the directory for installing all AREG SDK build components. - **Default**: `/areg-sdk` - **Example**: `cmake -B ./build -DAREG_INSTALL_PATH=/install/location` @@ -310,6 +342,8 @@ sudo cmake --install ./product/cache/llvm - **Compiler Configuration**: The `AREG_COMPILER_FAMILY` option allows you to specify a compiler family, such as `llvm`, which automatically selects `clang++` and `clang` as the default compilers. +- **Target Processor**: `AREG_PROCESSOR` can be set to cross-compile the AREG SDK binaries. For details, check the appropriate [Cross-Compiling AREG SDK](./01b-cmake-build.md#crosscompiling-areg-sdk) chapter. + - **Custom Output Directories**: `AREG_BUILD_ROOT` can be used to set a specific location for all build-related binaries, aiding in project organization. - **Disable AREG SDK Outputs**: Set `AREG_ENABLE_OUTPUTS` to `OFF`, to use CMake defaults or custom locations for builds. diff --git a/docs/wiki/02b-cmake-functions.md b/docs/wiki/02b-cmake-functions.md index 9e984f20..668d77e8 100644 --- a/docs/wiki/02b-cmake-functions.md +++ b/docs/wiki/02b-cmake-functions.md @@ -18,6 +18,8 @@ The [functions.cmake](./../../conf/cmake/functions.cmake) file in AREG SDK conta - [`macro_declare_executable`](#macro_declare_executable) - [`macro_setup_compilers_data`](#macro_setup_compilers_data) - [`macro_setup_compilers_data_by_family`](#macro_setup_compilers_data_by_family) + - [`macro_guess_processor_architecture`](#macro_guess_processor_architecture) + - [`macro_system_bitness`](#macro_system_bitness) - [CMake Functions Overview](#cmake-functions-overview) - [`setAppOptions`](#setappoptions) - [`addExecutableEx`](#addexecutableex) @@ -207,6 +209,30 @@ The [functions.cmake](./../../conf/cmake/functions.cmake) file includes reusable macro_setup_compilers_data_by_family("gnu" AREG_COMPILER_SHORT AREG_CXX_COMPILER AREG_C_COMPILER _is_identified) ``` +### `macro_guess_processor_architecture` +- **Syntax**: `macro_guess_processor_architecture(compiler_path target_processor target_bitness)` +- **Purpose**: If possible, detects the processor architecture and bitness by given compiler path. +- **Parameters**: + - `compiler_path` [in] : Compiler path. + - `target_processor` [out]: Name of variable to set the CPU architecture value. + - `target_bitness` [out]: Name of variable to set the CPU bitness value. +- **Usage**: `macro_guess_processor_architecture( )` +- **Example**: + ```cmake + macro_guess_processor_architecture("arm-linux-gnueabihf-g++" cpu_architect cpu_bitness) + ``` + +### `macro_system_bitness` +- **Syntax**: `macro_system_bitness(var_bitness)` +- **Purpose**: Extracts the system default bitness. Sets in variable value `32` for 32-bit, or `64` for 64-bit system. +- **Parameters**: + - `var_bitness` [out]: Name of variable to set the system bitness. +- **Usage**: `macro_system_bitness()` +- **Example**: + ```cmake + macro_system_bitness(_sys_bitness) + ``` + --- ## CMake Functions Overview diff --git a/docs/wiki/07a-troubleshooting-wsl-update.md b/docs/wiki/07a-troubleshooting-wsl-update.md new file mode 100644 index 00000000..bedfec66 --- /dev/null +++ b/docs/wiki/07a-troubleshooting-wsl-update.md @@ -0,0 +1,41 @@ +# Troubleshooting WSL Updates + +This document provides solutions for common issues encountered while updating the Windows Subsystem for Linux (WSL). + +## Table of Contents +- [Issue 1: Update Error Code `Wsl/Service/CreateInstance/0x80040326`](#issue-1-update-error-code-wslservicecreateinstance0x80040326) +- [Issue 2: Network Resolution (DNS) Issues](#issue-2-network-resolution-dns-issues) + - [Solution: Update DNS Settings in `/etc/resolv.conf`](#solution-update-dns-settings-in-etcresolvconf) + +## Issue 1: Update Error Code `Wsl/Service/CreateInstance/0x80040326` +If you receive this error code when trying to update, it typically indicates an issue with the WSL service. To resolve it, run the following command in your PowerShell or Command Prompt with administrator privileges: +```bash +wsl --update +``` +This command checks for and installs the latest WSL updates. If the problem persists, consider restarting your machine and running the command again. + +## Issue 2: Network Resolution (DNS) Issues +If you experience network-related issues, such as the following error: +```plaintext +W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/jammy/InRelease Temporary failure resolving 'archive.ubuntu.com' +``` +this is often due to DNS resolution errors in WSL. + +### Solution: Update DNS Settings in `/etc/resolv.conf` +1. **Edit `/etc/resolv.conf`**: + - Open the WSL Terminal. + - Edit the DNS resolver configuration file: + ```bash + sudo vim /etc/resolv.conf + ``` + - Change the `nameserver` entry to use Google's DNS by replacing it with `8.8.8.8`. + - Save and close the file. + +2. **Set DNS Using a Command**: + Alternatively, set the DNS directly with this command: + ```bash + sudo sh -c "echo nameserver 8.8.8.8 > /etc/resolv.conf" + ``` + This command updates the `nameserver` in `/etc/resolv.conf` to Google's DNS. Once updated, retry the WSL update command. + +By following these steps, most DNS-related update issues in WSL can be resolved. diff --git a/docs/wiki/07b-troubleshooting-cmake-linux-builds.md b/docs/wiki/07b-troubleshooting-cmake-linux-builds.md new file mode 100644 index 00000000..cabbf350 --- /dev/null +++ b/docs/wiki/07b-troubleshooting-cmake-linux-builds.md @@ -0,0 +1,38 @@ +# Troubleshooting CMake Builds on Linux + +This guide provides solutions for common issues encountered when compiling projects with CMake on Linux, helping to ensure a smooth and successful build process. + +--- + +## Table of Contents + +- [Missing `` File](#missing-asmerrnoh-file) + - [Solution: Create a Symbolic Link](#solution-create-a-symbolic-link) + +--- + +## Missing `` File + +If you receive an error during compilation indicating that `` could not be found, it often means certain header files are missing or not correctly linked in the system’s include directories. + +### Solution: Create a Symbolic Link + +> [!NOTE] +> You will need administrator (root) permissions for this solution. + +To address this issue, create a symbolic link from the `asm-generic` directory to the `asm` directory in `/usr/include`. This enables the compiler to locate the required header files. + +1. **Open Terminal**: Launch your terminal. +2. **Run the Command**: + ```bash + sudo ln -s /usr/include/asm-generic/ /usr/include/asm + ``` + This command creates a symbolic link called `asm` in `/usr/include`, pointing to the `asm-generic` directory. + +3. **Retry Compilation**: After creating the symbolic link, rerun the compilation command. This should resolve the error. + +> [!TIP] +> Alternatively, the `asm/errno.h` header file is included in some system packages. You can try installing it by running: +> ```bash +> sudo apt-get install -y linux-libc-dev +> ``` \ No newline at end of file diff --git a/docs/wiki/README.md b/docs/wiki/README.md index 2df0b99c..4b6edff5 100644 --- a/docs/wiki/README.md +++ b/docs/wiki/README.md @@ -39,6 +39,10 @@ The following sections guide you through installing, configuring, and using the 6. **Data Management** - **[Key-Value Data Persistence Syntax in AREG SDK](./06a-persistence-syntax.md)**: Persistent data storage and management using AREG SDK's key-value storage options. +7. **Troubleshootings** + - **[Troubleshooting WSL Updates](./07a-troubleshooting-wsl-update.md)**: Provides solutions for common issues encountered while updating the WSL. + - **[Troubleshooting CMake Builds on Linux](./07b-troubleshooting-cmake-linux-builds.md)**: Provides solutions for common errors encountered during the CMake compilation process on Linux. + ``` Help us to make docs greater. See something is wrong, unclear or need a help? diff --git a/framework/areg/base/GETypes.h b/framework/areg/base/GETypes.h index 3bd636e2..9a71939f 100644 --- a/framework/areg/base/GETypes.h +++ b/framework/areg/base/GETypes.h @@ -58,40 +58,38 @@ #include -/** - * \brief The type defining ID. It is 64-bit in 64-bit systems. - **/ +//! The type defining ID. It is 64-bit in 64-bit systems. +typedef unsigned long id_type; + +//! The digital value type of the pointer. #ifdef BIT64 #ifdef _UINTPTR_T_DEFINED - typedef uintptr_t id_type; + typedef uintptr_t ptr_type; #else // !_UINTPTR_T_DEFINED - typedef uint64_t id_type; + typedef uint64_t ptr_type; #endif // _UINTPTR_T_DEFINED #else // defined(BIT32) #ifdef _UINTPTR_T_DEFINED - typedef uintptr_t id_type; + typedef uintptr_t ptr_type; #else // !_UINTPTR_T_DEFINED - typedef uint32_t id_type; + typedef uint32_t ptr_type; #endif // _UINTPTR_T_DEFINED -#endif // id_type - -//! The digital value type of the pointer. -typedef id_type ptr_type; +#endif // ptr_type //! The sequence number type. -typedef uint64_t SequenceNumber; +typedef uint64_t SequenceNumber; //!< The signed sequence type. -typedef int64_t SignedSequence; +typedef int64_t SignedSequence; /** * \brief The type defines an item ID. **/ -typedef uint64_t ITEM_ID; +typedef uint64_t ITEM_ID; /** * \brief Type definition of socket descriptor. Differs in on different platforms diff --git a/framework/areg/base/private/posix/SynchLockAndWaitIX.cpp b/framework/areg/base/private/posix/SynchLockAndWaitIX.cpp index d6ef5368..1cbfadbd 100644 --- a/framework/areg/base/private/posix/SynchLockAndWaitIX.cpp +++ b/framework/areg/base/private/posix/SynchLockAndWaitIX.cpp @@ -59,7 +59,7 @@ int SynchLockAndWaitIX::waitForMultipleObjects( IEWaitableBaseIX ** listWaitable if ( (lockAndWait._isEmpty() == false) && lockAndWait._lock( ) ) { SynchLockAndWaitIX::MapWaitIDResource & mapReousrces { SynchLockAndWaitIX::_mapWaitResourceIds() }; - mapReousrces.registerResourceObject(reinterpret_cast(lockAndWait.mContext), &lockAndWait); + mapReousrces.registerResourceObject(lockAndWait.mContext, &lockAndWait); int waitResult = ENOLCK; bool makeLoop = true; @@ -282,7 +282,7 @@ SynchLockAndWaitIX::SynchLockAndWaitIX( IEWaitableBaseIX ** listWaitables if ( (mMatchCondition == NESynchTypesIX::eMatchCondition::MatchConditionAny ) || (mDescribe == SynchLockAndWaitIX::eWaitType::WaitSingleObject) ) { - for ( int i = 0; i < count; ++ i, ++ listWaitables ) + for ( uint32_t i = 0; i < static_cast(count); ++ i, ++ listWaitables ) { IEWaitableBaseIX * synchWaitable = *listWaitables; if (synchWaitable != nullptr) @@ -320,7 +320,7 @@ SynchLockAndWaitIX::SynchLockAndWaitIX( IEWaitableBaseIX ** listWaitables { bool eventFired = true; - for ( int i = 0; i < count; ++ i, ++ listWaitables ) + for ( uint32_t i = 0; i < static_cast(count); ++ i, ++ listWaitables ) { IEWaitableBaseIX * synchWaitable = *listWaitables; if ( synchWaitable != nullptr ) @@ -549,7 +549,7 @@ bool SynchLockAndWaitIX::_requestOwnership( const NESynchTypesIX::eSynchObjectFi if ( firedEvent != NESynchTypesIX::SynchObjectAll ) { ASSERT(mWaitingList.getSize() > static_cast(firedEvent)); - IEWaitableBaseIX *waitable = mWaitingList[static_cast(firedEvent)]; + IEWaitableBaseIX *waitable = mWaitingList[static_cast(firedEvent)]; #ifdef DEBUG if (waitable == nullptr) diff --git a/framework/areg/base/private/posix/SynchLockAndWaitIX.hpp b/framework/areg/base/private/posix/SynchLockAndWaitIX.hpp index 26b1c1bb..97156923 100644 --- a/framework/areg/base/private/posix/SynchLockAndWaitIX.hpp +++ b/framework/areg/base/private/posix/SynchLockAndWaitIX.hpp @@ -121,12 +121,12 @@ class SynchLockAndWaitIX /** * \brief Helper object for resource map basic method implementations **/ - using ImplWaitIDResource= TEResourceMapImpl; + using ImplWaitIDResource= TEResourceMapImpl; /** - * \brief Resource map of waitable where the keys are id_type (thread ID) and the values are + * \brief Resource map of waitable where the keys are pthread_t (thread ID) and the values are * LockAndWait objects. It is used in the timer. **/ - using MapWaitIDResource = TELockResourceMap; + using MapWaitIDResource = TELockResourceMap; ////////////////////////////////////////////////////////////////////////// // Friend classes diff --git a/framework/areg/component/private/Watchdog.hpp b/framework/areg/component/private/Watchdog.hpp index 5879a5bc..413025e5 100644 --- a/framework/areg/component/private/Watchdog.hpp +++ b/framework/areg/component/private/Watchdog.hpp @@ -70,7 +70,7 @@ class AREG_API Watchdog : public TimerBase /** * \brief The watchdog ID, which is generated when the watchdog is started. **/ - using WATCHDOG_ID = id_type; + using WATCHDOG_ID = ptr_type; /** * \brief Identifies invalid watchdog ID. @@ -239,9 +239,9 @@ inline Watchdog::WATCHDOG_ID Watchdog::watchdogId(void) inline Watchdog::WATCHDOG_ID Watchdog::makeWatchdogId(GUARD_ID guardId, SEQUENCE_ID sequence) { #if defined(BIT64) - return static_cast(MACRO_MAKE_64(guardId, sequence)); + return static_cast(MACRO_MAKE_64(guardId, sequence)); #else // !defined(BIT64) - return static_cast(MACRO_MAKE_32(guardId, sequence)); + return static_cast(MACRO_MAKE_32(guardId, sequence)); #endif // defined(BIT64) } diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 44ac7f8f..cefef5bb 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -5,6 +5,11 @@ if (AREG_BUILD_TESTS) + # Disable unit tests post-build for ARM processor + if (${AREG_PROCESSOR} STREQUAL "arm" OR ${AREG_PROCESSOR} STREQUAL "aarch64") + set(CMAKE_GTEST_DISCOVER_TESTS_DISCOVERY_MODE PRE_TEST) + endif() + # local variables set(AREG_GTEST_INCLUDES) set(AREG_GTEST_LIBRARY)