mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Merges a patch form naclports.
* configure.in (RUBY_NACL and others): Supports PNaCl.
* dln.c: replace the old hacky dynamic loading over HTTP with nacl_io.
* file.c: tenatively use access(2) instead of eaccess.
(rb_file_load_ok): weaken with attribute but not by postprocess.
* io.c (socket.h): now NaCl has socket.h
(flock): disable here instead of nacl/ioctl.h
* nacl/GNUmakefile.in (CC, LD, NM, AR, AS, RANLIB, OBJDUMP, OBJCOPY):
respect path to them if they are absolute.
This helps naclports to build ruby in their source tree.
(PROGRAM_NMF, .SUFFIXES): support .pnexe for PNaCl.
(ruby.o, file.o): move the hack to attributes in ruby.c and file.c
* nacl/ioctl.h: removed. move the hack to io.c.
* nacl/nacl-config.rb: support arm, pnacl and others.
* nacl/pepper_main.c: support build in a naclports tree.
* ruby.c (rb_load_file): weaken with attribute but not by postprocess.
The patch is by sbc@google.com and the Native Client Authors.
It is available at:
* 873ca4910a/ports/ruby/nacl.patch
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47872 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
f21431e574
commit
69ac654c90
10 changed files with 75 additions and 69 deletions
29
configure.in
29
configure.in
|
@ -96,8 +96,11 @@ AC_DEFUN([RUBY_NACL],
|
|||
[no], [nacl_cv_build_variant=glibc],
|
||||
[yes], [nacl_cv_build_variant=newlib])])
|
||||
|
||||
AS_CASE(["$build_cpu"],
|
||||
[x86_64|i?86], [nacl_cv_cpu_nick=x86], [nacl_cv_cpu_nick=$build_cpu])
|
||||
AS_CASE(["$target_cpu"],
|
||||
[x86_64|i?86], [nacl_cv_cpu_nick=x86],
|
||||
[le32], [nacl_cv_cpu_nick=pnacl
|
||||
ac_cv_exeext=.pexe],
|
||||
[nacl_cv_cpu_nick=$target_cpu])
|
||||
AS_CASE(["$build_os"],
|
||||
[linux*], [nacl_cv_os_nick=linux],
|
||||
[darwin*], [nacl_cv_os_nick=mac],
|
||||
|
@ -111,6 +114,9 @@ AC_DEFUN([RUBY_NACL],
|
|||
if test -d \
|
||||
"${NACL_SDK_ROOT}/toolchain/${nacl_cv_os_nick}_${nacl_cv_cpu_nick}_${nacl_cv_build_variant}"; then
|
||||
NACL_TOOLCHAIN="${nacl_cv_os_nick}_${nacl_cv_cpu_nick}_${nacl_cv_build_variant}"
|
||||
elif test -d \
|
||||
"${NACL_SDK_ROOT}/toolchain/${nacl_cv_os_nick}_x86_${nacl_cv_cpu_nick}/${nacl_cv_build_variant}"; then
|
||||
NACL_TOOLCHAIN="${nacl_cv_os_nick}_x86_${nacl_cv_cpu_nick}/${nacl_cv_build_variant}"
|
||||
else
|
||||
AS_CASE(
|
||||
["${nacl_cv_build_variant}"],
|
||||
|
@ -791,12 +797,16 @@ fi
|
|||
RUBY_TRY_CFLAGS(-Qunused-arguments, [RUBY_APPEND_OPTIONS(rb_cv_wsuppress_flags, -Qunused-arguments)])
|
||||
|
||||
if test "$GCC" = yes; then
|
||||
# -D_FORTIFY_SOURCE
|
||||
# When defined _FORTIFY_SOURCE, glibc enables some additional sanity
|
||||
# argument check. The performance drop is very little and Ubuntu enables
|
||||
# _FORTIFY_SOURCE=2 by default. So, let's support it for protecting us from
|
||||
# a mistake of silly C extensions.
|
||||
RUBY_TRY_CFLAGS(-D_FORTIFY_SOURCE=2, [RUBY_APPEND_OPTION(XCFLAGS, -D_FORTIFY_SOURCE=2)])
|
||||
# NaCl's glibc build generates undefined references to __memset_chk.
|
||||
# TODO(sbc): Remove this once NaCl's glibc is fixed.
|
||||
AS_CASE(["$target_os"], [nacl], [], [
|
||||
# -D_FORTIFY_SOURCE
|
||||
# When defined _FORTIFY_SOURCE, glibc enables some additional sanity
|
||||
# argument check. The performance drop is very little and Ubuntu enables
|
||||
# _FORTIFY_SOURCE=2 by default. So, let's support it for protecting us from
|
||||
# a mistake of silly C extensions.
|
||||
RUBY_TRY_CFLAGS(-D_FORTIFY_SOURCE=2, [RUBY_APPEND_OPTION(XCFLAGS, -D_FORTIFY_SOURCE=2)])
|
||||
])
|
||||
|
||||
# -fstack-protector
|
||||
AS_CASE(["$target_os"],
|
||||
|
@ -1087,12 +1097,9 @@ main()
|
|||
LIBS="-lm $LIBS"
|
||||
if test "${nacl_cv_build_variant}" = "newlib"; then
|
||||
RUBY_APPEND_OPTION(CPPFLAGS, -DNACL_NEWLIB)
|
||||
RUBY_APPEND_OPTION(LIBS, '-lnosys')
|
||||
else
|
||||
RUBY_APPEND_OPTION(XCFLAGS, -fPIC)
|
||||
fi
|
||||
ac_cv_func_shutdown=no
|
||||
ac_cv_func_fcntl=no
|
||||
],
|
||||
[ LIBS="-lm $LIBS"])
|
||||
|
||||
|
|
15
dln.c
15
dln.c
|
@ -1325,28 +1325,13 @@ dln_load(const char *file)
|
|||
# define RTLD_GLOBAL 0
|
||||
#endif
|
||||
|
||||
#ifdef __native_client__
|
||||
char* p, *orig;
|
||||
if (file[0] == '.' && file[1] == '/') file+=2;
|
||||
orig = strdup(file);
|
||||
for (p = file; *p; ++p) {
|
||||
if (*p == '/') *p = '_';
|
||||
}
|
||||
#endif
|
||||
/* Load file */
|
||||
if ((handle = (void*)dlopen(file, RTLD_LAZY|RTLD_GLOBAL)) == NULL) {
|
||||
#ifdef __native_client__
|
||||
free(orig);
|
||||
#endif
|
||||
error = dln_strerror();
|
||||
goto failed;
|
||||
}
|
||||
|
||||
init_fct = (void(*)())(VALUE)dlsym(handle, buf);
|
||||
#ifdef __native_client__
|
||||
strcpy(file, orig);
|
||||
free(orig);
|
||||
#endif
|
||||
if (init_fct == NULL) {
|
||||
error = DLN_ERROR();
|
||||
dlclose(handle);
|
||||
|
|
10
file.c
10
file.c
|
@ -1190,6 +1190,14 @@ rb_group_member(GETGROUPS_T gid)
|
|||
#define USE_GETEUID 1
|
||||
#endif
|
||||
|
||||
#ifdef __native_client__
|
||||
// Although the NaCl toolchain contain eaccess() is it not yet
|
||||
// overridden by nacl_io.
|
||||
// TODO(sbc): Remove this once eaccess() is wired up correctly
|
||||
// in NaCl.
|
||||
#define eaccess access
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_EACCESS
|
||||
int
|
||||
eaccess(const char *path, int mode)
|
||||
|
@ -5503,7 +5511,7 @@ rb_path_check(const char *path)
|
|||
|
||||
#ifndef _WIN32
|
||||
#ifdef __native_client__
|
||||
__attribute__((noinline))
|
||||
__attribute__((noinline,weak))
|
||||
#endif
|
||||
int
|
||||
rb_file_load_ok(const char *path)
|
||||
|
|
15
io.c
15
io.c
|
@ -32,9 +32,7 @@
|
|||
#if defined HAVE_NET_SOCKET_H
|
||||
# include <net/socket.h>
|
||||
#elif defined HAVE_SYS_SOCKET_H
|
||||
# ifndef __native_client__
|
||||
# include <sys/socket.h>
|
||||
# endif
|
||||
# include <sys/socket.h>
|
||||
#endif
|
||||
|
||||
#if defined(__BOW__) || defined(__CYGWIN__) || defined(_WIN32) || defined(__EMX__) || defined(__BEOS__) || defined(__HAIKU__)
|
||||
|
@ -53,9 +51,6 @@
|
|||
#if defined(HAVE_SYS_IOCTL_H) && !defined(_WIN32)
|
||||
#include <sys/ioctl.h>
|
||||
#endif
|
||||
#if defined(__native_client__) && defined(NACL_NEWLIB)
|
||||
# include "nacl/ioctl.h"
|
||||
#endif
|
||||
#if defined(HAVE_FCNTL_H) || defined(_WIN32)
|
||||
#include <fcntl.h>
|
||||
#elif defined(HAVE_SYS_FCNTL_H)
|
||||
|
@ -8947,6 +8942,14 @@ typedef long fcntl_arg_t;
|
|||
typedef int fcntl_arg_t;
|
||||
#endif
|
||||
|
||||
#if defined __native_client__ && !defined __GLIBC__
|
||||
// struct flock is currently missing the NaCl newlib headers
|
||||
// TODO(sbc): remove this once it gets added.
|
||||
#undef F_GETLK
|
||||
#undef F_SETLK
|
||||
#undef F_SETLKW
|
||||
#endif
|
||||
|
||||
static long
|
||||
fcntl_narg_len(int cmd)
|
||||
{
|
||||
|
|
|
@ -7,45 +7,54 @@ include Makefile
|
|||
NACL_SDK_ROOT=@NACL_SDK_ROOT@
|
||||
NACL_TOOLCHAIN=@NACL_TOOLCHAIN@
|
||||
NACL_TOOLCHAIN_DIR=$(NACL_SDK_ROOT)/toolchain/$(NACL_TOOLCHAIN)
|
||||
|
||||
# Don't override CC/LD/etc if they are already set to absolute
|
||||
# paths (this is the case when building in the naclports tree).
|
||||
ifeq ($(dir $(CC)),./)
|
||||
CC:=$(NACL_TOOLCHAIN_DIR)/bin/$(CC)
|
||||
endif
|
||||
ifeq ($(dir $(LD)),./)
|
||||
LD:=$(NACL_TOOLCHAIN_DIR)/bin/$(LD)
|
||||
endif
|
||||
ifeq ($(dir $(NM)),./)
|
||||
NM:=$(NACL_TOOLCHAIN_DIR)/bin/$(NM)
|
||||
endif
|
||||
ifeq ($(dir $(AR)),./)
|
||||
AR:=$(NACL_TOOLCHAIN_DIR)/bin/$(AR)
|
||||
endif
|
||||
ifeq ($(dir $(AS)),./)
|
||||
AS:=$(NACL_TOOLCHAIN_DIR)/bin/$(AS)
|
||||
endif
|
||||
ifeq ($(dir $(RANLIB)),./)
|
||||
RANLIB:=$(NACL_TOOLCHAIN_DIR)/bin/$(RANLIB)
|
||||
endif
|
||||
ifeq ($(dir $(OBJDUMP)),./)
|
||||
OBJDUMP:=$(NACL_TOOLCHAIN_DIR)/bin/$(OBJDUMP)
|
||||
endif
|
||||
ifeq ($(dir $(OBJCOPY)),./)
|
||||
OBJCOPY:=$(NACL_TOOLCHAIN_DIR)/bin/$(OBJCOPY)
|
||||
endif
|
||||
PYTHON=@PYTHON@
|
||||
|
||||
PPROGRAM=pepper-$(PROGRAM)
|
||||
PEPPER_LIBS=-lppapi
|
||||
PROGRAM_NMF=$(PROGRAM:.nexe=.nmf)
|
||||
PPROGRAM_NMF=$(PPROGRAM:.nexe=.nmf)
|
||||
PROGRAM_NMF=$(PROGRAM:$(EXEEXT)=.nmf)
|
||||
PPROGRAM_NMF=$(PPROGRAM:$(EXEEXT)=.nmf)
|
||||
|
||||
GNUmakefile: $(srcdir)/nacl/GNUmakefile.in
|
||||
$(PPROGRAM): $(PROGRAM) pepper_main.$(OBJEXT)
|
||||
$(Q)$(MAKE) $(MFLAGS) PROGRAM=$(PPROGRAM) MAINOBJ="pepper_main.$(OBJEXT)" LIBS="$(LIBS) $(PEPPER_LIBS)" program
|
||||
$(PROGRAM_NMF) $(PPROGRAM_NMF): $(@:.nmf=.nexe) nacl/create_nmf.rb
|
||||
$(PROGRAM_NMF) $(PPROGRAM_NMF): $(@:.nmf=$(EXEEXT)) nacl/create_nmf.rb
|
||||
|
||||
.PHONY: pprogram package show_naclflags
|
||||
.SUFFIXES: .nexe .nmf
|
||||
.nexe.nmf:
|
||||
.SUFFIXES: $(EXEEXT) .nmf
|
||||
$(EXEEXT).nmf:
|
||||
$(ECHO) generating manifest $@
|
||||
$(Q)$(MINIRUBY) $(srcdir)/nacl/create_nmf.rb --verbose=$(V) $(@:.nmf=.nexe) $@
|
||||
$(Q)$(MINIRUBY) $(srcdir)/nacl/create_nmf.rb --verbose=$(V) $(@:.nmf=$(EXEEXT)) $@
|
||||
|
||||
pepper_main.$(OBJEXT): $(srcdir)/nacl/pepper_main.c
|
||||
@$(ECHO) compiling nacl/pepper_main.c
|
||||
$(Q) $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(COUTFLAG)$@ -c $(srcdir)/nacl/pepper_main.c
|
||||
ruby.$(OBJEXT):
|
||||
@$(ECHO) compiling $<
|
||||
$(Q) $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(COUTFLAG)$@.tmp -c $<
|
||||
$(Q) $(OBJCOPY) --weaken-symbol=rb_load_file $@.tmp $@
|
||||
@-$(RM) $@.tmp
|
||||
file.$(OBJEXT):
|
||||
@$(ECHO) compiling $<
|
||||
$(Q) $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(COUTFLAG)$@.tmp -c $<
|
||||
$(Q) $(OBJCOPY) --weaken-symbol=rb_file_load_ok $@.tmp $@
|
||||
@-$(RM) $@.tmp
|
||||
|
||||
.rbconfig.time:
|
||||
@$(MAKE) .rbconfig.raw.time RBCONFIG=.rbconfig.raw.time
|
||||
|
|
|
@ -6,14 +6,14 @@
|
|||
You need to install the following things before building NaCl port of Ruby.
|
||||
* Ruby 1.9.3 or later
|
||||
* Python 2.6 or later
|
||||
* NativeClient SDK pepper 22 or later
|
||||
* NativeClient SDK pepper 37 or later
|
||||
* GNU make
|
||||
|
||||
== Steps
|
||||
(1) Extract all files from the tarball:
|
||||
$ tar xzf ruby-X.Y.Z.tar.gz
|
||||
(2) Set NACL_SDK_ROOT environment variable to the path to the Native Client SDK you installed:
|
||||
$ export NACL_SDK_ROOT=/home/yugui/src/nacl_sdk/pepper_16
|
||||
$ export NACL_SDK_ROOT=/home/yugui/src/nacl_sdk/pepper_37
|
||||
(3) Configure
|
||||
$ ./configure --prefix=/tmp/nacl-ruby --host=x86_64-nacl --with-baseruby=/path/to/ruby-1.9.3
|
||||
(4) Make
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
// Copyright 2012 Google Inc. All Rights Reserved.
|
||||
// Author: yugui@google.com (Yugui Sonoda)
|
||||
#ifndef RUBY_NACL_IOCTL_H
|
||||
#define RUBY_NACL_IOCTL_H
|
||||
int ioctl(int fd, int request, ...);
|
||||
struct flock{};
|
||||
#endif
|
|
@ -27,14 +27,12 @@ module NaClConfig
|
|||
INSTALL_PROGRAM = config['INSTALL_PROGRAM']
|
||||
INSTALL_LIBRARY = config['INSTALL_DATA']
|
||||
|
||||
SEL_LDR = [
|
||||
File.join(SDK_ROOT, 'toolchain', config['NACL_TOOLCHAIN'], 'bin', "sel_ldr_#{cpu_nick}"),
|
||||
File.join(SDK_ROOT, 'tools', "sel_ldr_#{cpu_nick}")
|
||||
].find{|path| File.executable?(path)} or raise "No sel_ldr found"
|
||||
IRT_CORE = [
|
||||
File.join(SDK_ROOT, 'toolchain', config['NACL_TOOLCHAIN'], 'bin', "irt_core_#{cpu_nick}.nexe"),
|
||||
File.join(SDK_ROOT, 'tools', "irt_core_#{cpu_nick}.nexe")
|
||||
].find{|path| File.exist?(path)} or raise "No irt_core found"
|
||||
if cpu_nick == 'x86_64' or cpu_nick == 'x86_32'
|
||||
SEL_LDR = File.join(SDK_ROOT, 'tools', "sel_ldr_#{cpu_nick}")
|
||||
IRT_CORE = File.join(SDK_ROOT, 'tools', "irt_core_#{cpu_nick}.nexe")
|
||||
raise "No sel_ldr found" if not File.executable?(SEL_LDR)
|
||||
raise "No irt_core found" if not File.exists?(IRT_CORE)
|
||||
end
|
||||
RUNNABLE_LD = File.join(HOST_LIB, 'runnable-ld.so')
|
||||
|
||||
module_function
|
||||
|
|
|
@ -210,7 +210,7 @@ pruby_async_return_value(void* data, VALUE value)
|
|||
static struct PP_Var
|
||||
pruby_cstr_to_var(const char* str)
|
||||
{
|
||||
#ifdef PPB_VAR_INTERFACE_1_0
|
||||
#ifndef PPB_VAR_INTERFACE_1_1
|
||||
if (var_interface != NULL)
|
||||
return var_interface->VarFromUtf8(module_id, str, strlen(str));
|
||||
return PP_MakeUndefined();
|
||||
|
@ -252,7 +252,7 @@ pruby_str_to_var(volatile VALUE str)
|
|||
fprintf(stderr, "[BUG] Unexpected object type: %x\n", TYPE(str));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
#ifdef PPB_VAR_INTERFACE_1_0
|
||||
#ifndef PPB_VAR_INTERFACE_1_1
|
||||
if (var_interface != NULL) {
|
||||
return var_interface->VarFromUtf8(module_id, RSTRING_PTR(str), RSTRING_LEN(str));
|
||||
}
|
||||
|
@ -517,7 +517,7 @@ static void Instance_DidDestroy(PP_Instance instance) {
|
|||
* the top left of the plugin's coordinate system (not the page). If the
|
||||
* plugin is invisible, @a clip will be (0, 0, 0, 0).
|
||||
*/
|
||||
#ifdef PPP_INSTANCE_INTERFACE_1_0
|
||||
#ifndef PPP_INSTANCE_INTERFACE_1_1
|
||||
static void
|
||||
Instance_DidChangeView(PP_Instance instance,
|
||||
const struct PP_Rect* position,
|
||||
|
|
3
ruby.c
3
ruby.c
|
@ -1729,6 +1729,9 @@ load_file(VALUE parser, VALUE fname, int script, struct cmdline_options *opt)
|
|||
return (NODE *)rb_ensure(load_file_internal, (VALUE)&arg, restore_lineno, rb_gv_get("$."));
|
||||
}
|
||||
|
||||
#ifdef __native_client__
|
||||
__attribute__((weak))
|
||||
#endif
|
||||
void *
|
||||
rb_load_file(const char *fname)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue