Merge upstream LLVM to 223068.
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..2f0da84
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,25 @@
+#==============================================================================#
+# This file specifies intentionally untracked files that git should ignore.
+# See: http://www.kernel.org/pub/software/scm/git/docs/gitignore.html
+#
+# This file is intentionally different from the output of `git svn show-ignore`,
+# as most of those are useless.
+#==============================================================================#
+
+#==============================================================================#
+# File extensions to be ignored anywhere in the tree.
+#==============================================================================#
+# Temp files created by most text editors.
+*~
+# Merge files created by git.
+*.orig
+# Byte compiled python modules.
+*.pyc
+# vim swap files
+.*.swp
+.sw?
+
+#==============================================================================#
+# Explicit files to ignore (only matches one).
+#==============================================================================#
+.gitusers
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f12c525..50c1fa2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -95,7 +95,15 @@
 set(LIBCXX_LINK_FLAGS "")
 
 # Configure compiler.
-include(config-ix)
+# @LOCALMOD-START Use a custom compiler config because cmake try_compile always
+# tries to link an executable and linking doesnt work during bootstrap without
+# libnacl.
+if (CMAKE_SYSTEM_NAME STREQUAL "nacl")
+  include(config-ix-pnacl)
+else()
+  include(config-ix)
+endif()
+# @LOCALMOD-END
 # Configure ABI library
 include(HandleLibCXXABI)
 
@@ -240,7 +248,8 @@
 endif()
 
 string(REPLACE ";" " " LIBCXX_CXX_FLAGS "${LIBCXX_CXX_FLAGS}")
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LIBCXX_CXX_FLAGS}")
+# @LOCALMOD reverse the order, so that we can override -std=...
+set(CMAKE_CXX_FLAGS "${LIBCXX_CXX_FLAGS} ${CMAKE_CXX_FLAGS}")
 
 #===============================================================================
 # Setup Source Code
diff --git a/OWNERS b/OWNERS
new file mode 100644
index 0000000..ac015a5
--- /dev/null
+++ b/OWNERS
@@ -0,0 +1,8 @@
+dschuff@chromium.org
+eliben@chromium.org
+jfb@chromium.org
+jvoung@chromium.org
+kschimpf@chromium.org
+mseaborn@chromium.org
+sehr@chromium.org
+stichnot@chromium.org
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
new file mode 100644
index 0000000..4d9f899
--- /dev/null
+++ b/PRESUBMIT.py
@@ -0,0 +1,66 @@
+# Copyright (c) 2013 The Native Client Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# Documentation on PRESUBMIT.py can be found at:
+# http://www.chromium.org/developers/how-tos/depottools/presubmit-scripts
+
+EXCLUDE_PROJECT_CHECKS_DIRS = [ '.' ]
+
+import subprocess
+def CheckGitBranch():
+  p = subprocess.Popen("git branch -vv", shell=True,
+                       stdout=subprocess.PIPE)
+  output, _ = p.communicate()
+
+  lines = output.split('\n')
+  for line in lines:
+    # output format for checked-out branch should be
+    # * branchname hash [TrackedBranchName ...
+    toks = line.split()
+    if '*' not in toks[0]:
+      continue
+    if not 'origin/master' in toks[3]:
+      warning = 'Warning: your current branch:\n' + line
+      warning += '\nis not tracking origin/master. git cl push may silently '
+      warning += 'fail to push your change. To fix this, do\n'
+      warning += 'git branch -u origin/master'
+      return warning
+    return None
+  print 'Warning: presubmit check could not determine local git branch'
+  return None
+
+def _CommonChecks(input_api, output_api):
+  """Checks for both upload and commit."""
+  results = []
+  results.extend(input_api.canned_checks.PanProjectChecks(
+      input_api, output_api, project_name='Native Client',
+      excluded_paths=tuple(EXCLUDE_PROJECT_CHECKS_DIRS)))
+  branch_warning = CheckGitBranch()
+  if branch_warning:
+    results.append(output_api.PresubmitPromptWarning(branch_warning))
+  return results
+
+def CheckChangeOnUpload(input_api, output_api):
+  """Verifies all changes in all files.
+  Args:
+    input_api: the limited set of input modules allowed in presubmit.
+    output_api: the limited set of output modules allowed in presubmit.
+  """
+  report = []
+  report.extend(_CommonChecks(input_api, output_api))
+  return report
+
+def CheckChangeOnCommit(input_api, output_api):
+  """Verifies all changes in all files and verifies that the
+  tree is open and can accept a commit.
+  Args:
+    input_api: the limited set of input modules allowed in presubmit.
+    output_api: the limited set of output modules allowed in presubmit.
+  """
+  report = []
+  report.extend(CheckChangeOnUpload(input_api, output_api))
+  return report
+
+def GetPreferredTrySlaves(project, change):
+  return []
diff --git a/cmake/config-ix-pnacl.cmake b/cmake/config-ix-pnacl.cmake
new file mode 100644
index 0000000..829cfcc
--- /dev/null
+++ b/cmake/config-ix-pnacl.cmake
@@ -0,0 +1,46 @@
+# @LOCALMOD-START The PNaCl driver automatically adds dependencies to
+#                 libc++ which hasn't been built yet. The tests for
+#                 flags therefore fail because the library can't be
+#                 found. We should fix this in a different CL, and add
+#                 proper detection for newlib's lack of locale_t
+#                 support. See:
+#                  https://code.google.com/p/nativeclient/issues/detail?id=3661
+
+set(LIBCXX_HAS_STDCXX0X_FLAG 1)
+set(LIBCXX_HAS_STDCXX11_FLAG 1)
+set(LIBCXX_HAS_FPIC_FLAG 0) # Not quite true, but untested in PNaCl.
+set(LIBCXX_HAS_NODEFAULTLIBS_FLAG 1)
+set(LIBCXX_HAS_NOSTDINCXX_FLAG 1)
+set(LIBCXX_HAS_WALL_FLAG 1)
+set(LIBCXX_HAS_W_FLAG 1)
+set(LIBCXX_HAS_WNO_UNUSED_PARAMETER_FLAG 1)
+set(LIBCXX_HAS_WWRITE_STRINGS_FLAG 1)
+set(LIBCXX_HAS_WNO_LONG_LONG_FLAG 1)
+set(LIBCXX_HAS_PEDANTIC_FLAG 1)
+set(LIBCXX_HAS_WERROR_FLAG 1)
+set(LIBCXX_HAS_WNO_ERROR_FLAG 1)
+set(LIBCXX_HAS_FNO_EXCEPTIONS_FLAG 1)
+set(LIBCXX_HAS_FNO_RTTI_FLAG 1)
+# MSVC flags:
+set(LIBCXX_HAS_WX_FLAG 0)
+set(LIBCXX_HAS_NO_WX_FLAG 0)
+set(LIBCXX_HAS_EHSC_FLAG 0)
+set(LIBCXX_HAS_NO_EHS_FLAG 0)
+set(LIBCXX_HAS_NO_EHA_FLAG 0)
+set(LIBCXX_HAS_NO_GR_FLAG 0)
+
+set(LIBCXX_HAS_PTHREAD_LIB 1)
+set(LIBCXX_HAS_C_LIB 1)
+set(LIBCXX_HAS_M_LIB 1)
+set(LIBCXX_HAS_RT_LIB 0)
+set(LIBCXX_HAS_GCC_S_LIB 0)
+# @LOCALMOD-END
+
+# Check C++0x features
+if (LIBCXX_ENABLE_CXX0X)
+  if (LIBCXX_HAS_STDCXX0X_FLAG)
+    set(CMAKE_REQUIRED_DEFINITIONS -std=c++0x)
+  endif()
+else()
+  set(LIBCXX_HAS_STDCXX0X_FLAG FALSE)
+endif()
diff --git a/codereview.settings b/codereview.settings
new file mode 100644
index 0000000..21c6452
--- /dev/null
+++ b/codereview.settings
@@ -0,0 +1,10 @@
+# This file is used by gcl to get repository specific information.
+CODE_REVIEW_SERVER: codereview.chromium.org
+CC_LIST: native-client-reviews@googlegroups.com
+VIEW_VC: https://gerrit.chromium.org/gerrit/gitweb?p=native_client/pnacl-libcxx.git;a=commit;h=
+STATUS: http://nativeclient-status.appspot.com/status
+TRY_ON_UPLOAD: False
+TRYSERVER_PROJECT: nacl
+TRYSERVER_SVN_URL: svn://svn.chromium.org/chrome-try/try-nacl
+PUSH_URL_CONFIG: url.ssh://gerrit.chromium.org.pushinsteadof
+ORIGIN_URL_CONFIG: http://chromium.googlesource.com
diff --git a/include/__config b/include/__config
index df0bb77..6f57df5 100644
--- a/include/__config
+++ b/include/__config
@@ -647,6 +647,10 @@
 #define _LIBCPP_ELAST ELAST
 #elif defined(__linux__)
 #define _LIBCPP_ELAST 4095
+// @LOCALMOD-START
+#elif defined(__native_client__)
+// NaCl doesn't have ELAST or __ELASTERROR
+// @LOCALMOD-END
 #elif defined(_NEWLIB_VERSION)
 #define _LIBCPP_ELAST __ELASTERROR
 #elif defined(__APPLE__)
diff --git a/include/__locale b/include/__locale
index 4711620..03f1b52 100644
--- a/include/__locale
+++ b/include/__locale
@@ -31,6 +31,13 @@
 # endif
 #elif defined(__sun__)
 # include <support/solaris/xlocale.h>
+// @LOCALMOD-START
+#elif defined(_NEWLIB_VERSION)
+// FIXME: replace all the uses of _NEWLIB_VERSION with __NEWLIB__ preceded by an
+// include of <sys/cdefs.h> once https://sourceware.org/ml/newlib-cvs/2014-q3/msg00038.html
+// has had a chance to bake for a bit.
+#include <support/newlib/xlocale.h>
+// @LOCALMOD-END
 #elif (defined(__GLIBC__) || defined(__APPLE__)      || defined(__FreeBSD__) \
     || defined(__EMSCRIPTEN__) || defined(__IBMCPP__))
 # include <xlocale.h>
@@ -391,6 +398,21 @@
     static const mask punct  = _ISPUNCT;
     static const mask xdigit = _ISXDIGIT;
     static const mask blank  = _ISBLANK;
+// @LOCALMOD-START
+#elif defined(_NEWLIB_VERSION)
+    typedef char mask; // Same type as Newlib's _ctype_ array in ctype.h.
+    // Defined in Newlib's ctype.h.
+    static const mask space  = _S;
+    static const mask print  = _P | _U | _L | _N | _B;
+    static const mask cntrl  = _C;
+    static const mask upper  = _U;
+    static const mask lower  = _L;
+    static const mask alpha  = _U | _L;
+    static const mask digit  = _N;
+    static const mask punct  = _P;
+    static const mask xdigit = _X | _N;
+    static const mask blank  = _B;
+// @LOCALMOD-END
 #else  // __GLIBC__ || _WIN32 || __APPLE__ || __FreeBSD__ || __EMSCRIPTEN__ || __sun__
     typedef unsigned long mask;
     static const mask space  = 1<<0;
diff --git a/include/atomic b/include/atomic
index b01a59f..fe85609 100644
--- a/include/atomic
+++ b/include/atomic
@@ -815,12 +815,24 @@
 {
     mutable _Atomic(_Tp) __a_;
 
+  // @LOCALMOD-BEGIN The NaCl builtin delays resolution of the lock-free
+  //                 property until translation time (time at which the
+  //                 actual target is known).
+#if defined (__pnacl__)
+    _LIBCPP_INLINE_VISIBILITY
+    bool is_lock_free() const volatile _NOEXCEPT
+        {return __nacl_atomic_is_lock_free(sizeof(_Tp), &__a_);}
+    _LIBCPP_INLINE_VISIBILITY
+    bool is_lock_free() const _NOEXCEPT
+        {return __nacl_atomic_is_lock_free(sizeof(_Tp), &__a_);}
+#else
     _LIBCPP_INLINE_VISIBILITY
     bool is_lock_free() const volatile _NOEXCEPT
         {return __c11_atomic_is_lock_free(sizeof(_Tp));}
     _LIBCPP_INLINE_VISIBILITY
     bool is_lock_free() const _NOEXCEPT
         {return __c11_atomic_is_lock_free(sizeof(_Tp));}
+#endif // @LOCALMOD-END
     _LIBCPP_INLINE_VISIBILITY
     void store(_Tp __d, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
         {__c11_atomic_store(&__a_, __d, __m);}
diff --git a/include/cmath b/include/cmath
index d3aa4be..bddae84 100644
--- a/include/cmath
+++ b/include/cmath
@@ -1377,7 +1377,11 @@
 using ::log2f;
 
 inline _LIBCPP_INLINE_VISIBILITY float       log2(float __lcpp_x) _NOEXCEPT       {return log2f(__lcpp_x);}
+#if defined(_NEWLIB_VERSION) // @LOCALMOD-START Missing from newlib. Note that PNaCl represents ``long double`` as ``double``, hence the intrinsic's type.
+inline _LIBCPP_INLINE_VISIBILITY long double log2(long double __lcpp_x) _NOEXCEPT {return __builtin_log2(__lcpp_x);}
+#else
 inline _LIBCPP_INLINE_VISIBILITY long double log2(long double __lcpp_x) _NOEXCEPT {return log2l(__lcpp_x);}
+#endif // @LOCALMOD-END
 
 template <class _A1>
 inline _LIBCPP_INLINE_VISIBILITY
@@ -1390,7 +1394,11 @@
 using ::logbf;
 
 inline _LIBCPP_INLINE_VISIBILITY float       logb(float __lcpp_x) _NOEXCEPT       {return logbf(__lcpp_x);}
+#if defined(_NEWLIB_VERSION) // @LOCALMOD-START Missing from newlib. Note that PNaCl represents ``long double`` as ``double``, hence the intrinsic's type.
+inline _LIBCPP_INLINE_VISIBILITY long double logb(long double __lcpp_x) _NOEXCEPT {return __builtin_logb(__lcpp_x);}
+#else
 inline _LIBCPP_INLINE_VISIBILITY long double logb(long double __lcpp_x) _NOEXCEPT {return logbl(__lcpp_x);}
+#endif // @LOCALMOD-END
 
 template <class _A1>
 inline _LIBCPP_INLINE_VISIBILITY
@@ -1475,6 +1483,15 @@
 
 // nexttoward
 
+#if defined(_NEWLIB_VERSION) // @LOCALMOD-START Missing from newlib. Note that PNaCl represents ``long double`` as ``double``, hence the intrinsic's type.
+inline _LIBCPP_INLINE_VISIBILITY float       nexttoward(float __lcpp_x, long double __lcpp_y) _NOEXCEPT       {return __builtin_nexttoward(__lcpp_x, __lcpp_y);}
+inline _LIBCPP_INLINE_VISIBILITY long double nexttoward(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return __builtin_nexttoward(__lcpp_x, __lcpp_y);}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if<is_integral<_A1>::value, double>::type
+nexttoward(_A1 __lcpp_x, long double __lcpp_y) _NOEXCEPT {return __builtin_nexttoward((double)__lcpp_x, __lcpp_y);}
+#else
 using ::nexttoward;
 using ::nexttowardf;
 
@@ -1485,7 +1502,7 @@
 inline _LIBCPP_INLINE_VISIBILITY
 typename enable_if<is_integral<_A1>::value, double>::type
 nexttoward(_A1 __lcpp_x, long double __lcpp_y) _NOEXCEPT {return nexttoward((double)__lcpp_x, __lcpp_y);}
-
+#endif // @LOCALMOD-END
 // remainder
 
 using ::remainder;
@@ -1658,14 +1675,18 @@
 using ::llrintl;
 using ::llroundl;
 using ::log1pl;
+#if !defined(_NEWLIB_VERSION) // @LOCALMOD-START Missing from newlib.
 using ::log2l;
 using ::logbl;
+#endif // @LOCALMOD-END
 using ::lrintl;
 using ::lroundl;
 using ::nanl;
 using ::nearbyintl;
 using ::nextafterl;
+#if !defined(_NEWLIB_VERSION) // @LOCALMOD-START Missing from newlib.
 using ::nexttowardl;
+#endif // @LOCALMOD-END
 using ::remainderl;
 using ::remquol;
 using ::rintl;
diff --git a/include/cstdio b/include/cstdio
index ce3af4d..e7d8fab 100644
--- a/include/cstdio
+++ b/include/cstdio
@@ -172,8 +172,11 @@
 using ::fsetpos;
 using ::ftell;
 using ::rewind;
+#undef clearerr // @LOCALMOD
 using ::clearerr;
+#undef feof // @LOCALMOD
 using ::feof;
+#undef ferror // @LOCALMOD
 using ::ferror;
 using ::perror;
 
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
index 12e9f4a..e83bc3e 100644
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -1,5 +1,19 @@
 # Get sources
 file(GLOB LIBCXX_SOURCES ../src/*.cpp)
+
+# @LOCALMOD-START Bake libcxxabi into the libcxx build except on Mac, where
+# we use the system libcxxabi. When we do this, also don't link against
+# libcxxabi when building shared libraries.
+file(GLOB LIBCXXABI_SOURCES ../../libcxxabi/src/*.cpp)
+file(GLOB PNACL_EH_SUPPORT ../../libcxxabi/src/cxa_pnacl_sjlj_exception.cpp)
+if ( NOT CMAKE_SYSTEM_NAME STREQUAL "nacl" )
+  # Don't include pnacl EH support for non-nacl builds.
+  list(REMOVE_ITEM LIBCXXABI_SOURCES ${PNACL_EH_SUPPORT})
+endif()
+  list(APPEND LIBCXX_SOURCES ${LIBCXXABI_SOURCES})
+  set(LIBCXX_CXX_ABI_LIBRARY)
+# @LOCALMOD-END
+
 if(WIN32)
   file(GLOB LIBCXX_WIN32_SOURCES ../src/support/win32/*.cpp)
   list(APPEND LIBCXX_SOURCES ${LIBCXX_WIN32_SOURCES})
@@ -53,10 +67,19 @@
 target_link_libraries(cxx ${libraries})
 
 # Setup flags.
-append_if(LIBCXX_COMPILE_FLAGS LIBCXX_HAS_FPIC_FLAG -fPIC)
+# @LOCALMOD removed append_if(LIBCXX_COMPILE_FLAGS LIBCXX_HAS_FPIC_FLAG -fPIC)
 append_if(LIBCXX_LINK_FLAGS LIBCXX_HAS_NODEFAULTLIBS_FLAG -nodefaultlibs)
 
-if ( APPLE )
+# @LOCALMOD-START
+if ( CMAKE_SYSTEM_NAME STREQUAL "Darwin" )
+  # Needed to build against OSX 10.6 SDK
+  list(APPEND compile_flags "-U__STRICT_ANSI__")
+  # Do not re-export libc++abi symbols since they do not come from another dylib
+  list(APPEND link_flags
+      "-Wl,-unexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++unexp.exp")
+endif()
+
+if ( False ) # @LOCALMOD-END
   if ( CMAKE_OSX_DEPLOYMENT_TARGET STREQUAL "10.6" )
     list(APPEND LIBCXX_COMPILE_FLAGS "-U__STRICT_ANSI__")
     list(APPEND LIBCXX_LINK_FLAGS
diff --git a/src/locale.cpp b/src/locale.cpp
index f21e35d..191b239 100644
--- a/src/locale.cpp
+++ b/src/locale.cpp
@@ -1033,6 +1033,10 @@
 // going to end up dereferencing it later...
 #elif defined(__EMSCRIPTEN__)
     return *__ctype_b_loc();
+#elif defined(_NEWLIB_VERSION) // @LOCALMOD-START
+    // Newlib has a 257-entry table in ctype_.c, where (char)0 starts at [1].
+    return _ctype_ + 1;
+    // @LOCALMOD-END
 #elif defined(_AIX)
     return (const unsigned int *)__lc_ctype_ptr->obj->mask;
 #elif defined(__ANDROID__)
diff --git a/src/thread.cpp b/src/thread.cpp
index 0ced1e3..6a18e2c 100644
--- a/src/thread.cpp
+++ b/src/thread.cpp
@@ -17,7 +17,7 @@
 #include "limits"
 #include <sys/types.h>
 #if !defined(_WIN32)
-#if !defined(__sun__) && !defined(__linux__) && !defined(_AIX)
+#if !defined(__sun__) && !defined(__linux__) && !defined(_AIX) && !defined(__native_client__) // @LOCALMOD
 #include <sys/sysctl.h>
 #endif // !__sun__ && !__linux__ && !_AIX
 #include <unistd.h>
diff --git a/test/lit.cfg b/test/lit.cfg
index ec05d1c..62a8a28 100644
--- a/test/lit.cfg
+++ b/test/lit.cfg
@@ -29,12 +29,18 @@
     """
 
     def __init__(self, cxx_under_test, use_verify_for_fail,
-                 cpp_flags, ld_flags, exec_env):
+                 cpp_flags, ld_flags, exec_env,
+                 # @LOCALMOD
+                 exe_suffix, shell_prefix):
         self.cxx_under_test = cxx_under_test
         self.use_verify_for_fail = use_verify_for_fail
         self.cpp_flags = list(cpp_flags)
         self.ld_flags = list(ld_flags)
         self.exec_env = dict(exec_env)
+        # @LOCALMOD-START
+        self.exe_suffix = exe_suffix
+        self.shell_prefix = shell_prefix
+        # @LOCALMOD-END
 
     def execute(self, test, lit_config):
         while True:
@@ -116,6 +122,10 @@
             cmd.extend('%s=%s' % (name, value)
                        for name,value in self.exec_env.items())
         cmd.append(exec_path)
+        # @LOCALMOD-START
+        if self.shell_prefix:
+            cmd = self.shell_prefix + cmd
+        # @LOCALMOD-END
         if lit_config.useValgrind:
             cmd = lit_config.valgrindArgs + cmd
         out, err, exitCode = lit.util.executeCommand(cmd, cwd=in_dir)
@@ -149,7 +159,10 @@
                 report += "\n\nExpected compilation to fail!"
                 return lit.Test.FAIL, report
         else:
-            exec_file = tempfile.NamedTemporaryFile(suffix="exe", delete=False)
+            # @LOCALMOD-START
+            exec_file = tempfile.NamedTemporaryFile(
+                suffix=self.exe_suffix, delete=False)
+            # @LOCALMOD-END
             exec_path = exec_file.name
             exec_file.close()
 
@@ -195,6 +208,10 @@
     def __init__(self, lit_config, config):
         self.lit_config = lit_config
         self.config = config
+        # @LOCALMOD-START
+        self.exe_suffix = None
+        self.shell_prefix = None
+        # @LOCALMOD-END
         self.cxx = None
         self.src_root = None
         self.obj_root = None
@@ -227,6 +244,8 @@
             "parameter '{}' should be true or false".format(name))
 
     def configure(self):
+        # @LOCALMOD
+        self.configure_exe_wrappers()
         self.configure_cxx()
         self.configure_triple()
         self.configure_src_root()
@@ -239,6 +258,13 @@
         self.configure_link_flags()
         self.configure_sanitizer()
         self.configure_features()
+        # @LOCALMOD-START -- filter out nostdinc++ and nodefaultlibs if needed.
+        if self.use_system_lib:
+            self.compile_flags = [flag for flag in self.compile_flags
+                                  if flag != '-nostdinc++']
+            self.link_flags = [flag for flag in self.link_flags
+                               if flag != '-nodefaultlibs']
+        # @LOCALMOD-END
         # Print the final compile and link flags.
         self.lit_config.note('Using compile flags: %s' % self.compile_flags)
         self.lit_config.note('Using link flags: %s' % self.link_flags)
@@ -252,7 +278,21 @@
             self.use_clang_verify,
             cpp_flags=self.compile_flags,
             ld_flags=self.link_flags,
-            exec_env=self.env)
+            exec_env=self.env,
+            # @LOCALMOD
+            exe_suffix=self.exe_suffix,
+            shell_prefix=self.shell_prefix)
+
+    # @LOCALMOD-START
+    def configure_exe_wrappers(self):
+        # Allow customizing the resulting executable's suffix
+        # as well as an wrapper around how to run the executable
+        # via a shell_prefix.
+        self.exe_suffix = self.get_lit_conf('exe_suffix', 'exe')
+        self.shell_prefix = self.get_lit_conf('shell_prefix', None)
+        if self.shell_prefix:
+            self.shell_prefix = shlex.split(self.shell_prefix)
+    # @LOCALMOD-END
 
     def configure_cxx(self):
         # Gather various compiler parameters.