diff --git a/lang/libcxx/Portfile b/lang/libcxx/Portfile
index ab52872..0fd720f 100644
--- a/lang/libcxx/Portfile
+++ b/lang/libcxx/Portfile
@@ -3,7 +3,7 @@ PortGroup               compiler_blacklist_versions 1.0
 
 name                    libcxx
 epoch                   1
-version                 5.0.1
+version                 5.0.1 ; revision 1
 categories              lang
 platforms               darwin
 license                 MIT NCSA
@@ -14,7 +14,9 @@ long_description        ${description} \
                         replace the host version in order to be used.  On Snow Leopard and earlier, this is done \
                         automatically because there is no existing host version of this library.  On Lion and later, \
                         users must build the port with +replacemnt_libcxx and install the root manually if they wish \
-                        to replace the existing host implementation.
+                        to replace the existing host implementation. They can also use the +runtime variant which installs \
+                        copies of the library that can be loaded via DYLD_INSERT_LIBRARIES or the optlibs script\; \
+                        applications started that way will then use a more recent libc++ than the host provides.
 
 homepage                http://libcxx.llvm.org/
 
@@ -68,8 +70,15 @@ platform darwin {
 }
 
 variant replacemnt_libcxx description {EXPERTS ONLY: Build a replacement libcxxabi and libcxx even if it is already part of the base OS.} {}
+variant runtime description "Install the libcxx library so that it can be used with DYLD_INSERT_LIBRARIES" {
+    depends_build-append \
+                        port:cctools
+    notes-append "Start applications via ${prefix}/bin/optlibs to use the latest libc++, or\
+         set DYLD_INSERT_LIBRARIES as illustrated in that script."
+}
+
 
-if {${os.major} < 11 || [variant_isset replacemnt_libcxx]} {
+if {${os.major} < 11 || [variant_isset replacemnt_libcxx] || [variant_isset runtime]} {
     compiler.blacklist *gcc* {clang < 500}
 
     # clang 3.5 and newer are conditionally blacklisted to prevent dependency cycles
@@ -129,7 +138,7 @@ if {${os.major} < 11 || [variant_isset replacemnt_libcxx]} {
         CXX="${configure.cxx}" \
         RC_XBS=1 \
         RC_ProjectSourceVersion="${version}" \
-        RC_CFLAGS="[get_canonical_archflags] -I${libcxxabi_worksrcpath}/include -I${libcxx_worksrcpath}/include" \
+        RC_CFLAGS="[get_canonical_archflags] -I${libcxxabi_worksrcpath}/include -I${libcxx_worksrcpath}/include ${configure.optflags}q" \
         TRIPLE="-apple-darwin${os.major}"
     build.args-append \
         LIBCXXABI_PATH=${libcxxabi_worksrcpath} \
@@ -146,15 +155,27 @@ if {${os.major} < 11 || [variant_isset replacemnt_libcxx]} {
     # runtime.
 
     destroot {
-        xinstall -m 755 -d ${destroot}${roots_path}/${root_name}/usr/lib
+        if {[variant_isset replacemnt_libcxx]} {
+            xinstall -m 755 -d ${destroot}${roots_path}/${root_name}/usr/lib
 
-        xinstall -m 755 ${libcxxabi_worksrcpath}/lib/libc++abi.dylib ${destroot}${roots_path}/${root_name}/usr/lib
+            xinstall -m 755 ${libcxxabi_worksrcpath}/lib/libc++abi.dylib ${destroot}${roots_path}/${root_name}/usr/lib
 
-        xinstall -m 755 ${libcxx_worksrcpath}/lib/libc++.1.dylib ${destroot}${roots_path}/${root_name}/usr/lib
-        ln -s libc++.1.dylib ${destroot}${roots_path}/${root_name}/usr/lib/libc++.dylib
+            xinstall -m 755 ${libcxx_worksrcpath}/lib/libc++.1.dylib ${destroot}${roots_path}/${root_name}/usr/lib
+            ln -s libc++.1.dylib ${destroot}${roots_path}/${root_name}/usr/lib/libc++.dylib
 
-        system -W ${destroot}${roots_path}/${root_name} "tar czf ../${root_name}.tgz ."
-        delete ${destroot}${roots_path}/${root_name}
+            system -W ${destroot}${roots_path}/${root_name} "tar czf ../${root_name}.tgz ."
+            delete ${destroot}${roots_path}/${root_name}
+        }
+        if {[variant_isset runtime]} {
+            # install only the runtime libraries so they will not be picked up by the linker/editor!
+            xinstall -m 755 ${libcxxabi_worksrcpath}/lib/libc++abi.dylib ${destroot}${prefix}/lib/libc++abi.1.dylib
+            xinstall -m 755 ${libcxx_worksrcpath}/lib/libc++.1.dylib ${destroot}${prefix}/lib/
+            system "install_name_tool -id ${prefix}/lib/libc++abi.1.dylib ${destroot}${prefix}/lib/libc++abi.1.dylib"
+            system "install_name_tool -id ${prefix}/lib/libc++.1.dylib ${destroot}${prefix}/lib/libc++.1.dylib"
+            system "install_name_tool -change /usr/lib/libc++abi.dylib ${prefix}/lib/libc++abi.1.dylib ${destroot}${prefix}/lib/libc++.1.dylib"
+            xinstall -m 755 ${filespath}/optlibs.sh ${destroot}${prefix}/bin/optlibs
+            reinplace "s|@PREFIX@|${prefix}|g" ${destroot}${prefix}/bin/optlibs
+        }
     }
 } else {
     distfiles
diff --git a/lang/libcxx/files/optlibs.sh b/lang/libcxx/files/optlibs.sh
new file mode 100755
index 0000000..53988b9
--- /dev/null
+++ b/lang/libcxx/files/optlibs.sh
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+if [ "${DYLD_INSERT_LIBRARIES}" != "" ] ;then
+	DYLD_INSERT_LIBRARIES="${DYLD_INSERT_LIBRARIES}:@PREFIX@/lib/libc++.1.dylib"
+else
+	DYLD_INSERT_LIBRARIES="@PREFIX@/lib/libc++.1.dylib"
+fi
+export DYLD_INSERT_LIBRARIES
+
+exec "$@"
