Opened 8 years ago
Last modified 8 years ago
#52634 new defect
nodejs4 @4.6.0: build does not respect CXXFLAGS
Reported by: | gallafent | Owned by: | ci42 |
---|---|---|---|
Priority: | Normal | Milestone: | |
Component: | ports | Version: | 2.3.4 |
Keywords: | Cc: | mojca (Mojca Miklavec) | |
Port: | nodejs4 |
Description
Building on current mac OS 10.12 with current Xcode 8.0. main.log attached.
Problem arises due to the presence of the following lines in my macports.conf:
macosx_deployment_target 10.8 configure.macosx_deployment_target 10.8 cxx_stdlib libc++ configure.cxx_stdlib libc++ cxxflags -std=c++14 configure.cxxflags -std=c++14
I'm aware that to do this is not particularly supported, but it does often work (!), and the fix here does not break more “normal” builds.
In this case, the build fails since it is not able to find type_traits. In particular, the following build line fails for that reason:
/usr/bin/clang++ '-D_DARWIN_USE_64_BIT_INODE=1' '-DGTEST_DONT_DEFINE_ASSERT_EQ=1' '-DGTEST_DONT_DEFINE_ASSERT_GE=1' '-DGTEST_DONT_DEFINE_ASSERT_GT=1' '-DGTEST_DONT_DEFINE_ASSERT_LE=1' '-DGTEST_DONT_DEFINE_ASSERT_LT=1' '-DGTEST_DONT_DEFINE_ASSERT_NE=1' -I../deps/gtest/include -I../deps/v8/include -I../src -I/opt/local/include -Os -gdwarf-2 -arch x86_64 -Wall -Wendif-labels -W -Wno-unused-parameter -std=gnu++0x -fno-rtti -fno-exceptions -fno-threadsafe-statics -fno-strict-aliasing -MMD -MF /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_devel_nodejs4/nodejs4/work/node-v4.6.0/out/Release/.deps//opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_devel_nodejs4/nodejs4/work/node-v4.6.0/out/Release/obj.target/cctest/test/cctest/util.o.d.raw -Os -c -o /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_devel_nodejs4/nodejs4/work/node-v4.6.0/out/Release/obj.target/cctest/test/cctest/util.o ../test/cctest/util.cc
In testing, I find that if the environment variable is set: MACOSX_DEPLOYMENT_TARGET=10.8
then I receive the same error. If that variable is empty then the file compiles correctly.
In file included from ../test/cctest/util.cc:1: ../src/util.h:11:10: fatal error: 'type_traits' file not found #include <type_traits> // std::remove_reference ^ 1 error generated.
This error may be prevented by adding the argument -stdlib=libc++
to the command line. I assume this is because when building for mac OS 10.12 libstdc++ is the standard version of the C++ runtime to use, whereas when targetting 10.8 libstdc++ is the default, which misses this library. That diagnosis may of course be wrong.
The solution, then, is to add the -stdlib=libc++ argument to build lines unconditionally (it does no harm on systems which already have that as the default). I'm having a nose around to see how that is achieved, since the build system here clearly ignores the cxx_stdlib variables set in macports.conf …
Attachments (2)
Change History (9)
Changed 8 years ago by gallafent
comment:1 Changed 8 years ago by larryv (Lawrence Velázquez)
Cc: | ciserlohn@… removed |
---|---|
Owner: | changed from macports-tickets@… to ciserlohn@… |
Summary: | -snodejs4 build failure — type_traits not found when targetting mac OS 10.8 → nodejs4 build failure — type_traits not found when targetting mac OS 10.8 |
Replying to william@…:
Problem arises due to the presence of the following lines in my macports.conf:
macosx_deployment_target 10.8 configure.macosx_deployment_target 10.8 cxx_stdlib libc++ configure.cxx_stdlib libc++ cxxflags -std=c++14 configure.cxxflags -std=c++14
The only valid settings here are macosx_deployment_target
and cxx_stdlib
. MacPorts does not recognize the others.
The solution, then, is to add the -stdlib=libc++ argument to build lines unconditionally (it does no harm on systems which already have that as the default). I'm having a nose around to see how that is achieved, since the build system here clearly ignores the cxx_stdlib variables set in macports.conf …
CXXFLAGS
already contains -stdlib=libc++
. So the problem is that the build system is not respecting that.
Many if not all of the compiler invocations use -std=gnu++0x
. Does this software require C++11 support? If so, the portfile ought to take this into account.
comment:2 Changed 8 years ago by larryv (Lawrence Velázquez)
Summary: | nodejs4 build failure — type_traits not found when targetting mac OS 10.8 → nodejs4 @4.6.0: build does not respect CXXFLAGS |
---|
comment:3 follow-up: 4 Changed 8 years ago by ken-cunningham-webuse
I suspect the issue here is that Xcode's clang knows that macOS systems before 10.9 used -libstdc++ by default, so that is what it will allow, as you've targeted 10.8. It's trying to help you.
:info:build /usr/bin/clang++ .... :info:build clang: warning: libstdc++ is deprecated; move to libc++ with a minimum deployment target of OS X 10.9
You probably could defeat this by using one of macport's compilers, like clang-3.9.
comment:4 Changed 8 years ago by larryv (Lawrence Velázquez)
No. The issue is that the portfile sets
build.args-append CC=${configure.cc} \ CXX=${configure.cxx} \ CXX.host=${configure.cxx} \ CPP=${configure.cpp} \ CFLAGS="${configure.cflags}" \ CXXFLAGS="${configure.cxxflags}" \ LDFLAGS="${configure.ldflags}" \ PYTHON=${configure.python} \ V=1
but -stdlib
is not added to configure.cxxflags
in the current release. The portfile must add it manually.
Changed 8 years ago by larryv (Lawrence Velázquez)
Attachment: | nodejs4-stdlib.patch added |
---|
pass -stdlib to compilation and linking
comment:5 Changed 8 years ago by larryv (Lawrence Velázquez)
Please try the patch I just attached:
$ sudo port clean nodejs4 $ curl https://trac.macports.org/raw-attachment/ticket/52634/nodejs4-stdlib.patch | sudo patch $(port file nodejs4) $ sudo port install nodejs4
If it fails again, attach the new main.log
.
comment:6 Changed 8 years ago by mojca (Mojca Miklavec)
Cc: | mojca added |
---|
comment:7 Changed 8 years ago by mojca (Mojca Miklavec)
Isn't that the same problem for all nodejs
version rather than just nodejs4
?
main.log building nodejs4 with MACOS_DEPLOYMENT_TARGET=10.8