@@ -31,7 +31,7 @@ endif()
31
31
# more useful error reports from users.
32
32
option (BYN_ENABLE_ASSERTIONS "Enable assertions" ON )
33
33
34
- option (BYN_ENABLE_LTO "Build with LTO" Off )
34
+ option (BYN_ENABLE_LTO "Build with LTO" ${EMSCRIPTEN} )
35
35
36
36
# Turn this off to avoid the dependency on gtest.
37
37
option (BUILD_TESTS "Build GTest-based tests" ON )
@@ -341,8 +341,10 @@ if(EMSCRIPTEN)
341
341
# On Node.js, make the tools immediately usable.
342
342
add_link_flag("-sNODERAWFS" )
343
343
endif ()
344
+ if (BYN_ENABLE_LTO)
344
345
# in opt builds, LTO helps so much (>20%) it's worth slow compile times
345
346
add_nondebug_compile_flag("-flto" )
347
+ endif ()
346
348
if (EMSCRIPTEN_ENABLE_WASM64)
347
349
add_compile_flag("-sMEMORY64 -Wno-experimental" )
348
350
add_link_flag("-sMEMORY64" )
@@ -523,7 +525,9 @@ if(EMSCRIPTEN)
523
525
target_link_libraries (binaryen_wasm PRIVATE optimized "--closure=1" )
524
526
# TODO: Fix closure warnings! (#5062)
525
527
target_link_libraries (binaryen_wasm PRIVATE optimized "-Wno-error=closure" )
526
- target_link_libraries (binaryen_wasm PRIVATE optimized "-flto" )
528
+ if (BYN_ENABLE_LTO)
529
+ target_link_libraries (binaryen_wasm PRIVATE optimized "-flto" )
530
+ endif ()
527
531
target_link_libraries (binaryen_wasm PRIVATE debug "--profiling" )
528
532
# Avoid catching exit as that can confuse error reporting in Node,
529
533
# see https://github.com/emscripten-core/emscripten/issues/17228
@@ -575,7 +579,9 @@ if(EMSCRIPTEN)
575
579
endif ()
576
580
# TODO: Fix closure warnings! (#5062)
577
581
target_link_libraries (binaryen_js PRIVATE optimized "-Wno-error=closure" )
578
- target_link_libraries (binaryen_js PRIVATE optimized "-flto" )
582
+ if (BYN_ENABLE_LTO)
583
+ target_link_libraries (binaryen_js PRIVATE optimized "-flto" )
584
+ endif ()
579
585
target_link_libraries (binaryen_js PRIVATE debug "--profiling" )
580
586
target_link_libraries (binaryen_js PRIVATE debug "-sASSERTIONS" )
581
587
# Avoid catching exit as that can confuse error reporting in Node,
0 commit comments