From e8c1e691ad1ec0d545b17007344ebc7621875aa4 Mon Sep 17 00:00:00 2001 From: Karol Suprynowicz Date: Mon, 14 Aug 2023 11:08:20 +0200 Subject: [PATCH 1/2] Align functions to avoid V8 asserts in debug builds --- CMakeLists.txt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b6ab39ae0b1..551889f23b8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -132,11 +132,12 @@ if( NOT WIN32 ) MESSAGE(STATUS "OVERTE_CPU_ARCHITECTURE: ${OVERTE_CPU_ARCHITECTURE}") endif() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OVERTE_OPTIMIZE_FLAGS}") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OVERTE_OPTIMIZE_FLAGS}") + # Function alignment is necessary for V8 + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OVERTE_OPTIMIZE_FLAGS} -falign-functions=16") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OVERTE_OPTIMIZE_FLAGS} -falign-functions=16") - set(ENV{CXXFLAGS} "$ENV{CXXFLAGS} ${OVERTE_OPTIMIZE_FLAGS}") - set(ENV{CFLAGS} "$ENV{CFLAGS} ${OVERTE_OPTIMIZE_FLAGS}") + set(ENV{CXXFLAGS} "$ENV{CXXFLAGS} ${OVERTE_OPTIMIZE_FLAGS} -falign-functions=16") + set(ENV{CFLAGS} "$ENV{CFLAGS} ${OVERTE_OPTIMIZE_FLAGS} -falign-functions=16") message($ENV{CXXFLAGS}) endif() From 70833f65913fba6524b14b51cc8d314f8be85550 Mon Sep 17 00:00:00 2001 From: Karol Suprynowicz Date: Fri, 18 Aug 2023 13:17:45 +0200 Subject: [PATCH 2/2] Chenged -falign-functions to use architecture-specific value --- CMakeLists.txt | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 551889f23b8..33e30fa6e43 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -132,12 +132,14 @@ if( NOT WIN32 ) MESSAGE(STATUS "OVERTE_CPU_ARCHITECTURE: ${OVERTE_CPU_ARCHITECTURE}") endif() - # Function alignment is necessary for V8 - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OVERTE_OPTIMIZE_FLAGS} -falign-functions=16") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OVERTE_OPTIMIZE_FLAGS} -falign-functions=16") - - set(ENV{CXXFLAGS} "$ENV{CXXFLAGS} ${OVERTE_OPTIMIZE_FLAGS} -falign-functions=16") - set(ENV{CFLAGS} "$ENV{CFLAGS} ${OVERTE_OPTIMIZE_FLAGS} -falign-functions=16") + # Function alignment is necessary for V8. + # SetAlignedPointerInInternalField requires at least 2 byte alignment and -falign-functions will set alignment + # to machine specific value which should be greater than 2. + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OVERTE_OPTIMIZE_FLAGS} -falign-functions") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OVERTE_OPTIMIZE_FLAGS} -falign-functions") + + set(ENV{CXXFLAGS} "$ENV{CXXFLAGS} ${OVERTE_OPTIMIZE_FLAGS} -falign-functions") + set(ENV{CFLAGS} "$ENV{CFLAGS} ${OVERTE_OPTIMIZE_FLAGS} -falign-functions") message($ENV{CXXFLAGS}) endif()