Skip to content

Commit 9cbe295

Browse files
dcodeIOkripken
authored andcommitted
Fix error when building wasm-opt.js with latest-fastcomp (#2494)
With #2483 merged, emcc hits the following warning when attempting to compile wasm-opt to JS with Emsdk:latest-fastcomp: shared:WARNING: for wasm there is no need to set ELIMINATE_DUPLICATE_FUNCTIONS, the binaryen optimizer does it automatically shared:ERROR: treating warnings as errors (-Werror) Appears this happens because ELIMINATE_DUPLICATE_FUNCTIONS is set for all targets when using fastcomp, even though only binaryen_js uses WASM=0. So this PR moves it into the binaryen_js target.
1 parent b7f75ab commit 9cbe295

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

CMakeLists.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,7 @@ IF (EMSCRIPTEN)
185185
ADD_COMPILE_FLAG("-Wno-almost-asm")
186186
# check for fastcomp by the clang version, which is stuck in fastcomp way
187187
# 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()
188+
IF (NOT ${CMAKE_CXX_COMPILER_VERSION} STREQUAL "6.0.1")
191189
# in opt builds, LTO helps so much (>20%) it's worth slow compile times
192190
ADD_NONDEBUG_COMPILE_FLAG("-s WASM_OBJECT_FILES=0")
193191
ENDIF()
@@ -343,6 +341,10 @@ IF (EMSCRIPTEN)
343341
# note that SHELL: is needed as otherwise cmake will coalesce -s link flags
344342
# in an incorrect way for emscripten
345343
TARGET_LINK_LIBRARIES(binaryen_js "-s WASM=0")
344+
IF (${CMAKE_CXX_COMPILER_VERSION} STREQUAL "6.0.1")
345+
# only valid with fastcomp and WASM=0
346+
TARGET_LINK_LIBRARIES(binaryen_js "-s ELIMINATE_DUPLICATE_FUNCTIONS=1")
347+
ENDIF()
346348
TARGET_LINK_LIBRARIES(binaryen_js "-s WASM_ASYNC_COMPILATION=0")
347349
TARGET_LINK_LIBRARIES(binaryen_js "-s MODULARIZE_INSTANCE=1")
348350
TARGET_LINK_LIBRARIES(binaryen_js "-s NO_FILESYSTEM=0")

0 commit comments

Comments
 (0)