Skip to content

Commit

Permalink
Getting rid of wasm64, which didn't work
Browse files Browse the repository at this point in the history
  • Loading branch information
Yahweasel committed Sep 28, 2024
1 parent ea08db4 commit c9fc444
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 53 deletions.
19 changes: 3 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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+=\
Expand Down Expand Up @@ -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 )
Expand Down Expand Up @@ -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 )
Expand Down Expand Up @@ -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 )
Expand Down Expand Up @@ -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 )
Expand Down Expand Up @@ -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 )
Expand Down Expand Up @@ -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 )
Expand Down Expand Up @@ -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 )
Expand Down Expand Up @@ -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 )
Expand Down Expand Up @@ -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 )
Expand Down Expand Up @@ -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 )
Expand Down Expand Up @@ -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 )
Expand Down Expand Up @@ -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 )
Expand Down Expand Up @@ -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 \
Expand Down
8 changes: 3 additions & 5 deletions Makefile.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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+=\
Expand Down Expand Up @@ -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 )
Expand Down Expand Up @@ -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 \
Expand Down
8 changes: 3 additions & 5 deletions mk/emfiberthreads.mk
Original file line number Diff line number Diff line change
@@ -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

Expand Down
8 changes: 4 additions & 4 deletions mk/ffmpeg.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions mk/ffmpeg.mk.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions mk/libvpx.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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`" \
Expand Down
21 changes: 7 additions & 14 deletions post.in.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand All @@ -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);
Expand Down
4 changes: 0 additions & 4 deletions tools/adjust-sourcemap.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit c9fc444

Please sign in to comment.