From c9fc444c84b46e0d38f7a4d152e1e916285b8f3e Mon Sep 17 00:00:00 2001 From: Yahweasel Date: Sat, 28 Sep 2024 11:16:39 -0400 Subject: [PATCH] Getting rid of wasm64, which didn't work --- Makefile | 19 +++---------------- Makefile.m4 | 8 +++----- mk/emfiberthreads.mk | 8 +++----- mk/ffmpeg.mk | 8 ++++---- mk/ffmpeg.mk.m4 | 4 ++-- mk/libvpx.mk | 4 +--- post.in.js | 21 +++++++-------------- tools/adjust-sourcemap.js | 4 ---- 8 files changed, 23 insertions(+), 53 deletions(-) diff --git a/Makefile b/Makefile index 710293c9..3989f9a1 100644 --- a/Makefile +++ b/Makefile @@ -28,8 +28,7 @@ EFLAGS=\ -s ASYNCIFY \ -s "ASYNCIFY_IMPORTS=['libavjs_wait_reader']" \ -s INITIAL_MEMORY=25165824 \ - -s ALLOW_MEMORY_GROWTH=1 \ - -s MEMORY64=2 + -s ALLOW_MEMORY_GROWTH=1 # For debugging: #EFLAGS+=\ @@ -178,7 +177,6 @@ dist/libav-$(LIBAVJS_VERSION)-%.asm.js: build/ffmpeg-$(FFMPEG_VERSION)/build-bas if [ -e $(@).d/libav-$(LIBAVJS_VERSION)-$(*).asm.wasm.map ] ; then \ ./tools/adjust-sourcemap.js $(@).d/libav-$(LIBAVJS_VERSION)-$(*).asm.wasm.map \ ffmpeg $(FFMPEG_VERSION) \ - emfiberthreads $(EMFT_VERSION) \ libvpx $(LIBVPX_VERSION) \ libaom $(LIBAOM_VERSION); \ fi || ( rm -f $(@) ; false ) @@ -248,7 +246,6 @@ dist/libav-$(LIBAVJS_VERSION)-%.asm.mjs: build/ffmpeg-$(FFMPEG_VERSION)/build-ba if [ -e $(@).d/libav-$(LIBAVJS_VERSION)-$(*).asm.wasm.map ] ; then \ ./tools/adjust-sourcemap.js $(@).d/libav-$(LIBAVJS_VERSION)-$(*).asm.wasm.map \ ffmpeg $(FFMPEG_VERSION) \ - emfiberthreads $(EMFT_VERSION) \ libvpx $(LIBVPX_VERSION) \ libaom $(LIBAOM_VERSION); \ fi || ( rm -f $(@) ; false ) @@ -318,7 +315,6 @@ dist/libav-$(LIBAVJS_VERSION)-%.dbg.asm.js: build/ffmpeg-$(FFMPEG_VERSION)/build if [ -e $(@).d/libav-$(LIBAVJS_VERSION)-$(*).dbg.asm.wasm.map ] ; then \ ./tools/adjust-sourcemap.js $(@).d/libav-$(LIBAVJS_VERSION)-$(*).dbg.asm.wasm.map \ ffmpeg $(FFMPEG_VERSION) \ - emfiberthreads $(EMFT_VERSION) \ libvpx $(LIBVPX_VERSION) \ libaom $(LIBAOM_VERSION); \ fi || ( rm -f $(@) ; false ) @@ -388,7 +384,6 @@ dist/libav-$(LIBAVJS_VERSION)-%.dbg.asm.mjs: build/ffmpeg-$(FFMPEG_VERSION)/buil if [ -e $(@).d/libav-$(LIBAVJS_VERSION)-$(*).dbg.asm.wasm.map ] ; then \ ./tools/adjust-sourcemap.js $(@).d/libav-$(LIBAVJS_VERSION)-$(*).dbg.asm.wasm.map \ ffmpeg $(FFMPEG_VERSION) \ - emfiberthreads $(EMFT_VERSION) \ libvpx $(LIBVPX_VERSION) \ libaom $(LIBAOM_VERSION); \ fi || ( rm -f $(@) ; false ) @@ -459,7 +454,6 @@ dist/libav-$(LIBAVJS_VERSION)-%.wasm.js: build/ffmpeg-$(FFMPEG_VERSION)/build-ba if [ -e $(@).d/libav-$(LIBAVJS_VERSION)-$(*).wasm.wasm.map ] ; then \ ./tools/adjust-sourcemap.js $(@).d/libav-$(LIBAVJS_VERSION)-$(*).wasm.wasm.map \ ffmpeg $(FFMPEG_VERSION) \ - emfiberthreads $(EMFT_VERSION) \ libvpx $(LIBVPX_VERSION) \ libaom $(LIBAOM_VERSION); \ fi || ( rm -f $(@) ; false ) @@ -529,7 +523,6 @@ dist/libav-$(LIBAVJS_VERSION)-%.wasm.mjs: build/ffmpeg-$(FFMPEG_VERSION)/build-b if [ -e $(@).d/libav-$(LIBAVJS_VERSION)-$(*).wasm.wasm.map ] ; then \ ./tools/adjust-sourcemap.js $(@).d/libav-$(LIBAVJS_VERSION)-$(*).wasm.wasm.map \ ffmpeg $(FFMPEG_VERSION) \ - emfiberthreads $(EMFT_VERSION) \ libvpx $(LIBVPX_VERSION) \ libaom $(LIBAOM_VERSION); \ fi || ( rm -f $(@) ; false ) @@ -599,7 +592,6 @@ dist/libav-$(LIBAVJS_VERSION)-%.dbg.wasm.js: build/ffmpeg-$(FFMPEG_VERSION)/buil if [ -e $(@).d/libav-$(LIBAVJS_VERSION)-$(*).dbg.wasm.wasm.map ] ; then \ ./tools/adjust-sourcemap.js $(@).d/libav-$(LIBAVJS_VERSION)-$(*).dbg.wasm.wasm.map \ ffmpeg $(FFMPEG_VERSION) \ - emfiberthreads $(EMFT_VERSION) \ libvpx $(LIBVPX_VERSION) \ libaom $(LIBAOM_VERSION); \ fi || ( rm -f $(@) ; false ) @@ -669,7 +661,6 @@ dist/libav-$(LIBAVJS_VERSION)-%.dbg.wasm.mjs: build/ffmpeg-$(FFMPEG_VERSION)/bui if [ -e $(@).d/libav-$(LIBAVJS_VERSION)-$(*).dbg.wasm.wasm.map ] ; then \ ./tools/adjust-sourcemap.js $(@).d/libav-$(LIBAVJS_VERSION)-$(*).dbg.wasm.wasm.map \ ffmpeg $(FFMPEG_VERSION) \ - emfiberthreads $(EMFT_VERSION) \ libvpx $(LIBVPX_VERSION) \ libaom $(LIBAOM_VERSION); \ fi || ( rm -f $(@) ; false ) @@ -740,7 +731,6 @@ dist/libav-$(LIBAVJS_VERSION)-%.thr.js: build/ffmpeg-$(FFMPEG_VERSION)/build-thr if [ -e $(@).d/libav-$(LIBAVJS_VERSION)-$(*).thr.wasm.map ] ; then \ ./tools/adjust-sourcemap.js $(@).d/libav-$(LIBAVJS_VERSION)-$(*).thr.wasm.map \ ffmpeg $(FFMPEG_VERSION) \ - emfiberthreads $(EMFT_VERSION) \ libvpx $(LIBVPX_VERSION) \ libaom $(LIBAOM_VERSION); \ fi || ( rm -f $(@) ; false ) @@ -810,7 +800,6 @@ dist/libav-$(LIBAVJS_VERSION)-%.thr.mjs: build/ffmpeg-$(FFMPEG_VERSION)/build-th if [ -e $(@).d/libav-$(LIBAVJS_VERSION)-$(*).thr.wasm.map ] ; then \ ./tools/adjust-sourcemap.js $(@).d/libav-$(LIBAVJS_VERSION)-$(*).thr.wasm.map \ ffmpeg $(FFMPEG_VERSION) \ - emfiberthreads $(EMFT_VERSION) \ libvpx $(LIBVPX_VERSION) \ libaom $(LIBAOM_VERSION); \ fi || ( rm -f $(@) ; false ) @@ -880,7 +869,6 @@ dist/libav-$(LIBAVJS_VERSION)-%.dbg.thr.js: build/ffmpeg-$(FFMPEG_VERSION)/build if [ -e $(@).d/libav-$(LIBAVJS_VERSION)-$(*).dbg.thr.wasm.map ] ; then \ ./tools/adjust-sourcemap.js $(@).d/libav-$(LIBAVJS_VERSION)-$(*).dbg.thr.wasm.map \ ffmpeg $(FFMPEG_VERSION) \ - emfiberthreads $(EMFT_VERSION) \ libvpx $(LIBVPX_VERSION) \ libaom $(LIBAOM_VERSION); \ fi || ( rm -f $(@) ; false ) @@ -950,7 +938,6 @@ dist/libav-$(LIBAVJS_VERSION)-%.dbg.thr.mjs: build/ffmpeg-$(FFMPEG_VERSION)/buil if [ -e $(@).d/libav-$(LIBAVJS_VERSION)-$(*).dbg.thr.wasm.map ] ; then \ ./tools/adjust-sourcemap.js $(@).d/libav-$(LIBAVJS_VERSION)-$(*).dbg.thr.wasm.map \ ffmpeg $(FFMPEG_VERSION) \ - emfiberthreads $(EMFT_VERSION) \ libvpx $(LIBVPX_VERSION) \ libaom $(LIBAOM_VERSION); \ fi || ( rm -f $(@) ; false ) @@ -981,11 +968,11 @@ node_modules/.bin/terser: # Targets build/inst/base/cflags.txt: mkdir -p build/inst/base - echo -gsource-map -sMEMORY64=2 -Wno-experimental > $@ + echo -gsource-map > $@ build/inst/thr/cflags.txt: mkdir -p build/inst/thr - echo $(THRFLAGS) -gsource-map -sMEMORY64=2 -Wno-experimental > $@ + echo $(THRFLAGS) -gsource-map > $@ RELEASE_VARIANTS=\ default default-cli opus opus-af flac flac-af wav wav-af obsolete webm \ diff --git a/Makefile.m4 b/Makefile.m4 index 6ee50c9a..890e0719 100644 --- a/Makefile.m4 +++ b/Makefile.m4 @@ -28,8 +28,7 @@ EFLAGS=\ -s ASYNCIFY \ -s "ASYNCIFY_IMPORTS=['libavjs_wait_reader']" \ -s INITIAL_MEMORY=25165824 \ - -s ALLOW_MEMORY_GROWTH=1 \ - -s MEMORY64=2 + -s ALLOW_MEMORY_GROWTH=1 # For debugging: #EFLAGS+=\ @@ -124,7 +123,6 @@ dist/libav-$(LIBAVJS_VERSION)-%.$2$1.$5: build/ffmpeg-$(FFMPEG_VERSION)/build-$3 if [ -e $(@).d/libav-$(LIBAVJS_VERSION)-$(*).$2$1.wasm.map ] ; then \ ./tools/adjust-sourcemap.js $(@).d/libav-$(LIBAVJS_VERSION)-$(*).$2$1.wasm.map \ ffmpeg $(FFMPEG_VERSION) \ - emfiberthreads $(EMFT_VERSION) \ libvpx $(LIBVPX_VERSION) \ libaom $(LIBAOM_VERSION); \ fi || ( rm -f $(@) ; false ) @@ -171,11 +169,11 @@ node_modules/.bin/terser: # Targets build/inst/base/cflags.txt: mkdir -p build/inst/base - echo -gsource-map -sMEMORY64=2 -Wno-experimental > $@ + echo -gsource-map > $@ build/inst/thr/cflags.txt: mkdir -p build/inst/thr - echo $(THRFLAGS) -gsource-map -sMEMORY64=2 -Wno-experimental > $@ + echo $(THRFLAGS) -gsource-map > $@ RELEASE_VARIANTS=\ default default-cli opus opus-af flac flac-af wav wav-af obsolete webm \ diff --git a/mk/emfiberthreads.mk b/mk/emfiberthreads.mk index 7786cb4a..771c25ae 100644 --- a/mk/emfiberthreads.mk +++ b/mk/emfiberthreads.mk @@ -1,13 +1,11 @@ EMFT_VERSION=0.2 -build/inst/base/lib/libemfiberthreads.a: build/emfiberthreads-$(EMFT_VERSION)/libemfiberthreads.a +build/inst/%/lib/libemfiberthreads.a: build/emfiberthreads-$(EMFT_VERSION)/libemfiberthreads.a cd build/emfiberthreads-$(EMFT_VERSION) && \ - $(MAKE) install PREFIX="$(PWD)/build/inst/base" + $(MAKE) install PREFIX="$(PWD)/build/inst/$*" build/emfiberthreads-$(EMFT_VERSION)/libemfiberthreads.a: build/emfiberthreads-$(EMFT_VERSION)/Makefile - cd build/emfiberthreads-$(EMFT_VERSION) && \ - $(MAKE) STACK_SIZE=1048576 \ - CFLAGS="-Oz `cat $(PWD)/build/inst/base/cflags.txt`" + cd build/emfiberthreads-$(EMFT_VERSION) && $(MAKE) STACK_SIZE=1048576 extract: build/emfiberthreads-$(EMFT_VERSION)/Makefile diff --git a/mk/ffmpeg.mk b/mk/ffmpeg.mk index fc6cc358..fd24f214 100644 --- a/mk/ffmpeg.mk +++ b/mk/ffmpeg.mk @@ -37,8 +37,8 @@ build/ffmpeg-$(FFMPEG_VERSION)/build-base-%/ffbuild/config.mak: build/inst/base/ ../configure $(FFMPEG_CONFIG) \ --disable-pthreads --arch=emscripten \ --optflags="$(OPTFLAGS)" \ - --extra-cflags="-I$(PWD)/build/inst/base/include -lemfiberthreads -sMEMORY64=2" \ - --extra-ldflags="-L$(PWD)/build/inst/base/lib -lemfiberthreads -sMEMORY64=2 -s INITIAL_MEMORY=25165824" \ + --extra-cflags="-I$(PWD)/build/inst/base/include -lemfiberthreads" \ + --extra-ldflags="-L$(PWD)/build/inst/base/lib -lemfiberthreads -s INITIAL_MEMORY=25165824" \ `cat ../../../configs/configs/$(*)/ffmpeg-config.txt` sed 's/--extra-\(cflags\|ldflags\)='\''[^'\'']*'\''//g' < build/ffmpeg-$(FFMPEG_VERSION)/build-base-$(*)/config.h > build/ffmpeg-$(FFMPEG_VERSION)/build-base-$(*)/config.h.tmp mv build/ffmpeg-$(FFMPEG_VERSION)/build-base-$(*)/config.h.tmp build/ffmpeg-$(FFMPEG_VERSION)/build-base-$(*)/config.h @@ -60,8 +60,8 @@ build/ffmpeg-$(FFMPEG_VERSION)/build-thr-%/ffbuild/config.mak: \ ../configure $(FFMPEG_CONFIG) \ --enable-pthreads --arch=emscripten \ --optflags="$(OPTFLAGS)" \ - --extra-cflags="-I$(PWD)/build/inst/thr/include $(THRFLAGS) -sMEMORY64=2" \ - --extra-ldflags="-L$(PWD)/build/inst/thr/lib $(THRFLAGS) -sMEMORY64=2 -s INITIAL_MEMORY=25165824" \ + --extra-cflags="-I$(PWD)/build/inst/thr/include $(THRFLAGS)" \ + --extra-ldflags="-L$(PWD)/build/inst/thr/lib $(THRFLAGS) -s INITIAL_MEMORY=25165824" \ `cat ../../../configs/configs/$(*)/ffmpeg-config.txt` sed 's/--extra-\(cflags\|ldflags\)='\''[^'\'']*'\''//g' < build/ffmpeg-$(FFMPEG_VERSION)/build-thr-$(*)/config.h > build/ffmpeg-$(FFMPEG_VERSION)/build-thr-$(*)/config.h.tmp mv build/ffmpeg-$(FFMPEG_VERSION)/build-thr-$(*)/config.h.tmp build/ffmpeg-$(FFMPEG_VERSION)/build-thr-$(*)/config.h diff --git a/mk/ffmpeg.mk.m4 b/mk/ffmpeg.mk.m4 index 3bf07941..9f930431 100644 --- a/mk/ffmpeg.mk.m4 +++ b/mk/ffmpeg.mk.m4 @@ -47,9 +47,9 @@ part-install-$1-%: build/ffmpeg-$(FFMPEG_VERSION)/build-$1-%/libavformat/libavfo ]]]) # Base (asm.js and wasm) -buildrule(base, build/inst/base/lib/libemfiberthreads.a, [[[--disable-pthreads --arch=emscripten]]], [[[-lemfiberthreads -sMEMORY64=2]]]) +buildrule(base, build/inst/base/lib/libemfiberthreads.a, [[[--disable-pthreads --arch=emscripten]]], [[[-lemfiberthreads]]]) # wasm + threads -buildrule(thr, [[[]]], [[[--enable-pthreads --arch=emscripten]]], [[[$(THRFLAGS) -sMEMORY64=2]]]) +buildrule(thr, [[[]]], [[[--enable-pthreads --arch=emscripten]]], [[[$(THRFLAGS)]]]) # All dependencies include configs/configs/*/deps.mk diff --git a/mk/libvpx.mk b/mk/libvpx.mk index adfb3f45..63dd4130 100644 --- a/mk/libvpx.mk +++ b/mk/libvpx.mk @@ -15,9 +15,7 @@ build/libvpx-$(LIBVPX_VERSION)/build-%/Makefile: build/libvpx-$(LIBVPX_VERSION)/ tools/libvpx-emcc-version-check.sh mkdir -p build/libvpx-$(LIBVPX_VERSION)/build-$* cd build/libvpx-$(LIBVPX_VERSION)/build-$* && \ - emconfigure \ - env LD="emcc `cat $(PWD)/build/inst/$*/cflags.txt`" \ - ../../libvpx-$(LIBVPX_VERSION)/configure \ + emconfigure ../../libvpx-$(LIBVPX_VERSION)/configure \ --prefix="$(PWD)/build/inst/$*" \ --target=generic-gnu \ --extra-cflags="-Oz `cat $(PWD)/build/inst/$*/cflags.txt`" \ diff --git a/post.in.js b/post.in.js index 494948bf..cecc2bc8 100644 --- a/post.in.js +++ b/post.in.js @@ -2543,15 +2543,11 @@ var ff_malloc_string_array = Module.ff_malloc_string_array = function(arr) { var ptr = malloc((arr.length + 1) * 4); if (ptr === 0) throw new Error("Failed to malloc"); - var inArr = new Uint32Array(Module.HEAPU8.buffer, ptr, (arr.length + 1) * 2); + var inArr = new Uint32Array(Module.HEAPU8.buffer, ptr, arr.length + 1); var i; - for (i = 0; i < arr.length; i++) { - var tmp = av_strdup(arr[i]); - inArr[i*2] = Number(tmp % 0x100000000n); - inArr[i*2+1] = Number(tmp / 0x100000000n); - } - inArr[i*2] = 0; - inArr[i*2+1] = 0; + for (i = 0; i < arr.length; i++) + inArr[i] = av_strdup(arr[i]); + inArr[i] = 0; return ptr; }; @@ -2561,12 +2557,9 @@ var ff_malloc_string_array = Module.ff_malloc_string_array = function(arr) { */ /// @types ff_free_string_array@sync(ptr: number): @promise@void@ var ff_free_string_array = Module.ff_free_string_array = function(ptr) { - var iPtr = Number(ptr / 4); - for (;; iPtr += 2) { - var elPtr = BigInt( - Module.HEAPU32[iPtr] + - Module.HEAPU32[iPtr+1] * 0x100000000 - ); + var iPtr = ptr / 4; + for (;; iPtr++) { + var elPtr = Module.HEAPU32[iPtr]; if (!elPtr) break; free(elPtr); diff --git a/tools/adjust-sourcemap.js b/tools/adjust-sourcemap.js index 67596d13..dd1e1f0e 100755 --- a/tools/adjust-sourcemap.js +++ b/tools/adjust-sourcemap.js @@ -63,10 +63,6 @@ async function main() { // AOM-specific hack res = `../build/libaom-${version("libaom")}/` + orig.slice(6); - } else if (/^\.\.\/\.\.\/src\/[a-z]*thread/.test(orig)) { - // emfiberthreads - res = `../build/emfiberthreads-${version("emfiberthreads")}/` + orig.slice(6); - } else if ( /cache\/sysroot/.test(orig) || /system\/lib/.test(orig)