diff --git a/API/jsi/jsi/CMakeLists.txt b/API/jsi/jsi/CMakeLists.txt index 3d2959e5491..28c661c9832 100644 --- a/API/jsi/jsi/CMakeLists.txt +++ b/API/jsi/jsi/CMakeLists.txt @@ -21,9 +21,6 @@ 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 PRIVATE ${jsi_compile_flags}) install(DIRECTORY "${PROJECT_SOURCE_DIR}/API/jsi/" DESTINATION include diff --git a/CMakeLists.txt b/CMakeLists.txt index cfde0268914..38a480a8998 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,8 +53,8 @@ set(CMAKE_OSX_SYSROOT ${HERMES_APPLE_TARGET_PLATFORM}) if(HERMES_APPLE_TARGET_PLATFORM MATCHES "catalyst") set(CMAKE_OSX_SYSROOT "macosx") - set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-target x86_64-arm64-apple-ios14.0-macabi -isystem ${CMAKE_OSX_SYSROOT}/System/iOSSupport/usr/include") - set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} "-target x86_64-arm64-apple-ios14.0-macabi -isystem ${CMAKE_OSX_SYSROOT}/System/iOSSupport/usr/include") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -target x86_64-arm64-apple-ios14.0-macabi -isystem ${CMAKE_OSX_SYSROOT}/System/iOSSupport/usr/include") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -target x86_64-arm64-apple-ios14.0-macabi -isystem ${CMAKE_OSX_SYSROOT}/System/iOSSupport/usr/include") set(CMAKE_THREAD_LIBS_INIT "-lpthread") set(CMAKE_HAVE_THREADS_LIBRARY 1) set(CMAKE_USE_WIN32_THREADS_INIT 0) @@ -202,10 +202,6 @@ set(HERMES_ENABLE_FUZZILLI OFF CACHE BOOL set(HERMES_ENABLE_TOOLS ON CACHE BOOL "Enable CLI tools") -# 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.") @@ -285,12 +281,9 @@ set(HERMES_ENABLE_UNICODE_REGEXP_PROPERTY_ESCAPES ON CACHE BOOL set(HERMES_ENABLE_TEST_SUITE ON CACHE BOOL "Enable the test suite") -set(HERMES_BUILD_APPLE_FRAMEWORK ON CACHE BOOL +set(HERMES_BUILD_APPLE_FRAMEWORK OFF CACHE BOOL "Whether to build the libhermes target as a framework bundle or dylib on Apple platforms") -set(HERMES_BUILD_APPLE_DSYM OFF CACHE BOOL - "Whether to build a DWARF debugging symbols bundle") - set(HERMES_BUILD_NODE_HERMES OFF CACHE BOOL "Whether to build node-hermes") set(HERMES_BUILD_LEAN_LIBHERMES OFF CACHE BOOL "Exclude the Hermes compiler from libhermes.") @@ -333,10 +326,6 @@ if(HERMES_CHECK_NATIVE_STACK) add_definitions(-DHERMES_CHECK_NATIVE_STACK) endif() -if(HERMES_BUILD_APPLE_DSYM) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -gdwarf") -endif() - if (HERMES_IS_MOBILE_BUILD) add_definitions(-DHERMES_IS_MOBILE_BUILD) endif() @@ -584,7 +573,8 @@ elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC") endif() # MSVC does not have strict aliasing so there is no need to support it. # Similar to GCC/Clang above, disable strict signed integer overflow. - append("/d2UndefIntOverflow-" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) + # TODO: Investigate disabling strict signed integer overflow for MSVC + # append("/d2UndefIntOverflow-" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) endif() # Export a JSON file with the compilation commands that external tools can use @@ -730,7 +720,13 @@ if(HERMES_IS_ANDROID) find_package(fbjni REQUIRED CONFIG) endif() -set(CMAKE_CXX_STANDARD 17) +if("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC") + # MSVC requires c++20, because of the use of designated initializers in the codebase. + set(CMAKE_CXX_STANDARD 20) +else() + set(CMAKE_CXX_STANDARD 17) +endif() + set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) diff --git a/android/intltest/java/com/facebook/hermes/test/CMakeLists.txt b/android/intltest/java/com/facebook/hermes/test/CMakeLists.txt index 6d3477432f0..4c234cd2025 100644 --- a/android/intltest/java/com/facebook/hermes/test/CMakeLists.txt +++ b/android/intltest/java/com/facebook/hermes/test/CMakeLists.txt @@ -24,7 +24,7 @@ if(HERMES_IS_ANDROID) add_hermes_library(jsijni SHARED ${jni_source_files} LINK_OBJLIBS - libhermes + hermesvm hermesapi compileJS fbjni::fbjni @@ -35,7 +35,7 @@ if(HERMES_IS_ANDROID) add_hermes_library(jsijniepi SHARED ${epi_source_files} LINK_OBJLIBS - libhermes + hermesvm hermesapi compileJS fbjni::fbjni diff --git a/cmake/modules/Hermes.cmake b/cmake/modules/Hermes.cmake index e54751b7b86..739f6293a94 100644 --- a/cmake/modules/Hermes.cmake +++ b/cmake/modules/Hermes.cmake @@ -127,9 +127,6 @@ function(add_hermes_library name) target_link_libraries(${name} ${ARG_LINK_OBJLIBS} ${ARG_LINK_LIBS}) 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 () else() # When asking to link an OBJECT library (the default), we create an OBJECT # library with a suffix _obj, which depends on all object libraries in @@ -151,9 +148,6 @@ function(add_hermes_library name) target_link_libraries(${name}_obj ${ARG_LINK_LIBS}) set_property(TARGET ${name}_obj PROPERTY POSITION_INDEPENDENT_CODE ON) hermes_update_compile_flags(${name}_obj) - if (HERMES_ENABLE_BITCODE) - target_compile_options(${name}_obj PUBLIC "-fembed-bitcode") - endif () add_library(${name} STATIC) target_link_libraries(${name} ${name}_obj ${ARG_LINK_OBJLIBS}) diff --git a/lib/BCGen/HBC/BytecodeStream.cpp b/lib/BCGen/HBC/BytecodeStream.cpp index 0950011d331..12697e2bb40 100644 --- a/lib/BCGen/HBC/BytecodeStream.cpp +++ b/lib/BCGen/HBC/BytecodeStream.cpp @@ -20,7 +20,7 @@ namespace hbc { namespace { class BytecodeSerializer { - friend void visitBytecodeSegmentsInOrder( + friend void hermes::hbc::visitBytecodeSegmentsInOrder( BytecodeSerializer &); /// Output Stream diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 794634f272c..1133004128c 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -173,6 +173,45 @@ target_link_libraries(hermesvmlean_a PUBLIC # CMake requires at least one file for the target, so create an empty file. add_library(hermesvm SHARED dummy.cpp) add_library(hermesvmlean SHARED dummy.cpp) + +if(APPLE AND HERMES_BUILD_APPLE_FRAMEWORK) + set_target_properties(hermesvm PROPERTIES + FRAMEWORK TRUE + VERSION ${PROJECT_VERSION} + SOVERSION ${PROJECT_VERSION} + FRAMEWORK_VERSION ${PROJECT_VERSION_MAJOR} + MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${PROJECT_VERSION} + MACOSX_FRAMEWORK_BUNDLE_VERSION ${PROJECT_VERSION} + MACOSX_FRAMEWORK_IDENTIFIER dev.hermesengine.${HERMES_APPLE_TARGET_PLATFORM} + ) + # Define the deployment target in the frameworks metadata + if(HERMES_APPLE_TARGET_PLATFORM MATCHES "iphone") + add_custom_command(TARGET hermesvm POST_BUILD + COMMAND /usr/libexec/PlistBuddy -c "Add :MinimumOSVersion string ${CMAKE_OSX_DEPLOYMENT_TARGET}" $/Info.plist + ) + elseif(HERMES_APPLE_TARGET_PLATFORM MATCHES "appletv") + add_custom_command(TARGET hermesvm POST_BUILD + COMMAND /usr/libexec/PlistBuddy -c "Add :MinimumOSVersion string ${CMAKE_OSX_DEPLOYMENT_TARGET}" $/Info.plist + ) + elseif(HERMES_APPLE_TARGET_PLATFORM MATCHES "catalyst") + add_custom_command(TARGET hermesvm POST_BUILD + COMMAND /usr/libexec/PlistBuddy -c "Add :LSMinimumSystemVersion string ${CMAKE_OSX_DEPLOYMENT_TARGET}" $/Resources/Info.plist + ) + elseif(HERMES_APPLE_TARGET_PLATFORM MATCHES "macos") + add_custom_command(TARGET hermesvm POST_BUILD + COMMAND /usr/libexec/PlistBuddy -c "Add :LSMinimumSystemVersion string ${CMAKE_OSX_DEPLOYMENT_TARGET}" $/Resources/Info.plist + ) + elseif(HERMES_APPLE_TARGET_PLATFORM MATCHES "xr") + if(CMAKE_VERSION VERSION_LESS 3.28.4) + message("VisionOS Simulator requires CMake version >= 3.28.4") + endif() + + add_custom_command(TARGET hermesvm POST_BUILD + COMMAND /usr/libexec/PlistBuddy -c "Add :MinimumOSVersion string ${CMAKE_OSX_DEPLOYMENT_TARGET}" $/Info.plist + ) + endif() +endif() + # Force the entire hermesvm_a library to be used by hermesvm. There is # no cross platform way to do this (force_load is for macOS). Once we upgrade # CMake 3.24, we can use the LINK_LIBRARY generator expression to do this. diff --git a/utils/build-apple-framework.sh b/utils/build-apple-framework.sh index ed1787f1f8b..647819aa484 100755 --- a/utils/build-apple-framework.sh +++ b/utils/build-apple-framework.sh @@ -53,13 +53,8 @@ function build_host_hermesc { # Utility function to configure an Apple framework function configure_apple_framework { - local build_cli_tools enable_bitcode + local build_cli_tools - if [[ $1 == appletvos || $1 == iphoneos || $1 == catalyst || $1 == visionos ]]; then - enable_bitcode="true" - else - enable_bitcode="false" - fi if [[ $1 == macosx ]]; then build_cli_tools="true" else @@ -75,9 +70,9 @@ function configure_apple_framework { -DHERMES_ENABLE_LIBFUZZER:BOOLEAN=false \ -DHERMES_ENABLE_FUZZILLI: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_CXX_FLAGS="-gdwarf" \ + -DCMAKE_C_FLAGS="-gdwarf" \ -DHERMES_ENABLE_TOOLS:BOOLEAN="$build_cli_tools" \ -DIMPORT_HERMESC:PATH="$PWD/build_host_hermesc/ImportHermesc.cmake" \ -DCMAKE_INSTALL_PREFIX:PATH=../destroot \