conan-center-index icon indicating copy to clipboard operation
conan-center-index copied to clipboard

[package] fmt/8.1.1: Missing symbols for WebAsembly

Open szigetics opened this issue 3 years ago • 1 comments

Description

I built the fmt recipe ( https://github.com/conan-io/conan-center-index/tree/master/recipes/fmt ) for WebAssembly using emsdk 3.1.14 ( https://github.com/conan-io/conan-center-index/tree/master/recipes/emsdk ) .

When I try to use the built package, I receive build errors about missing symbols :

em++: warning: /Users/myUser/.conan/data/fmt/8.1.1/jenkins-clt/stable/package/93b09e919707eae1e87c217c1903aef1ceda69e2/lib/libfmt.a: archive is missing an index; Use emar when creating libraries to ensure an index is created [-Wemcc]
em++: warning: /Users/myUser/.conan/data/fmt/8.1.1/jenkins-clt/stable/package/93b09e919707eae1e87c217c1903aef1ceda69e2/lib/libfmt.a: adding index [-Wemcc]
error: undefined symbol: _ZN3fmt2v86detail12format_floatIdEEiT_iNS1_11float_specsERNS1_6bufferIcEE (referenced by top-level compiled C/C++ code)
warning: Link with `-sLLD_REPORT_UNDEFINED` to get more information on undefined symbols
warning: To disable errors for undefined symbols use `-sERROR_ON_UNDEFINED_SYMBOLS=0`
warning: __ZN3fmt2v86detail12format_floatIdEEiT_iNS1_11float_specsERNS1_6bufferIcEE may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: _ZN3fmt2v86detail12format_floatIeEEiT_iNS1_11float_specsERNS1_6bufferIcEE (referenced by top-level compiled C/C++ code)
warning: __ZN3fmt2v86detail12format_floatIeEEiT_iNS1_11float_specsERNS1_6bufferIcEE may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: _ZN3fmt2v86detail13error_handler8on_errorEPKc (referenced by top-level compiled C/C++ code)
warning: __ZN3fmt2v86detail13error_handler8on_errorEPKc may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: _ZN3fmt2v86detail14snprintf_floatIdEEiT_iNS1_11float_specsERNS1_6bufferIcEE (referenced by top-level compiled C/C++ code)
warning: __ZN3fmt2v86detail14snprintf_floatIdEEiT_iNS1_11float_specsERNS1_6bufferIcEE may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: _ZN3fmt2v86detail14snprintf_floatIeEEiT_iNS1_11float_specsERNS1_6bufferIcEE (referenced by top-level compiled C/C++ code)
warning: __ZN3fmt2v86detail14snprintf_floatIeEEiT_iNS1_11float_specsERNS1_6bufferIcEE may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: _ZN3fmt2v86detail18decimal_point_implIcEET_NS1_10locale_refE (referenced by top-level compiled C/C++ code)
warning: __ZN3fmt2v86detail18decimal_point_implIcEET_NS1_10locale_refE may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: _ZN3fmt2v86detail18thousands_sep_implIcEENS1_20thousands_sep_resultIT_EENS1_10locale_refE (referenced by top-level compiled C/C++ code)
warning: __ZN3fmt2v86detail18thousands_sep_implIcEENS1_20thousands_sep_resultIT_EENS1_10locale_refE may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: _ZN3fmt2v86detail18throw_format_errorEPKc (referenced by top-level compiled C/C++ code)
warning: __ZN3fmt2v86detail18throw_format_errorEPKc may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: _ZN3fmt2v86detail9dragonbox10to_decimalIdEENS2_10decimal_fpIT_EES5_ (referenced by top-level compiled C/C++ code)
warning: __ZN3fmt2v86detail9dragonbox10to_decimalIdEENS2_10decimal_fpIT_EES5_ may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: _ZN3fmt2v86detail9dragonbox10to_decimalIfEENS2_10decimal_fpIT_EES5_ (referenced by top-level compiled C/C++ code)
warning: __ZN3fmt2v86detail9dragonbox10to_decimalIfEENS2_10decimal_fpIT_EES5_ may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: _ZN3fmt2v87vformatENS0_17basic_string_viewIcEENS0_17basic_format_argsINS0_20basic_format_contextINS0_8appenderEcEEEE (referenced by top-level compiled C/C++ code)
warning: __ZN3fmt2v87vformatENS0_17basic_string_viewIcEENS0_17basic_format_argsINS0_20basic_format_contextINS0_8appenderEcEEEE may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
Error: Aborting compilation due to previous errors

By modifying the fmt recipe to build in verbose mode ( self.run("VERBOSE=1 cmake --build .") ) I could see that indeed : it is the /usr/bin/ar which is being used, instead of the emar from emsdk ( /Users/myUser/.conan/data/emsdk/2.0.16/jenkins-clt/stable/package/cf186363a0bf37e3a91ee26c25ea5d664ac71fa5/bin/upstream/emscripten/emar ) .

Reason of this : Now there are 2 CMake helpers available : 1.: https://docs.conan.io/en/latest/reference/build_helpers/cmake.html 2.: https://docs.conan.io/en/latest/reference/conanfile/tools/cmake/cmake.html This second one is the newer one. This newer one doesn't pick up the AR variable.

See related bug report for conan : https://github.com/conan-io/conan/issues/12232 .

Package and Environment Details

  • Package Name/Version: fmt/8.1.1
  • Operating System+version: macOS 12.6, emsdk 3.1.14
  • Compiler+version: Clang 5.0 (shipped in emsdk (Emscripten))
  • Conan version: conan 1.52.0
  • Python version: Python 3.10.0

Conan profile

Configuration (profile_host): [settings] arch=wasm arch_build=x86_64 build_type=Release compiler=clang compiler.libcxx=libc++ compiler.version=15 os=Emscripten os_build=Macos [options] [build_requires] [env]

Configuration (profile_build): [settings] arch=x86_64 arch_build=x86_64 build_type=Release compiler=apple-clang compiler.libcxx=libc++ compiler.version=13.1 os=Macos os_build=Macos [options] [build_requires] [env]

Steps to reproduce

see above

Logs

Click to expand log
em++: warning: /Users/myUser/.conan/data/fmt/8.1.1/jenkins-clt/stable/package/93b09e919707eae1e87c217c1903aef1ceda69e2/lib/libfmt.a: archive is missing an index; Use emar when creating libraries to ensure an index is created [-Wemcc]
em++: warning: /Users/myUser/.conan/data/fmt/8.1.1/jenkins-clt/stable/package/93b09e919707eae1e87c217c1903aef1ceda69e2/lib/libfmt.a: adding index [-Wemcc]
error: undefined symbol: _ZN3fmt2v86detail12format_floatIdEEiT_iNS1_11float_specsERNS1_6bufferIcEE (referenced by top-level compiled C/C++ code)
warning: Link with `-sLLD_REPORT_UNDEFINED` to get more information on undefined symbols
warning: To disable errors for undefined symbols use `-sERROR_ON_UNDEFINED_SYMBOLS=0`
warning: __ZN3fmt2v86detail12format_floatIdEEiT_iNS1_11float_specsERNS1_6bufferIcEE may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: _ZN3fmt2v86detail12format_floatIeEEiT_iNS1_11float_specsERNS1_6bufferIcEE (referenced by top-level compiled C/C++ code)
warning: __ZN3fmt2v86detail12format_floatIeEEiT_iNS1_11float_specsERNS1_6bufferIcEE may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: _ZN3fmt2v86detail13error_handler8on_errorEPKc (referenced by top-level compiled C/C++ code)
warning: __ZN3fmt2v86detail13error_handler8on_errorEPKc may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: _ZN3fmt2v86detail14snprintf_floatIdEEiT_iNS1_11float_specsERNS1_6bufferIcEE (referenced by top-level compiled C/C++ code)
warning: __ZN3fmt2v86detail14snprintf_floatIdEEiT_iNS1_11float_specsERNS1_6bufferIcEE may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: _ZN3fmt2v86detail14snprintf_floatIeEEiT_iNS1_11float_specsERNS1_6bufferIcEE (referenced by top-level compiled C/C++ code)
warning: __ZN3fmt2v86detail14snprintf_floatIeEEiT_iNS1_11float_specsERNS1_6bufferIcEE may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: _ZN3fmt2v86detail18decimal_point_implIcEET_NS1_10locale_refE (referenced by top-level compiled C/C++ code)
warning: __ZN3fmt2v86detail18decimal_point_implIcEET_NS1_10locale_refE may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: _ZN3fmt2v86detail18thousands_sep_implIcEENS1_20thousands_sep_resultIT_EENS1_10locale_refE (referenced by top-level compiled C/C++ code)
warning: __ZN3fmt2v86detail18thousands_sep_implIcEENS1_20thousands_sep_resultIT_EENS1_10locale_refE may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: _ZN3fmt2v86detail18throw_format_errorEPKc (referenced by top-level compiled C/C++ code)
warning: __ZN3fmt2v86detail18throw_format_errorEPKc may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: _ZN3fmt2v86detail9dragonbox10to_decimalIdEENS2_10decimal_fpIT_EES5_ (referenced by top-level compiled C/C++ code)
warning: __ZN3fmt2v86detail9dragonbox10to_decimalIdEENS2_10decimal_fpIT_EES5_ may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: _ZN3fmt2v86detail9dragonbox10to_decimalIfEENS2_10decimal_fpIT_EES5_ (referenced by top-level compiled C/C++ code)
warning: __ZN3fmt2v86detail9dragonbox10to_decimalIfEENS2_10decimal_fpIT_EES5_ may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: _ZN3fmt2v87vformatENS0_17basic_string_viewIcEENS0_17basic_format_argsINS0_20basic_format_contextINS0_8appenderEcEEEE (referenced by top-level compiled C/C++ code)
warning: __ZN3fmt2v87vformatENS0_17basic_string_viewIcEENS0_17basic_format_argsINS0_20basic_format_contextINS0_8appenderEcEEEE may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
Error: Aborting compilation due to previous errors

szigetics avatar Oct 04 '22 07:10 szigetics

I am preparing a fix for this now. I will open the PR in some minutes.

szigetics avatar Oct 04 '22 07:10 szigetics

I can't reproduce your issue.

You don't provide a reproducible example and I don't understand where you inject emsdk as tool_requires.

So here is one:

build profile:

[settings]
os=Macos
arch=x86_64
compiler=apple-clang
compiler.version=14
compiler.libcxx=libc++
build_type=Release
[options]
[tool_requires]
[env]
[conf]

host profile:

[settings]
os=Emscripten
arch=wasm
compiler=clang
compiler.version=15
compiler.libcxx=libc++
build_type=Release
[options]
[tool_requires]
emsdk/3.1.23
[env]
[conf]
conan install fmt/8.1.1@ -pr:b build_profile -pr:h host_profile -b missing

(I've added CMAKE_VERBOSE_MAKEFILE in fmt recipe to see commands, unfortunately there is no way to enable verbose makefile externally in CMakeToolchain based recipe https://github.com/conan-io/conan/issues/9772#issuecomment-964368253)

fmt/8.1.1: CMake command: cmake --build "/Users/spaceim/.conan/data/fmt/8.1.1/_/_/build/93b09e919707eae1e87c217c1903aef1ceda69e2/build/Release" '--' '-j12'
[1/3] /Users/spaceim/.conan/data/emsdk/3.1.23/_/_/package/cf186363a0bf37e3a91ee26c25ea5d664ac71fa5/bin/upstream/emscripten/em++ -DFMT_LOCALE -I/Users/spaceim/.conan/data/fmt/8.1.1/_/_/build/93b09e919707eae1e87c217c1903aef1ceda69e2/src/include -stdlib=libc++ -O3 -DNDEBUG -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -std=gnu++11 -MD -MT CMakeFiles/fmt.dir/src/os.cc.o -MF CMakeFiles/fmt.dir/src/os.cc.o.d -o CMakeFiles/fmt.dir/src/os.cc.o -c /Users/spaceim/.conan/data/fmt/8.1.1/_/_/build/93b09e919707eae1e87c217c1903aef1ceda69e2/src/src/os.cc
[2/3] /Users/spaceim/.conan/data/emsdk/3.1.23/_/_/package/cf186363a0bf37e3a91ee26c25ea5d664ac71fa5/bin/upstream/emscripten/em++ -DFMT_LOCALE -I/Users/spaceim/.conan/data/fmt/8.1.1/_/_/build/93b09e919707eae1e87c217c1903aef1ceda69e2/src/include -stdlib=libc++ -O3 -DNDEBUG -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -std=gnu++11 -MD -MT CMakeFiles/fmt.dir/src/format.cc.o -MF CMakeFiles/fmt.dir/src/format.cc.o.d -o CMakeFiles/fmt.dir/src/format.cc.o -c /Users/spaceim/.conan/data/fmt/8.1.1/_/_/build/93b09e919707eae1e87c217c1903aef1ceda69e2/src/src/format.cc
[3/3] : && /Applications/CMake.app/Contents/bin/cmake -E rm -f libfmt.a && /Users/spaceim/.conan/data/emsdk/3.1.23/_/_/package/cf186363a0bf37e3a91ee26c25ea5d664ac71fa5/bin/upstream/emscripten/emar qc libfmt.a  CMakeFiles/fmt.dir/src/format.cc.o CMakeFiles/fmt.dir/src/os.cc.o && /Users/spaceim/.conan/data/emsdk/3.1.23/_/_/package/cf186363a0bf37e3a91ee26c25ea5d664ac71fa5/bin/upstream/emscripten/emranlib libfmt.a && /Applications/CMake.app/Contents/bin/cmake -E touch libfmt.a && :

You can see in my build that static lib is properly created with emar executable from emsdk package.

SpaceIm avatar Oct 04 '22 12:10 SpaceIm

Hi @szigetics - thank you for reporting this issue.

Would be able to provide us with what steps you have followed to initiate the build of fmt for Emscripten? I'll be happy to assist and make sure this is working for you.

jcar87 avatar Oct 04 '22 13:10 jcar87

FYI : https://github.com/emscripten-core/emscripten/issues/17992#issuecomment-1268656848 => https://github.com/emscripten-core/emscripten/pull/17997

So in newer emsdk versions this will probably be fixed. ( Of course previous emsdk versions will still have to be fixed using the same solution. )

szigetics avatar Oct 05 '22 21:10 szigetics