Skip to content

Commit 31eac76

Browse files
authored
Apply old fastcomp flags, reverting a large 30% size regression (#2483)
And use LTO in upstream opt builds, which improves code size by >20%.
1 parent 0c2b5b4 commit 31eac76

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,17 @@ IF (EMSCRIPTEN)
180180
ADD_LINK_FLAG("-s DISABLE_EXCEPTION_CATCHING=0")
181181
# make the tools immediately usable on Node.js
182182
ADD_LINK_FLAG("-s NODERAWFS")
183+
# this can be moved into the fastcomp section once upstream ignores this flag,
184+
# https://github.com/emscripten-core/emscripten/pull/9897
185+
ADD_COMPILE_FLAG("-Wno-almost-asm")
186+
# check for fastcomp by the clang version, which is stuck in fastcomp way
187+
# back in the past
188+
IF (${CMAKE_CXX_COMPILER_VERSION} STREQUAL "6.0.1")
189+
ADD_LINK_FLAG("-s ELIMINATE_DUPLICATE_FUNCTIONS=1")
190+
ELSE()
191+
# in opt builds, LTO helps so much (>20%) it's worth slow compile times
192+
ADD_NONDEBUG_COMPILE_FLAG("-s WASM_OBJECT_FILES=0")
193+
ENDIF()
183194
ENDIF()
184195

185196
# clang doesn't print colored diagnostics when invoked from Ninja
@@ -339,6 +350,7 @@ IF (EMSCRIPTEN)
339350
TARGET_LINK_LIBRARIES(binaryen_js "-s EXPORT_NAME=Binaryen")
340351
TARGET_LINK_LIBRARIES(binaryen_js "--post-js ${CMAKE_CURRENT_SOURCE_DIR}/src/js/binaryen.js-post.js")
341352
TARGET_LINK_LIBRARIES(binaryen_js optimized "--closure 1")
353+
TARGET_LINK_LIBRARIES(binaryen_js optimized "--llvm-lto 1")
342354
TARGET_LINK_LIBRARIES(binaryen_js debug "--profiling")
343355
SET_PROPERTY(TARGET binaryen_js PROPERTY CXX_STANDARD 14)
344356
SET_PROPERTY(TARGET binaryen_js PROPERTY CXX_STANDARD_REQUIRED ON)

0 commit comments

Comments
 (0)