Update pnacl toolchain version
Add x86 binutils build
Add simple test for nacl-clang under sel_ldr.
CQ_EXTRA_TRYBOTS=tryserver.nacl:webports-linux-toolchain-0
BUG= https://bugs.chromium.org/p/naclports/issues/detail?id=244
R=bradnelson@chromium.org
Review URL: https://codereview.chromium.org/1607793004 .
diff --git a/docs/port_list.md b/docs/port_list.md
index e90b521..f46ce6c 100644
--- a/docs/port_list.md
+++ b/docs/port_list.md
@@ -228,10 +228,11 @@
| [physfs] | 2.0.3 | [physfs-2.0.3.tar.bz2][physfs_upstream] | [1 KiB][physfs_patch] | [] | [] |
| [pixman] | 0.32.4 | [pixman-0.32.4.tar.gz][pixman_upstream] | [633 B][pixman_patch] | [] | [] |
| [pkg] | 1.6.1 | [pkg-1.6.1.tar.gz][pkg_upstream] | [58 KiB][pkg_patch] | [] | [] |
-| [pnacl] | 0.0.1 | [None][pnacl_upstream] | [3 KiB][pnacl_patch] | [] | [] |
-| [pnacl-binutils-src] | 0.0.1 | [None][pnacl-binutils-src_upstream] | | [] | [] |
-| [pnacl-clang-src] | 0.0.1 | [None][pnacl-clang-src_upstream] | | [] | [] |
-| [pnacl-llvm-src] | 0.0.1 | [None][pnacl-llvm-src_upstream] | [546 B][pnacl-llvm-src_patch] | [] | [] |
+| [pnacl] | 0.0.1 | [None][pnacl_upstream] | [4 KiB][pnacl_patch] | [] | [] |
+| [pnacl-binutils-src] | 0.0.1 | [None][pnacl-binutils-src_upstream] | [11 KiB][pnacl-binutils-src_patch] | [] | [] |
+| [pnacl-binutils-x86-src] | 0.0.1 | [None][pnacl-binutils-x86-src_upstream] | | [] | [] |
+| [pnacl-clang-src] | 0.0.1 | [None][pnacl-clang-src_upstream] | [1 KiB][pnacl-clang-src_patch] | [] | [] |
+| [pnacl-llvm-src] | 0.0.1 | [None][pnacl-llvm-src_upstream] | [13 KiB][pnacl-llvm-src_patch] | [] | [] |
| [poly2tri] | 26242d0aa7b8 | [26242d0aa7b8.tar.gz][poly2tri_upstream] | | [] | [] |
| [protobuf] | 3.0.0-beta-2 | [protobuf-cpp-3.0.0-beta-2.tar.gz][protobuf_upstream] | [7 KiB][protobuf_patch] | [] | [] |
| [protobuf-c] | 1.0.2 | [protobuf-c-1.0.2.tar.gz][protobuf-c_upstream] | | [] | [] |
@@ -313,7 +314,7 @@
| [zeromq] | 4.0.3 | [zeromq-4.0.3.tar.gz][zeromq_upstream] | [4 KiB][zeromq_patch] | [] | [] |
| [zlib] | 1.2.8 | [zlib-1.2.8.tar.gz][zlib_upstream] | [592 B][zlib_patch] | [] | [] |
-_Total = 323_
+_Total = 324_
# Local Ports (not based on upstream sources) =
@@ -888,14 +889,18 @@
[pkg_upstream]: https://github.com/freebsd/pkg/archive/1.6.1/pkg-1.6.1.tar.gz
[pnacl]: https://chromium.googlesource.com/webports/+/master/ports/pnacl
[pnacl_patch]: https://chromium.googlesource.com/webports/+/master/ports/pnacl/nacl.patch
-[pnacl_upstream]: https://chromium.googlesource.com/native_client/src/native_client.git@6863b50a1f88905e31e69c1e1787f5656502f1ad
+[pnacl_upstream]: https://chromium.googlesource.com/native_client/src/native_client.git@642939f
[pnacl-binutils-src]: https://chromium.googlesource.com/webports/+/master/ports/pnacl-binutils-src
-[pnacl-binutils-src_upstream]: https://chromium.googlesource.com/native_client/nacl-binutils.git@d9b81d6377ffd6e28e5649246c1f450d6e2a9083
+[pnacl-binutils-src_patch]: https://chromium.googlesource.com/webports/+/master/ports/pnacl-binutils-src/nacl.patch
+[pnacl-binutils-src_upstream]: https://chromium.googlesource.com/native_client/nacl-binutils.git@d5a23a3
+[pnacl-binutils-x86-src]: https://chromium.googlesource.com/webports/+/master/ports/pnacl-binutils-x86-src
+[pnacl-binutils-x86-src_upstream]: https://chromium.googlesource.com/native_client/nacl-binutils.git@1d8592c
[pnacl-clang-src]: https://chromium.googlesource.com/webports/+/master/ports/pnacl-clang-src
-[pnacl-clang-src_upstream]: https://chromium.googlesource.com/native_client/pnacl-clang.git@e218816eca6fd206758096d7b88a6517ad7fa425
+[pnacl-clang-src_patch]: https://chromium.googlesource.com/webports/+/master/ports/pnacl-clang-src/nacl.patch
+[pnacl-clang-src_upstream]: https://chromium.googlesource.com/native_client/pnacl-clang.git@cf0dc7f
[pnacl-llvm-src]: https://chromium.googlesource.com/webports/+/master/ports/pnacl-llvm-src
[pnacl-llvm-src_patch]: https://chromium.googlesource.com/webports/+/master/ports/pnacl-llvm-src/nacl.patch
-[pnacl-llvm-src_upstream]: https://chromium.googlesource.com/native_client/pnacl-llvm.git@caf6bbe98a0b7dd7dfd71dbb72b77bf71c4ff0d8
+[pnacl-llvm-src_upstream]: https://chromium.googlesource.com/native_client/pnacl-llvm.git@1ac309a
[poly2tri]: https://chromium.googlesource.com/webports/+/master/ports/poly2tri
[poly2tri_upstream]: https://poly2tri.googlecode.com/archive/26242d0aa7b8.tar.gz
[protobuf]: https://chromium.googlesource.com/webports/+/master/ports/protobuf
diff --git a/ports/pnacl-binutils-src/nacl.patch b/ports/pnacl-binutils-src/nacl.patch
new file mode 100644
index 0000000..58de783
--- /dev/null
+++ b/ports/pnacl-binutils-src/nacl.patch
@@ -0,0 +1,383 @@
+diff --git a/bfd/configure b/bfd/configure
+--- a/bfd/configure
++++ b/bfd/configure
+@@ -11809,9 +11809,7 @@ if test "${enable_plugins+set}" = set; then :
+ enableval=$enable_plugins; case "${enableval}" in
+ no) plugins=no ;;
+ *) plugins=yes
+- if test "$maybe_plugins" != "yes" ; then
+- as_fn_error "Building with plugin support requires a host that supports dlopen." "$LINENO" 5
+- fi ;;
++ ;;
+ esac
+ else
+ plugins=$maybe_plugins
+diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c
+--- a/bfd/elfxx-mips.c
++++ b/bfd/elfxx-mips.c
+@@ -2161,6 +2161,7 @@ got_page_reloc_p (unsigned int r_type)
+ return r_type == R_MIPS_GOT_PAGE || r_type == R_MICROMIPS_GOT_PAGE;
+ }
+
++#if !defined(__native_client__)
+ static inline bfd_boolean
+ got_ofst_reloc_p (unsigned int r_type)
+ {
+@@ -2172,6 +2173,7 @@ got_hi16_reloc_p (unsigned int r_type)
+ {
+ return r_type == R_MIPS_GOT_HI16 || r_type == R_MICROMIPS_GOT_HI16;
+ }
++#endif
+
+ static inline bfd_boolean
+ got_lo16_reloc_p (unsigned int r_type)
+diff --git a/bfd/opncls.c b/bfd/opncls.c
+--- a/bfd/opncls.c
++++ b/bfd/opncls.c
+@@ -673,6 +673,9 @@ bfd_openw (const char *filename, const char *target)
+ static inline void
+ _maybe_make_executable (bfd * abfd)
+ {
++#if defined(__native_client__)
++ (void) abfd;
++#else
+ /* If the file was open for writing and is now executable,
+ make it so. */
+ if (abfd->direction == write_direction
+@@ -694,6 +697,7 @@ _maybe_make_executable (bfd * abfd)
+ & (buf.st_mode | ((S_IXUSR | S_IXGRP | S_IXOTH) &~ mask))));
+ }
+ }
++#endif
+ }
+
+ /*
+diff --git a/bfd/plugin.c b/bfd/plugin.c
+--- a/bfd/plugin.c
++++ b/bfd/plugin.c
+@@ -28,6 +28,8 @@
+ #include <dlfcn.h>
+ #elif defined (HAVE_WINDOWS_H)
+ #include <windows.h>
++#elif defined (__native_client__)
++// Handled inline.
+ #else
+ #error Unknown how to handle dynamic-load-libraries.
+ #endif
+@@ -204,13 +206,19 @@ try_claim (bfd *abfd)
+ static int
+ try_load_plugin (const char *pname, bfd *abfd)
+ {
++#if !defined(__native_client__)
+ void *plugin_handle;
++#endif
+ int tv_size = 4;
+ struct ld_plugin_tv tv[tv_size];
+ int i;
+ ld_plugin_onload onload;
+ enum ld_plugin_status status;
+
++#if defined(__native_client__)
++ (void) pname;
++ onload = 0;
++#else
+ plugin_handle = dlopen (pname, RTLD_NOW);
+ if (!plugin_handle)
+ {
+@@ -221,6 +229,7 @@ try_load_plugin (const char *pname, bfd *abfd)
+ onload = dlsym (plugin_handle, "onload");
+ if (!onload)
+ goto err;
++#endif
+
+ i = 0;
+ tv[i].tv_tag = LDPT_MESSAGE;
+@@ -252,7 +261,9 @@ try_load_plugin (const char *pname, bfd *abfd)
+ return 1;
+
+ err:
++#if !defined(__native_client__)
+ plugin_handle = NULL;
++#endif
+ return 0;
+ }
+
+diff --git a/binutils/configure b/binutils/configure
+--- a/binutils/configure
++++ b/binutils/configure
+@@ -11373,9 +11373,7 @@ if test "${enable_plugins+set}" = set; then :
+ enableval=$enable_plugins; case "${enableval}" in
+ no) plugins=no ;;
+ *) plugins=yes
+- if test "$maybe_plugins" != "yes" ; then
+- as_fn_error "Building with plugin support requires a host that supports dlopen." "$LINENO" 5
+- fi ;;
++ ;;
+ esac
+ else
+ plugins=$maybe_plugins
+diff --git a/gas/configure b/gas/configure
+--- a/gas/configure
++++ b/gas/configure
+@@ -11353,9 +11353,7 @@ if test "${enable_plugins+set}" = set; then :
+ enableval=$enable_plugins; case "${enableval}" in
+ no) plugins=no ;;
+ *) plugins=yes
+- if test "$maybe_plugins" != "yes" ; then
+- as_fn_error "Building with plugin support requires a host that supports dlopen." "$LINENO" 5
+- fi ;;
++ ;;
+ esac
+ else
+ plugins=$maybe_plugins
+diff --git a/gold/Makefile.in b/gold/Makefile.in
+--- a/gold/Makefile.in
++++ b/gold/Makefile.in
+@@ -563,7 +563,7 @@ incremental_dump_SOURCES = incremental-dump.cc
+ incremental_dump_DEPENDENCIES = $(TARGETOBJS) libgold.a $(LIBIBERTY) \
+ $(LIBINTL_DEP)
+
+-incremental_dump_LDADD = $(TARGETOBJS) libgold.a $(LIBIBERTY) $(LIBINTL) \
++incremental_dump_LDADD = $(TARGETOBJS) libgold.a $(LIBIBERTY) $(GOLD_LDADD) $(LIBINTL) \
+ $(THREADSLIB) $(LIBDL)
+
+ dwp_SOURCES = dwp.cc
+diff --git a/gold/descriptors.cc b/gold/descriptors.cc
+--- a/gold/descriptors.cc
++++ b/gold/descriptors.cc
+@@ -48,7 +48,7 @@ static inline void
+ set_close_on_exec(int fd ATTRIBUTE_UNUSED)
+ {
+ // @LOCALMOD-SB-BEGIN
+-#if defined(__native_client__)
++#if 0 && defined(__native_client__)
+ gold::gold_fatal(_("NaCl gold: unexpected use of fcntl for %d"), fd);
+ #else
+ // Mingw does not define F_SETFD.
+diff --git a/gold/fileread.cc b/gold/fileread.cc
+--- a/gold/fileread.cc
++++ b/gold/fileread.cc
+@@ -180,7 +180,7 @@ File_read::~File_read()
+ if (this->is_descriptor_opened_)
+ {
+ // @LOCALMOD-SB-BEGIN
+-#if defined(__native_client__)
++#if 0 && defined(__native_client__)
+ nacl_file::NaClReleaseFileDescriptor(this->descriptor_);
+ #else
+ release_descriptor(this->descriptor_, true);
+@@ -205,7 +205,7 @@ File_read::open(const Task* task, const std::string& name)
+ this->name_ = name;
+
+ // @LOCALMOD-SB-BEGIN
+-#if defined(__native_client__)
++#if 0 && defined(__native_client__)
+ this->descriptor_ = nacl_file::NaClOpenFileDescriptor(this->name_.c_str());
+ #else
+ this->descriptor_ = open_descriptor(-1, this->name_.c_str(),
+@@ -257,7 +257,7 @@ File_read::reopen_descriptor()
+ {
+
+ // @LOCALMOD-SB-BEGIN
+-#if defined(__native_client__)
++#if 0 && defined(__native_client__)
+ this->descriptor_ = nacl_file::NaClOpenFileDescriptor(this->name_.c_str());
+ #else
+ this->descriptor_ = open_descriptor(this->descriptor_,
+@@ -300,7 +300,7 @@ File_read::release()
+ if (this->is_descriptor_opened_)
+ {
+ // @LOCALMOD-SB-BEGIN
+-#if defined(__native_client__)
++#if 0 && defined(__native_client__)
+ nacl_file::NaClReleaseFileDescriptor(this->descriptor_);
+ #else
+ release_descriptor(this->descriptor_, false);
+diff --git a/gold/main.cc b/gold/main.cc
+--- a/gold/main.cc
++++ b/gold/main.cc
+@@ -137,7 +137,7 @@ write_debug_script(std::string, const char*, const char*)
+ // For the in-browser sandboxed build, main() is defined in
+ // nacl_file.cc and calls an IRT interface for handling the browser's
+ // request. gold_main() is called by that request handler.
+-#if defined(__native_client__)
++#if 0 && defined(__native_client__)
+ int
+ gold_main(int argc, char** argv)
+ #else
+@@ -162,7 +162,7 @@ main(int argc, char** argv)
+ // @LOCALMOD-SB: skip this in sandboxed mode since the commandline we
+ // build will likely not have @filename (and we can avoid hijacking
+ // the file open operation there).
+-#if !defined(__native_client__)
++#if 1 || !defined(__native_client__)
+ expandargv(&argc, &argv);
+ #endif
+
+@@ -341,7 +341,7 @@ main(int argc, char** argv)
+ // @LOCALMOD-SB-BEGIN
+ // This function is called from an IPC request handler. We do not
+ // want it to exit.
+-#if defined(__native_client__)
++#if 0 && defined(__native_client__)
+ return errors.error_count() > 0;
+ #else
+ // If the user used --noinhibit-exec, we force the exit status to be
+diff --git a/gold/output.cc b/gold/output.cc
+--- a/gold/output.cc
++++ b/gold/output.cc
+@@ -5017,7 +5017,7 @@ Output_file::open(off_t file_size)
+ // We let the name "-" mean "stdout"
+
+ // @LOCALMOD-SB-BEGIN
+-#if defined(__native_client__)
++#if 0 && defined(__native_client__)
+ int o = nacl_file::NaClOpenFileDescriptor(this->name_);
+ if (o < 0)
+ gold_fatal(_("%s: open: %s"), this->name_, strerror(errno));
+@@ -5037,6 +5037,7 @@ Output_file::open(off_t file_size)
+ ::unlink(this->name_);
+ else if (!parameters->options().relocatable())
+ {
++#if !defined(__native_client__)
+ // If we don't unlink the existing file, add execute
+ // permission where read permissions already exist
+ // and where the umask permits.
+@@ -5044,6 +5045,7 @@ Output_file::open(off_t file_size)
+ ::umask(mask);
+ s.st_mode |= (s.st_mode & 0444) >> 2;
+ ::chmod(this->name_, s.st_mode & ~mask);
++#endif
+ }
+ }
+
+diff --git a/gold/plugin.cc b/gold/plugin.cc
+--- a/gold/plugin.cc
++++ b/gold/plugin.cc
+@@ -33,6 +33,8 @@
+ #include <dlfcn.h>
+ #elif defined (HAVE_WINDOWS_H)
+ #include <windows.h>
++#elif defined (__native_client__)
++/* Handled inline. */
+ #else
+ #error Unknown how to handle dynamic-load-libraries.
+ #endif
+@@ -74,6 +76,10 @@ dlerror(void)
+ #include "descriptors.h"
+ #include "elfcpp.h"
+
++#if defined(__native_client__)
++extern "C" ld_plugin_status LLVMgold_onload(ld_plugin_tv *tv);
++#endif
++
+ namespace gold
+ {
+
+@@ -178,6 +184,9 @@ void
+ Plugin::load()
+ {
+ #ifdef ENABLE_PLUGINS
++#if defined(__native_client__)
++ ld_plugin_onload onload = ::LLVMgold_onload;
++#else
+ // Load the plugin library.
+ // FIXME: Look for the library in standard locations.
+ this->handle_ = dlopen(this->filename_.c_str(), RTLD_NOW);
+@@ -199,6 +208,7 @@ Plugin::load()
+ ld_plugin_onload onload;
+ gold_assert(sizeof(onload) == sizeof(ptr));
+ memcpy(&onload, &ptr, sizeof(ptr));
++#endif
+
+ // Get the linker's version number.
+ const char* ver = get_version_string();
+diff --git a/gprof/configure b/gprof/configure
+--- a/gprof/configure
++++ b/gprof/configure
+@@ -11283,9 +11283,7 @@ if test "${enable_plugins+set}" = set; then :
+ enableval=$enable_plugins; case "${enableval}" in
+ no) plugins=no ;;
+ *) plugins=yes
+- if test "$maybe_plugins" != "yes" ; then
+- as_fn_error "Building with plugin support requires a host that supports dlopen." "$LINENO" 5
+- fi ;;
++ ;;
+ esac
+ else
+ plugins=$maybe_plugins
+diff --git a/ld/configure b/ld/configure
+--- a/ld/configure
++++ b/ld/configure
+@@ -15109,14 +15109,14 @@ fi
+ done
+
+
++enable_plugins=no
++
+ # Check whether --enable-plugins was given.
+ if test "${enable_plugins+set}" = set; then :
+ enableval=$enable_plugins; case "${enableval}" in
+ no) plugins=no ;;
+ *) plugins=yes
+- if test "$maybe_plugins" != "yes" ; then
+- as_fn_error "Building with plugin support requires a host that supports dlopen." "$LINENO" 5
+- fi ;;
++ ;;
+ esac
+ else
+ plugins=$maybe_plugins
+diff --git a/libiberty/strsignal.c b/libiberty/strsignal.c
+--- a/libiberty/strsignal.c
++++ b/libiberty/strsignal.c
+@@ -550,6 +550,7 @@ followed by a newline.
+
+ #ifndef HAVE_PSIGNAL
+
++#if !defined(__native_client__)
+ void
+ psignal (int signo, char *message)
+ {
+@@ -566,6 +567,7 @@ psignal (int signo, char *message)
+ fprintf (stderr, "%s: %s\n", message, sys_siglist[signo]);
+ }
+ }
++#endif
+
+ #endif /* ! HAVE_PSIGNAL */
+
+diff --git a/libiberty/vfork.c b/libiberty/vfork.c
+--- a/libiberty/vfork.c
++++ b/libiberty/vfork.c
+@@ -11,6 +11,7 @@ Emulates @code{vfork} by calling @code{fork} and returning its value.
+
+ */
+
++#if !defined(__native_client__)
+ #include "ansidecl.h"
+
+ extern int fork (void);
+@@ -20,3 +21,4 @@ vfork (void)
+ {
+ return (fork ());
+ }
++#endif
+diff --git a/opcodes/mips-dis.c b/opcodes/mips-dis.c
+--- a/opcodes/mips-dis.c
++++ b/opcodes/mips-dis.c
+@@ -157,6 +157,7 @@ static const char * const mips_cp0_names_r5900[32] =
+ "c0_taglo", "c0_taghi", "c0_errorepc", "$31"
+ };
+
++#if !defined(__native_client__)
+ static const struct mips_cp0sel_name mips_cp0sel_names_mipsr5900[] =
+ {
+ { 24, 2, "c0_iab" },
+@@ -168,6 +169,7 @@ static const struct mips_cp0sel_name mips_cp0sel_names_mipsr5900[] =
+ { 25, 1, "c0_perfcnt,1" },
+ { 25, 2, "c0_perfcnt,2" }
+ };
++#endif
+
+ static const char * const mips_cp0_names_mips3264[32] =
+ {
diff --git a/ports/pnacl-binutils-src/pkg_info b/ports/pnacl-binutils-src/pkg_info
index eca16ba..8130ad5 100644
--- a/ports/pnacl-binutils-src/pkg_info
+++ b/ports/pnacl-binutils-src/pkg_info
@@ -1,5 +1,5 @@
NAME=pnacl-binutils-src
VERSION=0.0.1
ARCHIVE_ROOT=binutils
-URL=https://chromium.googlesource.com/native_client/nacl-binutils.git@d9b81d6377ffd6e28e5649246c1f450d6e2a9083
+URL=https://chromium.googlesource.com/native_client/nacl-binutils.git@d5a23a3
LICENSE=BSD
diff --git a/ports/pnacl-binutils-x86-src/build.sh b/ports/pnacl-binutils-x86-src/build.sh
new file mode 100644
index 0000000..352546f
--- /dev/null
+++ b/ports/pnacl-binutils-x86-src/build.sh
@@ -0,0 +1,17 @@
+# Copyright (c) 2015 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.
+
+BUILD_DIR=${SRC_DIR}
+
+ConfigureStep() {
+ return
+}
+
+BuildStep() {
+ return
+}
+
+InstallStep() {
+ return
+}
diff --git a/ports/pnacl-binutils-x86-src/pkg_info b/ports/pnacl-binutils-x86-src/pkg_info
new file mode 100644
index 0000000..3036e27
--- /dev/null
+++ b/ports/pnacl-binutils-x86-src/pkg_info
@@ -0,0 +1,5 @@
+NAME=pnacl-binutils-x86-src
+VERSION=0.0.1
+ARCHIVE_ROOT=binutils
+URL=https://chromium.googlesource.com/native_client/nacl-binutils.git@1d8592c
+LICENSE=BSD
diff --git a/ports/pnacl-clang-src/nacl.patch b/ports/pnacl-clang-src/nacl.patch
new file mode 100644
index 0000000..ec09e05
--- /dev/null
+++ b/ports/pnacl-clang-src/nacl.patch
@@ -0,0 +1,45 @@
+diff --git a/tools/libclang/CIndexer.cpp b/tools/libclang/CIndexer.cpp
+--- a/tools/libclang/CIndexer.cpp
++++ b/tools/libclang/CIndexer.cpp
+@@ -37,7 +37,7 @@
+
+ #ifdef LLVM_ON_WIN32
+ #include <windows.h>
+-#else
++#elif !defined(_NEWLIB_VERSION)
+ #include <dlfcn.h>
+ #endif
+
+@@ -69,6 +69,8 @@ const std::string &CIndexer::getClangResourcesPath() {
+ #endif
+
+ LibClangPath += llvm::sys::path::parent_path(path);
++#elif defined(_NEWLIB_VERSION)
++ LibClangPath += "";
+ #else
+ // This silly cast below avoids a C++ warning.
+ Dl_info info;
+diff --git a/unittests/Makefile b/unittests/Makefile
+--- a/unittests/Makefile
++++ b/unittests/Makefile
+@@ -10,6 +10,14 @@
+ # If CLANG_LEVEL is not set, then we are the top-level Makefile. Otherwise, we
+ # are being included from a subdirectory makefile.
+
++ifeq ($(HOST_OS),NativeClient)
++all:
++ echo skipping
++
++install:
++ echo skipping
++else
++
+ ifndef CLANG_LEVEL
+
+ IS_UNITTEST_LEVEL := 1
+@@ -33,3 +41,5 @@ MAKEFILE_UNITTEST_NO_INCLUDE_COMMON := 1
+ include $(LLVM_SRC_ROOT)/unittests/Makefile.unittest
+
+ endif # IS_UNITTEST_LEVEL
++
++endif
diff --git a/ports/pnacl-clang-src/pkg_info b/ports/pnacl-clang-src/pkg_info
index 0c3d510..26dd36f 100644
--- a/ports/pnacl-clang-src/pkg_info
+++ b/ports/pnacl-clang-src/pkg_info
@@ -1,5 +1,5 @@
NAME=pnacl-clang-src
VERSION=0.0.1
ARCHIVE_ROOT=clang
-URL=https://chromium.googlesource.com/native_client/pnacl-clang.git@e218816eca6fd206758096d7b88a6517ad7fa425
+URL=https://chromium.googlesource.com/native_client/pnacl-clang.git@cf0dc7f
LICENSE=BSD
diff --git a/ports/pnacl-llvm-src/README.nacl b/ports/pnacl-llvm-src/README.nacl
new file mode 100644
index 0000000..a99f989
--- /dev/null
+++ b/ports/pnacl-llvm-src/README.nacl
@@ -0,0 +1,10 @@
+This source tree is a pinned revsion of that NaCl llvm repository.
+
+The nacl.patch contains changes needed to make llvm build with
+the nacl and pnacl toolchains.
+
+1. Fix unused symbol errors in Signals.inc
+
+2. Remove inline assembly use of xgetbv instruction
+
+3. Makefile.rules: Don't attempt to build loadable modules when ENABLE_SHARED=0
diff --git a/ports/pnacl-llvm-src/nacl.patch b/ports/pnacl-llvm-src/nacl.patch
index d06f6f0..a121418 100644
--- a/ports/pnacl-llvm-src/nacl.patch
+++ b/ports/pnacl-llvm-src/nacl.patch
@@ -1,12 +1,410 @@
+diff --git a/Makefile.rules b/Makefile.rules
+--- a/Makefile.rules
++++ b/Makefile.rules
+@@ -1200,6 +1200,7 @@ ifdef EXPORTED_SYMBOL_FILE
+ $(LibName.SO): $(NativeExportsFile)
+ endif
+
++ifeq ($(ENABLE_SHARED),1)
+ ifdef LINK_LIBS_IN_SHARED
+ ifdef LOADABLE_MODULE
+ SharedLibKindMessage := "Loadable Module"
+@@ -1217,6 +1218,7 @@ $(LibName.SO): $(ObjectsO) $(SharedLibDir)/.dir
+ $(Echo) Linking $(BuildMode) Shared Library $(notdir $@)
+ $(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO)
+ endif
++endif
+
+ clean-local::
+ ifneq ($(strip $(LibName.SO)),)
+@@ -1239,6 +1241,7 @@ endif
+ DestSharedLib := $(DestSharedLibDir)/$(BaseLibName.SO)
+ DestSharedAlias := $(DestSharedLibDir)/$(BaseAliasName.SO)
+
++ifeq ($(ENABLE_SHARED),1)
+ install-local:: $(DestSharedLib)
+
+ $(DestSharedLib): $(LibName.SO) $(DestSharedLibDir)
+@@ -1257,6 +1260,7 @@ ifdef SHARED_ALIAS
+ endif
+ endif
+ endif
++endif
+
+ #---------------------------------------------------------
+ # Library Targets:
+@@ -1265,9 +1269,13 @@ endif
+ #---------------------------------------------------------
+ ifndef NO_BUILD_ARCHIVE
+ ifndef BUILD_ARCHIVE
++ifeq ($(ENABLE_SHARED),1)
+ ifndef LOADABLE_MODULE
+ BUILD_ARCHIVE = 1
+ endif
++else
++BUILD_ARCHIVE = 1
++endif
+ endif
+ endif
+
+diff --git a/include/llvm/Support/TargetRegistry.h b/include/llvm/Support/TargetRegistry.h
+--- a/include/llvm/Support/TargetRegistry.h
++++ b/include/llvm/Support/TargetRegistry.h
+@@ -814,7 +814,7 @@ namespace llvm {
+ // @LOCALMOD-BEGIN
+ // Prune out the .s printer for the sandboxed translator,
+ // by preventing an InstPrinter from being used at all.
+- #if !defined(__native_client__)
++ #if !defined(PNACL_BROWSER_TRANSLATOR)
+ T.MCInstPrinterCtorFn = Fn;
+ #endif
+ // @LOCALMOD-END
+diff --git a/lib/ExecutionEngine/RuntimeDyld/RTDyldMemoryManager.cpp b/lib/ExecutionEngine/RuntimeDyld/RTDyldMemoryManager.cpp
+--- a/lib/ExecutionEngine/RuntimeDyld/RTDyldMemoryManager.cpp
++++ b/lib/ExecutionEngine/RuntimeDyld/RTDyldMemoryManager.cpp
+@@ -34,7 +34,8 @@ RTDyldMemoryManager::~RTDyldMemoryManager() {}
+
+ // Determine whether we can register EH tables.
+ #if (defined(__GNUC__) && !defined(__ARM_EABI__) && !defined(__ia64__) && \
+- !defined(__SEH__) && !defined(__USING_SJLJ_EXCEPTIONS__))
++ !defined(__SEH__) && !defined(__USING_SJLJ_EXCEPTIONS__) && \
++ !defined(__pnacl__))
+ #define HAVE_EHTABLE_SUPPORT 1
+ #else
+ #define HAVE_EHTABLE_SUPPORT 0
diff --git a/lib/Support/Host.cpp b/lib/Support/Host.cpp
--- a/lib/Support/Host.cpp
+++ b/lib/Support/Host.cpp
-@@ -168,7 +168,7 @@ static bool GetX86CpuIDAndInfoEx(unsigned value, unsigned subleaf,
+@@ -183,7 +183,7 @@ static bool GetX86CpuIDAndInfoEx(unsigned value, unsigned subleaf,
}
- static bool OSHasAVXSupport() {
+ static bool GetX86XCR0(unsigned *rEAX, unsigned *rEDX) {
-#if defined(__GNUC__)
+#if defined(__GNUC__) && !defined(__native_client__)
// Check xgetbv; this uses a .byte sequence instead of the instruction
// directly because older assemblers do not include support for xgetbv and
// there is no easy way to conditionally compile based on the assembler used.
+diff --git a/lib/Support/Unix/Path.inc b/lib/Support/Unix/Path.inc
+--- a/lib/Support/Unix/Path.inc
++++ b/lib/Support/Unix/Path.inc
+@@ -67,7 +67,8 @@ namespace sys {
+ namespace fs {
+ #if defined(__FreeBSD__) || defined (__NetBSD__) || defined(__Bitrig__) || \
+ defined(__OpenBSD__) || defined(__minix) || defined(__FreeBSD_kernel__) || \
+- defined(__linux__) || defined(__CYGWIN__) || defined(__DragonFly__)
++ defined(__linux__) || defined(__CYGWIN__) || defined(__DragonFly__) || \
++ defined(__native_client__)
+ static int
+ test_dir(char ret[PATH_MAX], const char *dir, const char *bin)
+ {
+@@ -171,6 +172,11 @@ std::string getMainExecutable(const char *argv0, void *MainAddr) {
+ // @LOCALMOD-BEGIN
+ #elif defined(__native_client__)
+ // Nothing.
++#if !defined(PNACL_BROWSER_TRANSLATOR)
++ char exe_path[MAXPATHLEN];
++ if (getprogpath(exe_path, argv0) != NULL)
++ return exe_path;
++#endif
+ // @LOCALMOD-END
+ #else
+ #error GetMainExecutable is not implemented on this host yet.
+@@ -192,13 +198,13 @@ std::error_code current_path(SmallVectorImpl<char> &result) {
+ result.clear();
+ // @LOCALMOD-START NaCl doesn't have paths, and the translator returns an
+ // error for getcwd below. Return a dummy path instead.
+-#if defined(__native_client__)
++#if defined(PNACL_BROWSER_TRANSLATOR)
+ result.reserve(2);
+ result.set_size(2);
+ result[0] = '/';
+ result[1] = '\0';
+ return std::error_code();
+-#else // !defined(__native_client__)
++#else // !defined(PNACL_BROWSER_TRANSLATOR)
+ // @LOCALMOD-END
+ const char *pwd = ::getenv("PWD");
+ llvm::sys::fs::file_status PWDStatus, DotStatus;
+diff --git a/lib/Support/Unix/Process.inc b/lib/Support/Unix/Process.inc
+--- a/lib/Support/Unix/Process.inc
++++ b/lib/Support/Unix/Process.inc
+@@ -61,7 +61,9 @@ using namespace llvm;
+ using namespace sys;
+
+ static std::pair<TimeValue, TimeValue> getRUsageTimes() {
+-#if defined(HAVE_GETRUSAGE)
++// @LOCALMOD-BEGIN
++#if defined(HAVE_GETRUSAGE) && !defined(__native_client__)
++// @LOCALMOD-END
+ struct rusage RU;
+ ::getrusage(RUSAGE_SELF, &RU);
+ return std::make_pair(
+diff --git a/lib/Support/Unix/Program.inc b/lib/Support/Unix/Program.inc
+--- a/lib/Support/Unix/Program.inc
++++ b/lib/Support/Unix/Program.inc
+@@ -16,6 +16,11 @@
+ //=== is guaranteed to work on *all* UNIX variants.
+ //===----------------------------------------------------------------------===//
+
++// @LOCALMOD-BEGIN
++#if defined(__native_client__) && !defined(PNACL_BROWSER_TRANSLATOR)
++#include <spawn.h>
++#endif
++// @LOCALMOD-END
+ #include "Unix.h"
+ #include "llvm/ADT/StringExtras.h"
+ #include "llvm/Config/config.h"
+@@ -187,6 +192,15 @@ static bool Execute(ProcessInfo &PI, StringRef Program, const char **args,
+ return false;
+ }
+
++// @LOCALMOD-BEGIN
++#if defined(__native_client__) && !defined(PNACL_BROWSER_TRANSLATOR)
++ int child = spawnve(P_NOWAIT, Program.begin(), (char**) args, (char**) envp);
++ if (child < 0) {
++ MakeErrMsg(ErrMsg, "Couldn't spawn");
++ return false;
++ }
++#else
++// @LOCALMOD-END
+ // If this OS has posix_spawn and there is no memory limit being implied, use
+ // posix_spawn. It is more efficient than fork/exec.
+ #ifdef HAVE_POSIX_SPAWN
+@@ -312,6 +326,7 @@ static bool Execute(ProcessInfo &PI, StringRef Program, const char **args,
+ default:
+ break;
+ }
++#endif
+
+ PI.Pid = child;
+
+@@ -324,8 +339,10 @@ ProcessInfo sys::Wait(const ProcessInfo &PI, unsigned SecondsToWait,
+ bool WaitUntilTerminates, std::string *ErrMsg) {
+ // @LOCALMOD-BEGIN
+ #if defined(HAVE_SYS_WAIT_H) && !defined(PNACL_BROWSER_TRANSLATOR)
+- // @LOCALMOD-END
++#if !defined(__native_client__)
+ struct sigaction Act, Old;
++#endif
++ // @LOCALMOD-END
+ assert(PI.Pid && "invalid pid to wait on, process not started?");
+
+ int WaitPidOptions = 0;
+@@ -333,6 +350,9 @@ ProcessInfo sys::Wait(const ProcessInfo &PI, unsigned SecondsToWait,
+ if (WaitUntilTerminates) {
+ SecondsToWait = 0;
+ } else if (SecondsToWait) {
++// @LOCALMOD-BEGIN
++#if !defined(__native_client__)
++// @LOCALMOD-END
+ // Install a timeout handler. The handler itself does nothing, but the
+ // simple fact of having a handler at all causes the wait below to return
+ // with EINTR, unlike if we used SIG_IGN.
+@@ -341,6 +361,9 @@ ProcessInfo sys::Wait(const ProcessInfo &PI, unsigned SecondsToWait,
+ sigemptyset(&Act.sa_mask);
+ sigaction(SIGALRM, &Act, &Old);
+ alarm(SecondsToWait);
++// @LOCALMOD-BEGIN
++#endif
++// @LOCALMOD-END
+ } else if (SecondsToWait == 0)
+ WaitPidOptions = WNOHANG;
+
+@@ -358,12 +381,18 @@ ProcessInfo sys::Wait(const ProcessInfo &PI, unsigned SecondsToWait,
+ return WaitResult;
+ } else {
+ if (SecondsToWait && errno == EINTR) {
++// @LOCALMOD-BEGIN
++#if !defined(__native_client__)
++// @LOCALMOD-END
+ // Kill the child.
+ kill(PI.Pid, SIGKILL);
+
+ // Turn off the alarm and restore the signal handler
+ alarm(0);
+ sigaction(SIGALRM, &Old, nullptr);
++// @LOCALMOD-BEGIN
++#endif
++// @LOCALMOD-END
+
+ // Wait for child to die
+ if (wait(&status) != ChildPid)
+@@ -381,11 +410,17 @@ ProcessInfo sys::Wait(const ProcessInfo &PI, unsigned SecondsToWait,
+ }
+ }
+
++// @LOCALMOD-BEGIN
++#if !defined(__native_client__)
++// @LOCALMOD-END
+ // We exited normally without timeout, so turn off the timer.
+ if (SecondsToWait && !WaitUntilTerminates) {
+ alarm(0);
+ sigaction(SIGALRM, &Old, nullptr);
+ }
++// @LOCALMOD-BEGIN
++#endif
++// @LOCALMOD-END
+
+ // Return the proper exit status. Detect error conditions
+ // so we can return -1 for them and set ErrMsg informatively.
+@@ -455,11 +490,13 @@ llvm::sys::writeFileWithEncoding(StringRef FileName, StringRef Contents,
+ }
+
+ bool llvm::sys::argumentsFitWithinSystemLimits(ArrayRef<const char*> Args) {
++// @LOCALMOD-BEGIN
+ #if defined(__native_client__)
+ static long ArgMax = -1;
+ #else // !__native_client__
+ static long ArgMax = sysconf(_SC_ARG_MAX);
+ #endif // __native_client__
++// @LOCALMOD-END
+
+ // System says no practical limit.
+ if (ArgMax == -1)
+diff --git a/lib/Support/Unix/Signals.inc b/lib/Support/Unix/Signals.inc
+--- a/lib/Support/Unix/Signals.inc
++++ b/lib/Support/Unix/Signals.inc
+@@ -50,7 +50,9 @@
+
+ using namespace llvm;
+
++#if !defined(__native_client__)
+ static RETSIGTYPE SignalHandler(int Sig); // defined below.
++#endif
+
+ static ManagedStatic<SmartMutex<true> > SignalsMutex;
+
+@@ -121,15 +123,15 @@ static void RegisterHandlers() {
+ for (auto S : KillSigs) RegisterHandler(S);
+ }
+
+-static void UnregisterHandlers() {
+ #if !defined(__native_client__)
++static void UnregisterHandlers() {
+ // Restore all of the signal handlers to how they were before we showed up.
+ for (unsigned i = 0, e = NumRegisteredSignals; i != e; ++i)
+ sigaction(RegisteredSignalInfo[i].SigNo,
+ &RegisteredSignalInfo[i].SA, nullptr);
+ NumRegisteredSignals = 0;
+-#endif // (__native_client__)
+ }
++#endif // (__native_client__)
+
+
+ /// RemoveFilesToRemove - Process the FilesToRemove list. This function
+@@ -164,6 +166,7 @@ static void RemoveFilesToRemove() {
+ }
+ }
+
++#if !defined(__native_client__)
+ // SignalHandler - The signal handler that runs.
+ static RETSIGTYPE SignalHandler(int Sig) {
+ // Restore the signal behavior to default, so that the program actually
+@@ -172,12 +175,10 @@ static RETSIGTYPE SignalHandler(int Sig) {
+ // instead of recursing in the signal handler.
+ UnregisterHandlers();
+
+-#if !defined(__native_client__)
+ // Unmask all potentially blocked kill signals.
+ sigset_t SigMask;
+ sigfillset(&SigMask);
+ sigprocmask(SIG_UNBLOCK, &SigMask, nullptr);
+-#endif
+
+ {
+ unique_lock<SmartMutex<true>> Guard(*SignalsMutex);
+@@ -214,6 +215,7 @@ static RETSIGTYPE SignalHandler(int Sig) {
+ raise(Sig);
+ #endif
+ }
++#endif
+
+ void llvm::sys::RunInterruptHandlers() {
+ sys::SmartScopedLock<true> Guard(*SignalsMutex);
+diff --git a/tools/gold/gold-plugin.cpp b/tools/gold/gold-plugin.cpp
+--- a/tools/gold/gold-plugin.cpp
++++ b/tools/gold/gold-plugin.cpp
+@@ -154,14 +154,20 @@ static ld_plugin_status claim_file_hook(const ld_plugin_input_file *file,
+ static ld_plugin_status all_symbols_read_hook(void);
+ static ld_plugin_status cleanup_hook(void);
+
++// @LOCALMOD-BEGIN
++#if defined(__native_client__)
++extern "C" ld_plugin_status LLVMgold_onload(ld_plugin_tv *tv);
++ld_plugin_status LLVMgold_onload(ld_plugin_tv *tv) {
++#else
+ extern "C" ld_plugin_status onload(ld_plugin_tv *tv);
+ ld_plugin_status onload(ld_plugin_tv *tv) {
++#endif
++// @LOCALMOD-END
+ InitializeAllTargetInfos();
+ InitializeAllTargets();
+ InitializeAllTargetMCs();
+ InitializeAllAsmParsers();
+ InitializeAllAsmPrinters();
+-
+ // We're given a pointer to the first transfer vector. We read through them
+ // until we find one where tv_tag == LDPT_NULL. The REGISTER_* tagged values
+ // contain pointers to functions that we need to call to register our own
+diff --git a/tools/lli/lli.cpp b/tools/lli/lli.cpp
+--- a/tools/lli/lli.cpp
++++ b/tools/lli/lli.cpp
+@@ -386,7 +386,15 @@ static void addCygMingExtraModule(ExecutionEngine *EE,
+ //===----------------------------------------------------------------------===//
+ // main Driver function
+ //
++// @LOCALMOD-BEGIN
++#if defined(__native_client__)
++extern char **environ;
++int main(int argc, char **argv) {
++ char * const *envp = environ;
++#else
+ int main(int argc, char **argv, char * const *envp) {
++#endif
++// @LOCALMOD-END
+ sys::PrintStackTraceOnErrorSignal();
+ PrettyStackTraceProgram X(argc, argv);
+
+diff --git a/unittests/Bitcode/NaClMungeWriteErrorTests.cpp b/unittests/Bitcode/NaClMungeWriteErrorTests.cpp
+--- a/unittests/Bitcode/NaClMungeWriteErrorTests.cpp
++++ b/unittests/Bitcode/NaClMungeWriteErrorTests.cpp
+@@ -180,6 +180,7 @@ TEST(NaClMungeWriteErrorTests, CantWriteBadAbbrevIndex) {
+ ExpectedDumpedBitcode);
+ }
+
++#ifdef GTEST_HAS_DEATH_TEST
+ // Show that writing out an illegal abbreviation index, causes the
+ // parser to fail.
+ TEST(MyNaClMungerWriteErrorTests, DieOnWriteBadAbbreviationIndex) {
+@@ -199,6 +200,7 @@ TEST(MyNaClMungerWriteErrorTests, DieOnWriteBadAbbreviationIndex) {
+ "LLVM ERROR\\: Unable to continue"
+ ".*");
+ }
++#endif
+
+ // Show what happens when we use more local abbreviations than specified in the
+ // corresponding enclosing block.
+diff --git a/unittests/Makefile b/unittests/Makefile
+--- a/unittests/Makefile
++++ b/unittests/Makefile
+@@ -7,6 +7,14 @@
+ #
+ ##===----------------------------------------------------------------------===##
+
++ifeq ($(HOST_OS),NativeClient)
++all:
++ echo skipping
++
++install:
++ echo skipping
++else
++
+ LEVEL = ..
+
+ PARALLEL_DIRS = ADT Analysis Bitcode CodeGen DebugInfo ExecutionEngine IR \
+@@ -17,3 +25,5 @@ include $(LLVM_SRC_ROOT)/unittests/Makefile.unittest
+
+ clean::
+ $(Verb) $(RM) -f *Tests
++
++endif
diff --git a/ports/pnacl-llvm-src/pkg_info b/ports/pnacl-llvm-src/pkg_info
index b4064d7..2a3c12b 100644
--- a/ports/pnacl-llvm-src/pkg_info
+++ b/ports/pnacl-llvm-src/pkg_info
@@ -1,5 +1,5 @@
NAME=pnacl-llvm-src
VERSION=0.0.1
ARCHIVE_ROOT=llvm
-URL=https://chromium.googlesource.com/native_client/pnacl-llvm.git@caf6bbe98a0b7dd7dfd71dbb72b77bf71c4ff0d8
+URL=https://chromium.googlesource.com/native_client/pnacl-llvm.git@1ac309a
LICENSE=BSD
diff --git a/ports/pnacl/build.sh b/ports/pnacl/build.sh
index 21e8cc7..60d1937 100644
--- a/ports/pnacl/build.sh
+++ b/ports/pnacl/build.sh
@@ -2,7 +2,6 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-EXECUTABLES="bin/arm-nacl-readelf bin/le32-nacl-strings bin/clang bin/clang++"
EnableGlibcCompat
EnableCliMain
@@ -21,6 +20,9 @@
Remove ${SRC_DIR}/toolchain_build/src/llvm/tools/clang
LogExecute ln -fs ${SRC_DIR}/../../pnacl-clang-src/clang \
${SRC_DIR}/toolchain_build/src/llvm/tools/clang
+ Remove ${SRC_DIR}/toolchain_build/src/binutils-x86
+ LogExecute ln -fs ${SRC_DIR}/../../pnacl-binutils-x86-src/binutils \
+ ${SRC_DIR}/toolchain_build/src/binutils-x86
}
ConfigureStep() {
@@ -28,7 +30,7 @@
}
OUT_DIR=${BUILD_DIR}/out
-OUT_BIN=${BUILD_DIR}/bin
+OUT_INSTALL=${BUILD_DIR}/install
BuildStep() {
PNACL_DIR=${NACL_SDK_ROOT}/toolchain/linux_pnacl
@@ -67,6 +69,13 @@
EXTRA_CONFIGURE="--extra-configure-arg=--disable-compiler-version-checks"
EXTRA_CONFIGURE+=" --extra-configure-arg=--enable-libcpp"
+ # Without this configure will detect vfork as missing and define
+ # vfork to fork which clobbers that define in "spawn.h".
+ EXTRA_CONFIGURE+=" --extra-configure-arg=ac_cv_func_vfork_works=yes"
+ EXTRA_CONFIGURE+=" --extra-configure-arg=ac_cv_func_getrusage=no"
+ if [[ ${NACL_DEBUG} == 1 ]]; then
+ EXTRA_CONFIGURE+=" --host-flavor=debug"
+ fi
# Some code in llvm uses intrisics not supported in the pnacl stable abi.
if [[ ${TOOLCHAIN} == pnacl ]]; then
@@ -77,18 +86,13 @@
EXTRA_CC_ARGS+=" -I${NACLPORTS_INCLUDE}/glibc-compat"
fi
- LINUX_PNACL=${NACL_SDK_ROOT}/toolchain/linux_pnacl
EXTRA_CC_ARGS+=" -include spawn.h"
EXTRA_CC_ARGS+=" -I${NACL_SDK_ROOT}/include"
EXTRA_CC_ARGS+=" -I${NACLPORTS_INCLUDE}"
- # export EXTRA_LIBS so that compiler_wapper.py can access it
- export EXTRA_LIBS="${NACLPORTS_LDFLAGS} ${NACLPORTS_LIBS}"
- echo "EXTRA_LIBS=${EXTRA_LIBS}"
-
- # Without this configure will detect vfork as missing and define
- # vfork to fork which clobbers that define in "spawn.h".
- export ac_cv_func_vfork_works=yes
+ # export WEBPORTS_EXTRA_LIBS so that compiler_wapper.py can access it
+ export WEBPORTS_EXTRA_LIBS="${NACLPORTS_LDFLAGS} ${NACLPORTS_LIBS}"
+ echo "WEBPORTS_EXTRA_LIBS=${WEBPORTS_EXTRA_LIBS}"
# Inject a shim that speed up pnacl invocations for configure.
if [ "${NACL_ARCH}" = "pnacl" ]; then
@@ -100,6 +104,9 @@
NACLCC="${START_DIR}/compiler_wrapper.py ${NACLCC}"
NACLCXX="${START_DIR}/compiler_wrapper.py ${NACLCXX}"
+ Remove ${OUT_INSTALL}
+ MakeDir ${OUT_INSTALL}
+
export CC=${NACLCC}
export CXX=${NACLCXX}
export AR=${NACLAR}
@@ -110,19 +117,68 @@
--no-annotator \
--pnacl-in-pnacl \
--output=${OUT_DIR} \
+ --install=${OUT_INSTALL} \
"--extra-cc-args=${EXTRA_CC_ARGS}" \
${EXTRA_CONFIGURE} \
"--binutils-pnacl-extra-configure=${GOLD_LDADD}"
- Remove ${OUT_BIN}
- MakeDir ${OUT_BIN}
- LogExecute cp ${OUT_DIR}/llvm_le32_nacl_install/bin/* ${OUT_BIN}
- LogExecute cp ${OUT_DIR}/binutils_pnacl_le32_nacl_install/bin/* \
- ${OUT_BIN}
- # TODO(bradnelson): Drop this once shell script fix is done.
- MakeDir ${OUT_BIN}/driver
- LogExecute cp ${SRC_DIR}/pnacl/driver/redirect.sh ${OUT_BIN}/driver/
- LogExecute cp ${SRC_DIR}/pnacl/driver/*.py ${OUT_BIN}/driver/
+ CreateHybridToolchain
+}
+
+CreateHybridToolchain() {
+ Banner "Creating Hybrid Toolchain"
+
+ # Build a full toolchain based on the one in NACL_SDK_ROOT, but overlayed
+ # with the one we just compiled.
+ Remove toolchain
+ MakeDir toolchain
+
+ host_toolchain=${NACL_SDK_ROOT}/toolchain/linux_pnacl
+ LogExecute cp -r ${host_toolchain}/* toolchain
+
+ # Drop pyc files.
+ LogExecute find toolchain -name "*.pyc" -exec rm {} \;
+
+ # Overlay compiled toolchain
+ Remove ${OUT_INSTALL}/x86_64-nacl/lib/32
+ Remove ${OUT_INSTALL}/x86_64-nacl/lib64
+ LogExecute cp -r ${OUT_INSTALL}/* toolchain/
+
+ # Rename the nacl executables.
+ for f in $(cd ${host_toolchain} && find . -executable -type f); do
+ if [[ "$(file ${host_toolchain}/${f} | grep ELF)" != "" \
+ && ${f} != *pnacl-abicheck ]]; then
+ # We are dealing with an executable
+ local built_exe="${OUT_INSTALL}/${f}"
+ local exe="toolchain/${f}"
+ if [[ -f ${built_exe} ]]; then
+ LogExecute mv ${exe} ${exe}${NACL_EXEEXT}
+ elif [[ $f == *-clang* ]]; then
+ Remove ${exe}
+ LogExecute ln -sf clang${NACL_EXEEXT} ${exe}${NACL_EXEEXT}
+ else
+ echo "Warning: dropping ${f} without a nacl replacement."
+ LogExecute rm -f ${exe}
+ fi
+ fi
+ done
+
+ # Now create launcher scripts for each executable
+ for f in toolchain/bin/*${NACL_EXEEXT}; do
+ script=${f%.*}
+ if [[ ${TOOLCHAIN} == pnacl ]]; then
+ TranslateAndWriteLauncherScript "${f}" x86-64 "${script}.nexe" "${script}"
+ else
+ WriteLauncherScript "${script}" "$(basename ${f})"
+ fi
+ done
+
+ # Drop parts we don't care about
+ LogExecute rm -rf toolchain/translator
+ LogExecute rm -rf toolchain/mipsel-nacl
+ LogExecute rm -rf toolchain/*-nacl/usr
+ LogExecute rm -f toolchain/bin/mipsel-*
+ LogExecute rm -f toolchain/lib/*.so
}
InstallStep() {
@@ -130,48 +186,65 @@
Remove ${INSTALL_DIR}/
MakeDir ${INSTALL_DIR}/
- LogExecute cp -r ${NACL_SDK_ROOT}/toolchain/linux_pnacl/* ${INSTALL_DIR}
-
- # Drop pyc files.
- LogExecute find ${INSTALL_DIR} -name "*.pyc" -exec rm {} \;
-
- LogExecute rm -rf ${INSTALL_DIR}/mipsel-nacl
- LogExecute rm -rf ${INSTALL_DIR}/translator
- LogExecute rm -rf ${INSTALL_DIR}/*-nacl/usr
-
- # TODO(bradnelson): Drop this once shell script fix is done.
- LogExecute cp ${OUT_BIN}/driver/*.py ${INSTALL_DIR}/bin/pydir/
-
- # Swap in nacl executables.
- Remove ${INSTALL_DIR}/lib/*.so
- for f in $(find ${INSTALL_DIR} -executable -type f); do
- if [ "$(file ${f} | grep ELF)" != "" ]; then
- local exe="${OUT_BIN}/$(basename ${f})"
- if [[ -f ${exe} ]]; then
- if [[ ${TOOLCHAIN} == pnacl ]]; then
- echo "Finalizing ${exe}"
- ${PNACLFINALIZE} ${exe} -o ${f}
- else
- echo "Copying ${exe}"
- cp ${exe} ${f}
- fi
- elif [[ $f == *-clang* ]]; then
- LogExecute ln -sf ${f} $(basename ${f})
- else
- echo "Warning: dropping ${f} without a nacl replacement."
- LogExecute rm -f ${f}
- fi
- elif [ "$(head -n 1 ${f} | grep /bin/sh)" != "" ]; then
- # TODO(bradnelson): Drop this once shell script fix is done.
- LogExecute cp -f ${OUT_BIN}/driver/redirect.sh ${f}
- LogExecute chmod a+x ${f}
- fi
+ LogExecute cp -r toolchain/* ${INSTALL_DIR}
+ for f in $(find ${INSTALL_DIR} -type l -name *-clang*${NACL_EXEEXT}); do
+ # link to clang binary
+ Remove $f ${f%.*}
+ LogExecute ln -s clang ${f%.*}
+ done
+ for f in $(find ${INSTALL_DIR} -executable -type f -name *${NACL_EXEEXT}); do
+ LogExecute mv $f ${f%.*}
done
}
-PostInstallTestStep() {
+TestStep() {
# Verify that binaries at least load under sel_ldr
- LogExecute ./bin/le32-nacl-strings.sh --version
- LogExecute ./bin/arm-nacl-readelf.sh --version
- LogExecute ./bin/clang.sh --version
+ LogExecute toolchain/bin/le32-nacl-strings --version
+ LogExecute toolchain/bin/arm-nacl-readelf --version
+ LogExecute toolchain/bin/x86_64-nacl-as --version
+ LogExecute toolchain/bin/clang --version
+
+ # The end-to-end tests doesn't currently work for PNaCl
+ if [[ $TOOLCHAIN == pnacl ]]; then
+ return
+ fi
+ TestNaClClang
+}
+
+TestNaClClang() {
+ # Try compiling and running a simple hello world program. We have to
+ # use explicit compile, assemble and link commands since sel_ldr doesn't
+ # provide fork().
+
+ compile_command="toolchain/bin/x86_64-nacl-clang -cc1 -triple x86_64--nacl
+ -S -disable-free -main-file-name ${START_DIR}/hello.c -mrelocation-model
+ static -mthread-model posix -mdisable-fp-elim -fmath-errno -no-integrated-as
+ -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64
+ -target-linker-version 2.24 -v -dwarf-column-info
+ -resource-dir $PWD/toolchain/bin/../lib/clang/3.7.0
+ -internal-isystem $PWD/toolchain/bin/../lib/clang/3.7.0/include
+ -internal-isystem $PWD/toolchain/bin/../x86_64-nacl/usr/include
+ -internal-isystem $PWD/toolchain/bin/../x86_64-nacl/include
+ -fno-dwarf-directory-asm -ferror-limit 19 -fmessage-length 0 -mstackrealign
+ -fobjc-runtime=gcc -fdiagnostics-show-option -o hello.s -x c
+ ${START_DIR}/hello.c
+ "
+ LogExecute $compile_command
+
+ LogExecute toolchain/bin/x86_64-nacl-as --64 hello.s -o hello.o
+ link_command="toolchain/x86_64-nacl/bin/ld --build-id -m
+ elf_x86_64_nacl -static -o hello.nexe
+ $PWD/toolchain/bin/../x86_64-nacl/lib/crt1.o
+ $PWD/toolchain/bin/../x86_64-nacl/lib/crti.o
+ $PWD/toolchain/bin/../lib/clang/3.7.0/lib/x86_64-nacl/crtbeginT.o
+ -L$PWD/toolchain/bin/../x86_64-nacl/lib
+ -L$PWD/toolchain/bin/../x86_64-nacl/usr/lib
+ -L$PWD/toolchain/bin/../lib/clang/3.7.0/lib/x86_64-nacl
+ ./hello.o --start-group -lc -lgcc --as-needed -lgcc_eh --no-as-needed
+ --end-group
+ $PWD/toolchain/bin/../lib/clang/3.7.0/lib/x86_64-nacl/crtend.o
+ $PWD/toolchain/bin/../x86_64-nacl/lib/crtn.o
+ "
+ LogExecute $link_command
+ RunSelLdrCommand hello.nexe
}
diff --git a/ports/pnacl/compiler_wrapper.py b/ports/pnacl/compiler_wrapper.py
index 9ef2fe7..b1ce27e 100755
--- a/ports/pnacl/compiler_wrapper.py
+++ b/ports/pnacl/compiler_wrapper.py
@@ -16,9 +16,16 @@
cmd = sys.argv[1:]
-# Add extra libs when linking
+is_configuring = 'conftest.c' in cmd or 'conftest.pexe' in cmd
is_linking = '-c' not in cmd and '-E' not in cmd
-if is_linking:
- cmd += os.environ['EXTRA_LIBS'].split()
+is_shared = '-shared' in cmd
+
+# Add extra libs when linking executables
+if is_linking and not is_shared:
+ cmd += os.environ['WEBPORTS_EXTRA_LIBS'].split()
+
+if is_configuring:
+ cmd.remove('-include')
+ cmd.remove('spawn.h')
sys.exit(subprocess.call(cmd))
diff --git a/ports/pnacl/hello.c b/ports/pnacl/hello.c
new file mode 100644
index 0000000..2bbd671
--- /dev/null
+++ b/ports/pnacl/hello.c
@@ -0,0 +1,14 @@
+/*
+ * Copyright 2016 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.
+ */
+
+/* Simple hello world test program for compiler smoketest */
+
+#include <stdio.h>
+
+int main() {
+ printf("Hello, world!\n");
+ return 0;
+}
diff --git a/ports/pnacl/nacl.patch b/ports/pnacl/nacl.patch
index 5b22a6c..3d817af 100644
--- a/ports/pnacl/nacl.patch
+++ b/ports/pnacl/nacl.patch
@@ -1,9 +1,9 @@
diff --git a/toolchain_build/toolchain_build_pnacl.py b/toolchain_build/toolchain_build_pnacl.py
--- a/toolchain_build/toolchain_build_pnacl.py
+++ b/toolchain_build/toolchain_build_pnacl.py
-@@ -151,30 +151,33 @@ def ProgramPath(program):
- # Return a tuple (C compiler, C++ compiler) of the compilers to compile the host
- # toolchains
+@@ -191,29 +191,31 @@ binaries themselves should be considered inputs for memoization.
+ # Return a tuple (C compiler, C++ compiler, ar, ranlib) of the compilers and
+ # tools to compile the host toolchains.
def CompilersForHost(host):
- compiler = {
+ rtn = {
@@ -27,7 +27,6 @@
- nacl_sdk = os.environ.get('NACL_SDK_ROOT')
- assert nacl_sdk, 'NACL_SDK_ROOT not set'
- pnacl_bin_dir = os.path.join(nacl_sdk, 'toolchain/linux_pnacl/bin')
-- glibc_bin_dir = os.path.join(nacl_sdk, 'toolchain/linux_x86_glibc/bin')
- compiler.update({
- 'le32-nacl': (os.path.join(pnacl_bin_dir, 'pnacl-clang'),
- os.path.join(pnacl_bin_dir, 'pnacl-clang++'),
@@ -36,8 +35,6 @@
- })
- return compiler[host]
+ 'i686-pc-cygwin': ['gcc', 'g++', 'ar', 'ranlib'],
-+ # In practice these don't get used since when naclports builds the
-+ # pnacl toolchain it explictly sets CC/CXX/etc
+ 'le32-nacl': ['pnacl-clang', 'pnacl-clang++', 'pnacl-ar', 'pnacl-ranlib'],
+ }[host]
+
@@ -53,11 +50,11 @@
+
+ return rtn
-
- def GSDJoin(*args):
-@@ -532,10 +535,12 @@ def HostTools(host, options):
- # too many arguments for format.
- binutils_do_werror = not TripleIsWindows(host)
+ def AflFuzzCompilers(afl_fuzz_dir):
+ """Returns the AFL (clang) compiler executables, assuming afl_fuzz_dir
+@@ -677,10 +679,12 @@ def HostTools(host, options):
+ # [-Werror,-Wshift-negative-value]
+ binutils_do_werror = False
extra_gold_deps = []
+ install_step = 'install-strip'
if host == 'le32-nacl':
@@ -66,24 +63,42 @@
extra_gold_deps = [H('llvm')]
+ install_step = 'install'
- # Binutils still has some warnings when building with clang
- if not options.gcc:
-@@ -574,7 +579,7 @@ def HostTools(host, options):
+ # The binutils git checkout includes all the directories in the
+ # upstream binutils-gdb.git repository, but some of these
+@@ -730,7 +734,7 @@ def HostTools(host, options):
'--without-gas'
- ]),
+ ])] + DummyDirCommands(binutils_dummy_dirs) + [
command.Command(MakeCommand(host)),
- command.Command(MAKE_DESTDIR_CMD + ['install-strip'])] +
+ command.Command(MAKE_DESTDIR_CMD + [install_step])] +
[command.RemoveDirectory(os.path.join('%(output)s', dir))
for dir in ('lib', 'lib32')] +
# Since it has dual use, just create links for both sets of names
-@@ -624,7 +629,8 @@ def HostTools(host, options):
- # TODO(jfb) Windows currently uses MinGW's GCC 4.8.1 which generates warnings
- # on upstream LLVM code. Turn on -Werror once these are fixed.
- # The same applies for the default GCC on current Ubuntu.
-- llvm_do_werror = not (TripleIsWindows(host) or options.gcc)
-+ llvm_do_werror = not (TripleIsWindows(host) or options.gcc or
-+ host == 'le32-nacl')
-
- llvm_cmake = {
- H('llvm'): {
+@@ -1033,6 +1037,9 @@ def HostToolsDirectToNacl(host, options):
+ binutils_flags, binutils_inputs, binutils_deps = ConfigureBinutilsCommon(
+ host, options, False)
+ redirect_inputs.update(binutils_inputs)
++ install_step = 'install-strip'
++ if host == 'le32-nacl':
++ install_step = 'install'
+ tools.update({
+ H('binutils_x86'): {
+ 'type': 'build',
+@@ -1049,7 +1056,7 @@ def HostToolsDirectToNacl(host, options):
+ '--enable-targets=x86_64-nacl,i686-nacl',
+ '--disable-werror']),
+ command.Command(MakeCommand(host)),
+- command.Command(MAKE_DESTDIR_CMD + ['install-strip'])] +
++ command.Command(MAKE_DESTDIR_CMD + [install_step])] +
+ # Remove the share dir from this binutils build and leave the one
+ # from the newer version used for bitcode linking. Always remove
+ # the lib dirs, which have unneeded host libs.
+@@ -1311,7 +1318,7 @@ def main():
+ packages.update(HostTools(host, args))
+ if not args.pnacl_in_pnacl:
+ packages.update(HostLibs(host, args))
+- packages.update(HostToolsDirectToNacl(host, args))
++ packages.update(HostToolsDirectToNacl(host, args))
+ if not args.pnacl_in_pnacl:
+ packages.update(TargetLibCompiler(pynacl.platform.PlatformTriple(), args))
+ # Don't build the target libs on Windows because of pathname issues.
diff --git a/ports/pnacl/pkg_info b/ports/pnacl/pkg_info
index e05e9e6..54b0b62 100644
--- a/ports/pnacl/pkg_info
+++ b/ports/pnacl/pkg_info
@@ -1,9 +1,9 @@
NAME=pnacl
VERSION=0.0.1
ARCHIVE_ROOT=native_client
-URL=https://chromium.googlesource.com/native_client/src/native_client.git@6863b50a1f88905e31e69c1e1787f5656502f1ad
+URL=https://chromium.googlesource.com/native_client/src/native_client.git@642939f
LICENSE=BSD
-DEPENDS=(glibc-compat nacl-spawn pnacl-clang-src pnacl-binutils-src pnacl-llvm-src)
+DEPENDS=(glibc-compat nacl-spawn pnacl-clang-src pnacl-binutils-src pnacl-llvm-src pnacl-binutils-x86-src)
# x86 glibc toolchain is too old to build clang
# arm glibc fails with unrecognized command line option ‘-stdlib=libc++’
DISABLED_TOOLCHAIN=(glibc emscripten)