Skip to content

Commit

Permalink
nodejs4: Fix build with libc++
Browse files Browse the repository at this point in the history
nodejs4 originally assumed all versions of macOS use tr1. This is not
true with libc++, which is the default on Mavericks and later.

The original patch was conditionally applied on Mavericks and later. It
removed the use of tr1 in one place, but not in another place, so the
build failed on Mavericks and later, and presumably on earlier systems
configured to use libc++.

nodejs6 contains preprocessor directives that avoids using tr1 on
Mavericks and later. This would presumably still fail on earlier systems
configured to use libc++.

This new patch avoids tr1 when libc++ is in use, regardless of macOS
version, and is unconditionally applied.

Closes: https://trac.macports.org/ticket/53401
  • Loading branch information
ryandesign committed Feb 11, 2017
1 parent 58552b3 commit 5ea23e3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
8 changes: 2 additions & 6 deletions devel/nodejs4/Portfile
Expand Up @@ -5,7 +5,7 @@ PortGroup compiler_blacklist_versions 1.0

name nodejs4
version 4.7.2

revision 1
categories devel net
platforms darwin
license {MIT BSD}
Expand Down Expand Up @@ -45,13 +45,9 @@ proc rec_glob {basedir pattern} {
configure.python ${prefix}/bin/python2.7

patchfiles patch-common.gypi.diff \
patch-src-util.h.diff \
patch-tools-gyp-pylib-gyp-generator-make.py.diff

if {${os.major} > 12} {
patchfiles-append patch-src-util.h.diff
}


post-patch {
foreach f [concat ${worksrcpath}/configure \
${worksrcpath}/tools/gyp/gyp \
Expand Down
28 changes: 20 additions & 8 deletions devel/nodejs4/files/patch-src-util.h.diff
@@ -1,14 +1,26 @@
--- src/util.h.orig
+++ src/util.h
@@ -8,11 +8,7 @@
--- src/util.h.orig 2017-01-05 15:05:24.000000000 -0600
+++ src/util.h 2017-02-11 00:41:28.000000000 -0600
@@ -8,7 +8,13 @@
#include <stddef.h>
#include <stdlib.h>

-#ifdef __APPLE__
-#include <tr1/type_traits> // NOLINT(build/c++tr1)
-#else
+// libc++ provides a C++11 <type_traits> header.
+#include <ciso646>
+#if defined(__APPLE__) && !defined(_LIBCPP_VERSION)
+#define USE_TR1_TYPE_TRAITS
+#endif
+
+#ifdef USE_TR1_TYPE_TRAITS
#include <tr1/type_traits> // NOLINT(build/c++tr1)
#else
#include <type_traits> // std::remove_reference
-#endif

namespace node {
@@ -27,7 +33,7 @@
inline void* Malloc(size_t size);
inline void* Calloc(size_t n, size_t size);

-#ifdef __APPLE__
+#ifdef USE_TR1_TYPE_TRAITS
template <typename T> using remove_reference = std::tr1::remove_reference<T>;
#else
template <typename T> using remove_reference = std::remove_reference<T>;

0 comments on commit 5ea23e3

Please sign in to comment.