blob: 158c46379e6116abfac40b1b407bba05e4cdb0d1 [file] [log] [blame]
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -913,7 +913,7 @@ BUILD_LIBDEPS= $(BUILD_LIBIBERTY)
# How to link with both our special library facilities
# and the system's installed libraries.
-LIBS = @LIBS@ $(CPPLIB) $(LIBINTL) $(LIBICONV) $(LIBIBERTY) $(LIBDECNUMBER)
+LIBS = @LIBS@ $(CPPLIB) $(LIBINTL) $(LIBICONV) $(LIBIBERTY) $(LIBDECNUMBER) $(EXTRA_LIBS)
BACKENDLIBS = $(CLOOGLIBS) $(PPLLIBS) $(GMPLIBS)
# Any system libraries needed just for GNAT.
SYSLIBS = @GNAT_LIBEXC@
@@ -3654,6 +3654,11 @@ s-fixinc_list : $(GCC_PASSES)
else \
echo ";"; \
fi > tmp-fixinc_list
+# It seems GCC tries to fix the host system include files as we are
+# using same values (x86_64-nacl) for --host and --target. There seems
+# to be no way to skip this step by adjusting ./configure flags. We
+# disable this step by providing empty fixinc targets.
+ echo > tmp-fixinc_list
$(SHELL) $(srcdir)/../move-if-change tmp-fixinc_list fixinc_list
$(STAMP) s-fixinc_list
diff --git a/gcc/collect2.c b/gcc/collect2.c
--- a/gcc/collect2.c
+++ b/gcc/collect2.c
@@ -47,6 +47,14 @@ along with GCC; see the file COPYING3. If not see
#include "intl.h"
#include "version.h"
+#if defined(__native_client__) && defined(CROSS_DIRECTORY_STRUCTURE)
+/* ./configure of GCC thinks we should find i686-nacl-ld instead of
+ ld on i686 because --target is different from --host. As we always
+ use plain "ld", we undefine the macro which indicates we are
+ cross-compiling. */
+#undef CROSS_DIRECTORY_STRUCTURE
+#endif
+
/* On certain systems, we have code that works by scanning the object file
directly. But this code uses system-specific header files and library
functions, so turn it off in a cross-compiler. Likewise, the names of
diff --git a/gcc/config/i386/cpuid.h b/gcc/config/i386/cpuid.h
--- a/gcc/config/i386/cpuid.h
+++ b/gcc/config/i386/cpuid.h
@@ -110,6 +110,10 @@
static __inline unsigned int
__get_cpuid_max (unsigned int __ext, unsigned int *__sig)
{
+ /* NaCl verifier does not allow cpuid. */
+#if defined(__native_client__)
+ return 0;
+#else
unsigned int __eax, __ebx, __ecx, __edx;
#ifndef __x86_64__
@@ -155,6 +159,7 @@ __get_cpuid_max (unsigned int __ext, unsigned int *__sig)
*__sig = __ebx;
return __eax;
+#endif
}
/* Return cpuid data for requested cpuid level, as found in returned
diff --git a/libiberty/pex-unix.c b/libiberty/pex-unix.c
--- a/libiberty/pex-unix.c
+++ b/libiberty/pex-unix.c
@@ -56,6 +56,16 @@ extern int errno;
#include <sys/stat.h>
#endif
+/*
+ * Declared inline rather than by including spawn.h because this portion
+ * of the build may build for x86-64 without nacl-spawn having been built for
+ * that architecture (ie when building for i686).
+ */
+#if defined(__native_client__)
+#define P_NOWAIT 1
+extern int spawnve(int mode, const char* path,
+ char *const argv[], char *const envp[]);
+#endif
#ifdef vfork /* Autoconf may define this to fork for us. */
# define VFORK_STRING "fork"
@@ -361,6 +371,12 @@ pex_unix_exec_child (struct pex_obj *obj, int flags, const char *executable,
int in, int out, int errdes,
int toclose, const char **errmsg, int *err)
{
+ /* Use spawnve to spawn a child process.
+ TODO(hamaji): Add support of pipes to nacl-spawn and handle
+ arguments for file descriptors to support -pipe option. */
+#if defined(__native_client__)
+ return spawnve(P_NOWAIT, argv[0], argv, NULL);
+#else
pid_t pid;
/* We declare these to be volatile to avoid warnings from gcc about
@@ -469,6 +485,7 @@ pex_unix_exec_child (struct pex_obj *obj, int flags, const char *executable,
return pid;
}
+#endif
}
/* Wait for a child process to complete. */
@@ -478,6 +495,15 @@ pex_unix_wait (struct pex_obj *obj, pid_t pid, int *status,
struct pex_time *time, int done, const char **errmsg,
int *err)
{
+#if defined(__native_client__)
+ if (waitpid(pid, status, 0) < 0)
+ {
+ *err = errno;
+ *errmsg = "wait";
+ return -1;
+ }
+ return 0;
+#else
/* If we are cleaning up when the caller didn't retrieve process
status for some reason, encourage the process to go away. */
if (done)
@@ -491,6 +517,7 @@ pex_unix_wait (struct pex_obj *obj, pid_t pid, int *status,
}
return 0;
+#endif
}
/* Create a pipe. */