From 98a7eaf95d3008307e4d124442338097ce45bb7d Mon Sep 17 00:00:00 2001 From: HyukWoo Park Date: Wed, 16 Oct 2024 16:06:52 +0900 Subject: [PATCH] Update macOS build including both x64 and arm64 Signed-off-by: HyukWoo Park --- .github/workflows/es-actions.yml | 32 +++++++++++++++++++++++++++++++- README.md | 7 ++++++- build/target.cmake | 7 ++++--- third_party/walrus | 2 +- 4 files changed, 42 insertions(+), 6 deletions(-) diff --git a/.github/workflows/es-actions.yml b/.github/workflows/es-actions.yml index d37b4343a..60f710bc2 100644 --- a/.github/workflows/es-actions.yml +++ b/.github/workflows/es-actions.yml @@ -38,6 +38,36 @@ jobs: env: BUILD_OPTIONS: -DESCARGOT_WASM=ON -DESCARGOT_TEMPORAL=ON -DESCARGOT_TCO=ON -DESCARGOT_TEST=ON -DESCARGOT_OUTPUT=shell -GNinja run: | + # check cpu + sysctl -a | grep machdep.cpu + # add icu path to pkg_config_path + export PKG_CONFIG_PATH="/usr/local/opt/icu4c/lib/pkgconfig:$PKG_CONFIG_PATH" + cmake -H. -Bout/debug/ -DESCARGOT_MODE=debug $BUILD_OPTIONS + ninja -Cout/debug/ + $RUNNER --engine="./out/debug/escargot" new-es + cmake -H. -Bout/release/ -DESCARGOT_MODE=release $BUILD_OPTIONS + ninja -Cout/release/ + cp test/octane/*.js . + ./out/release/escargot run.js + + build-on-macos-arm64: + runs-on: macos-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + - name: Install Packages + run: | + brew update + brew install cmake ninja pkg-config icu4c + - name: Build arm64 + env: + BUILD_OPTIONS: -DESCARGOT_WASM=ON -DESCARGOT_TEMPORAL=ON -DESCARGOT_TCO=ON -DESCARGOT_TEST=ON -DESCARGOT_OUTPUT=shell -GNinja + run: | + # check cpu + sysctl -a | grep machdep.cpu + # add icu path to pkg_config_path + export PKG_CONFIG_PATH="/opt/homebrew/opt/icu4c/lib/pkgconfig:$PKG_CONFIG_PATH" cmake -H. -Bout/debug/ -DESCARGOT_MODE=debug $BUILD_OPTIONS ninja -Cout/debug/ $RUNNER --engine="./out/debug/escargot" new-es @@ -365,7 +395,7 @@ jobs: submodules: true - name: Build env: - BUILD_OPTIONS: -DESCARGOT_HOST=linux -DESCARGOT_THREADING=ON -DESCARGOT_TEMPORAL=ON -DESCARGOT_TCO=ON -DESCARGOT_TEST=ON -DESCARGOT_OUTPUT=shell -GNinja + BUILD_OPTIONS: -DESCARGOT_THREADING=ON -DESCARGOT_TEMPORAL=ON -DESCARGOT_TCO=ON -DESCARGOT_TEST=ON -DESCARGOT_OUTPUT=shell -GNinja run: | LDFLAGS=" -L/usr/icu32/lib/ -Wl,-rpath=/usr/icu32/lib/" PKG_CONFIG_PATH="/usr/icu32/lib/pkgconfig/" cmake -H./ -Bbuild/out_linux -DESCARGOT_ARCH=x86 -DESCARGOT_MODE=debug -DESCARGOT_TCO_DEBUG=ON $BUILD_OPTIONS LDFLAGS=" -L/usr/icu32/lib/ -Wl,-rpath=/usr/icu32/lib/" PKG_CONFIG_PATH="/usr/icu32/lib/pkgconfig/" cmake -H./ -Bbuild/out_linux_release -DESCARGOT_ARCH=x86 $BUILD_OPTIONS diff --git a/README.md b/README.md index 8e69a907b..ede1dcedc 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ Escargot is an open-source project that allows developers to contribute to its d | **OS** | **Architecture** | |-|-| | **Linux(Ubuntu)** | x86/x64/arm/aarch64 | -| macOS | x64 | +| macOS | x64/aarch64 | | Windows | x86 | | Android | x86/x64/arm/aarch64 | @@ -82,6 +82,11 @@ ninja General build prerequisites: ```sh brew install autoconf automake cmake icu4c libtool ninja pkg-config + +# add icu path to pkg_config_path (x64) +export PKG_CONFIG_PATH="/usr/local/opt/icu4c/lib/pkgconfig:$PKG_CONFIG_PATH" +# add icu path to pkg_config_path (arm64) +export PKG_CONFIG_PATH="/opt/homebrew/opt/icu4c/lib/pkgconfig:$PKG_CONFIG_PATH" ``` Build Escargot: diff --git a/build/target.cmake b/build/target.cmake index 651d22a0b..d2a6d1cb9 100644 --- a/build/target.cmake +++ b/build/target.cmake @@ -152,8 +152,11 @@ ELSEIF (${ESCARGOT_HOST} STREQUAL "android") # bdwgc android amd64 cannot support keeping back ptrs SET (ESCARGOT_THIRDPARTY_CFLAGS ${ESCARGOT_THIRDPARTY_CFLAGS} -UKEEP_BACK_PTRS -USAVE_CALL_COUNT -UDBG_HDRS_ALL) ENDIF() -ELSEIF (${ESCARGOT_HOST} STREQUAL "darwin" AND ${ESCARGOT_ARCH} STREQUAL "x64") +ELSEIF (${ESCARGOT_HOST} STREQUAL "darwin") FIND_PACKAGE (PkgConfig REQUIRED) + IF ((NOT ${ESCARGOT_ARCH} STREQUAL "x64") AND (NOT ${ESCARGOT_ARCH} STREQUAL "aarch64")) + MESSAGE (FATAL_ERROR ${ESCARGOT_ARCH} " is unsupported") + ENDIF() SET (ESCARGOT_LDFLAGS -lpthread -Wl,-dead_strip) SET (ESCARGOT_BUILD_64BIT_LARGE ON) # bdwgc mac cannot support pthread_getattr_np @@ -162,8 +165,6 @@ ELSEIF (${ESCARGOT_HOST} STREQUAL "darwin" AND ${ESCARGOT_ARCH} STREQUAL "x64") IF (NOT DEFINED ESCARGOT_LIBICU_SUPPORT_WITH_DLOPEN) SET (ESCARGOT_LIBICU_SUPPORT_WITH_DLOPEN OFF) ENDIF() - # add pkg_config_path icu install path of brew - SET (ENV{PKG_CONFIG_PATH} "/usr/local/opt/icu4c/lib/pkgconfig:$ENV{PKG_CONFIG_PATH}") ELSEIF (${ESCARGOT_HOST} STREQUAL "windows") SET (ESCARGOT_LDFLAGS ${ESCARGOT_LDFLAGS} icu.lib) IF ((${ESCARGOT_ARCH} STREQUAL "x64") OR (${ESCARGOT_ARCH} STREQUAL "x86_64")) diff --git a/third_party/walrus b/third_party/walrus index 75dc3e4eb..4ae176a00 160000 --- a/third_party/walrus +++ b/third_party/walrus @@ -1 +1 @@ -Subproject commit 75dc3e4eb8ba92a1b064a8b7322be0faaf9d7d68 +Subproject commit 4ae176a0021136133292e4e0331ef9f536f527a1