diff --git a/API/hermes/CMakeLists.txt b/API/hermes/CMakeLists.txt index 076cf8547c4..3d5b9fd71cf 100644 --- a/API/hermes/CMakeLists.txt +++ b/API/hermes/CMakeLists.txt @@ -119,6 +119,10 @@ if(APPLE AND HERMES_BUILD_APPLE_FRAMEWORK) set_source_files_properties(${api_public_headers} PROPERTIES MACOSX_PACKAGE_LOCATION Headers/Public ) + if(HERMES_ENABLE_BITCODE) + target_compile_options(libhermes PUBLIC "-fembed-bitcode") + target_link_libraries(libhermes PUBLIC "-fembed-bitcode") + endif() endif() install(TARGETS libhermes diff --git a/API/jsi/jsi/CMakeLists.txt b/API/jsi/jsi/CMakeLists.txt index d04af0006af..121d697fd8e 100644 --- a/API/jsi/jsi/CMakeLists.txt +++ b/API/jsi/jsi/CMakeLists.txt @@ -21,6 +21,9 @@ elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC") # when they go out of scope due to exceptions. list(APPEND jsi_compile_flags "/EHsc") endif() +if (HERMES_ENABLE_BITCODE) + list(APPEND jsi_compile_flags "-fembed-bitcode") +endif () target_compile_options(jsi PUBLIC ${jsi_compile_flags}) install(DIRECTORY "${PROJECT_SOURCE_DIR}/API/jsi/" DESTINATION include diff --git a/CMakeLists.txt b/CMakeLists.txt index c362b5a567a..d8b26bf04e0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -146,6 +146,10 @@ set(HERMES_ENABLE_THREAD_SANITIZER OFF CACHE BOOL set(HERMES_ENABLE_FUZZING OFF CACHE BOOL "Enable fuzzing") +# Enable bitcode +set(HERMES_ENABLE_BITCODE OFF CACHE BOOL + "Include bitcode with the framework") + # Set linker flag for building the fuzzer set(HERMES_FUZZING_FLAG "-fsanitize=fuzzer" CACHE STRING "Linker argument to link fuzz targets against a given fuzzer.") diff --git a/cmake/modules/Hermes.cmake b/cmake/modules/Hermes.cmake index f789eedb0fa..391f480bde5 100644 --- a/cmake/modules/Hermes.cmake +++ b/cmake/modules/Hermes.cmake @@ -124,6 +124,9 @@ function(add_hermes_library name) target_link_libraries(${name} ${ARG_LINK_LIBS} ${HERMES_LINK_COMPONENTS}) set_property(TARGET ${name} PROPERTY POSITION_INDEPENDENT_CODE ON) hermes_update_compile_flags(${name}) + if (HERMES_ENABLE_BITCODE) + target_compile_options(${name} PUBLIC "-fembed-bitcode") + endif () endfunction(add_hermes_library) function(add_hermes_executable name) diff --git a/utils/build-apple-framework.sh b/utils/build-apple-framework.sh index 48552cff432..3c853d2abc6 100755 --- a/utils/build-apple-framework.sh +++ b/utils/build-apple-framework.sh @@ -27,6 +27,13 @@ fi # Utility function to configure an Apple framework function configure_apple_framework { + local enable_bitcode + if [[ $1 == "macosx" ]]; then + enable_bitcode="false" + else + enable_bitcode="true" + fi + local cmake_flags=" \ -DHERMES_APPLE_TARGET_PLATFORM:STRING=$1 \ -DCMAKE_OSX_ARCHITECTURES:STRING=$2 \ @@ -34,6 +41,7 @@ function configure_apple_framework { -DHERMES_ENABLE_DEBUGGER:BOOLEAN=true \ -DHERMES_ENABLE_FUZZING:BOOLEAN=false \ -DHERMES_ENABLE_TEST_SUITE:BOOLEAN=false \ + -DHERMES_ENABLE_BITCODE:BOOLEAN=$enable_bitcode \ -DHERMES_BUILD_APPLE_FRAMEWORK:BOOLEAN=true \ -DHERMES_BUILD_APPLE_DSYM:BOOLEAN=true -DCMAKE_INSTALL_PREFIX:PATH=../destroot"