View Issue Details

IDProjectCategoryView StatusLast Update
0000198fileGeneralpublic2020-12-15 23:58
ReporterThomas Assigned Tochristos  
Status feedbackResolutionopen 
PlatformIntel64OSUbuntuOS Version18.04
Product Version5.39 
Summary0000198: Compiling with emscripten to WebAssembly fails
DescriptionI'm trying to compile libmagic to WebAssembly by using the emscripten toolchain to be able to use it in a WebExtension. It would be sufficient to get a static library. Unfortunately, the build of the library requires the execution of another target (e. g. file, to compile the magic list). This is a show stopper for emscripten, because executable targets will be WASM/JS (instead of a binary) and for sure not be executable on any build system.

According to the comment in 'magic/' line 333 (, you might already be aware of this problem. It would be nice to have a fix for this soon. If you know any workaround for this, I would appreciate it to let me know.

Thanks for looking into it!
Steps To Reproduce# setup emscripten first:
cd /tmp
git clone
cd file
autoreconf -i
emconfigure ./configure --prefix=/tmp/file --enable-static=yes --disable-shared
emmake make
Additional InformationError log:
Making all in magic
make[2]: Entering directory '/tmp/file/magic'
../src/file -C -m magic
/bin/bash: ../src/file: Permission denied
Makefile:831: recipe for target 'magic.mgc' failed
make[2]: *** [magic.mgc] Error 126
make[2]: Leaving directory '/tmp/file/magic'
Makefile:460: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/tmp/file'
Makefile:369: recipe for target 'all' failed
make: *** [all] Error 2



2020-10-11 20:05

manager   ~0003487

The file binary is built before it is being used to compile the magic database. So you are fine, you have a file binary and libmagic. Building magic.mgc can be done using a native build (and the same file will be produced). I don't really have the time to figure out the autoconf magic to make it build a native version of file in a cross-compile environment.


2020-10-12 04:53

reporter   ~0003493

Do you have a target that allows to only build libmagic (without the file binary and especially without magic.mgc)? And do you have a target or two to only build the file binary and magic.mgc?


2020-10-14 21:13

manager   ~0003496

cd src && make
cd magic && make magic.mgc
cd src && make file

Like that?


2020-10-17 17:35

reporter   ~0003497

Sounds promising, thank you! I cannot test it right now, but I'll give you feedback on that in several weeks and I will also post a solution for emscripten, if found.


2020-12-15 23:58

manager   ~0003502

Waiting on feedback.

Issue History

Date Modified Username Field Change
2020-09-20 10:00 Thomas New Issue
2020-09-20 10:00 Thomas Tag Attached: build
2020-10-11 20:05 christos Note Added: 0003487
2020-10-12 04:53 Thomas Note Added: 0003493
2020-10-14 21:13 christos Note Added: 0003496
2020-10-17 17:35 Thomas Note Added: 0003497
2020-12-15 23:58 christos Assigned To => christos
2020-12-15 23:58 christos Status new => assigned
2020-12-15 23:58 christos Status assigned => feedback
2020-12-15 23:58 christos Note Added: 0003502