summaryrefslogtreecommitdiffstats
path: root/native_client_sdk
diff options
context:
space:
mode:
authorsbc@chromium.org <sbc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-18 17:26:18 +0000
committersbc@chromium.org <sbc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-18 17:26:18 +0000
commit9f4a33d48f6916c7190b1de572a3fc857f684394 (patch)
treec2af0b8aef53778b9e172074a7488bf290ab3a6b /native_client_sdk
parentc0fdf8af4d44f65b90561db2630034575463383e (diff)
downloadchromium_src-9f4a33d48f6916c7190b1de572a3fc857f684394.zip
chromium_src-9f4a33d48f6916c7190b1de572a3fc857f684394.tar.gz
chromium_src-9f4a33d48f6916c7190b1de572a3fc857f684394.tar.bz2
[NaCl SDK] Enable linux host build for nacl_io and nacl_io_tests.
The process of doing this already found one serious bug in lseek and will enable us to find many more via asan and other sanitisers which run on the linux host envionment. R=binji@chromium.org, binji Review URL: https://codereview.chromium.org/73083005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@235753 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'native_client_sdk')
-rw-r--r--native_client_sdk/src/build_tools/sdk_files.list4
-rwxr-xr-xnative_client_sdk/src/build_tools/verify_filelist.py11
-rw-r--r--native_client_sdk/src/libraries/nacl_io/event_emitter.cc8
-rw-r--r--native_client_sdk/src/libraries/nacl_io/event_listener.cc33
-rw-r--r--native_client_sdk/src/libraries/nacl_io/fifo_interface.h4
-rw-r--r--native_client_sdk/src/libraries/nacl_io/fifo_null.h4
-rw-r--r--native_client_sdk/src/libraries/nacl_io/kernel_handle.cc8
-rw-r--r--native_client_sdk/src/libraries/nacl_io/kernel_wrap.h1
-rw-r--r--native_client_sdk/src/libraries/nacl_io/kernel_wrap_dummy.cc81
-rw-r--r--native_client_sdk/src/libraries/nacl_io/kernel_wrap_glibc.cc6
-rw-r--r--native_client_sdk/src/libraries/nacl_io/kernel_wrap_newlib.cc6
-rw-r--r--native_client_sdk/src/libraries/nacl_io/kernel_wrap_win.cc68
-rw-r--r--native_client_sdk/src/libraries/nacl_io/library.dsc3
-rw-r--r--native_client_sdk/src/libraries/nacl_io/mount_dev.cc5
-rw-r--r--native_client_sdk/src/libraries/nacl_io/mount_node_http.cc6
-rw-r--r--native_client_sdk/src/libraries/nacl_io/mount_node_mem.cc4
-rw-r--r--native_client_sdk/src/libraries/nacl_io/mount_node_tty.cc3
-rw-r--r--native_client_sdk/src/libraries/nacl_io/osinttypes.h4
-rw-r--r--native_client_sdk/src/libraries/nacl_io/ossignal.h4
-rw-r--r--native_client_sdk/src/libraries/nacl_io/ossocket.h2
-rw-r--r--native_client_sdk/src/libraries/nacl_io/ostermios.h11
-rw-r--r--native_client_sdk/src/libraries/ppapi_simple/library.dsc2
-rw-r--r--native_client_sdk/src/tests/nacl_io_test/example.dsc2
-rw-r--r--native_client_sdk/src/tests/nacl_io_test/kernel_proxy_test.cc30
-rw-r--r--native_client_sdk/src/tests/nacl_io_test/kernel_wrap_test.cc6
-rw-r--r--native_client_sdk/src/tests/nacl_io_test/mount_html5fs_test.cc4
-rw-r--r--native_client_sdk/src/tests/nacl_io_test/mount_node_tty_test.cc42
-rw-r--r--native_client_sdk/src/tools/common.mk66
-rw-r--r--native_client_sdk/src/tools/host_gcc.mk21
-rw-r--r--native_client_sdk/src/tools/nacl_gcc.mk14
30 files changed, 266 insertions, 197 deletions
diff --git a/native_client_sdk/src/build_tools/sdk_files.list b/native_client_sdk/src/build_tools/sdk_files.list
index 73cd38a..f585170 100644
--- a/native_client_sdk/src/build_tools/sdk_files.list
+++ b/native_client_sdk/src/build_tools/sdk_files.list
@@ -89,17 +89,21 @@ include/win/sys/poll.h
[linux]lib/${PLATFORM}_host/Debug/libgmock.a
[linux]lib/${PLATFORM}_host/Debug/libgtest.a
[linux]lib/${PLATFORM}_host/Debug/libjsoncpp.a
+[linux]lib/${PLATFORM}_host/Debug/libnacl_io.a
[linux,mac]lib/${PLATFORM}_host/Debug/libppapi.a
[linux]lib/${PLATFORM}_host/Debug/libppapi_cpp.a
[linux]lib/${PLATFORM}_host/Debug/libppapi_cpp_private.a
[linux]lib/${PLATFORM}_host/Debug/libppapi_gles2.a
+[linux]lib/${PLATFORM}_host/Debug/libppapi_simple.a
[linux]lib/${PLATFORM}_host/Release/libgmock.a
[linux]lib/${PLATFORM}_host/Release/libgtest.a
[linux]lib/${PLATFORM}_host/Release/libjsoncpp.a
+[linux]lib/${PLATFORM}_host/Release/libnacl_io.a
[linux,mac]lib/${PLATFORM}_host/Release/libppapi.a
[linux]lib/${PLATFORM}_host/Release/libppapi_cpp.a
[linux]lib/${PLATFORM}_host/Release/libppapi_cpp_private.a
[linux]lib/${PLATFORM}_host/Release/libppapi_gles2.a
+[linux]lib/${PLATFORM}_host/Release/libppapi_simple.a
[win]lib/${PLATFORM}_x86_32_host/Debug/gmock.lib
[win]lib/${PLATFORM}_x86_32_host/Debug/gtest.lib
[win]lib/${PLATFORM}_x86_32_host/Debug/jsoncpp.lib
diff --git a/native_client_sdk/src/build_tools/verify_filelist.py b/native_client_sdk/src/build_tools/verify_filelist.py
index e6ccbb0..02e3491 100755
--- a/native_client_sdk/src/build_tools/verify_filelist.py
+++ b/native_client_sdk/src/build_tools/verify_filelist.py
@@ -8,7 +8,8 @@ import os
import re
import sys
-from build_paths import SDK_SRC_DIR
+import build_version
+from build_paths import SDK_SRC_DIR, SCRIPT_DIR, OUT_DIR
# Add SDK make tools scripts to the python path.
sys.path.append(os.path.join(SDK_SRC_DIR, 'tools'))
@@ -188,14 +189,18 @@ def main(args):
help='Sort the file list in place, rather than verifying the contents.')
options, args = parser.parse_args(args)
+ if not args:
+ args = [os.path.join(SCRIPT_DIR, 'sdk_files.list')]
+
if options.sort:
if not args:
parser.error('Expected rule file.')
SortFile(args[0])
return 0
- if len(args) != 2:
- parser.error('Expected rule file and directory.')
+ if len(args) < 2:
+ version = build_version.ChromeMajorVersion()
+ args.append(os.path.join(OUT_DIR, 'pepper_%s' % version))
rule_path, directory_path = args
if options.platform:
diff --git a/native_client_sdk/src/libraries/nacl_io/event_emitter.cc b/native_client_sdk/src/libraries/nacl_io/event_emitter.cc
index b3db06f..a135971 100644
--- a/native_client_sdk/src/libraries/nacl_io/event_emitter.cc
+++ b/native_client_sdk/src/libraries/nacl_io/event_emitter.cc
@@ -1,7 +1,7 @@
-/* Copyright (c) 2013 The Chromium Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
#include <assert.h>
#include <poll.h>
diff --git a/native_client_sdk/src/libraries/nacl_io/event_listener.cc b/native_client_sdk/src/libraries/nacl_io/event_listener.cc
index 8ad13bd..ea87128 100644
--- a/native_client_sdk/src/libraries/nacl_io/event_listener.cc
+++ b/native_client_sdk/src/libraries/nacl_io/event_listener.cc
@@ -1,21 +1,46 @@
-/* Copyright (c) 2013 The Chromium Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
#include <errno.h>
#include <poll.h>
#include <pthread.h>
#include <stdio.h>
+#include <sys/time.h>
#include "nacl_io/error.h"
#include "nacl_io/event_listener.h"
#include "nacl_io/kernel_wrap.h"
#include "nacl_io/osstat.h"
+#include "nacl_io/ostime.h"
#include "nacl_io/osunistd.h"
#include "sdk_util/auto_lock.h"
+#if defined(WIN32)
+
+#define USECS_FROM_WIN_TO_TO_UNIX_EPOCH 11644473600000LL
+static uint64_t usec_since_epoch() {
+ FILETIME ft;
+ ULARGE_INTEGER ularge;
+ GetSystemTimeAsFileTime(&ft);
+
+ ularge.LowPart = ft.dwLowDateTime;
+ ularge.HighPart = ft.dwHighDateTime;
+
+ // Truncate to usec resolution.
+ return ularge.QuadPart / 10;
+}
+
+#else
+
+static uint64_t usec_since_epoch() {
+ struct timeval tv;
+ gettimeofday(&tv, NULL);
+ return tv.tv_usec + (tv.tv_sec * 1000000);
+}
+
+#endif
namespace nacl_io {
diff --git a/native_client_sdk/src/libraries/nacl_io/fifo_interface.h b/native_client_sdk/src/libraries/nacl_io/fifo_interface.h
index 46d4e82..38f53d1 100644
--- a/native_client_sdk/src/libraries/nacl_io/fifo_interface.h
+++ b/native_client_sdk/src/libraries/nacl_io/fifo_interface.h
@@ -23,8 +23,8 @@ class FIFOInterface {
virtual bool IsFull() = 0;
virtual bool Resize(size_t len) = 0;
- virtual uint32_t ReadAvailable() = 0;
- virtual uint32_t WriteAvailable() = 0;
+ virtual size_t ReadAvailable() = 0;
+ virtual size_t WriteAvailable() = 0;
};
} // namespace nacl_io
diff --git a/native_client_sdk/src/libraries/nacl_io/fifo_null.h b/native_client_sdk/src/libraries/nacl_io/fifo_null.h
index 88bdbe5..5047cb2 100644
--- a/native_client_sdk/src/libraries/nacl_io/fifo_null.h
+++ b/native_client_sdk/src/libraries/nacl_io/fifo_null.h
@@ -20,8 +20,8 @@ class FIFONull : public FIFOInterface {
virtual bool IsFull() { return false; }
virtual bool Resize(size_t) { return false; }
- virtual uint32_t ReadAvailable() { return 1; }
- virtual uint32_t WriteAvailable() { return 1; }
+ virtual size_t ReadAvailable() { return 1; }
+ virtual size_t WriteAvailable() { return 1; }
};
} // namespace nacl_io
diff --git a/native_client_sdk/src/libraries/nacl_io/kernel_handle.cc b/native_client_sdk/src/libraries/nacl_io/kernel_handle.cc
index 1eaa88e..5736a3a 100644
--- a/native_client_sdk/src/libraries/nacl_io/kernel_handle.cc
+++ b/native_client_sdk/src/libraries/nacl_io/kernel_handle.cc
@@ -55,7 +55,7 @@ Error KernelHandle::Init(int open_flags) {
Error KernelHandle::Seek(off_t offset, int whence, off_t* out_offset) {
// By default, don't move the offset.
*out_offset = offset;
- size_t base;
+ ssize_t base;
size_t node_size;
AUTO_LOCK(handle_lock_);
@@ -64,8 +64,6 @@ Error KernelHandle::Seek(off_t offset, int whence, off_t* out_offset) {
return error;
switch (whence) {
- default:
- return -1;
case SEEK_SET:
base = 0;
break;
@@ -75,12 +73,14 @@ Error KernelHandle::Seek(off_t offset, int whence, off_t* out_offset) {
case SEEK_END:
base = node_size;
break;
+ default:
+ return -1;
}
if (base + offset < 0)
return EINVAL;
- off_t new_offset = base + offset;
+ size_t new_offset = base + offset;
// Seeking past the end of the file will zero out the space between the old
// end and the new end.
diff --git a/native_client_sdk/src/libraries/nacl_io/kernel_wrap.h b/native_client_sdk/src/libraries/nacl_io/kernel_wrap.h
index 1067ecb..39eb863 100644
--- a/native_client_sdk/src/libraries/nacl_io/kernel_wrap.h
+++ b/native_client_sdk/src/libraries/nacl_io/kernel_wrap.h
@@ -96,7 +96,6 @@ int stat(const char* path, struct stat* buf) NOTHROW;
int symlink(const char* oldpath, const char* newpath) NOTHROW;
int umount(const char* path) NOTHROW;
int NAME(unlink)(const char* path) NOTHROW;
-uint64_t usec_since_epoch();
int utime(const char* filename, const struct utimbuf* times);
read_ssize_t NAME(write)(int fd, const void* buf, size_t nbyte);
diff --git a/native_client_sdk/src/libraries/nacl_io/kernel_wrap_dummy.cc b/native_client_sdk/src/libraries/nacl_io/kernel_wrap_dummy.cc
new file mode 100644
index 0000000..44ce8f6
--- /dev/null
+++ b/native_client_sdk/src/libraries/nacl_io/kernel_wrap_dummy.cc
@@ -0,0 +1,81 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#if defined(WIN32) || defined(__linux__)
+
+#include <errno.h>
+
+#include "nacl_io/kernel_wrap.h"
+#include "nacl_io/kernel_wrap_real.h"
+
+// "real" functions, i.e. the unwrapped original functions. For Windows/Linux
+// host builds we don't wrap, so the real functions aren't accessible. In most
+// cases, we just fail.
+
+int _real_close(int fd) {
+ return ENOSYS;
+}
+
+int _real_fstat(int fd, struct stat *buf) {
+ return 0;
+}
+
+int _real_getdents(int fd, void* nacl_buf, size_t nacl_count, size_t *nread) {
+ return ENOSYS;
+}
+
+int _real_lseek(int fd, off_t offset, int whence, off_t* new_offset) {
+ return ENOSYS;
+}
+
+int _real_mkdir(const char* pathname, mode_t mode) {
+ return ENOSYS;
+}
+
+int _real_mmap(void** addr, size_t length, int prot, int flags, int fd,
+ off_t offset) {
+ return ENOSYS;
+}
+
+int _real_munmap(void* addr, size_t length) {
+ return ENOSYS;
+}
+
+int _real_open(const char* pathname, int oflag, mode_t cmode, int* newfd) {
+ return ENOSYS;
+}
+
+int _real_open_resource(const char* file, int* fd) {
+ return ENOSYS;
+}
+
+int _real_read(int fd, void *buf, size_t count, size_t *nread) {
+ *nread = count;
+ return 0;
+}
+
+int _real_rmdir(const char* pathname) {
+ return ENOSYS;
+}
+
+int _real_write(int fd, const void *buf, size_t count, size_t *nwrote) {
+ int rtn = write(fd, buf, count);
+ if (rtn < 0)
+ return -1;
+
+ *nwrote = rtn;
+ return 0;
+}
+
+#endif
+
+#if defined(__linux__)
+
+void kernel_wrap_init() {
+}
+
+void kernel_wrap_uninit() {
+}
+
+#endif
diff --git a/native_client_sdk/src/libraries/nacl_io/kernel_wrap_glibc.cc b/native_client_sdk/src/libraries/nacl_io/kernel_wrap_glibc.cc
index 8c270b1..fc3eb54 100644
--- a/native_client_sdk/src/libraries/nacl_io/kernel_wrap_glibc.cc
+++ b/native_client_sdk/src/libraries/nacl_io/kernel_wrap_glibc.cc
@@ -388,12 +388,6 @@ int _real_write(int fd, const void *buf, size_t count, size_t *nwrote) {
return REAL(write)(fd, buf, count, nwrote);
}
-uint64_t usec_since_epoch() {
- struct timeval tv;
- gettimeofday(&tv, NULL);
- return tv.tv_usec + (tv.tv_sec * 1000000);
-}
-
static bool s_wrapped = false;
void kernel_wrap_init() {
if (!s_wrapped) {
diff --git a/native_client_sdk/src/libraries/nacl_io/kernel_wrap_newlib.cc b/native_client_sdk/src/libraries/nacl_io/kernel_wrap_newlib.cc
index be1d759..0809866 100644
--- a/native_client_sdk/src/libraries/nacl_io/kernel_wrap_newlib.cc
+++ b/native_client_sdk/src/libraries/nacl_io/kernel_wrap_newlib.cc
@@ -314,12 +314,6 @@ int _real_write(int fd, const void* buf, size_t count, size_t* nwrote) {
return REAL(write)(fd, buf, count, nwrote);
}
-uint64_t usec_since_epoch() {
- struct timeval tv;
- gettimeofday(&tv, NULL);
- return tv.tv_usec + (tv.tv_sec * 1000000);
-}
-
static bool s_wrapped = false;
void kernel_wrap_init() {
diff --git a/native_client_sdk/src/libraries/nacl_io/kernel_wrap_win.cc b/native_client_sdk/src/libraries/nacl_io/kernel_wrap_win.cc
index c5dcc02..cf35f96 100644
--- a/native_client_sdk/src/libraries/nacl_io/kernel_wrap_win.cc
+++ b/native_client_sdk/src/libraries/nacl_io/kernel_wrap_win.cc
@@ -215,74 +215,6 @@ int _write(int fd, const void* buf, size_t nbyte) {
return ki_write(fd, buf, nbyte);
}
-
-// "real" functions, i.e. the unwrapped original functions. On Windows we don't
-// wrap, so the real functions aren't accessible. In most cases, we just fail.
-
-int _real_close(int fd) {
- return ENOSYS;
-}
-
-int _real_fstat(int fd, struct stat *buf) {
- return 0;
-}
-
-int _real_getdents(int fd, void* nacl_buf, size_t nacl_count, size_t *nread) {
- return ENOSYS;
-}
-
-int _real_lseek(int fd, off_t offset, int whence, off_t* new_offset) {
- return ENOSYS;
-}
-
-int _real_mkdir(const char* pathname, mode_t mode) {
- return ENOSYS;
-}
-
-int _real_mmap(void** addr, size_t length, int prot, int flags, int fd,
- off_t offset) {
- return ENOSYS;
-}
-
-int _real_munmap(void* addr, size_t length) {
- return ENOSYS;
-}
-
-int _real_open(const char* pathname, int oflag, mode_t cmode, int* newfd) {
- return ENOSYS;
-}
-
-int _real_open_resource(const char* file, int* fd) {
- return ENOSYS;
-}
-
-int _real_read(int fd, void *buf, size_t count, size_t *nread) {
- *nread = count;
- return 0;
-}
-
-int _real_rmdir(const char* pathname) {
- return ENOSYS;
-}
-
-int _real_write(int fd, const void *buf, size_t count, size_t *nwrote) {
- *nwrote = count;
- return 0;
-}
-
-#define USECS_FROM_WIN_TO_TO_UNIX_EPOCH 11644473600000LL
-uint64_t usec_since_epoch() {
- FILETIME ft;
- ULARGE_INTEGER ularge;
- GetSystemTimeAsFileTime(&ft);
-
- ularge.LowPart = ft.dwLowDateTime;
- ularge.HighPart = ft.dwHighDateTime;
-
- // Truncate to usec resolution.
- return ularge.QuadPart / 10;
-}
-
// Do nothing for Windows, we replace the library at link time.
void kernel_wrap_init() {
}
diff --git a/native_client_sdk/src/libraries/nacl_io/library.dsc b/native_client_sdk/src/libraries/nacl_io/library.dsc
index 0c2e0ac..5f4645c 100644
--- a/native_client_sdk/src/libraries/nacl_io/library.dsc
+++ b/native_client_sdk/src/libraries/nacl_io/library.dsc
@@ -1,5 +1,5 @@
{
- 'TOOLS': ['newlib', 'glibc', 'pnacl'],
+ 'TOOLS': ['newlib', 'glibc', 'pnacl', 'linux'],
'SEARCH': [
'.',
'pepper',
@@ -27,6 +27,7 @@
"kernel_intercept.cc",
"kernel_object.cc",
"kernel_proxy.cc",
+ "kernel_wrap_dummy.cc",
"kernel_wrap_glibc.cc",
"kernel_wrap_newlib.cc",
"kernel_wrap_win.cc",
diff --git a/native_client_sdk/src/libraries/nacl_io/mount_dev.cc b/native_client_sdk/src/libraries/nacl_io/mount_dev.cc
index 14acb6d..8fee68a 100644
--- a/native_client_sdk/src/libraries/nacl_io/mount_dev.cc
+++ b/native_client_sdk/src/libraries/nacl_io/mount_dev.cc
@@ -228,9 +228,6 @@ Error UrandomNode::Read(const HandleAttr& attr,
int error = (*random_interface_.get_random_bytes)(buf, count, &nread);
if (error)
return error;
-
- *out_bytes = count;
- return 0;
#elif defined(WIN32)
char* out = static_cast<char*>(buf);
size_t bytes_left = count;
@@ -247,10 +244,10 @@ Error UrandomNode::Read(const HandleAttr& attr,
out += bytes_to_copy;
bytes_left -= bytes_to_copy;
}
+#endif
*out_bytes = count;
return 0;
-#endif
}
Error UrandomNode::Write(const HandleAttr& attr,
diff --git a/native_client_sdk/src/libraries/nacl_io/mount_node_http.cc b/native_client_sdk/src/libraries/nacl_io/mount_node_http.cc
index d6355ad..5a65d41 100644
--- a/native_client_sdk/src/libraries/nacl_io/mount_node_http.cc
+++ b/native_client_sdk/src/libraries/nacl_io/mount_node_http.cc
@@ -101,9 +101,9 @@ bool ParseContentRange(const StringMap_t& headers,
// The key should look like "bytes ##-##/##" or "bytes ##-##/*". The last
// value is the entity length, which can potentially be * (i.e. unknown).
- int read_start_int;
- int read_end_int;
- int entity_length_int;
+ size_t read_start_int;
+ size_t read_end_int;
+ size_t entity_length_int;
int result = sscanf(iter->second.c_str(),
"bytes %" SCNuS "-%" SCNuS "/%" SCNuS,
&read_start_int,
diff --git a/native_client_sdk/src/libraries/nacl_io/mount_node_mem.cc b/native_client_sdk/src/libraries/nacl_io/mount_node_mem.cc
index 5ae7095..50dafd7 100644
--- a/native_client_sdk/src/libraries/nacl_io/mount_node_mem.cc
+++ b/native_client_sdk/src/libraries/nacl_io/mount_node_mem.cc
@@ -61,7 +61,7 @@ Error MountNodeMem::Write(const HandleAttr& attr,
if (count == 0)
return 0;
- if (count + attr.offs > stat_.st_size) {
+ if (count + attr.offs > static_cast<size_t>(stat_.st_size)) {
Resize(count + attr.offs);
count = stat_.st_size - attr.offs;
}
@@ -78,7 +78,7 @@ Error MountNodeMem::FTruncate(off_t new_size) {
}
void MountNodeMem::Resize(off_t new_size) {
- if (new_size > data_.capacity()) {
+ if (new_size > static_cast<off_t>(data_.capacity())) {
// While the node size is small, grow exponentially. When it starts to get
// larger, grow linearly.
size_t extra = std::min<size_t>(new_size, kMaxResizeIncrement);
diff --git a/native_client_sdk/src/libraries/nacl_io/mount_node_tty.cc b/native_client_sdk/src/libraries/nacl_io/mount_node_tty.cc
index 6b8fb66..48581c46 100644
--- a/native_client_sdk/src/libraries/nacl_io/mount_node_tty.cc
+++ b/native_client_sdk/src/libraries/nacl_io/mount_node_tty.cc
@@ -16,6 +16,7 @@
#include "nacl_io/ioctl.h"
#include "nacl_io/kernel_handle.h"
+#include "nacl_io/kernel_intercept.h"
#include "nacl_io/mount.h"
#include "nacl_io/pepper_interface.h"
#include "sdk_util/auto_lock.h"
@@ -262,7 +263,7 @@ Error MountNodeTty::VIoctl(int request, va_list args) {
rows_ = size->ws_row;
cols_ = size->ws_col;
}
- kill(getpid(), SIGWINCH);
+ ki_kill(getpid(), SIGWINCH);
{
// Wake up any thread waiting on Read with POLLERR then immediate
// clear it to signal EINTR.
diff --git a/native_client_sdk/src/libraries/nacl_io/osinttypes.h b/native_client_sdk/src/libraries/nacl_io/osinttypes.h
index 438e66f..1c907a3 100644
--- a/native_client_sdk/src/libraries/nacl_io/osinttypes.h
+++ b/native_client_sdk/src/libraries/nacl_io/osinttypes.h
@@ -17,7 +17,7 @@
#define SCNuS "Iu"
#endif
-#elif defined(__native_client__)
+#else
#include <inttypes.h>
@@ -29,6 +29,6 @@
#define SCNuS "zu"
#endif
-#endif /* defined(__native_client__) */
+#endif
#endif /* NACL_IO_OSINTTYPES_H_ */
diff --git a/native_client_sdk/src/libraries/nacl_io/ossignal.h b/native_client_sdk/src/libraries/nacl_io/ossignal.h
index 3ce0071..796abd9 100644
--- a/native_client_sdk/src/libraries/nacl_io/ossignal.h
+++ b/native_client_sdk/src/libraries/nacl_io/ossignal.h
@@ -5,9 +5,9 @@
#ifndef LIBRARIES_NACL_IO_OSSIGNAL_H_
#define LIBRARIES_NACL_IO_OSSIGNAL_H_
-#ifdef __native_client__
+#if !defined(WIN23)
#include <signal.h>
-#ifdef __GLIBC__
+#if defined(__GLIBC__)
typedef __sighandler_t sighandler_t;
#else
typedef _sig_func_ptr sighandler_t;
diff --git a/native_client_sdk/src/libraries/nacl_io/ossocket.h b/native_client_sdk/src/libraries/nacl_io/ossocket.h
index 936509b..7807bfb 100644
--- a/native_client_sdk/src/libraries/nacl_io/ossocket.h
+++ b/native_client_sdk/src/libraries/nacl_io/ossocket.h
@@ -7,7 +7,7 @@
#include <sys/types.h>
-#if defined(__native_client__)
+#if !defined(WIN32)
#include <arpa/inet.h>
#include <netdb.h>
#include <netinet/in.h>
diff --git a/native_client_sdk/src/libraries/nacl_io/ostermios.h b/native_client_sdk/src/libraries/nacl_io/ostermios.h
index 03c4b6c..a03b8a7 100644
--- a/native_client_sdk/src/libraries/nacl_io/ostermios.h
+++ b/native_client_sdk/src/libraries/nacl_io/ostermios.h
@@ -5,11 +5,7 @@
#ifndef LIBRARIES_NACL_IO_OSTERMIOS_H
#define LIBRARIES_NACL_IO_OSTERMIOS_H
-#if defined(__native_client__)
-
-#include <termios.h>
-
-#else
+#if defined(WIN32)
#include "sdk_util/macros.h"
@@ -37,6 +33,11 @@ int tcsetattr(int fd,int optional_actions,const struct termios *termios_p);
EXTERN_C_END
+#else
+
+#include <termios.h>
+
#endif
+
#endif /* LIBRARIES_NACL_IO_OSTERMIOS_H */
diff --git a/native_client_sdk/src/libraries/ppapi_simple/library.dsc b/native_client_sdk/src/libraries/ppapi_simple/library.dsc
index 8cb2c05..0b2683d 100644
--- a/native_client_sdk/src/libraries/ppapi_simple/library.dsc
+++ b/native_client_sdk/src/libraries/ppapi_simple/library.dsc
@@ -1,5 +1,5 @@
{
- 'TOOLS': ['newlib', 'glibc', 'pnacl'],
+ 'TOOLS': ['newlib', 'glibc', 'pnacl', 'linux'],
'TARGETS': [
{
'NAME' : 'ppapi_simple',
diff --git a/native_client_sdk/src/tests/nacl_io_test/example.dsc b/native_client_sdk/src/tests/nacl_io_test/example.dsc
index 07920f6..059c389 100644
--- a/native_client_sdk/src/tests/nacl_io_test/example.dsc
+++ b/native_client_sdk/src/tests/nacl_io_test/example.dsc
@@ -1,5 +1,5 @@
{
- 'TOOLS': ['newlib', 'glibc', 'pnacl'],
+ 'TOOLS': ['newlib', 'glibc', 'pnacl', 'linux'],
'SEL_LDR': True,
'TARGETS': [
diff --git a/native_client_sdk/src/tests/nacl_io_test/kernel_proxy_test.cc b/native_client_sdk/src/tests/nacl_io_test/kernel_proxy_test.cc
index 5d2f72e..470ad17 100644
--- a/native_client_sdk/src/tests/nacl_io_test/kernel_proxy_test.cc
+++ b/native_client_sdk/src/tests/nacl_io_test/kernel_proxy_test.cc
@@ -117,12 +117,12 @@ TEST_F(KernelProxyTest, FileLeak) {
for (int file_num = 0; file_num < 4096; file_num++) {
sprintf(filename, "/foo%i.tmp", file_num++);
- FILE* f = fopen(filename, "w");
- ASSERT_NE((FILE*)NULL, f);
+ int fd = ki_open(filename, O_WRONLY | O_CREAT);
+ ASSERT_GT(fd, -1);
ASSERT_EQ(1, root->ChildCount());
- ASSERT_EQ(buffer_size, fwrite(garbage, 1, buffer_size, f));
- fclose(f);
- ASSERT_EQ(0, remove(filename));
+ ASSERT_EQ(buffer_size, ki_write(fd, garbage, buffer_size));
+ ki_close(fd);
+ ASSERT_EQ(0, ki_remove(filename));
}
ASSERT_EQ(0, root->ChildCount());
}
@@ -358,21 +358,21 @@ TEST_F(KernelProxyTest, MemMountIO) {
TEST_F(KernelProxyTest, MemMountLseek) {
int fd = ki_open("/foo", O_CREAT | O_RDWR);
ASSERT_GT(fd, -1);
- EXPECT_EQ(9, ki_write(fd, "Some text", 9));
+ ASSERT_EQ(9, ki_write(fd, "Some text", 9));
- EXPECT_EQ(9, ki_lseek(fd, 0, SEEK_CUR));
- EXPECT_EQ(9, ki_lseek(fd, 0, SEEK_END));
- EXPECT_EQ(-1, ki_lseek(fd, -1, SEEK_SET));
- EXPECT_EQ(EINVAL, errno);
+ ASSERT_EQ(9, ki_lseek(fd, 0, SEEK_CUR));
+ ASSERT_EQ(9, ki_lseek(fd, 0, SEEK_END));
+ ASSERT_EQ(-1, ki_lseek(fd, -1, SEEK_SET));
+ ASSERT_EQ(EINVAL, errno);
// Seek past end of file.
- EXPECT_EQ(13, ki_lseek(fd, 13, SEEK_SET));
+ ASSERT_EQ(13, ki_lseek(fd, 13, SEEK_SET));
char buffer[4];
memset(&buffer[0], 0xfe, 4);
- EXPECT_EQ(9, ki_lseek(fd, -4, SEEK_END));
- EXPECT_EQ(9, ki_lseek(fd, 0, SEEK_CUR));
- EXPECT_EQ(4, ki_read(fd, &buffer[0], 4));
- EXPECT_EQ(0, memcmp("\0\0\0\0", buffer, 4));
+ ASSERT_EQ(9, ki_lseek(fd, -4, SEEK_END));
+ ASSERT_EQ(9, ki_lseek(fd, 0, SEEK_CUR));
+ ASSERT_EQ(4, ki_read(fd, &buffer[0], 4));
+ ASSERT_EQ(0, memcmp("\0\0\0\0", buffer, 4));
}
TEST_F(KernelProxyTest, CloseTwice) {
diff --git a/native_client_sdk/src/tests/nacl_io_test/kernel_wrap_test.cc b/native_client_sdk/src/tests/nacl_io_test/kernel_wrap_test.cc
index a163985..2eb474b 100644
--- a/native_client_sdk/src/tests/nacl_io_test/kernel_wrap_test.cc
+++ b/native_client_sdk/src/tests/nacl_io_test/kernel_wrap_test.cc
@@ -2,6 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+// The linux host build of nacl_io can't do wrapping of syscalls so all
+// these tests must be disabled.
+#if !defined(__linux__)
+
#include <unistd.h>
#include <string>
@@ -714,3 +718,5 @@ TEST_F(KernelWrapTest, socketpair) {
}
#endif // PROVIDES_SOCKET_API
+
+#endif // __linux__
diff --git a/native_client_sdk/src/tests/nacl_io_test/mount_html5fs_test.cc b/native_client_sdk/src/tests/nacl_io_test/mount_html5fs_test.cc
index 12f4fcf..3f1bd11 100644
--- a/native_client_sdk/src/tests/nacl_io_test/mount_html5fs_test.cc
+++ b/native_client_sdk/src/tests/nacl_io_test/mount_html5fs_test.cc
@@ -452,7 +452,7 @@ TEST_F(MountHtml5FsTest, GetDents) {
EXPECT_EQ(sizeof(dirent) * num_dirents, bytes_read);
std::multiset<std::string> dirnames;
- for (int i = 0; i < num_dirents; ++i) {
+ for (size_t i = 0; i < num_dirents; ++i) {
EXPECT_EQ(sizeof(dirent), dirents[i].d_off);
EXPECT_EQ(sizeof(dirent), dirents[i].d_reclen);
dirnames.insert(dirents[i].d_name);
@@ -476,7 +476,7 @@ TEST_F(MountHtml5FsTest, GetDents) {
EXPECT_EQ(sizeof(dirent) * num_dirents, bytes_read);
std::multiset<std::string> dirnames;
- for (int i = 0; i < num_dirents; ++i) {
+ for (size_t i = 0; i < num_dirents; ++i) {
EXPECT_EQ(sizeof(dirent), dirents[i].d_off);
EXPECT_EQ(sizeof(dirent), dirents[i].d_reclen);
dirnames.insert(dirents[i].d_name);
diff --git a/native_client_sdk/src/tests/nacl_io_test/mount_node_tty_test.cc b/native_client_sdk/src/tests/nacl_io_test/mount_node_tty_test.cc
index 02adb15..04cd84f 100644
--- a/native_client_sdk/src/tests/nacl_io_test/mount_node_tty_test.cc
+++ b/native_client_sdk/src/tests/nacl_io_test/mount_node_tty_test.cc
@@ -75,7 +75,7 @@ TEST_F(TtyTest, TtyInput) {
// more than we ask for.
HandleAttr attrs;
EXPECT_EQ(0, dev_tty_->Read(attrs, buffer, 5, &bytes_read));
- EXPECT_EQ(bytes_read, 5);
+ EXPECT_EQ(5, bytes_read);
EXPECT_EQ(0, memcmp(message.data(), buffer, 5));
EXPECT_EQ(0, memcmp(buffer + 5, backup_buffer + 5, 95));
@@ -172,7 +172,7 @@ TEST_F(TtyTest, TtySelect) {
fd_set errorfds;
int tty_fd = ki_open("/dev/tty", O_RDONLY);
- ASSERT_TRUE(tty_fd >= 0) << "tty open failed: " << errno;
+ ASSERT_GT(tty_fd, 0) << "tty open failed: " << errno;
FD_ZERO(&readfds);
FD_ZERO(&errorfds);
@@ -183,7 +183,7 @@ TEST_F(TtyTest, TtySelect) {
timeout.tv_usec = 10 * 1000;
// Should timeout when no input is available.
int rtn = ki_select(tty_fd + 1, &readfds, NULL, &errorfds, &timeout);
- ASSERT_EQ(rtn, 0) << "select failed: " << rtn << " err=" << strerror(errno);
+ ASSERT_EQ(0, rtn) << "select failed: " << rtn << " err=" << strerror(errno);
ASSERT_FALSE(FD_ISSET(tty_fd, &readfds));
ASSERT_FALSE(FD_ISSET(tty_fd, &errorfds));
@@ -195,7 +195,7 @@ TEST_F(TtyTest, TtySelect) {
FD_SET(tty_fd, &errorfds);
// TTY should be writable on startup.
rtn = ki_select(tty_fd + 1, &readfds, &writefds, &errorfds, NULL);
- ASSERT_EQ(rtn, 1);
+ ASSERT_EQ(1, rtn);
ASSERT_TRUE(FD_ISSET(tty_fd, &writefds));
ASSERT_FALSE(FD_ISSET(tty_fd, &readfds));
ASSERT_FALSE(FD_ISSET(tty_fd, &errorfds));
@@ -208,7 +208,7 @@ TEST_F(TtyTest, TtySelect) {
ASSERT_EQ(0, TtyWrite(tty_fd, "input:\n"));
// TTY should now be readable
- ASSERT_EQ(IsReadable(tty_fd), 1);
+ ASSERT_EQ(1, IsReadable(tty_fd));
ki_close(tty_fd);
}
@@ -216,33 +216,33 @@ TEST_F(TtyTest, TtySelect) {
TEST_F(TtyTest, TtyICANON) {
int tty_fd = ki_open("/dev/tty", O_RDONLY);
- ASSERT_EQ(IsReadable(tty_fd), 0);
+ ASSERT_EQ(0, IsReadable(tty_fd));
struct termios tattr;
- tcgetattr(tty_fd, &tattr);
+ ki_tcgetattr(tty_fd, &tattr);
tattr.c_lflag &= ~(ICANON|ECHO); /* Clear ICANON and ECHO. */
- tcsetattr(tty_fd, TCSAFLUSH, &tattr);
+ ki_tcsetattr(tty_fd, TCSAFLUSH, &tattr);
- ASSERT_EQ(IsReadable(tty_fd), 0);
+ ASSERT_EQ(0, IsReadable(tty_fd));
// Set some bytes to the TTY, not including newline
ASSERT_EQ(0, TtyWrite(tty_fd, "a"));
// Since we are not in canonical mode the bytes should be
// immediately readable.
- ASSERT_EQ(IsReadable(tty_fd), 1);
+ ASSERT_EQ(1, IsReadable(tty_fd));
// Read byte from tty.
char c;
- ASSERT_EQ(1, read(tty_fd, &c, 1));
+ ASSERT_EQ(1, ki_read(tty_fd, &c, 1));
ASSERT_EQ('a', c);
- ASSERT_EQ(IsReadable(tty_fd), 0);
+ ASSERT_EQ(0, IsReadable(tty_fd));
}
-int g_recieved_signal = 0;
+static int g_recieved_signal;
-void sighandler(int sig) {
+static void sighandler(int sig) {
g_recieved_signal = sig;
}
@@ -254,14 +254,16 @@ TEST_F(TtyTest, WindowSize) {
// Install signal handler
sighandler_t new_handler = sighandler;
sighandler_t old_handler = ki_signal(SIGWINCH, new_handler);
- ASSERT_NE(old_handler, SIG_ERR) << "signal return error: " << errno;
+ ASSERT_NE(SIG_ERR, old_handler) << "signal return error: " << errno;
+
+ g_recieved_signal = 0;
// Set a new windows size
struct winsize winsize;
winsize.ws_col = 100;
winsize.ws_row = 200;
EXPECT_EQ(0, dev_tty_->Ioctl(TIOCSWINSZ, &winsize));
- EXPECT_EQ(g_recieved_signal, SIGWINCH);
+ EXPECT_EQ(SIGWINCH, g_recieved_signal);
// Restore old signal handler
EXPECT_EQ(new_handler, ki_signal(SIGWINCH, old_handler));
@@ -270,8 +272,8 @@ TEST_F(TtyTest, WindowSize) {
winsize.ws_col = 0;
winsize.ws_row = 0;
EXPECT_EQ(0, dev_tty_->Ioctl(TIOCGWINSZ, &winsize));
- EXPECT_EQ(winsize.ws_col, 100);
- EXPECT_EQ(winsize.ws_row, 200);
+ EXPECT_EQ(100, winsize.ws_col);
+ EXPECT_EQ(200, winsize.ws_row);
// Restore original windows size.
EXPECT_EQ(0, dev_tty_->Ioctl(TIOCSWINSZ, &old_winsize));
@@ -313,13 +315,13 @@ TEST_F(TtyTest, ResizeDuringSelect) {
// TTY should not be readable either before or after the
// call to select(3).
- ASSERT_EQ(IsReadable(tty_fd), 0);
+ ASSERT_EQ(0, IsReadable(tty_fd));
int rtn = ki_select(tty_fd + 1, &readfds, NULL, &errorfds, &timeout);
pthread_join(resize_thread, NULL);
ASSERT_EQ(-1, rtn);
ASSERT_EQ(EINTR, errno);
- ASSERT_EQ(IsReadable(tty_fd), 0);
+ ASSERT_EQ(0, IsReadable(tty_fd));
}
/*
diff --git a/native_client_sdk/src/tools/common.mk b/native_client_sdk/src/tools/common.mk
index ac91790..64b1b0b2 100644
--- a/native_client_sdk/src/tools/common.mk
+++ b/native_client_sdk/src/tools/common.mk
@@ -225,10 +225,13 @@ all:
install:
.PHONY: install
+ifdef SEL_LDR
+STANDALONE = 1
+endif
OUTBASE ?= .
-ifdef SEL_LDR
-OUTDIR := $(OUTBASE)/$(TOOLCHAIN)/sel_ldr_$(CONFIG)
+ifdef STANDALONE
+OUTDIR := $(OUTBASE)/$(TOOLCHAIN)/standalone_$(CONFIG)
else
OUTDIR := $(OUTBASE)/$(TOOLCHAIN)/$(CONFIG)
endif
@@ -288,12 +291,19 @@ $(STAMPDIR)/$(1).stamp:
endif
endef
-
ifeq ($(TOOLCHAIN),win)
+ifdef STANDALONE
+HOST_EXT = .exe
+else
HOST_EXT = .dll
+endif
+else
+ifdef STANDALONE
+HOST_EXT =
else
HOST_EXT = .so
endif
+endif
#
@@ -310,13 +320,13 @@ else
POSIX_FLAGS ?= -g -O0 -pthread -MMD -DNACL_SDK_DEBUG
endif
-ifdef SEL_LDR
+ifdef STANDALONE
POSIX_FLAGS += -DSEL_LDR=1
endif
NACL_CFLAGS ?= -Wno-long-long -Werror
NACL_CXXFLAGS ?= -Wno-long-long -Werror
-NACL_LDFLAGS += -Wl,-as-needed
+NACL_LDFLAGS += -Wl,-as-needed -pthread
#
# Default Paths
@@ -421,23 +431,6 @@ else
DEV_NULL = /dev/null
endif
-#
-# Assign a sensible default to CHROME_PATH.
-#
-CHROME_PATH ?= $(shell $(GETOS) --chrome 2> $(DEV_NULL))
-
-#
-# Verify we can find the Chrome executable if we need to launch it.
-#
-.PHONY: check_for_chrome
-check_for_chrome:
-ifeq (,$(wildcard $(CHROME_PATH)))
- $(warning No valid Chrome found at CHROME_PATH=$(CHROME_PATH))
- $(error Set CHROME_PATH via an environment variable, or command-line.)
-else
- $(warning Using chrome at: $(CHROME_PATH))
-endif
-
#
# Variables for running examples with Chrome.
@@ -471,19 +464,23 @@ ifeq ($(CONFIG),Debug)
SEL_LDR_ARGS += --debug-libs
endif
-ifdef SEL_LDR
-run: all
-ifndef NACL_ARCH
- $(error Cannot run in sel_ldr unless $$NACL_ARCH is set)
-endif
- $(SEL_LDR_PATH) $(SEL_LDR_ARGS) $(OUTDIR)/$(TARGET)_$(NACL_ARCH).nexe -- $(NEXE_ARGS)
+ifndef STANDALONE
+#
+# Assign a sensible default to CHROME_PATH.
+#
+CHROME_PATH ?= $(shell $(GETOS) --chrome 2> $(DEV_NULL))
-debug: all
-ifndef NACL_ARCH
- $(error Cannot run in sel_ldr unless $$NACL_ARCH is set)
-endif
- $(SEL_LDR_PATH) -d $(SEL_LDR_ARGS) $(OUTDIR)/$(TARGET)_$(NACL_ARCH).nexe -- $(NEXE_ARGS)
+#
+# Verify we can find the Chrome executable if we need to launch it.
+#
+.PHONY: check_for_chrome
+check_for_chrome:
+ifeq (,$(wildcard $(CHROME_PATH)))
+ $(warning No valid Chrome found at CHROME_PATH=$(CHROME_PATH))
+ $(error Set CHROME_PATH via an environment variable, or command-line.)
else
+ $(warning Using chrome at: $(CHROME_PATH))
+endif
PAGE ?= index.html
PAGE_TC_CONFIG ?= "$(PAGE)?tc=$(TOOLCHAIN)&config=$(CONFIG)"
@@ -509,12 +506,11 @@ debug: check_for_chrome all $(PAGE)
$(addprefix -E ,$(CHROME_ENV)) -- $(CHROME_PATH) $(CHROME_ARGS) \
--enable-nacl-debug \
--register-pepper-plugins="$(PPAPI_DEBUG),$(PPAPI_RELEASE)"
-endif
.PHONY: serve
serve: all
$(HTTPD_PY) -C $(CURDIR)
-
+endif
# uppercase aliases (for backward compatibility)
.PHONY: CHECK_FOR_CHROME DEBUG LAUNCH RUN
diff --git a/native_client_sdk/src/tools/host_gcc.mk b/native_client_sdk/src/tools/host_gcc.mk
index b732431..a05b173 100644
--- a/native_client_sdk/src/tools/host_gcc.mk
+++ b/native_client_sdk/src/tools/host_gcc.mk
@@ -40,14 +40,14 @@ LINUX_CFLAGS = -fPIC -pthread $(LINUX_WARNINGS) -I$(NACL_SDK_ROOT)/include -I$(N
define C_COMPILER_RULE
-include $(call SRC_TO_DEP,$(1))
$(call SRC_TO_OBJ,$(1)): $(1) $(TOP_MAKE) | $(dir $(call SRC_TO_OBJ,$(1)))dir.stamp
- $(call LOG,CC ,$$@,$(HOST_CC) -o $$@ -c $$< -fPIC $(POSIX_FLAGS) $(2) $(LINUX_CFLAGS))
+ $(call LOG,CC ,$$@,$(HOST_CC) -o $$@ -c $$< -fPIC $(POSIX_FLAGS) $(LINUX_CFLAGS) $(2))
@$(FIXDEPS) $(call SRC_TO_DEP_PRE_FIXUP,$(1))
endef
define CXX_COMPILER_RULE
-include $(call SRC_TO_DEP,$(1))
$(call SRC_TO_OBJ,$(1)): $(1) $(TOP_MAKE) | $(dir $(call SRC_TO_OBJ,$(1)))dir.stamp
- $(call LOG,CXX ,$$@,$(HOST_CXX) -o $$@ -c $$< -fPIC $(POSIX_FLAGS) $(2) $(LINUX_CFLAGS))
+ $(call LOG,CXX ,$$@,$(HOST_CXX) -o $$@ -c $$< -fPIC $(POSIX_FLAGS) $(LINUX_CFLAGS) $(2))
@$(FIXDEPS) $(call SRC_TO_DEP_PRE_FIXUP,$(1))
endef
@@ -108,11 +108,19 @@ endef
# $5 = List of lib dirs
# $6 = Other Linker Args
#
+ifdef STANDALONE
+define LINKER_RULE
+all: $(1)
+$(1): $(2) $(foreach dep,$(4),$(STAMPDIR)/$(dep).stamp)
+ $(call LOG,LINK,$$@,$(HOST_LINK) -o $(1) $(2) $(NACL_LDFLAGS) $(foreach path,$(5),-L$(path)/$(OSNAME)_host)/$(CONFIG) $(foreach lib,$(3),-l$(lib)) $(6))
+endef
+else
define LINKER_RULE
all: $(1)
$(1): $(2) $(foreach dep,$(4),$(STAMPDIR)/$(dep).stamp)
$(call LOG,LINK,$$@,$(HOST_LINK) -shared -o $(1) $(2) $(NACL_LDFLAGS) $(foreach path,$(5),-L$(path)/$(OSNAME)_host)/$(CONFIG) $(foreach lib,$(3),-l$(lib)) $(6))
endef
+endif
#
@@ -145,3 +153,12 @@ all: $(OUTDIR)/$(1)$(HOST_EXT)
$(OUTDIR)/$(1)$(HOST_EXT): $(OUTDIR)/$(2)$(HOST_EXT)
$(call LOG,STRIP,$$@,$(HOST_STRIP) --strip-debug -o $$@ $$^)
endef
+
+
+#
+# Run standalone builds (command line builds outside of chrome)
+#
+ifdef STANDALONE
+run: all
+ $(OUTDIR)/$(TARGET)$(HOST_EXT) $(EXE_ARGS)
+endif
diff --git a/native_client_sdk/src/tools/nacl_gcc.mk b/native_client_sdk/src/tools/nacl_gcc.mk
index 675b464..2727447 100644
--- a/native_client_sdk/src/tools/nacl_gcc.mk
+++ b/native_client_sdk/src/tools/nacl_gcc.mk
@@ -452,3 +452,17 @@ GDB_DEBUG_TARGET = $(abspath $(OUTDIR))/$(TARGET)_$(SYSARCH).nexe
else
GDB_DEBUG_TARGET = $(abspath $(OUTDIR))/$(LIB_NAME)/runnable-ld.so
endif
+
+ifdef STANDALONE
+run: all
+ifndef NACL_ARCH
+ $(error Cannot run in sel_ldr unless $$NACL_ARCH is set)
+endif
+ $(SEL_LDR_PATH) $(SEL_LDR_ARGS) $(OUTDIR)/$(TARGET)_$(NACL_ARCH).nexe -- $(EXE_ARGS)
+
+debug: all
+ifndef NACL_ARCH
+ $(error Cannot run in sel_ldr unless $$NACL_ARCH is set)
+endif
+ $(SEL_LDR_PATH) -d $(SEL_LDR_ARGS) $(OUTDIR)/$(TARGET)_$(NACL_ARCH).nexe -- $(EXE_ARGS)
+endif