Index: README.md
===================================================================
--- README.md	(revision 10620)
+++ README.md	(working copy)
@@ -179,8 +179,8 @@
 
      -  emscripten (on Unix-like systems):
 
-        libopenmpt has been tested and verified to work with emscripten 1.31 or
-        later (earlier versions might or might not work).
+        libopenmpt has been tested and verified to work with emscripten 1.38.1
+        or later (earlier versions might or might not work).
 
         Run:
 
@@ -187,7 +187,7 @@
             make CONFIG=emscripten
 
         Running the test suite on the command line is also supported by using
-        node.js. Version 0.10.25 or greater has been tested. Earlier versions
+        node.js. Version 8.9.1 or greater has been tested. Earlier versions
         might or might not work. Depending on how your distribution calls the
         `node.js` binary, you might have to edit
         `build/make/config-emscripten.mk`.
Index: build/make/config-emscripten.mk
===================================================================
--- build/make/config-emscripten.mk	(revision 10620)
+++ build/make/config-emscripten.mk	(working copy)
@@ -4,7 +4,7 @@
 LD  = em++
 AR  = emar
 
-EMSCRIPTEN_TARGET?=asmjs
+EMSCRIPTEN_TARGET?=default
 
 ifneq ($(STDCXX),)
 CXXFLAGS_STDCXX = -std=$(STDCXX)
@@ -25,47 +25,47 @@
 CXXFLAGS += $(CXXFLAGS_STDCXX)
 CFLAGS += $(CFLAGS_STDC)
 
-ifeq ($(EMSCRIPTEN_TARGET),js)
-
-CPPFLAGS += 
-CXXFLAGS += -fPIC -O2 -s ASM_JS=2 -s DISABLE_EXCEPTION_CATCHING=0 -s PRECISE_F32=1 -s ERROR_ON_UNDEFINED_SYMBOLS=1 -ffast-math 
-CFLAGS   += -fPIC -O2 -s ASM_JS=2 -s DISABLE_EXCEPTION_CATCHING=0 -s PRECISE_F32=1 -s ERROR_ON_UNDEFINED_SYMBOLS=1 -ffast-math -fno-strict-aliasing 
-LDFLAGS  += -O2 -s ASM_JS=2 -s DISABLE_EXCEPTION_CATCHING=0 -s PRECISE_F32=1 -s ERROR_ON_UNDEFINED_SYMBOLS=1 -s EXPORT_NAME="'libopenmpt'"
-LDLIBS   += 
+CPPFLAGS +=
+CXXFLAGS += -fPIC
+CFLAGS   += -fPIC
+LDFLAGS  +=
+LDLIBS   +=
 ARFLAGS  := rcs
 
-# allow growing heap (might be slower, especially with V8 (as used by Chrome))
-#LDFLAGS += -s ALLOW_MEMORY_GROWTH=1
-# limit memory to 64MB, faster but loading modules bigger than about 16MB will not work
-#LDFLAGS += -s TOTAL_MEMORY=67108864
+ifeq ($(EMSCRIPTEN_TARGET),default)
+# emits whatever is emscripten's default, currently (1.38.8) this is native-wasm with a polyfill.
+CPPFLAGS += -DMPT_BUILD_WASM
+CXXFLAGS += -Os
+CFLAGS   += -Os
+LDFLAGS  += -Os
 
-LDFLAGS += -s ALLOW_MEMORY_GROWTH=1
+else ifeq ($(EMSCRIPTEN_TARGET),wasm)
+# emits native wasm AND an emulator for running wasm in asmjs/js with full wasm optimizations.
+CPPFLAGS += -DMPT_BUILD_WASM
+CXXFLAGS += -Os -s WASM=1 -s BINARYEN_METHOD='native-wasm'
+CFLAGS   += -Os -s WASM=1 -s BINARYEN_METHOD='native-wasm'
+LDFLAGS  += -Os -s WASM=1 -s BINARYEN_METHOD='native-wasm'
 
 else ifeq ($(EMSCRIPTEN_TARGET),asmjs)
+# emits only asmjs
+CPPFLAGS += -DMPT_BUILD_ASMJS
+CXXFLAGS += -O2 -s WASM=0 -s ASM_JS=1
+CFLAGS   += -O2 -s WASM=0 -s ASM_JS=1
+LDFLAGS  += -O2 -s WASM=0 -s ASM_JS=1
 
-CPPFLAGS += 
-CXXFLAGS += -fPIC -O2 -s DISABLE_EXCEPTION_CATCHING=0 -s PRECISE_F32=1 -s ERROR_ON_UNDEFINED_SYMBOLS=1 -ffast-math 
-CFLAGS   += -fPIC -O2 -s DISABLE_EXCEPTION_CATCHING=0 -s PRECISE_F32=1 -s ERROR_ON_UNDEFINED_SYMBOLS=1 -ffast-math -fno-strict-aliasing 
-LDFLAGS  += -O2 -s DISABLE_EXCEPTION_CATCHING=0 -s PRECISE_F32=1 -s ERROR_ON_UNDEFINED_SYMBOLS=1 -s EXPORT_NAME="'libopenmpt'"
-LDLIBS   += 
-ARFLAGS  := rcs
+else ifeq ($(EMSCRIPTEN_TARGET),js)
+# emits only plain javascript with plain javascript focused optimizations.
+CPPFLAGS += -DMPT_BUILD_ASMJS
+CXXFLAGS += -O2 -s WASM=0 -s ASM_JS=2
+CFLAGS   += -O2 -s WASM=0 -s ASM_JS=2
+LDFLAGS  += -O2 -s WASM=0 -s ASM_JS=2
 
-# allow growing heap (might be slower, especially with V8 (as used by Chrome))
-#LDFLAGS += -s ALLOW_MEMORY_GROWTH=1
-# limit memory to 64MB, faster but loading modules bigger than about 16MB will not work
-#LDFLAGS += -s TOTAL_MEMORY=67108864
+endif
 
-LDFLAGS += -s ALLOW_MEMORY_GROWTH=1
+CXXFLAGS += -s DISABLE_EXCEPTION_CATCHING=0 -s ERROR_ON_UNDEFINED_SYMBOLS=1 -ffast-math
+CFLAGS   += -s DISABLE_EXCEPTION_CATCHING=0 -s ERROR_ON_UNDEFINED_SYMBOLS=1 -ffast-math -fno-strict-aliasing
+LDFLAGS  += -s DISABLE_EXCEPTION_CATCHING=0 -s ERROR_ON_UNDEFINED_SYMBOLS=1 -s EXPORT_NAME="'libopenmpt'"
 
-else ifeq ($(EMSCRIPTEN_TARGET),wasm)
-
-CPPFLAGS += -DMPT_BUILD_WASM
-CXXFLAGS += -fPIC -Os -s WASM=1 -s DISABLE_EXCEPTION_CATCHING=0 -s ERROR_ON_UNDEFINED_SYMBOLS=1 -ffast-math 
-CFLAGS   += -fPIC -Os -s WASM=1 -s DISABLE_EXCEPTION_CATCHING=0 -s ERROR_ON_UNDEFINED_SYMBOLS=1 -ffast-math -fno-strict-aliasing 
-LDFLAGS  += -Os -s WASM=1 -s DISABLE_EXCEPTION_CATCHING=0 -s ERROR_ON_UNDEFINED_SYMBOLS=1 -s EXPORT_NAME="'libopenmpt'"
-LDLIBS   += 
-ARFLAGS  := rcs
-
 # allow growing heap (might be slower, especially with V8 (as used by Chrome))
 #LDFLAGS += -s ALLOW_MEMORY_GROWTH=1
 # limit memory to 64MB, faster but loading modules bigger than about 16MB will not work
@@ -73,8 +73,6 @@
 
 LDFLAGS += -s ALLOW_MEMORY_GROWTH=1
 
-endif
-
 CFLAGS_SILENT += -Wno-unused-parameter -Wno-unused-function -Wno-cast-qual
 
 CXXFLAGS_WARNINGS += -Wmissing-declarations
@@ -82,23 +80,11 @@
 
 REQUIRES_RUNPREFIX=1
 
-ifeq ($(EMSCRIPTEN_TARGET),wasm)
-
-EXESUFFIX=.html
-SOSUFFIX=.wasm
-SO_LDFLAGS=-s SIDE_MODULE=1
-BIN_LDFLAGS=-s SIDE_MODULE=0
-TEST_LDFLAGS=-s SIDE_MODULE=0 --emrun
-
-else
-
 EXESUFFIX=.js
 SOSUFFIX=.js
 RUNPREFIX=nodejs 
 TEST_LDFLAGS= --pre-js build/make/test-pre.js 
 
-endif
-
 DYNLINK=0
 SHARED_LIB=1
 STATIC_LIB=0
Index: common/CompilerDetect.h
===================================================================
--- common/CompilerDetect.h	(revision 10620)
+++ common/CompilerDetect.h	(working copy)
@@ -193,14 +193,12 @@
 	#define MPT_OS_EMSCRIPTEN 1
 	#if defined(__EMSCRIPTEN_major__) && defined(__EMSCRIPTEN_minor__)
 		#if (__EMSCRIPTEN_major__ > 1)
-			#define MPT_OS_EMSCRIPTEN_ANCIENT 0
-		#elif (__EMSCRIPTEN_major__ == 1) && (__EMSCRIPTEN_minor__ >= 36)
-			#define MPT_OS_EMSCRIPTEN_ANCIENT 0
+			// ok 
+		#elif (__EMSCRIPTEN_major__ == 1) && (__EMSCRIPTEN_minor__ >= 38)
+			// ok 		
 		#else
-			#define MPT_OS_EMSCRIPTEN_ANCIENT 1
+			#error "Emscripten >= 1.38 is required."
 		#endif
-	#else
-		#define MPT_OS_EMSCRIPTEN_ANCIENT 1
 	#endif
 #elif defined(_WIN32)
 	#define MPT_OS_WINDOWS 1
Index: common/mptBaseUtils.h
===================================================================
--- common/mptBaseUtils.h	(revision 10620)
+++ common/mptBaseUtils.h	(working copy)
@@ -581,13 +581,7 @@
 {
 
 	// C++11 std::round
-#if (MPT_OS_EMSCRIPTEN && MPT_OS_EMSCRIPTEN_ANCIENT)
-	// Certain emscripten versions and/or combinations with nodejs (at least the following combination: emscripten 1.34.8, clang 3.7.0, nodejs 0.10.38) fail assert(std::round(1.5)==2.0). The work-around always works.
-	inline double round(double val) {if(val >= 0.0) return std::floor(val + 0.5); else return std::ceil(val - 0.5);}
-	inline float round(float val) {if(val >= 0.0f) return std::floor(val + 0.5f); else return std::ceil(val - 0.5f);}
-#else
 	using std::round;
-#endif
 
 	// Rounds given double value to nearest integer value of type T.
 	// Out-of-range values are saturated to the specified integer type's limits.
Index: libopenmpt/dox/changelog.md
===================================================================
--- libopenmpt/dox/changelog.md	(revision 10620)
+++ libopenmpt/dox/changelog.md	(working copy)
@@ -56,6 +56,8 @@
  *  [**Regression**] Support for Clang 3.4, 3.5 has been removed.
  *  [**Regression**] Building with Android NDK older than NDK r16b is not
     supported any more.
+ *  [**Regression**] Support for Emscripten versions older than 1.38.1 has been
+    removed.
  *  [**Regression**] Support for libmpg123 older than 1.14.0 has been removed.
  *  [**Regression**] Using MediaFoundation to decode MP3 samples is no longer
     supported. Use libmpg123 or minimp3 instead.
Index: libopenmpt/dox/dependencies.md
===================================================================
--- libopenmpt/dox/dependencies.md	(revision 10620)
+++ libopenmpt/dox/dependencies.md	(working copy)
@@ -15,7 +15,7 @@
      *  **MinGW-W64 4.8** or higher (it is recommended to preferably use
         posix threading model as opposed to win32 threading model, or at least
         have mingw-std-threads available otherwise)
-     *  **emscripten 1.31** or higher
+     *  **emscripten 1.38.1** or higher
      *  any other **C++11 compliant** compiler (full standard compliant mode is
         known to work with GCC >= 5.1 and Clang)
         
Index: test/test.cpp
===================================================================
--- test/test.cpp	(revision 10620)
+++ test/test.cpp	(working copy)
@@ -685,12 +685,7 @@
 	VERIFY_EQUAL(mpt::fmt::flt(6.12345, 3), "6.12");
 	VERIFY_EQUAL(mpt::fmt::fix(6.12345, 3), "6.123");
 	VERIFY_EQUAL(mpt::fmt::flt(6.12345, 4), "6.123");
-	#if !(MPT_OS_EMSCRIPTEN && MPT_OS_EMSCRIPTEN_ANCIENT)
 	VERIFY_EQUAL(mpt::fmt::fix(6.12345, 4), "6.1235");
-	#else
-	// emscripten(1.21)/nodejs(v0.10.25) print 6.1234 instead of 6.1235 for unknown reasons.
-	// As this test case is not fatal, ignore it for now in order to make the test cases pass.
-	#endif
 
 #if MPT_WSTRING_FORMAT
 	VERIFY_EQUAL(mpt::wfmt::flt(6.12345, 3), L"6.12");
