Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation error "no member named 'make_unique' in namespace 'std'" on MacOS for v2.5 #1647

Closed
empiredan opened this issue Oct 18, 2023 · 0 comments
Labels
2.5 issues and pull requests dedicated to v2.5 build cmake cpp

Comments

@empiredan
Copy link
Contributor

empiredan commented Oct 18, 2023

According to #1640 (comment), for v2.5, MacOS compilation failed due to "no member named 'make_unique' in namespace 'std'" as below:

>>> compiling thrift file dsn.layer2.thrift ...
mkdir /Users/runner/work/incubator-pegasus/incubator-pegasus/idl/output
/Users/runner/work/incubator-pegasus/incubator-pegasus/thirdparty/output/bin/thrift -gen cpp:moveable_types -out output dsn.layer2.thrift
mv output/dsn.layer2_types.h /Users/runner/work/incubator-pegasus/incubator-pegasus/src/common/serialization_helper
mv output/dsn.layer2_types.cpp /Users/runner/work/incubator-pegasus/incubator-pegasus/src/runtime
rm -rf /Users/runner/work/incubator-pegasus/incubator-pegasus/idl/output

done
Running cmake Pegasus...
~/work/incubator-pegasus/incubator-pegasus/build/release ~/work/incubator-pegasus/incubator-pegasus ~/work/incubator-pegasus/incubator-pegasus
CMake Warning (dev) at CMakeLists.txt:18 (project):
  cmake_minimum_required() should be called prior to this top-level project()
  call.  Please see the cmake-commands(7) manual for usage documentation of
  both commands.
This warning is for project developers.  Use -Wno-dev to suppress it.

-- The C compiler identification is AppleClang 14.0.0.14000029
-- The CXX compiler identification is AppleClang 14.0.0.14000029
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/gcc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
Running CompilerInfo.cmake
Apple clang version 14.0.0 (clang-1400.0.29.202)
Target: x86_64-apple-darwin21.6.0
Thread model: posix
InstalledDir: /Applications/Xcode_14.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

Selected compiler clang 14.0
-- THIRDPARTY_INSTALL_DIR = /Users/runner/work/incubator-pegasus/incubator-pegasus/thirdparty/output
-- BUILD_DIR = /Users/runner/work/incubator-pegasus/incubator-pegasus/src/builder
-- BUILD_TEST = ON
-- ENABLE_GCOV = NO
-- ENABLE_GPERF = ON
-- USE_JEMALLOC = OFF
-- CCACHE: /usr/local/bin/ccache
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE  
-- FIND_LIBRARY_USE_LIB64_PATHS = ON
-- Found components for DL
-- DL_INCLUDES = /Applications/Xcode_14.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/usr/include
-- DL_LIBRARIES = /Applications/Xcode_14.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/usr/lib/libdl.tbd
-- Found OpenSSL: /usr/local/opt/openssl/lib/libcrypto.dylib (found version "3.1.2")  
-- use ccache to speed up compilation
-- CMAKE_PREFIX_PATH = /Users/runner/work/incubator-pegasus/incubator-pegasus/thirdparty/output
-- Found Boost: /Users/runner/work/incubator-pegasus/incubator-pegasus/thirdparty/output/include (found version "1.[69](https://github.com/apache/incubator-pegasus/actions/runs/6546807374/job/17778038617?pr=1640#step:6:70).0") found components: system filesystem regex 
-- Found snappy: /usr/local/lib/libsnappy.dylib  
-- Found zstd: /usr/local/lib/libzstd.dylib  
-- Found lz4: /usr/local/lib/liblz4.dylib  
-- Found JNI: /Users/runner/hostedtoolcache/Java_Temurin-Hotspot_jdk/8.0.382-5/x64/Contents/Home/include  found components: AWT JVM 
-- JAVA_JVM_LIBRARY=/Users/runner/hostedtoolcache/Java_Temurin-Hotspot_jdk/8.0.382-5/x64/Contents/Home/jre/lib/server/libjvm.dylib
-- MACOS_OPENSSL_ROOT_DIR: /usr/local/opt/openssl
-- THRIFT_GENERATED_FILE_PATH=/Users/runner/work/incubator-pegasus/incubator-pegasus/build/release/thrift-gen
-- THRIFT_GENERATE_CPP: /Users/runner/work/incubator-pegasus/incubator-pegasus/idl/metadata.thrift
-- THRIFT_GENERATE_CPP: /Users/runner/work/incubator-pegasus/incubator-pegasus/src/common/consensus.thrift
-- THRIFT_GENERATE_CPP: /Users/runner/work/incubator-pegasus/incubator-pegasus/src/common/duplication_internal.thrift
-- THRIFT_GENERATE_CPP: /Users/runner/work/incubator-pegasus/incubator-pegasus/idl/duplication.thrift
-- THRIFT_GENERATE_CPP: /Users/runner/work/incubator-pegasus/incubator-pegasus/idl/backup.thrift
-- THRIFT_GENERATE_CPP: /Users/runner/work/incubator-pegasus/incubator-pegasus/idl/meta_admin.thrift
-- THRIFT_GENERATE_CPP: /Users/runner/work/incubator-pegasus/incubator-pegasus/idl/bulk_load.thrift
-- THRIFT_GENERATE_CPP: /Users/runner/work/incubator-pegasus/incubator-pegasus/idl/partition_split.thrift
-- THRIFT_GENERATE_CPP: /Users/runner/work/incubator-pegasus/incubator-pegasus/idl/replica_admin.thrift
-- THRIFT_GENERATE_CPP: /Users/runner/work/incubator-pegasus/incubator-pegasus/src/failure_detector/fd.thrift
-- THRIFT_GENERATE_CPP: /Users/runner/work/incubator-pegasus/incubator-pegasus/src/nfs/nfs.thrift
-- THRIFT_GENERATE_CPP: /Users/runner/work/incubator-pegasus/incubator-pegasus/idl/command.thrift
-- THRIFT_GENERATE_CPP: /Users/runner/work/incubator-pegasus/incubator-pegasus/src/replica/storage/simple_kv/simple_kv.thrift
-- Found ZLIB: /Applications/Xcode_14.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/usr/lib/libz.tbd (found version "1.2.11")  
-- Found CURL: /Users/runner/work/incubator-pegasus/incubator-pegasus/thirdparty/output/lib/libcurl.a (found version "7.47.0")  
-- THRIFT_GENERATE_CPP: /Users/runner/work/incubator-pegasus/incubator-pegasus/src/runtime/rpc/request_meta.thrift
-- THRIFT_GENERATE_CPP: /Users/runner/work/incubator-pegasus/incubator-pegasus/idl/security.thrift
-- Configuring done (7.9s)
-- Generating done (1.0s)
-- Build files have been written to: /Users/runner/work/incubator-pegasus/incubator-pegasus/build/release
Gen git_commit.h ...
~/work/incubator-pegasus/incubator-pegasus/src ~/work/incubator-pegasus/incubator-pegasus/build/release ~/work/incubator-pegasus/incubator-pegasus ~/work/incubator-pegasus/incubator-pegasus
d2aa7978d9d141e39841f114d48b6b8[70](https://github.com/apache/incubator-pegasus/actions/runs/6546807374/job/17778038617?pr=1640#step:6:71)1a9e76f
PEGASUS_GIT_COMMIT=d2aa7978d9d141e39841f114d48b6b8701a9e76f
Generating /Users/runner/work/incubator-pegasus/incubator-pegasus/src/include/pegasus/git_commit.h...
[Tue Oct 17 12:35:48 UTC 2023] Building Pegasus ...
~/work/incubator-pegasus/incubator-pegasus/build/release ~/work/incubator-pegasus/incubator-pegasus/src ~/work/incubator-pegasus/incubator-pegasus/build/release ~/work/incubator-pegasus/incubator-pegasus ~/work/incubator-pegasus/incubator-pegasus
[  0%] Building CXX object src/perf_counter/CMakeFiles/dsn.perf_counter.dir/builtin_counters.cpp.o
[  0%] Building CXX object src/utils/CMakeFiles/dsn_utils.dir/alloc.cpp.o
[  0%] Building CXX object src/aio/CMakeFiles/dsn_aio.dir/aio_provider.cpp.o
[  0%] Building CXX object src/utils/CMakeFiles/dsn_utils.dir/binary_reader.cpp.o
[  0%] Building CXX object src/perf_counter/CMakeFiles/dsn.perf_counter.dir/perf_counter.cpp.o

......

[ 33%] Built target dsn_runtime
[ 33%] Building CXX object src/aio/test/CMakeFiles/dsn_aio_test.dir/aio.cpp.o
[ 33%] Building CXX object src/block_service/test/CMakeFiles/dsn_block_service_test.dir/block_service_manager_test.cpp.o
[ 33%] Building CXX object src/base/test/CMakeFiles/base_test.dir/main.cpp.o
[ 34%] Building CXX object src/base/test/CMakeFiles/base_test.dir/utils_test.cpp.o
/Users/runner/work/incubator-pegasus/incubator-pegasus/src/aio/test/aio.cpp:177:21: error: no member named 'make_unique' in namespace 'std'
    auto err = std::make_unique<dsn::error_code>();
               ~~~~~^
/Users/runner/work/incubator-pegasus/incubator-pegasus/src/aio/test/aio.cpp:177:48: error: expected '(' for function-style cast or type construction
    auto err = std::make_unique<dsn::error_code>();
                                ~~~~~~~~~~~~~~~^
/Users/runner/work/incubator-pegasus/incubator-pegasus/src/aio/test/aio.cpp:177:50: error: expected expression
    auto err = std::make_unique<dsn::error_code>();
                                                 ^
/Users/runner/work/incubator-pegasus/incubator-pegasus/src/aio/test/aio.cpp:178:23: error: no member named 'make_unique' in namespace 'std'
    auto count = std::make_unique<size_t>();
                 ~~~~~^
/Users/runner/work/incubator-pegasus/incubator-pegasus/src/aio/test/aio.cpp:178:35: error: unexpected type name 'size_t': expected expression
    auto count = std::make_unique<size_t>();
                                  ^
/Users/runner/work/incubator-pegasus/incubator-pegasus/src/aio/test/aio.cpp:178:43: error: expected expression
    auto count = std::make_unique<size_t>();
                                          ^
6 errors generated.
make[2]: *** [src/aio/test/CMakeFiles/dsn_aio_test.dir/aio.cpp.o] Error 1
make[1]: *** [src/aio/test/CMakeFiles/dsn_aio_test.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 35%] Building CXX object src/block_service/test/CMakeFiles/dsn_block_service_test.dir/fds_service_test.cpp.o
[ 35%] Building CXX object src/base/test/CMakeFiles/base_test.dir/value_manager_test.cpp.o
In file included from /Users/runner/work/incubator-pegasus/incubator-pegasus/src/block_service/test/block_service_manager_test.cpp:29:
In file included from /Users/runner/work/incubator-pegasus/incubator-pegasus/src/block_service/local/local_service.h:24:
In file included from /Users/runner/work/incubator-pegasus/incubator-pegasus/src/block_service/block_service.h:32:
In file included from /Users/runner/work/incubator-pegasus/incubator-pegasus/src/common/serialization_helper/thrift_helper.h:30:
In file included from /Users/runner/work/incubator-pegasus/incubator-pegasus/src/runtime/rpc/rpc_host_port.h:31:
In file included from /Users/runner/work/incubator-pegasus/incubator-pegasus/src/utils/errors.h:36:
/Users/runner/work/incubator-pegasus/incubator-pegasus/src/utils/smart_pointers.h:110:60: error: cannot define or redeclare 'make_unique' here because namespace 'dsn' does not enclose namespace 'std'
typename memory_internal::MakeUniqueResult<T>::scalar std::make_unique(Args &&... args)
                                                      ~~~~~^
/Users/runner/work/incubator-pegasus/incubator-pegasus/src/utils/smart_pointers.h:120:59: error: cannot define or redeclare 'make_unique' here because namespace 'dsn' does not enclose namespace 'std'
typename memory_internal::MakeUniqueResult<T>::array std::make_unique(size_t n)
                                                     ~~~~~^
/Users/runner/work/incubator-pegasus/incubator-pegasus/src/utils/smart_pointers.h:129:6: error: cannot define or redeclare 'make_unique' here because namespace 'dsn' does not enclose namespace 'std'
std::make_unique(Args &&... /* args */) = delete;
~~~~~^
In file included from /Users/runner/work/incubator-pegasus/incubator-pegasus/src/block_service/test/fds_service_test.cpp:18:
In file included from /Users/runner/work/incubator-pegasus/incubator-pegasus/src/block_service/fds/fds_service.h:29:
In file included from /Users/runner/work/incubator-pegasus/incubator-pegasus/src/block_service/block_service.h:32:
In file included from /Users/runner/work/incubator-pegasus/incubator-pegasus/src/runtime/rpc/serialization.h:32:
In file included from /Users/runner/work/incubator-pegasus/incubator-pegasus/src/common/serialization_helper/thrift_helper.h:30:
In file included from /Users/runner/work/incubator-pegasus/incubator-pegasus/src/runtime/rpc/rpc_host_port.h:31:
/Users/runner/work/incubator-pegasus/incubator-pegasus/src/utils/errors.h:165:21: error: no matching function for call to 'make_unique'
            _info = std::make_unique<error_info>(rhs._info->code, rhs._info->msg);
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /Users/runner/work/incubator-pegasus/incubator-pegasus/src/block_service/test/fds_service_test.cpp:18:
In file included from /Users/runner/work/incubator-pegasus/incubator-pegasus/src/block_service/fds/fds_service.h:29:
In file included from /Users/runner/work/incubator-pegasus/incubator-pegasus/src/block_service/block_service.h:34:
In file included from /Users/runner/work/incubator-pegasus/incubator-pegasus/src/runtime/serverlet.h:29:
In file included from /Users/runner/work/incubator-pegasus/incubator-pegasus/src/runtime/rpc/rpc_holder.h:28:
In file included from /Users/runner/work/incubator-pegasus/incubator-pegasus/src/client/partition_resolver.h:40:
/Users/runner/work/incubator-pegasus/incubator-pegasus/src/runtime/task/async_calls.h:133:10: error: initialized lambda captures are a C++14 extension [-Werror,-Wc++14-extensions]
        [cb_fwd = std::move(callback)](
         ^
In file included from /Users/runner/work/incubator-pegasus/incubator-pegasus/src/block_service/test/fds_service_test.cpp:18:
In file included from /Users/runner/work/incubator-pegasus/incubator-pegasus/src/block_service/fds/fds_service.h:29:
In file included from /Users/runner/work/incubator-pegasus/incubator-pegasus/src/block_service/block_service.h:34:
In file included from /Users/runner/work/incubator-pegasus/incubator-pegasus/src/runtime/serverlet.h:29:
/Users/runner/work/incubator-pegasus/incubator-pegasus/src/runtime/rpc/rpc_holder.h:171:15: error: initialized lambda captures are a C++14 extension [-Werror,-Wc++14-extensions]
            [ cb_fwd = std::forward<TCallback>(callback),
              ^
/Users/runner/work/incubator-pegasus/incubator-pegasus/src/runtime/rpc/rpc_holder.h:172:15: error: initialized lambda captures are a C++14 extension [-Werror,-Wc++14-extensions]
              rpc = *this ](error_code err, message_ex * req, message_ex * resp) mutable {
              ^
/Users/runner/work/incubator-pegasus/incubator-pegasus/src/runtime/rpc/rpc_holder.h:203:15: error: initialized lambda captures are a C++14 extension [-Werror,-Wc++14-extensions]
            [ cb_fwd = std::forward<TCallback>(callback),
              ^
/Users/runner/work/incubator-pegasus/incubator-pegasus/src/runtime/rpc/rpc_holder.h:204:15: error: initialized lambda captures are a C++14 extension [-Werror,-Wc++14-extensions]
              rpc = *this ](error_code err, message_ex * req, message_ex * resp) mutable {
              ^
9 errors generated.
make[2]: *** [src/block_service/test/CMakeFiles/dsn_block_service_test.dir/fds_service_test.cpp.o] Error 1
make[1]: *** [src/block_service/test/CMakeFiles/dsn_block_service_test.dir/all] Error 2
make: *** [all] Error 2
Error: Process completed with exit code 2.

The compilation error on MacOS for master branch was fixed by #1603 which mark C++17 as required.

std::make_unique was introduced since C++14:

And actually pegasus has adopted C++14 before as c++1y:

  include(CheckCXXCompilerFlag)
  CHECK_CXX_COMPILER_FLAG("-std=c++1y" COMPILER_SUPPORTS_CXX1Y)
  if(NOT ${COMPILER_SUPPORTS_CXX1Y})
    message(FATAL_ERROR "You need a compiler with C++1y support.")
  endif()

c++1y has been deprecated, thus

In #1605 and #1640 we use following statements instead, however it does not work for MacOS, the reason should be found and the compilation error should be fixed:

  set(CMAKE_CXX_STANDARD 14)
  set(CMAKE_CXX_STANDARD_REQUIRED ON)
  set(CMAKE_CXX_EXTENSIONS OFF)
@empiredan empiredan added type/enhancement Indicates new feature requests 2.5 issues and pull requests dedicated to v2.5 and removed type/enhancement Indicates new feature requests labels Oct 18, 2023
empiredan added a commit that referenced this issue Oct 19, 2023
#1647
 
The standard followed by [v2.5](https://github.com/apache/incubator-pegasus/tree/v2.5)
would be C++14. However, Compilation on MacOS failed due to some errors, such as:
- no member named 'make_unique' in namespace 'std'
- initialized lambda captures are a C++14 extension
- 'ext/alloc_traits.h' file not found

Most of the errors are about C++14. `cmake` directives should be fixed to make C++14
compilation on MacOS work well.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.5 issues and pull requests dedicated to v2.5 build cmake cpp
Projects
None yet
Development

No branches or pull requests

1 participant