From b789110803b33ff3756462897bcebb37c27a6212 Mon Sep 17 00:00:00 2001 From: Kenneth Geisshirt Date: Sun, 27 Aug 2023 16:12:31 +0200 Subject: [PATCH] Pick correct toolchain for Linux builds (#6094) --- CHANGELOG.md | 3 +-- packages/realm/bindgen/CMakeLists.txt | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 41e4637420..da4d4cf4ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,8 +7,7 @@ * None ### Fixed -* ([#????](https://github.com/realm/realm-js/issues/????), since v?.?.?) -* None +* Fixed toolchain on Linux. On older Linux installations, the error `GLIBC_2.34' not found (required by /home/user/MyProject/node_modules/realm/generated/ts/realm.node)` could be observed. ([#6082](https://github.com/realm/realm-js/issues/6082), since v12.0.0) ### Compatibility * React Native >= v0.71.4 diff --git a/packages/realm/bindgen/CMakeLists.txt b/packages/realm/bindgen/CMakeLists.txt index ceab4ef2d8..5df763b612 100644 --- a/packages/realm/bindgen/CMakeLists.txt +++ b/packages/realm/bindgen/CMakeLists.txt @@ -22,9 +22,19 @@ if(DEFINED CMAKE_JS_VERSION) set(CMAKE_OSX_ARCHITECTURES "x86_64" CACHE STRING "") endif() elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux") - add_link_options(-fuse-ld=gold) - add_link_options(-Wl,-z,noexecstack) - add_link_options(-Wl,--warn-execstack) + if(NODE_ARCH STREQUAL "arm") + set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/vendor/realm-core/tools/cmake/armv7-linux-gnueabihf.toolchain.cmake") + # due to how multiarch works in debian this is needed to link to the correct system libraries + set(CMAKE_IGNORE_PATH "/usr/lib/x86_64-linux-gnu") + elseif(NODE_ARCH STREQUAL "arm64") + set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/vendor/realm-core/tools/cmake/aarch64-linux-gnu.toolchain.cmake") + set(CMAKE_IGNORE_PATH "/usr/lib/x86_64-linux-gnu") + elseif(NODE_ARCH STREQUAL "x64") + set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/vendor/realm-core/tools/cmake/x86_64-linux-gnu.toolchain.cmake") + endif() + add_link_options(-fuse-ld=gold) + add_link_options(-Wl,-z,noexecstack) + add_link_options(-Wl,--warn-execstack) endif() endif()