Revision: 14299
Author:   [email protected]
Date:     Wed Apr 17 01:27:40 2013
Log:      Enable Native Client build of V8.

These changes implement make targets nacl_ia32.check, nacl_x64.check,
and related debug/release targets.

BUG=2614

Review URL: https://codereview.chromium.org/13841011

Patch from Brad Chen <[email protected]>.
http://code.google.com/p/v8/source/detail?r=14299

Modified:
 /branches/bleeding_edge/Makefile
 /branches/bleeding_edge/build/common.gypi
 /branches/bleeding_edge/src/globals.h

=======================================
--- /branches/bleeding_edge/Makefile    Tue Apr 16 08:36:11 2013
+++ /branches/bleeding_edge/Makefile    Wed Apr 17 01:27:40 2013
@@ -36,6 +36,7 @@
 ANDROID_NDK_ROOT ?=
 ANDROID_TOOLCHAIN ?=
 ANDROID_V8 ?= /data/local/v8
+NACL_SDK_ROOT ?=

 # Special build flags. Use them like this: "make library=shared"

@@ -185,6 +186,7 @@
 # - "native": current host's architecture, release mode
 # - any of the above with .check appended, e.g. "ia32.release.check"
 # - "android": cross-compile for Android/ARM
+# - "nacl" : cross-compile for Native Client (ia32 and x64)
 # - default (no target specified): build all DEFAULT_ARCHES and MODES
 # - "check": build all targets and run all tests
 # - "<arch>.clean" for any <arch> in ARCHES
@@ -198,6 +200,7 @@
 DEFAULT_ARCHES = ia32 x64 arm
 MODES = release debug
 ANDROID_ARCHES = android_ia32 android_arm android_mipsel
+NACL_ARCHES = nacl_ia32 nacl_x64

 # List of files that trigger Makefile regeneration:
 GYPFILES = build/all.gyp build/common.gypi build/standalone.gypi \
@@ -212,9 +215,12 @@
 BUILDS = $(foreach mode,$(MODES),$(addsuffix .$(mode),$(ARCHES)))
 ANDROID_BUILDS = $(foreach mode,$(MODES), \
                    $(addsuffix .$(mode),$(ANDROID_ARCHES)))
+NACL_BUILDS = $(foreach mode,$(MODES), \
+                   $(addsuffix .$(mode),$(NACL_ARCHES)))
 # Generates corresponding test targets, e.g. "ia32.release.check".
 CHECKS = $(addsuffix .check,$(BUILDS))
 ANDROID_CHECKS = $(addsuffix .check,$(ANDROID_BUILDS))
+NACL_CHECKS = $(addsuffix .check,$(NACL_BUILDS))
 # File where previously used GYPFLAGS are stored.
 ENVFILE = $(OUTDIR)/environment

@@ -222,7 +228,9 @@
$(ARCHES) $(MODES) $(BUILDS) $(CHECKS) $(addsuffix .clean,$(ARCHES)) \
         $(addsuffix .check,$(MODES)) $(addsuffix .check,$(ARCHES)) \
         $(ANDROID_ARCHES) $(ANDROID_BUILDS) $(ANDROID_CHECKS) \
-        must-set-ANDROID_NDK_ROOT_OR_TOOLCHAIN
+        must-set-ANDROID_NDK_ROOT_OR_TOOLCHAIN \
+        $(NACL_ARCHES) $(NACL_BUILDS) $(NACL_CHECKS) \
+        must-set-NACL_SDK_ROOT

 # Target definitions. "all" is the default.
 all: $(MODES)
@@ -266,6 +274,16 @@
                OUTDIR="$(OUTDIR)" \
                GYPFLAGS="$(GYPFLAGS)"

+$(NACL_ARCHES): $(addprefix $$@.,$(MODES))
+
+$(NACL_BUILDS): $(GYPFILES) $(ENVFILE) \
+                  Makefile.nacl must-set-NACL_SDK_ROOT
+       @$(MAKE) -f Makefile.nacl $@ \
+               ARCH="$(basename $@)" \
+               MODE="$(subst .,,$(suffix $@))" \
+               OUTDIR="$(OUTDIR)" \
+               GYPFLAGS="$(GYPFLAGS)"
+
 # Test targets.
 check: all
        @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
@@ -297,12 +315,21 @@
 $(addsuffix .check, $(ANDROID_ARCHES)): \
                 $(addprefix $$(basename $$@).,$(MODES)).check

+$(addsuffix .check, $(NACL_BUILDS)): $$(basename $$@)
+       @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
+            --arch-and-mode=$(basename $@) \
+            --timeout=600 --nopresubmit \
+            --command-prefix="tools/nacl-run.py"
+
+$(addsuffix .check, $(NACL_ARCHES)): \
+                $(addprefix $$(basename $$@).,$(MODES)).check
+
 native.check: native
        @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR)/native \
            --arch-and-mode=. $(TESTFLAGS)

# Clean targets. You can clean each architecture individually, or everything.
-$(addsuffix .clean, $(ARCHES) $(ANDROID_ARCHES)):
+$(addsuffix .clean, $(ARCHES) $(ANDROID_ARCHES) $(NACL_ARCHES)):
        rm -f $(OUTDIR)/Makefile.$(basename $@)
        rm -rf $(OUTDIR)/$(basename $@).release
        rm -rf $(OUTDIR)/$(basename $@).debug
@@ -313,7 +340,7 @@
        rm -rf $(OUTDIR)/native
        find $(OUTDIR) -regex '.*\(host\|target\).native\.mk' -delete

-clean: $(addsuffix .clean, $(ARCHES) $(ANDROID_ARCHES)) native.clean
+clean: $(addsuffix .clean, $(ARCHES) $(ANDROID_ARCHES) $(NACL_ARCHES)) native.clean

 # GYP file generation targets.
 OUT_MAKEFILES = $(addprefix $(OUTDIR)/Makefile.,$(ARCHES))
@@ -334,6 +361,18 @@
 ifndef ANDROID_TOOLCHAIN
          $(error ANDROID_NDK_ROOT or ANDROID_TOOLCHAIN must be set))
 endif
+endif
+
+# Note that NACL_SDK_ROOT must be set to point to an appropriate
+# Native Client SDK before using this makefile. You can download
+# an SDK here:
+#   https://developers.google.com/native-client/sdk/download
+# The path indicated by NACL_SDK_ROOT will typically end with
+# a folder for a pepper version such as "pepper_25" that should
+# have "tools" and "toolchain" subdirectories.
+must-set-NACL_SDK_ROOT:
+ifndef NACL_SDK_ROOT
+         $(error NACL_SDK_ROOT must be set)
 endif

# Replaces the old with the new environment file if they're different, which
=======================================
--- /branches/bleeding_edge/build/common.gypi   Tue Apr 16 08:17:27 2013
+++ /branches/bleeding_edge/build/common.gypi   Wed Apr 17 01:27:40 2013
@@ -35,6 +35,13 @@
     'CXX%': '${CXX:-$(which g++)}',  # Used to assemble a shell command.
     'v8_compress_startup_data%': 'off',
     'v8_target_arch%': '<(target_arch)',
+    # Native Client builds currently use the V8 ARM JIT and
+    # arm/simulator-arm.cc to defer the significant effort required
+    # for NaCl JIT support. The nacl_target_arch variable provides
+    # the 'true' target arch for places in this file that need it.
+    # TODO(bradchen): get rid of nacl_target_arch when someday
+    # NaCl V8 builds stop using the ARM simulator
+    'nacl_target_arch%': 'none',     # must be set externally

     # Setting 'v8_can_use_unaligned_accesses' to 'true' will allow the code
# generated by V8 to do unaligned memory access, and setting it to 'false'
@@ -357,7 +364,8 @@
               'clang%': 0,
             },
             'conditions': [
-              ['OS!="android" or clang==1', {
+              ['(OS!="android" or clang==1) and \
+                nacl_target_arch!="nacl_x64"', {
                 'cflags': [ '<(m32flag)' ],
                 'ldflags': [ '<(m32flag)' ],
               }],
=======================================
--- /branches/bleeding_edge/src/globals.h       Wed Jan  9 02:30:54 2013
+++ /branches/bleeding_edge/src/globals.h       Wed Apr 17 01:27:40 2013
@@ -67,9 +67,21 @@
 //   http://www.agner.org/optimize/calling_conventions.pdf
 //   or with gcc, run: "echo | gcc -E -dM -"
 #if defined(_M_X64) || defined(__x86_64__)
+#if defined(__native_client__)
+// For Native Client builds of V8, use V8_TARGET_ARCH_ARM, so that V8
+// generates ARM machine code, together with a portable ARM simulator
+// compiled for the host architecture in question.
+//
+// Since Native Client is ILP-32 on all architectures we use
+// V8_HOST_ARCH_IA32 on both 32- and 64-bit x86.
+#define V8_HOST_ARCH_IA32 1
+#define V8_HOST_ARCH_32_BIT 1
+#define V8_HOST_CAN_READ_UNALIGNED 1
+#else
 #define V8_HOST_ARCH_X64 1
 #define V8_HOST_ARCH_64_BIT 1
 #define V8_HOST_CAN_READ_UNALIGNED 1
+#endif  // __native_client__
 #elif defined(_M_IX86) || defined(__i386__)
 #define V8_HOST_ARCH_IA32 1
 #define V8_HOST_ARCH_32_BIT 1

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to