changeset 3599:e01900f913e7

fix duplicate symbol "jaritab" in wasm
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 07 Jan 2020 10:53:32 +0100
parents f2df51bff2fd
children 4066998150ef
files Resources/CMake/Compiler.cmake Resources/CMake/DcmtkConfiguration.cmake
diffstat 2 files changed, 13 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/Resources/CMake/Compiler.cmake	Mon Jan 06 19:57:11 2020 +0100
+++ b/Resources/CMake/Compiler.cmake	Tue Jan 07 10:53:32 2020 +0100
@@ -199,12 +199,15 @@
   # zero (and similar conditions like integer overflows) are
   # encountered: The "clamp" mode avoids throwing errors, as they
   # cannot be properly catched by "try {} catch (...)" constructions.
-  if (EMSCRIPTEN_SET_LLVM_WASM_BACKEND)
-    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s EXTRA_EXPORTED_RUNTIME_METHODS='[\"ccall\", \"cwrap\"]'")
-  else()
-    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s EXTRA_EXPORTED_RUNTIME_METHODS='[\"ccall\", \"cwrap\"]' -s BINARYEN_TRAP_MODE='\"clamp\"'")
+  # Setting this option to "ON" fixes error: "shared:ERROR:
+  # BINARYEN_TRAP_MODE is not supported by the LLVM wasm backend" if
+  # using the "upstream" backend of Emscripten.
+  if (NOT EMSCRIPTEN_SET_LLVM_WASM_BACKEND)
+    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s BINARYEN_TRAP_MODE='\"clamp\"'")
   endif()
 
+  set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s EXTRA_EXPORTED_RUNTIME_METHODS='[\"ccall\", \"cwrap\"]'")
+  
 elseif (CMAKE_SYSTEM_NAME STREQUAL "Android")
 
 else()
--- a/Resources/CMake/DcmtkConfiguration.cmake	Mon Jan 06 19:57:11 2020 +0100
+++ b/Resources/CMake/DcmtkConfiguration.cmake	Tue Jan 07 10:53:32 2020 +0100
@@ -49,6 +49,12 @@
     list(REMOVE_ITEM DCMTK_SOURCES 
       ${DCMTK_SOURCES_DIR}/dcmjpeg/libsrc/ddpiimpl.cc
 
+      # Solves linking problem in WebAssembly: "wasm-ld: error:
+      # duplicate symbol: jaritab" (modification in Orthanc 1.5.9)
+      ${DCMTK_SOURCES_DIR}/dcmjpeg/libijg8/jaricom.c
+      ${DCMTK_SOURCES_DIR}/dcmjpeg/libijg12/jaricom.c
+      ${DCMTK_SOURCES_DIR}/dcmjpeg/libijg24/jaricom.c
+
       # Disable support for encoding JPEG (modification in Orthanc 1.0.1)
       ${DCMTK_SOURCES_DIR}/dcmjpeg/libsrc/djcodece.cc
       ${DCMTK_SOURCES_DIR}/dcmjpeg/libsrc/djencsv1.cc