Skip to content

Undefined symbol when compiling with latest emscripten: __tls_base #18632

@laelath

Description

@laelath
System information (version)
  • OpenCV => 4.3/4.4/4.5
  • Operating System / Platform => js/wasm
  • Compiler => emscripten 2.0.7
Detailed description

When compiling with the default wasm build settings with the latest emscripten I get the following error.

[100%] Linking CXX executable ../../bin/opencv_js.js
cd /path/to/opencv/build_wasm/modules/js && /usr/bin/cmake -E cmake_link_script CMakeFiles/opencv_js.dir/link.txt --verbose=1
/path/to/emscripten/em++ -s WASM=1 -s USE_PTHREADS=0    -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Winconsistent-missing-override -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -Wno-deprecated-enum-enum-conversion -Wno-deprecated-anon-enum-enum-conversion -fdiagnostics-show-option -pthread -Qunused-arguments -ffunction-sections -fdata-sections  -fvisibility=hidden -fvisibility-inlines-hidden -DNDEBUG -O2  -DNDEBUG   -Wl,--gc-sections -O2   --memory-init-file 0 -s TOTAL_MEMORY=128MB -s WASM_MEM_MAX=1GB -s ALLOW_MEMORY_GROWTH=1 -s MODULARIZE=1 -s SINGLE_FILE=1 -s EXPORT_NAME="'cv'" -s DEMANGLE_SUPPORT=1 -s FORCE_FILESYSTEM=1 --use-preload-plugins --bind --post-js /path/to/opencv/modules/js/src/helpers.js  -Wno-missing-prototypes @CMakeFiles/opencv_js.dir/objects1.rsp -o ../../bin/opencv_js.js @CMakeFiles/opencv_js.dir/linklibs.rsp
error: undefined symbol: __tls_base (referenced by top-level compiled C/C++ code)
warning: Link with `-s LLD_REPORT_UNDEFINED` to get more information on undefined symbols
warning: To disable errors for undefined symbols use `-s ERROR_ON_UNDEFINED_SYMBOLS=0`
warning: ___tls_base may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
Error: Aborting compilation due to previous errors
em++: error: '/path/to/node/12.18.1_64bit/bin/node /path/to/emscripten/src/compiler.js /tmp/tmp8jgc1o32.txt' failed (1)
make[3]: *** [modules/js/CMakeFiles/opencv_js.dir/build.make:194: bin/opencv_js.js] Error 1
make[3]: Leaving directory '/path/to/opencv/build_wasm'
make[2]: *** [CMakeFiles/Makefile2:1495: modules/js/CMakeFiles/opencv_js.dir/all] Error 2
make[2]: Leaving directory '/path/to/opencv/build_wasm'
make[1]: *** [CMakeFiles/Makefile2:1465: modules/js/CMakeFiles/opencv.js.dir/rule] Error 2
make[1]: Leaving directory '/path/to/opencv/build_wasm'
make: *** [Makefile:424: opencv.js] Error 2
Traceback (most recent call last):
  File "./platforms/js/build_js.py", line 277, in <module>
    builder.build_opencvjs()
  File "./platforms/js/build_js.py", line 195, in build_opencvjs
    execute(["make", "-j", str(multiprocessing.cpu_count()), "opencv.js"])
  File "./platforms/js/build_js.py", line 23, in execute
    raise Fail("Child returned: %s" % retcode)
__main__.Fail: Child returned: 2
Steps to reproduce
  1. Install the latest emscripten
  2. Checkout the 4.3.0, 4.4.0, or 4.5.0 tag
  3. Run python ./platforms/js/build_js.py --build_wasm --emscripten_dir=/path/to/emscripten build_wasm
Issue submission checklist
  • I report the issue, it's not a question
  • I checked the problem with documentation, FAQ, open issues,
    answers.opencv.org, Stack Overflow, etc and have not found solution
  • I updated to latest OpenCV version and the issue is still there
  • There is reproducer code and related data files: videos, images, onnx, etc

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions