[vlc-commits] [Git][videolan/vlc][master] 8 commits: extras: tools/libtool: Implement exported functions for emscripten

Steve Lhomme (@robUx4) gitlab at videolan.org
Sun Sep 24 21:10:02 UTC 2023



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
c36ab16c by Khalid Masum at 2023-09-24T20:31:18+00:00
extras: tools/libtool: Implement exported functions for emscripten

Emscripten needs symbols to be exported with -s EXPORTED_FUNCTIONS
in case of building with -s SIDE_MODULE=2, otherwise the functions
are not "visible" from other modules or removed as optimization.

This patch will implement exported functions on libtool for
emscripten.

- - - - -
30503ba4 by Khalid Masum at 2023-09-24T20:31:18+00:00
wasm: build: Enable ffmpeg libraries for shared compilation

ffmpeg libraries ie. avcodec, avformat, swscale and postproc were
disabled for emscripten shared compilation as ffmpeg was not built
with position independent code.

Enable pic for ffmpeg, and ultimately enable those libraries
shared compilation.

- - - - -
a40c987a by Khalid Masum at 2023-09-24T20:31:18+00:00
buildsystem: -sMAIN_MODULE for compiling executables

- - - - -
f9af617f by Khalid Masum at 2023-09-24T20:31:18+00:00
wasm: build: Do not link incompatible c++ libraries

Some libraries in emscripten for C++ are not compiled with fPIC.
Do not link them when building cpp modules.

- - - - -
c1da3d2b by Alexandre Janniaux at 2023-09-24T20:31:18+00:00
contrib: Enable pthread for emsripten

- - - - -
46bfe998 by Khalid Masum at 2023-09-24T20:31:18+00:00
contrib: rust: Add atomics feature for emscripten

To dynamically link rust objects, they need to be compiled with
atomics or bulk memory feature.

- - - - -
cc39c96e by Alexandre Janniaux at 2023-09-24T20:31:18+00:00
wasm: build.sh: removing some contrib

- - - - -
a7ede0f0 by Khalid Masum at 2023-09-24T20:31:18+00:00
wasm: build: Use .wasm extension for shared module

This makes sure the shared modules are built with .wasm extension
instead of .so.

However libvlc and libvlccore are still built with .so extension.

- - - - -


8 changed files:

- bin/Makefile.am
- contrib/src/ffmpeg/rules.mak
- contrib/src/main-rust.mak
- contrib/src/main.mak
- extras/package/wasm-emscripten/build.sh
- extras/tools/libtool-2.4.7-emscripten-dlinker.patch
- m4/vlc.m4
- test/Makefile.am


Changes:

=====================================
bin/Makefile.am
=====================================
@@ -19,6 +19,9 @@ AM_CFLAGS = $(CFLAGS_vlc)
 if HAVE_DBUS
 AM_CPPFLAGS += -DHAVE_DBUS
 endif
+if HAVE_EMSCRIPTEN
+AM_CFLAGS += -sMAIN_MODULE=1
+endif
 
 #
 # Main VLC executable


=====================================
contrib/src/ffmpeg/rules.mak
=====================================
@@ -191,7 +191,7 @@ FFMPEGCONF += --target-os=sunos --enable-pic
 endif
 
 ifdef HAVE_EMSCRIPTEN
-FFMPEGCONF+= --arch=wasm32 --target-os=emscripten
+FFMPEGCONF+= --arch=wasm32 --target-os=emscripten --enable-pic
 endif
 
 # Build


=====================================
contrib/src/main-rust.mak
=====================================
@@ -64,6 +64,10 @@ CARGO_PROFILE := "release"
 RUSTFLAGS += -C opt-level=z
 endif
 
+ifdef HAVE_EMSCRIPTEN
+RUSTFLAGS += -C target-feature=+atomics
+endif
+
 CARGO_ENV = TARGET_CC="$(CC)" TARGET_AR="$(AR)" TARGET_RANLIB="$(RANLIB)" \
 	TARGET_CFLAGS="$(CFLAGS)" RUSTFLAGS="$(RUSTFLAGS)"
 


=====================================
contrib/src/main.mak
=====================================
@@ -122,6 +122,11 @@ XCODE_FLAGS += -arch $(ARCH)
 endif
 endif
 
+ifdef HAVE_EMSCRIPTEN
+EXTRA_CFLAGS += -pthread
+EXTRA_CXXFLAGS += -pthread
+endif
+
 CCAS=$(CC) -c
 
 LN_S = ln -s


=====================================
extras/package/wasm-emscripten/build.sh
=====================================
@@ -141,6 +141,7 @@ diagnostic "vlc contribs: bootstrap"
             --disable-spatialaudio --disable-speex \
             --disable-speexdsp --disable-taglib --disable-zvbi \
             --disable-rnnoise --disable-libaribcaption \
+            --disable-ogg --disable-vorbis --disable-kate --disable-flac \
             --host=wasm32-unknown-emscripten --enable-rav1e
 
 diagnostic "vlc contribs: make"
@@ -169,11 +170,9 @@ echo "$BUILD_PATH";
 
 if [ "$VLC_COMPILE_SHARED" -eq "1" ]; then
 #enable shared, while disabling some of the incompatible dependencies
-    SHARED_CONFIGURE_FLAGS=" --enable-shared --disable-avcodec --disable-avformat \
-                             --disable-swscale --disable-postproc "
+    SHARED_CONFIGURE_FLAGS="--enable-shared"
 else
-    SHARED_CONFIGURE_FLAGS=" --disable-shared --enable-avcodec --enable-avformat \
-                             --enable-swscale --enable-postproc "
+    SHARED_CONFIGURE_FLAGS="--disable-shared"
 fi
 
 cd "$BUILD_PATH"
@@ -194,6 +193,7 @@ if [ $BUILD_MODE -eq 1 ]; then
     fi
     emconfigure "$VLC_SRCPATH"/configure --host=wasm32-unknown-emscripten --enable-debug \
                         $SHARED_CONFIGURE_FLAGS --disable-vlc \
+                        --enable-avcodec --enable-avformat --enable-swscale --enable-postproc \
                         --disable-sout --disable-vlm --disable-a52 --disable-xcb --disable-lua \
                         --disable-addonmanagermodules --disable-ssp --disable-nls \
                         --enable-gles2 \
@@ -201,6 +201,11 @@ if [ $BUILD_MODE -eq 1 ]; then
                         "${SANITIZER_OPTIONS}"
 fi
 
+if [ "$VLC_COMPILE_SHARED" -eq "1" ]; then
+    sed -i "s|^postdeps_CXX=.*$|postdeps_CXX='-L/$(dirname $(which emcc))/cache/sysroot/lib/wasm32-emscripten -lal -lhtml5 -lbulkmemory -lstubs -lsockets-mt'|" config.status
+fi
+
+
 diagnostic "libvlc build: make"
 emmake make
 


=====================================
extras/tools/libtool-2.4.7-emscripten-dlinker.patch
=====================================
@@ -15,8 +15,8 @@ index 009155ee..797604af 100644
 +  finish_cmds=
 +  dynamic_linker="Emscripten linker"
 +  _LT_COMPILER_PIC($1)='-fPIC'
-+  _LT_TAGVAR(archive_cmds, $1)='$CC -sSIDE_MODULE=2 -shared -fPIC $libobjs $deplibs $compiler_flags -o $lib'
-+  _LT_TAGVAR(archive_expsym_cmds, $1)=
++  _LT_TAGVAR(archive_cmds, $1)='$CC -sSIDE_MODULE=2 -shared $libobjs $deplibs $compiler_flags -o $lib'
++  _LT_TAGVAR(archive_expsym_cmds, $1)='$SED "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -sSIDE_MODULE=2 -shared $libobjs $deplibs $compiler_flags -o $lib -s EXPORTED_FUNCTIONS=@$output_objdir/$soname.expsym'
 +  _LT_TAGVAR(archive_cmds_need_lc, $1)=no
 +  _LT_TAGVAR(no_undefined_flag, $1)=
 +  ;;


=====================================
m4/vlc.m4
=====================================
@@ -89,6 +89,9 @@ AC_DEFUN([VLC_LIBRARY_SUFFIX], [
     hpux*)
       LIBEXT=".sl"
       ;;
+    emscripten*)
+      LIBEXT=".wasm"
+      ;;
     *)
       LIBEXT=".so"
       ;;


=====================================
test/Makefile.am
=====================================
@@ -108,6 +108,11 @@ AM_CPPFLAGS = \
 	-DSRCDIR=\"$(srcdir)\" \
 	-DTOP_BUILDDIR=\"$(abs_top_builddir)\" \
 	-DTOP_SRCDIR=\"$(abs_top_srcdir)\"
+
+if HAVE_EMSCRIPTEN
+AM_CFLAGS = -sMAIN_MODULE=1
+endif
+
 AM_LDFLAGS = -no-install $(LDFLAGS_vlc)
 LIBVLCCORE = -L../src/ -lvlccore
 LIBVLC = -L../lib -lvlc



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/91bde00c81978a2360e278764a619fa7835c66e4...a7ede0f07569996aa8d8e688a894a2056bcb21fa

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/91bde00c81978a2360e278764a619fa7835c66e4...a7ede0f07569996aa8d8e688a894a2056bcb21fa
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list