facebookincubator / velox

A composable and fully extensible C++ execution engine library for data management systems.
https://velox-lib.io/
Apache License 2.0
3.51k stars 1.15k forks source link

fmt latest (11+) would break builds #10886

Closed zuyu closed 1 month ago

zuyu commented 2 months ago

Problem description

https://github.com/Homebrew/homebrew-core/pull/178811 upgraded fmt from 10.2.1 to 11.0.2 that introduces a breaking change:

In velox, there are several places using different fmt versions that works before, as the brew-installed version was 10.2.1:

https://github.com/facebookincubator/velox/blob/5f935a73ff85dd4de3e326c5181621586d437ccc/scripts/setup-macos.sh#L38

https://github.com/facebookincubator/velox/blob/5f935a73ff85dd4de3e326c5181621586d437ccc/scripts/setup-macos.sh#L41

https://github.com/facebookincubator/velox/blob/5f935a73ff85dd4de3e326c5181621586d437ccc/CMakeLists.txt#L414

Fixing Suggestions

velox was built successfully w/

Code changes to #include <fmt/ranges.h> due to fmt::join usage (IWYU):

Note that https://formulae.brew.sh/formula/folly shows folly v2024.08.26.00 depends on fmt 11.0.2 (brew-installed folly might work on macOS 14, but not macOS 15 due to some weird linking issue). An earlier version of folly might also works.

System information

Velox System Info v0.0.2 Commit: 5f935a73ff85dd4de3e326c5181621586d437ccc CMake Version: 3.30.2 System: Darwin-24.1.0 Arch: arm64 C++ Compiler: /opt/homebrew/opt/ccache/libexec/c++ C++ Compiler Version: 16.0.0.16000026 C Compiler: /opt/homebrew/opt/ccache/libexec/cc C Compiler Version: 16.0.0.16000026 CMake Prefix Path: /Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr;/opt/homebrew;/usr/local;/usr;/;/opt/homebrew/Cellar/cmake/3.30.2;/usr/local;/usr/X11R6;/usr/pkg;/opt;/sw;/opt/local

CMake log

FAILED: _deps/folly-build/CMakeFiles/folly_base.dir/folly/IPAddressV4.cpp.o 
/usr/local/bin/ccache /Applications/Xcode_15.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -DBOOST_ATOMIC_DYN_LINK -DBOOST_ATOMIC_NO_LIB -DBOOST_CONTEXT_DYN_LINK -DBOOST_CONTEXT_NO_LIB -DBOOST_FILESYSTEM_DYN_LINK -DBOOST_FILESYSTEM_NO_LIB -DBOOST_PROGRAM_OPTIONS_DYN_LINK -DBOOST_PROGRAM_OPTIONS_NO_LIB -DBOOST_REGEX_DYN_LINK -DBOOST_REGEX_NO_LIB -DBOOST_SYSTEM_DYN_LINK -DBOOST_SYSTEM_NO_LIB -DBOOST_THREAD_DYN_LINK -DBOOST_THREAD_NO_LIB -DFMT_SHARED -DFOLLY_HAVE_INT128_T=1 -DFOLLY_XLOG_STRIP_PREFIXES=\"/Users/runner/work/velox/velox:/Users/runner/work/velox/velox/_build/Debug\" -DGFLAGS_IS_A_DLL=0 -DVELOX_ENABLE_PARQUET -D_GNU_SOURCE -D_REENTRANT -I/Users/runner/work/velox/velox/_build/Debug/_deps/folly-src -I/Users/runner/work/velox/velox/_build/Debug/_deps/folly-build -I/usr/local/include -I/usr/local/Cellar/openssl@3/3.3.1/include -mavx2 -mfma -mavx -mf16c -mlzcnt -std=c++17 -mbmi2 -D USE_VELOX_COMMON_BASE -D HAS_UNCAUGHT_EXCEPTIONS -Wall -Wextra -Wno-unused        -Wno-unused-parameter        -Wno-sign-compare        -Wno-ignored-qualifiers        -Wno-range-loop-analysis          -Wno-mismatched-tags          -Wno-nullability-completeness -g -g -Wall -Wextra -std=gnu++17 -isysroot /Applications/Xcode_15.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk -mmacosx-version-min=13.6 -fPIC -g -finput-charset=UTF-8 -fsigned-char -Wall -Wno-deprecated -Wno-deprecated-declarations -Wno-sign-compare -Wno-unused -Wuninitialized -Wunused-label -Wunused-result -w -Wno-noexcept-type -Wno-nullability-completeness -Wno-inconsistent-missing-override -faligned-new -MD -MT _deps/folly-build/CMakeFiles/folly_base.dir/folly/IPAddressV4.cpp.o -MF _deps/folly-build/CMakeFiles/folly_base.dir/folly/IPAddressV4.cpp.o.d -o _deps/folly-build/CMakeFiles/folly_base.dir/folly/IPAddressV4.cpp.o -c /Users/runner/work/velox/velox/_build/Debug/_deps/folly-src/folly/IPAddressV4.cpp
In file included from /Users/runner/work/velox/velox/_build/Debug/_deps/folly-src/folly/IPAddressV4.cpp:17:
In file included from /Users/runner/work/velox/velox/_build/Debug/_deps/folly-src/folly/IPAddressV4.h:34:
In file included from /Users/runner/work/velox/velox/_build/Debug/_deps/folly-src/folly/FBString.h:34:
In file included from /usr/local/include/fmt/format.h:41:
/usr/local/include/fmt/base.h:1627:3: error: static assertion failed due to requirement 'formattable_char': Mixing character types is disallowed.
  static_assert(formattable_char, "Mixing character types is disallowed.");
  ^             ~~~~~~~~~~~~~~~~
/usr/local/include/fmt/base.h:2018:20: note: in instantiation of function template specialization 'fmt::detail::make_arg<true, fmt::context, folly::Range<const char *>, 0>' requested here
  return {{detail::make_arg<NUM_ARGS <= detail::max_packed_args, Context>(
                   ^
/usr/local/include/fmt/format.h:4365:28: note: in instantiation of function template specialization 'fmt::make_format_args<fmt::context, folly::Range<const char *>, 1UL, 0UL, 15ULL, 0>' requested here
  return vformat(fmt, fmt::make_format_args(args...));
                           ^
/Users/runner/work/velox/velox/_build/Debug/_deps/folly-src/folly/IPAddressV4.cpp:73:14: note: in instantiation of function template specialization 'fmt::format<folly::Range<const char *> &>' requested here
        fmt::format("Can't convert invalid IP '{}' to long", ip));
             ^
1 error generated.
aditi-pandit commented 2 months ago

+1.

My system is messed up as well. setup_macos ccache picks up v 4.10.2 https://formulae.brew.sh/formula/ccache brings fmt 11.0.2 which breaks folly

FAILED: CMakeFiles/folly_base.dir/folly/Singleton.cpp.o 
/Library/Developer/CommandLineTools/usr/bin/c++ -DBOOST_ATOMIC_DYN_LINK -DBOOST_ATOMIC_NO_LIB -DBOOST_CONTEXT_DYN_LINK -DBOOST_CONTEXT_NO_LIB -DBOOST_FILESYSTEM_DYN_LINK -DBOOST_FILESYSTEM_NO_LIB -DBOOST_PROGRAM_OPTIONS_DYN_LINK -DBOOST_PROGRAM_OPTIONS_NO_LIB -DBOOST_REGEX_DYN_LINK -DBOOST_REGEX_NO_LIB -DBOOST_SYSTEM_DYN_LINK -DBOOST_SYSTEM_NO_LIB -DBOOST_THREAD_DYN_LINK -DBOOST_THREAD_NO_LIB -DFOLLY_XLOG_STRIP_PREFIXES=\"/Users/aditipandit/ahana_dev/presto/presto/presto-native-execution/folly:/Users/aditipandit/ahana_dev/presto/presto/presto-native-execution/folly/_build\" -DGFLAGS_IS_A_DLL=0 -D_GNU_SOURCE -D_REENTRANT -I/Users/aditipandit/ahana_dev/presto/presto/presto-native-execution/folly -I/Users/aditipandit/ahana_dev/presto/presto/presto-native-execution/folly/_build -I/opt/homebrew/include -I/Users/aditipandit/velox_install/include -I/opt/homebrew/opt/openssl@1.1/include -mcpu=apple-m1+crc -std=c++17 -fvisibility=hidden -std=gnu++17 -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk -fPIC -g -finput-charset=UTF-8 -fsigned-char -Wall -Wno-deprecated -Wno-deprecated-declarations -Wno-sign-compare -Wno-unused -Wuninitialized -Wunused-label -Wunused-result -Wno-noexcept-type -Wno-nullability-completeness -Wno-inconsistent-missing-override -faligned-new -MD -MT CMakeFiles/folly_base.dir/folly/Singleton.cpp.o -MF CMakeFiles/folly_base.dir/folly/Singleton.cpp.o.d -o CMakeFiles/folly_base.dir/folly/Singleton.cpp.o -c /Users/aditipandit/ahana_dev/presto/presto/presto-native-execution/folly/folly/Singleton.cpp
In file included from /Users/aditipandit/ahana_dev/presto/presto/presto-native-execution/folly/folly/Singleton.cpp:38:
In file included from /Users/aditipandit/ahana_dev/presto/presto/presto-native-execution/folly/folly/portability/FmtCompile.h:19:
/opt/homebrew/include/fmt/compile.h:153:12: error: call to 'write' is ambiguous
    return write<Char>(out, arg);
           ^~~~~~~~~~~
/opt/homebrew/include/fmt/compile.h:217:15: note: in instantiation of function template specialization 'fmt::detail::field<char, folly::Range<const char *>, 0>::format<std::back_insert_iterator<std::string>, folly::Range<const char *>>' requested here
    out = lhs.format(out, args...);
              ^
/opt/homebrew/include/fmt/compile.h:218:16: note: in instantiation of function template specialization 'fmt::detail::concat<fmt::detail::field<char, folly::Range<const char *>, 0>, fmt::detail::text<char>>::format<std::back_insert_iterator<std::string>, folly::Range<const char *>>' requested here
    return rhs.format(out, args...);
               ^
/opt/homebrew/include/fmt/compile.h:432:6: note: in instantiation of function template specialization 'fmt::detail::concat<fmt::detail::text<char>, fmt::detail::concat<fmt::detail::field<char, folly::Range<const char *>, 0>, fmt::detail::text<char>>>::format<std::back_insert_iterator<std::string>, folly::Range<const char *>>' requested here
  cf.format(std::back_inserter(s), args...);
     ^

Uninstalling fmt 11 and bringing in fmt 10 fixes the folly and completes the rest of the setup, but then this breaks ccache

FAILED: velox/velox/connectors/hive/storage_adapters/abfs/CMakeFiles/velox_abfs.dir/RegisterAbfsFileSystem.cpp.o 
/opt/homebrew/bin/ccache /Library/Developer/CommandLineTools/usr/bin/c++ -DFOLLY_HAVE_INT128_T=1 -I/Users/aditipandit/ahana_dev/presto/presto/presto-native-execution/. -I/Users/aditipandit/ahana_dev/presto/presto/presto-native-execution/velox -I/Users/aditipandit/ahana_dev/presto/presto/presto-native-execution/velox/velox/external/xxhash -I/Users/aditipandit/ahana_dev/presto/presto/presto-native-execution/cmake-build-debug/velox -I/Users/aditipandit/ahana_dev/presto/presto/presto-native-execution/cmake-build-debug -I/Users/aditipandit/ahana_dev/presto/presto/presto-native-execution/cmake-build-debug/_deps/protobuf-src/src -I/Users/aditipandit/ahana_dev/presto/presto/presto-native-execution/velox/. -isystem /opt/homebrew/include -isystem /Users/aditipandit/velox_install/include -isystem /opt/homebrew/opt/openssl@1.1/include -isystem /Users/aditipandit/velox_install/include/proxygen -isystem /Users/aditipandit/ahana_dev/presto/presto/presto-native-execution/velox/velox -isystem /Users/aditipandit/ahana_dev/presto/presto/presto-native-execution/velox/velox/external -mcpu=apple-m1+crc -std=c++17 -fvisibility=hidden -Wno-nullability-completeness -Wno-deprecated-declarations -Wreorder -mcpu=apple-m1+crc -std=c++17 -fvisibility=hidden -D USE_VELOX_COMMON_BASE -D HAS_UNCAUGHT_EXCEPTIONS -g -std=gnu++17 -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk -fPIC -fcolor-diagnostics -MD -MT velox/velox/connectors/hive/storage_adapters/abfs/CMakeFiles/velox_abfs.dir/RegisterAbfsFileSystem.cpp.o -MF velox/velox/connectors/hive/storage_adapters/abfs/CMakeFiles/velox_abfs.dir/RegisterAbfsFileSystem.cpp.o.d -o velox/velox/connectors/hive/storage_adapters/abfs/CMakeFiles/velox_abfs.dir/RegisterAbfsFileSystem.cpp.o -c /Users/aditipandit/ahana_dev/presto/presto/presto-native-execution/velox/velox/connectors/hive/storage_adapters/abfs/RegisterAbfsFileSystem.cpp
dyld[99479]: Library not loaded: /opt/homebrew/opt/fmt/lib/libfmt.11.dylib
  Referenced from: <2B4CCBD1-71A1-35E6-903D-1217D1C46092> /opt/homebrew/Cellar/ccache/4.10.2_1/bin/ccache
  Reason: tried: '/opt/homebrew/opt/fmt/lib/libfmt.11.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/opt/fmt/lib/libfmt.11.dylib' (no such file), '/opt/homebrew/opt/fmt/lib/libfmt.11.
czentgr commented 2 months ago

As a workaround for now - given that fmt is still in the system (from install_fmt) but the homebrew version is picked up (also is used by other depend such as folly and fbthrift - the latter executable dynamically links fmt in that was removed from homebrew).

The workaround for now would be:

ccache is a wrapper around the C/C++ compilers but is not strictly necessary to build the components. It is just that nothing is cached and on make clean things we be rebuilt instead of the cache used.

I was able to use this and unblock me for now until the issue is resolved.

yingsu00 commented 2 months ago

I have a working fix. Will send pr today