Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use cross-compilers instead of CentOS image #6559

Merged
merged 9 commits into from
May 31, 2023
Merged
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

### Internals
* Upgraded to Catch from v3.0.1 to v3.3.2. ([#6623](https://github.com/realm/realm-core/issues/6623))
* Added CMake toolchains for cross-targeting Linux x86_64, armv7, and aarch64. (PR [#6559](https://github.com/realm/realm-core/pull/6559))

----------------------------------------------

Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,8 @@ endif()
# Just use -lz and let Xcode figure it out
# Emscripten does provide Zlib, but it doesn't work with find_package and is handled specially
if(NOT APPLE AND NOT EMSCRIPTEN AND NOT TARGET ZLIB::ZLIB)
if(WIN32)
realm_acquire_dependency(zlib ${DEP_WIN32_ZLIB_VERSION} ZLIB_CMAKE_INCLUDE_FILE)
if(WIN32 OR (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND REALM_LINUX_TOOLCHAIN))
realm_acquire_dependency(zlib ${DEP_ZLIB_VERSION} ZLIB_CMAKE_INCLUDE_FILE)
include(${ZLIB_CMAKE_INCLUDE_FILE})
elseif(ANDROID)
# On Android FindZLIB chooses the static libz over the dynamic one, but this leads to issues
Expand Down
20 changes: 12 additions & 8 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ jobWrapper {

parallelExecutors = [
buildLinuxRelease : doBuildLinux('Release'),
checkLinuxDebug : doCheckInDocker(buildOptions),
checkLinuxDebug : doCheckInDocker(buildOptions + [useToolchain : true]),
checkLinuxDebugEncrypt : doCheckInDocker(buildOptions + [useEncryption : true]),
checkLinuxRelease_4 : doCheckInDocker(buildOptions + [maxBpNodeSize: 4, buildType : 'Release']),
checkLinuxRelease_4 : doCheckInDocker(buildOptions + [maxBpNodeSize: 4, buildType : 'Release', useToolchain : true]),
checkLinuxDebug_Sync : doCheckInDocker(buildOptions + [enableSync: true, dumpChangesetTransform: true]),
checkLinuxDebugNoEncryp : doCheckInDocker(buildOptions + [enableEncryption: false]),
checkMacOsRelease_Sync : doBuildMacOs(buildOptions + [buildType: 'Release', enableSync: true]),
Expand Down Expand Up @@ -251,7 +251,7 @@ def doCheckInDocker(Map options = [:]) {
rlmNode('docker') {
getArchive()

def buildEnv = buildDockerEnv('testing.Dockerfile')
def buildEnv = buildDockerEnv('linux.Dockerfile')

def environment = environment()
environment << 'UNITTEST_XML=unit-test-report.xml'
Expand All @@ -260,6 +260,10 @@ def doCheckInDocker(Map options = [:]) {
environment << 'UNITTEST_ENCRYPT_ALL=1'
}

if (options.useToolchain) {
cmakeDefinitions += " -DCMAKE_TOOLCHAIN_FILE=\"${env.WORKSPACE}/tools/cmake/x86_64-linux-gnu.toolchain.cmake\""
}

def buildSteps = { String dockerArgs = "" ->
buildEnv.inside(dockerArgs) {
withEnv(environment) {
Expand Down Expand Up @@ -351,7 +355,7 @@ def doCheckSanity(Map options = [:]) {
"UNITTEST_SUITE_NAME=Linux-${options.buildType}",
"TSAN_OPTIONS=\"suppressions=${WORKSPACE}/test/tsan.suppress\""
]
buildDockerEnv('testing.Dockerfile').inside(privileged) {
buildDockerEnv('linux.Dockerfile').inside(privileged) {
withEnv(environment) {
try {
dir('build-dir') {
Expand Down Expand Up @@ -379,12 +383,12 @@ def doBuildLinux(String buildType) {
rlmNode('docker') {
getSourceArchive()

buildDockerEnv('packaging.Dockerfile').inside {
buildDockerEnv('linux.Dockerfile').inside {
sh """
rm -rf build-dir
mkdir build-dir
cd build-dir
cmake -DCMAKE_BUILD_TYPE=${buildType} -DREALM_NO_TESTS=1 -DREALM_VERSION="${gitDescribeVersion}" -G Ninja ..
cmake -DCMAKE_BUILD_TYPE=${buildType} -DCMAKE_TOOLCHAIN_FILE=../tools/cmake/x86_64-linux-gnu.toolchain.cmake -DREALM_NO_TESTS=1 -DREALM_VERSION="${gitDescribeVersion}" -G Ninja ..
ninja
cpack -G TGZ
"""
Expand All @@ -410,7 +414,7 @@ def doBuildLinuxClang(String buildType) {
'CXX=clang++'
]

buildDockerEnv('testing.Dockerfile').inside {
buildDockerEnv('linux.Dockerfile').inside {
withEnv(environment) {
dir('build-dir') {
sh "cmake -D CMAKE_BUILD_TYPE=${buildType} -DREALM_NO_TESTS=1 -DREALM_VERSION=\"${gitDescribeVersion}\" -G Ninja .."
Expand Down Expand Up @@ -778,7 +782,7 @@ def doBuildCoverage() {
rlmNode('docker') {
getArchive()

buildDockerEnv('testing.Dockerfile').inside {
buildDockerEnv('linux.Dockerfile').inside {
sh '''
mkdir build
cd build
Expand Down
2 changes: 1 addition & 1 deletion dependencies.list
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PACKAGE_NAME=realm-core
VERSION=13.11.0
OPENSSL_VERSION=3.0.8
WIN32_ZLIB_VERSION=1.2.13
ZLIB_VERSION=1.2.13
MDBREALM_TEST_SERVER_TAG=2023-05-05
File renamed without changes.
2 changes: 0 additions & 2 deletions packaging.Dockerfile

This file was deleted.

4 changes: 2 additions & 2 deletions tools/cmake/RealmConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ find_dependency(Threads)
# so for an iOS build it'll use the path from the Device plaform, which is an error on Simulator.
# Just use -lz and let Xcode figure it out
if(TARGET Realm::Sync AND NOT APPLE AND NOT TARGET ZLIB::ZLIB)
if(WIN32)
realm_acquire_dependency(zlib @DEP_WIN32_ZLIB_VERSION@ ZLIB_CMAKE_INCLUDE_FILE)
if(WIN32 OR (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND REALM_LINUX_TOOLCHAIN))
realm_acquire_dependency(zlib @DEP_ZLIB_VERSION@ ZLIB_CMAKE_INCLUDE_FILE)
include(${ZLIB_CMAKE_INCLUDE_FILE})
elseif(ANDROID)
# On Android FindZLIB chooses the static libz over the dynamic one, but this leads to issues
Expand Down
3 changes: 3 additions & 0 deletions tools/cmake/aarch64-linux-gnu.toolchain.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
set(_TRIPLET "aarch64-unknown-linux-gnu")
set(_TOOLCHAIN_MD5 a3a14d87f98904c2558b43bbd310f337)
include("${CMAKE_CURRENT_LIST_DIR}/linux.toolchain.base.cmake")
16 changes: 0 additions & 16 deletions tools/cmake/aarch64.toolchain.cmake

This file was deleted.

88 changes: 0 additions & 88 deletions tools/cmake/android-build-openssl.sh.in

This file was deleted.

17 changes: 0 additions & 17 deletions tools/cmake/armhf.toolchain.cmake

This file was deleted.

3 changes: 3 additions & 0 deletions tools/cmake/armv7-linux-gnueabihf.toolchain.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
set(_TRIPLET "armv7-unknown-linux-gnueabihf")
set(_TOOLCHAIN_MD5 fbf817b1428bb35c93be8e6c15f73d7d)
include("${CMAKE_CURRENT_LIST_DIR}/linux.toolchain.base.cmake")
19 changes: 19 additions & 0 deletions tools/cmake/linux.toolchain.base.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
if(NOT CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux" OR NOT CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "x86_64")
message(FATAL_ERROR "This toolchain can only be used on x86_64 Linux.")
endif()

file(DOWNLOAD https://static.realm.io/toolchains/v3/${_TRIPLET}.tar.zst ${CMAKE_BINARY_DIR}/${_TRIPLET}.tar.zst
EXPECTED_HASH MD5=${_TOOLCHAIN_MD5} STATUS _DOWNLOAD_STATUS)
list(GET _DOWNLOAD_STATUS 0 _DOWNLOAD_STATUS_CODE)
if(NOT ${_DOWNLOAD_STATUS_CODE} EQUAL 0)
message(FATAL_ERROR "Error downloading ${_TRIPLET}.tar.zst: ${_DOWNLOAD_STATUS}")
endif()

file(ARCHIVE_EXTRACT INPUT ${CMAKE_BINARY_DIR}/${_TRIPLET}.tar.zst DESTINATION ${CMAKE_BINARY_DIR})
include("${CMAKE_BINARY_DIR}/${_TRIPLET}/toolchain.cmake")

set(CMAKE_EXE_LINKER_FLAGS_INIT "-Xlinker --exclude-libs=libgcc.a,libstdc++.a -static-libgcc -static-libstdc++")
set(CMAKE_SHARED_LINKER_FLAGS_INIT "-Xlinker --exclude-libs=libgcc.a,libstdc++.a -static-libgcc -static-libstdc++")
set(CMAKE_MODULE_LINKER_FLAGS_INIT "-Xlinker --exclude-libs=libgcc.a,libstdc++.a -static-libgcc -static-libstdc++")

set(REALM_LINUX_TOOLCHAIN ON)
3 changes: 0 additions & 3 deletions tools/cmake/run_ldconfig.sh

This file was deleted.

3 changes: 3 additions & 0 deletions tools/cmake/x86_64-linux-gnu.toolchain.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
set(_TRIPLET "x86_64-unknown-linux-gnu")
set(_TOOLCHAIN_MD5 aa99fc16d85adf1bb2f8b63b83542044)
include("${CMAKE_CURRENT_LIST_DIR}/linux.toolchain.base.cmake")