nodejs / node

Node.js JavaScript runtime βœ¨πŸ’πŸš€βœ¨
https://nodejs.org
Other
106.95k stars 29.18k forks source link

Build error with clang on Mac OS X 10.15.7 (wasm-engine.cc:157:19: error: no viable overloaded '=') #52847

Open tobbi opened 5 months ago

tobbi commented 5 months ago

Version

v22.1

Platform

Darwin Tobiass-MBP-2.fritz.box 19.6.0 Darwin Kernel Version 19.6.0: Tue Jun 21 21:18:39 PDT 2022; root:xnu-6153.141.66~1/RELEASE_X86_64 x86_64

Subsystem

No response

What steps will reproduce the bug?

Try to install node on Mac OS X

How often does it reproduce? Is there a required condition?

every time

What is the expected behavior? Why is that the expected behavior?

Build does not fail.

What do you see instead?

clang++ -o /private/tmp/node-20240505-15989-9z81ho/node-v22.1.0/out/Release/obj.target/v8_base_without_compiler/deps/v8/src/wasm/wasm-import-wrapper-cache.o ../deps/v8/src/wasm/wasm-import-wrapper-cache.cc '-D_GLIBCXX_USE_CXX11_ABI=1' '-DNODE_OPENSSL_CONF_NAME=nodejs_conf' '-DNODE_OPENSSL_CERT_STORE' '-DICU_NO_USER_DATA_OVERRIDE' '-DV8_GYP_BUILD' '-DV8_TYPED_ARRAY_MAX_SIZE_IN_HEAP=64' '-D_DARWIN_USE_64_BIT_INODE=1' '-DV8_TARGET_ARCH_X64' '-DV8_HAVE_TARGET_OS' '-DV8_TARGET_OS_MACOS' '-DV8_EMBEDDER_STRING="-node.11"' '-DENABLE_DISASSEMBLER' '-DV8_PROMISE_INTERNAL_FIELD_COUNT=1' '-DV8_SHORT_BUILTIN_CALLS' '-DOBJECT_PRINT' '-DV8_INTL_SUPPORT' '-DV8_ATOMIC_OBJECT_FIELD_WRITES' '-DV8_ENABLE_LAZY_SOURCE_POSITIONS' '-DV8_USE_SIPHASH' '-DV8_SHARED_RO_HEAP' '-DNDEBUG' '-DV8_WIN64_UNWINDING_INFO' '-DV8_ENABLE_REGEXP_INTERPRETER_THREADED_DISPATCH' '-DV8_USE_ZLIB' '-DV8_ENABLE_SPARKPLUG' '-DV8_ENABLE_MAGLEV' '-DV8_ENABLE_TURBOFAN' '-DV8_ENABLE_SYSTEM_INSTRUMENTATION' '-DV8_ENABLE_WEBASSEMBLY' '-DV8_ENABLE_JAVASCRIPT_PROMISE_HOOKS' '-DV8_ENABLE_CONTINUATION_PRESERVED_EMBEDDER_DATA' '-DV8_ALLOCATION_FOLDING' '-DV8_ALLOCATION_SITE_TRACKING' '-DV8_ADVANCED_BIGINT_ALGORITHMS' '-DICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_STATIC' -I/usr/local/opt/libuv/include -I/usr/local/opt/brotli/include -I/usr/local/opt/c-ares/include -I/usr/local/opt/libnghttp2/include -I/usr/local/opt/openssl@3/include -I/usr/local/Cellar/icu4c/74.2/include -I../deps/v8 -I../deps/v8/include -I/private/tmp/node-20240505-15989-9z81ho/node-v22.1.0/out/Release/obj/gen/inspector-generated-output-root -I../deps/v8/third_party/inspector_protocol -I/private/tmp/node-20240505-15989-9z81ho/node-v22.1.0/out/Release/obj/gen -I/private/tmp/node-20240505-15989-9z81ho/node-v22.1.0/out/Release/obj/gen/generate-bytecode-output-root -I../deps/v8/third_party/zlib -I../deps/v8/third_party/zlib/google -I../deps/v8/third_party/abseil-cpp -I../deps/v8/third_party/fp16/src/include  -O3 -gdwarf-2 -fstrict-aliasing -mmacosx-version-min=11.0 -arch x86_64 -Wall -Wendif-labels -W -Wno-unused-parameter -Wno-invalid-offsetof -std=gnu++17 -stdlib=libc++ -fno-rtti -fno-exceptions -fno-strict-aliasing -MMD -MF /private/tmp/node-20240505-15989-9z81ho/node-v22.1.0/out/Release/.deps//private/tmp/node-20240505-15989-9z81ho/node-v22.1.0/out/Release/obj.target/v8_base_without_compiler/deps/v8/src/wasm/wasm-import-wrapper-cache.o.d.raw   -c
../deps/v8/src/wasm/wasm-engine.cc:157:19: error: no viable overloaded '='
      source_url_ = String::cast(script->name())->ToCString();
      ~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/memory:3737:17: note: candidate function not viable: no known conversion from 'std::unique_ptr<char []>' to 'const std::__1::shared_ptr<char const[]>' for 1st argument
    shared_ptr& operator=(const shared_ptr& __r) _NOEXCEPT;
                ^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/memory:3748:17: note: candidate function not viable: no known conversion from 'std::unique_ptr<char []>' to 'std::__1::shared_ptr<char const[]>' for 1st argument
    shared_ptr& operator=(shared_ptr&& __r) _NOEXCEPT;
                ^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/memory:3745:9: note: candidate template ignored: could not match 'shared_ptr' against 'unique_ptr'
        operator=(const shared_ptr<_Yp>& __r) _NOEXCEPT;
        ^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/memory:3756:9: note: candidate template ignored: could not match 'shared_ptr' against 'unique_ptr'
        operator=(shared_ptr<_Yp>&& __r);
        ^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/memory:3790:9: note: candidate template ignored: requirement '!is_array<char []>::value' was not satisfied [with _Yp = char [], _Dp = std::__1::default_delete<char []>]
        operator=(unique_ptr<_Yp, _Dp>&& __r);
        ^
../deps/v8/src/wasm/wasm-engine.cc:1347:21: error: cannot initialize a variable of type 'const char *' with an rvalue of type 'std::__1::shared_ptr<char const[]>::element_type *' (aka 'char const (*)[]')
        const char* source_url = code_to_log.source_url.get();
                    ^            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  clang++ -o /private/tmp/node-20240505-15989-9z81ho/node-v22.1.0/out/Release/obj.target/v8_base_without_compiler/deps/v8/src/wasm/wasm-js.o ../deps/v8/src/wasm/wasm-js.cc '-D_GLIBCXX_USE_CXX11_ABI=1' '-DNODE_OPENSSL_CONF_NAME=nodejs_conf' '-DNODE_OPENSSL_CERT_STORE' '-DICU_NO_USER_DATA_OVERRIDE' '-DV8_GYP_BUILD' '-DV8_TYPED_ARRAY_MAX_SIZE_IN_HEAP=64' '-D_DARWIN_USE_64_BIT_INODE=1' '-DV8_TARGET_ARCH_X64' '-DV8_HAVE_TARGET_OS' '-DV8_TARGET_OS_MACOS' '-DV8_EMBEDDER_STRING="-node.11"' '-DENABLE_DISASSEMBLER' '-DV8_PROMISE_INTERNAL_FIELD_COUNT=1' '-DV8_SHORT_BUILTIN_CALLS' '-DOBJECT_PRINT' '-DV8_INTL_SUPPORT' '-DV8_ATOMIC_OBJECT_FIELD_WRITES' '-DV8_ENABLE_LAZY_SOURCE_POSITIONS' '-DV8_USE_SIPHASH' '-DV8_SHARED_RO_HEAP' '-DNDEBUG' '-DV8_WIN64_UNWINDING_INFO' '-DV8_ENABLE_REGEXP_INTERPRETER_THREADED_DISPATCH' '-DV8_USE_ZLIB' '-DV8_ENABLE_SPARKPLUG' '-DV8_ENABLE_MAGLEV' '-DV8_ENABLE_TURBOFAN' '-DV8_ENABLE_SYSTEM_INSTRUMENTATION' '-DV8_ENABLE_WEBASSEMBLY' '-DV8_ENABLE_JAVASCRIPT_PROMISE_HOOKS' '-DV8_ENABLE_CONTINUATION_PRESERVED_EMBEDDER_DATA' '-DV8_ALLOCATION_FOLDING' '-DV8_ALLOCATION_SITE_TRACKING' '-DV8_ADVANCED_BIGINT_ALGORITHMS' '-DICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_STATIC' -I/usr/local/opt/libuv/include -I/usr/local/opt/brotli/include -I/usr/local/opt/c-ares/include -I/usr/local/opt/libnghttp2/include -I/usr/local/opt/openssl@3/include -I/usr/local/Cellar/icu4c/74.2/include -I../deps/v8 -I../deps/v8/include -I/private/tmp/node-20240505-15989-9z81ho/node-v22.1.0/out/Release/obj/gen/inspector-generated-output-root -I../deps/v8/third_party/inspector_protocol -I/private/tmp/node-20240505-15989-9z81ho/node-v22.1.0/out/Release/obj/gen -I/private/tmp/node-20240505-15989-9z81ho/node-v22.1.0/out/Release/obj/gen/generate-bytecode-output-root -I../deps/v8/third_party/zlib -I../deps/v8/third_party/zlib/google -I../deps/v8/third_party/abseil-cpp -I../deps/v8/third_party/fp16/src/include  -O3 -gdwarf-2 -fstrict-aliasing -mmacosx-version-min=11.0 -arch x86_64 -Wall -Wendif-labels -W -Wno-unused-parameter -Wno-invalid-offsetof -std=gnu++17 -stdlib=libc++ -fno-rtti -fno-exceptions -fno-strict-aliasing -MMD -MF /private/tmp/node-20240505-15989-9z81ho/node-v22.1.0/out/Release/.deps//private/tmp/node-20240505-15989-9z81ho/node-v22.1.0/out/Release/obj.target/v8_base_without_compiler/deps/v8/src/wasm/wasm-js.o.d.raw   -c
2 errors generated.

Additional information

No response

targos commented 5 months ago

macOS 10.15 is no longer supported to build node. We require at least macOS 11.

tobbi commented 5 months ago

To me it seems like the build error might not be specific to OS X 10.15.

targos commented 5 months ago

It's specific to the clang version that ships with Xcode on 10.15

tobbi commented 5 months ago

Assuming I fixed that locally and put it under a platform-specific #ifdef guard, would you accept patches?

ireddick commented 5 months ago

I am experiencing something similar on Mac OS 11.7.10

I'm building v22.1 via Homebrew (I'm aware that Homebrew no longer officially supports this OS version)

Clang: 13.0.0 build 1300 macOS: 11.7.10-x86_64 CLT: 13.2.0.0.1.1638488800 Xcode: 13.2.1

../deps/v8/src/wasm/wasm-engine.cc:157:19: error: no viable overloaded '='
      source_url_ = String::cast(script->name())->ToCString();
      ~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk/usr/include/c++/v1/memory:3435:17: note: candidate function not viable: no known conversion from 'std::unique_ptr<char []>' to 'const std::shared_ptr<char const[]>' for 1st argument
    shared_ptr& operator=(const shared_ptr& __r) _NOEXCEPT;
                ^
/Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk/usr/include/c++/v1/memory:3443:9: note: candidate template ignored: could not match 'shared_ptr' against 'unique_ptr'
        operator=(const shared_ptr<_Yp>& __r) _NOEXCEPT;
        ^
/Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk/usr/include/c++/v1/memory:3445:17: note: candidate function not viable: no known conversion from 'std::unique_ptr<char []>' to 'std::shared_ptr<char const[]>' for 1st argument
    shared_ptr& operator=(shared_ptr&& __r) _NOEXCEPT;
                ^
/Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk/usr/include/c++/v1/memory:3453:9: note: candidate template ignored: could not match 'shared_ptr' against 'unique_ptr'
        operator=(shared_ptr<_Yp>&& __r);
        ^
/Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk/usr/include/c++/v1/memory:3473:9: note: candidate template ignored: requirement '!is_array<char []>::value' was not satisfied [with _Yp = char [], _Dp = std::default_delete<char []>]
        operator=(unique_ptr<_Yp, _Dp>&& __r);
        ^
1 error generated.
tobbi commented 5 months ago

Does this need to be reported upstream to the maintainers of v8 or to what extent is the version bundled with nodejs up-to-date with that?

targos commented 5 months ago

Official macOS releases are built with Xcode 13.2.1 too and we don't get this error πŸ€”

wehrwein1 commented 4 months ago

Had similar issue to @ireddick -- install node v22.1 from source via homebrew on macOS 11 failed, re: wasm-engine

Clang="Apple clang version 13.0.0 (clang-1300.0.29.30)" macOS=11.7.10 (older OS, unsupported by homebrew) Xcode CommandLineTools: 13.2.0.0.1.1638488800 (ref)

Error: node "make install" step failing on wasm-engine.o:

/Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk/usr/include/c++/v1/memory:3445:17: note: candidate function not viable: no known conversion from 'std::unique_ptr<char []>' to 'std::shared_ptr<char const[]>' for 1st argument
    shared_ptr& operator=(shared_ptr&& __r) _NOEXCEPT;
                ^
/Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk/usr/include/c++/v1/memory:3453:9: note: candidate template ignored: could not match 'shared_ptr' against 'unique_ptr'
        operator=(shared_ptr<_Yp>&& __r);
        ^
/Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk/usr/include/c++/v1/memory:3473:9: note: candidate template ignored: requirement '!is_array<char []>::value' was not satisfied [with _Yp = char [], _Dp = std::default_delete<char []>]
        operator=(unique_ptr<_Yp, _Dp>&& __r);
        ^
1 error generated.
make[1]: *** [/private/tmp/node-20240508-1940-mkq0xj/node-v22.1.0/out/Release/obj.target/v8_base_without_compiler/deps/v8/src/wasm/wasm-engine.o] Error 1
..
make: *** [node] Error 2

Workaround (sufficient for my needs): revert to older node version in homebrew: node@20 (ref), build/install completed without error

baldr9 commented 4 months ago

I'm getting a similar error when using brew to upgrade node:

==> Upgrading node
  21.7.1 -> 22.2.0
==> ./configure --without-npm --without-corepack --with-intl=system-icu --shared-libuv --shared-nghttp2 --shared-openssl
==> make install

/Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk/usr/include/c++/v1/memory:3453:9: note: candidate template ignored: could not match 'shared_ptr' against 'unique_ptr'
        operator=(shared_ptr<_Yp>&& __r);
        ^
/Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk/usr/include/c++/v1/memory:3473:9: note: candidate template ignored: requirement '!is_array<char []>::value' was not satisfied [with _Yp = char [], _Dp = std::default_delete<char []>]
        operator=(unique_ptr<_Yp, _Dp>&& __r);

Clang="Apple clang version 13.0.0 (clang-1300.0.29.30)" macOS=11.7.10 (older OS, unsupported by homebrew) Xcode CommandLineTools: 13.2.0.0.1.1638488800

ireddick commented 2 months ago

I've now successfully built v22.3.0 directly (ie. not via Homebrew) using the same release archive that Homebrew uses in its formula:

https://nodejs.org/dist/v22.3.0/node-v22.3.0.tar.xz

Homebrew formula

I used the default build steps from BUILDING.md

./configure
make -j4

This resulted in a working node executable πŸ‘

I then tried installing v22.3.0 via Homebrew and got the same build error as before, so I'm fairly confident that this is a Homebrew related thing.

Something I've noticed is that Homebrew sets a lot of environment variables and passes a lot of configuration options. This is from the log of my last attempt:

HOMEBREW_CC: clang
HOMEBREW_CXX: clang++
MAKEFLAGS: -j4
CMAKE_PREFIX_PATH: /usr/local/opt/icu4c:/usr/local
CMAKE_INCLUDE_PATH: /Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk/System/Library/Frameworks/OpenGL.framework/Versions/Current/Headers
CMAKE_LIBRARY_PATH: /Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk/System/Library/Frameworks/OpenGL.framework/Versions/Current/Libraries
CMAKE_FRAMEWORK_PATH: /usr/local/opt/python@3.12/Frameworks
PKG_CONFIG_PATH: /usr/local/opt/python@3.12/lib/pkgconfig:/usr/local/opt/brotli/lib/pkgconfig:/usr/local/opt/c-ares/lib/pkgconfig:/usr/local/opt/icu4c/lib/pkgconfig:/usr/local/opt/libnghttp2/lib/pkgconfig:/usr/local/opt/libuv/lib/pkgconfig:/usr/local/opt/openssl@3/lib/pkgconfig
PKG_CONFIG_LIBDIR: /usr/lib/pkgconfig:/usr/local/Homebrew/Library/Homebrew/os/mac/pkgconfig/11
HOMEBREW_GIT: git
HOMEBREW_SDKROOT: /Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk
ACLOCAL_PATH: /usr/local/share/aclocal
PATH: /usr/local/Homebrew/Library/Homebrew/shims/mac/super:/usr/local/opt/pkg-config/bin:/usr/local/opt/python@3.12/bin:/usr/local/opt/brotli/bin:/usr/local/opt/c-ares/bin:/usr/local/opt/icu4c/bin:/usr/local/opt/openssl@3/bin:/usr/local/opt/python@3.12/libexec/bin:/usr/bin:/bin:/usr/sbin:/sbin
./configure --prefix=/usr/local/Cellar/node/22.3.0 --without-npm --without-corepack --with-intl=system-icu --shared-libuv --shared-nghttp2 --shared-openssl --shared-zlib --shared-brotli --shared-cares --shared-libuv-includes=/usr/local/opt/libuv/include --shared-libuv-libpath=/usr/local/opt/libuv/lib --shared-nghttp2-includes=/usr/local/opt/libnghttp2/include --shared-nghttp2-libpath=/usr/local/opt/libnghttp2/lib --shared-openssl-includes=/usr/local/opt/openssl@3/include --shared-openssl-libpath=/usr/local/opt/openssl@3/lib --shared-brotli-includes=/usr/local/opt/brotli/include --shared-brotli-libpath=/usr/local/opt/brotli/lib --shared-cares-includes=/usr/local/opt/c-ares/include --shared-cares-libpath=/usr/local/opt/c-ares/lib --openssl-use-def-ca-store

make install

Platform and tools:

Clang: 13.0.0 build 1300 macOS: 11.7.10-x86_64 CLT: 13.2.0.0.1.1638488800 Xcode: 13.2.1

Worth highlighting again that I'm aware that Homebrew no longer supports this OS version.

markellos918 commented 1 month ago

Same issue here. I have got the same platform and tools as the previous comment. Similarly, I can build from the release available from nodejs website as well as the node@20 release with Homebrew. I tried editing the node.rb formula to remove most config options, to no avail.