diff options
author | Michal Klocek <michal.klocek@qt.io> | 2021-05-23 17:39:28 +0200 |
---|---|---|
committer | Michal Klocek <michal.klocek@qt.io> | 2021-07-02 12:51:15 +0200 |
commit | 3a962d8a2d3b70639a195fe5fd442f6c653bbe8f (patch) | |
tree | fc29d1aa945b0ad90c9a558e6e3155f4c35f1f9a /src/core | |
parent | 9e8f10247a5c5d433f5f983345f636fbedb26e2d (diff) |
Add cross compilation support to cmake builds
Add arm cross-compile basic support. CMake does not
support host builds. However we do host build with gn and
changing that would require an extra effort to keep all necessary
changes with Chromium upstream. Therefore let gn to perform
the host build for required tools and just feed gn with all the
build data.
Add new build steps:
* install gn into QT_HOST_PATH/libexec.
* run hostBuild project to get native architecture and compiler
* call PkgConfigHost to pass pkg-config paths to gn
* create wrapper script for host pkg-config to escape
yocto shell pkg config exports
This change also splits gn toolchain into 3 toolchains host,target,v8
Now hostBuild provides host and v8 toolchain in case of cross compile.
The build optimizations will follow in another patch.
Fix not existing 'boot2qt' condition and enables more test on QEMU.
Note this is tested only with yocto based images.
Pick-to: dev
Task-number: QTBUG-91760
Change-Id: Ic2bea12229acc71fbd36a848e9ed4fed7e14b485
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/CMakeLists.txt | 48 | ||||
-rw-r--r-- | src/core/api/configure.cmake | 10 | ||||
-rw-r--r-- | src/core/configure/BUILD.toolchain.gn.in | 32 | ||||
-rw-r--r-- | src/core/configure/CMakeLists.txt | 35 |
4 files changed, 80 insertions, 45 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index e9d34adfb..1b4e4930e 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -24,6 +24,11 @@ find_package(Nodejs 12.0) find_package(PkgConfig) if(PkgConfig_FOUND) pkg_check_modules(XSCRNSAVER xscrnsaver) + find_package(PkgConfigHost) + if(CMAKE_CROSSCOMPILING) + create_pkg_config_host_wrapper("${buildDir}/pkg-config-host_wrapper.sh" "${PKG_CONFIG_HOST_EXECUTABLE}") + set(PKG_CONFIG_HOST_EXECUTABLE "${buildDir}/pkg-config-host_wrapper.sh") + endif() endif() get_target_property(qtWebEngineProcessName WebEngineCore QTWEBENGINEPROCESS_NAME) @@ -36,6 +41,24 @@ else() set(configs ${CMAKE_BUILD_TYPE}) endif() +## +# TOOLCHAIN SETUP +## + +if(LINUX) + if(NOT CMAKE_CROSSCOMPILING) # delivered by hostBuild project + configure_gn_toolchain(host ${TEST_architecture_arch} ${TEST_architecture_arch} + ${WEBENGINE_ROOT_SOURCE_DIR}/src/core/configure/BUILD.toolchain.gn.in + ${buildDir}/host_toolchain) + configure_gn_toolchain(v8 ${TEST_architecture_arch} ${TEST_architecture_arch} + ${WEBENGINE_ROOT_SOURCE_DIR}/src/core/configure/BUILD.toolchain.gn.in + ${buildDir}/v8_toolchain) + endif() + configure_gn_toolchain(target ${TEST_architecture_arch} ${TEST_architecture_arch} + ${WEBENGINE_ROOT_SOURCE_DIR}/src/core/configure/BUILD.toolchain.gn.in + ${buildDir}/target_toolchain) +endif() + foreach(config ${configs}) ## @@ -249,12 +272,6 @@ foreach(config ${configs}) configure_gn_target(${buildGn} ${config} ${WEBENGINE_ROOT_SOURCE_DIR}/src/core/configure/BUILD.root.gn.in ${buildDir}/${config}/BUILD.gn) -## -# TOOLCHAIN SETUP -## - - configure_file(${WEBENGINE_ROOT_SOURCE_DIR}/src/core/configure/BUILD.toolchain.gn.in - ${buildDir}/${config}/toolchain/BUILD.gn @ONLY) ## # GN CALL PARAMETERS SETUP @@ -416,6 +433,15 @@ foreach(config ${configs}) ) endif() if(LINUX) + get_gn_arch(cpu ${TEST_architecture_arch}) + if(CMAKE_CROSSCOMPILING) + list(APPEND gnArgArg target_cpu="${cpu}") + else() + list(APPEND gnArgArg host_cpu="${cpu}") + endif() + if(CMAKE_SYSROOT) + list(APPEND gnArgArg target_sysroot="${CMAKE_SYSROOT}") + endif() list(APPEND gnArgArg use_cups=false use_gio=false @@ -432,11 +458,11 @@ foreach(config ${configs}) ozone_platform_external=true ozone_platform="qt" ozone_extra_path="${CMAKE_CURRENT_LIST_DIR}/ozone/ozone_extra.gni" - custom_toolchain="${buildDir}/${config}/toolchain:target" - host_toolchain="${buildDir}/${config}/toolchain:host" - host_cpu="x64" - pkg_config="pkg-config" - host_pkg_config="/usr/bin/pkg-config" + custom_toolchain="${buildDir}/target_toolchain:target" + host_toolchain="${buildDir}/host_toolchain:host" + v8_snapshot_toolchain="${buildDir}/v8_toolchain:v8" + pkg_config="${PKG_CONFIG_EXECUTABLE}" + host_pkg_config="${PKG_CONFIG_HOST_EXECUTABLE}" use_glib=false ) set(systemLibs libjpeg libpng freetype harfbuzz libevent libwebp libxml diff --git a/src/core/api/configure.cmake b/src/core/api/configure.cmake index e0332cab4..c8518f6ee 100644 --- a/src/core/api/configure.cmake +++ b/src/core/api/configure.cmake @@ -145,11 +145,11 @@ qt_configure_add_summary_entry( CONDITION UNIX ) qt_configure_end_summary_section() # end of "Qt WebEngineCore" section -qt_configure_add_report_entry( - TYPE WARNING - MESSAGE "Thumb instruction set is required to build ffmpeg for QtWebEngine." - CONDITION LINUX AND QT_FEATURE_webengine_embedded_build AND NOT QT_FEATURE_webengine_system_ffmpeg AND ( TEST_architecture_arch STREQUAL arm ) AND NOT QT_FEATURE_webengine_arm_thumb -) +#qt_configure_add_report_entry( +# TYPE WARNING +# MESSAGE "Thumb instruction set is required to build ffmpeg for QtWebEngine." +# CONDITION LINUX AND QT_FEATURE_webengine_embedded_build AND NOT QT_FEATURE_webengine_system_ffmpeg AND ( TEST_architecture_arch STREQUAL arm ) AND NOT QT_FEATURE_webengine_arm_thumb +#) qt_configure_add_report_entry( TYPE WARNING MESSAGE "V8 snapshot cannot be built. Most likely, the 32-bit host compiler does not work. Please make sure you have 32-bit devel environment installed." diff --git a/src/core/configure/BUILD.toolchain.gn.in b/src/core/configure/BUILD.toolchain.gn.in index e44fa42de..c1bf3845b 100644 --- a/src/core/configure/BUILD.toolchain.gn.in +++ b/src/core/configure/BUILD.toolchain.gn.in @@ -1,6 +1,6 @@ import("//build/config/sysroot.gni") import("//build/toolchain/gcc_toolchain.gni") -gcc_toolchain("host") { +gcc_toolchain("@GN_TOOLCHAIN@") { cc = "@CMAKE_C_COMPILER@" cxx = "@CMAKE_CXX_COMPILER@" ld = "@CMAKE_CXX_COMPILER@" @@ -9,34 +9,8 @@ gcc_toolchain("host") { extra_cppflags = "" toolchain_args = { current_os = "linux" - current_cpu = "x64" - is_clang = false - use_gold = false - } -} -gcc_toolchain("v8_snapshot") { - cc = "@CMAKE_C_COMPILER@" - cxx = "@CMAKE_CXX_COMPILER@" - ld = "@CMAKE_CXX_COMPILER@" - ar = "@CMAKE_AR@" - nm = "@CMAKE_NM@" - toolchain_args = { - current_os = "linux" - current_cpu = "x64" - v8_current_cpu = "x64" - is_clang = false - use_gold = false - } - } -gcc_toolchain("target") { - cc = "@CMAKE_C_COMPILER@" - cxx = "@CMAKE_CXX_COMPILER@" - ld = "@CMAKE_CXX_COMPILER@" - ar = "@CMAKE_AR@" - nm = "@CMAKE_NM@" - toolchain_args = { - current_os = "linux" - current_cpu = "x64" + current_cpu = "@GN_CPU@" + v8_current_cpu = "@GN_V8_CPU@" is_clang = false use_gold = false } diff --git a/src/core/configure/CMakeLists.txt b/src/core/configure/CMakeLists.txt new file mode 100644 index 000000000..0ae4b4b48 --- /dev/null +++ b/src/core/configure/CMakeLists.txt @@ -0,0 +1,35 @@ +cmake_minimum_required(VERSION 3.19) + +if(NOT DEFINED WEBENGINE_ROOT_SOURCE_DIR) + get_filename_component(WEBENGINE_ROOT_SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/../../.." REALPATH) +endif() +if (NOT DEFINED WEBENGINE_ROOT_BUILD_DIR) + get_filename_component(WEBENGINE_ROOT_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/../../.." REALPATH) +endif() + +include(${WEBENGINE_ROOT_SOURCE_DIR}/.cmake.conf) +include(${WEBENGINE_ROOT_SOURCE_DIR}/cmake/Functions.cmake) + +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${WEBENGINE_ROOT_SOURCE_DIR}/cmake") + +project(QtWebEngineConfigure + VERSION "${QT_REPO_MODULE_VERSION}" + LANGUAGES CXX C) + +find_package(Qt6 ${PROJECT_VERSION} CONFIG REQUIRED COMPONENTS BuildInternals Core) + +set(buildDir ${CMAKE_CURRENT_BINARY_DIR}) +configure_gn_toolchain(host ${TEST_architecture_arch} ${TEST_architecture_arch} + ${WEBENGINE_ROOT_SOURCE_DIR}/src/core/configure/BUILD.toolchain.gn.in + ${buildDir}/host_toolchain +) +install(FILES ${buildDir}/host_toolchain/BUILD.gn + DESTINATION ${WEBENGINE_ROOT_BUILD_DIR}/src/core/host_toolchain + ) +get_v8_arch(GN_V8_HOST_CPU ${GN_TARGET_CPU}) +configure_gn_toolchain(v8 ${GN_V8_HOST_CPU} ${GN_TARGET_CPU} + ${WEBENGINE_ROOT_SOURCE_DIR}/src/core/configure/BUILD.toolchain.gn.in + ${buildDir}/v8_toolchain) +install(FILES ${buildDir}/v8_toolchain/BUILD.gn + DESTINATION ${WEBENGINE_ROOT_BUILD_DIR}/src/core/v8_toolchain +) |