CONSOLE: Fix PS3 build.

This commit is contained in:
Mike Pall 2012-06-10 01:38:44 +02:00
parent 37be8a5478
commit b8f5727ab4
12 changed files with 73 additions and 29 deletions

View File

@ -214,7 +214,7 @@ TARGET_XCFLAGS= $(TARGET_LFSFLAGS) -U_FORTIFY_SOURCE
TARGET_XLDFLAGS=
TARGET_XLIBS= -lm
TARGET_TCFLAGS= $(CCOPTIONS) $(TARGET_XCFLAGS) $(TARGET_FLAGS) $(TARGET_CFLAGS)
TARGET_ACFLAGS= $(CCOPTIONS) $(TARGET_XCFLAGS) $(TARGET_ARCH) $(TARGET_FLAGS) $(TARGET_CFLAGS)
TARGET_ACFLAGS= $(CCOPTIONS) $(TARGET_XCFLAGS) $(TARGET_FLAGS) $(TARGET_CFLAGS)
TARGET_ALDFLAGS= $(LDOPTIONS) $(TARGET_XLDFLAGS) $(TARGET_FLAGS) $(TARGET_LDFLAGS)
TARGET_ASHLDFLAGS= $(LDOPTIONS) $(TARGET_XSHLDFLAGS) $(TARGET_FLAGS) $(TARGET_SHLDFLAGS)
TARGET_ALIBS= $(TARGET_XLIBS) $(LIBS) $(TARGET_LIBS)
@ -249,6 +249,15 @@ endif
endif
endif
ifneq (,$(findstring __CELLOS_LV2__ ,$(TARGET_TESTARCH)))
TARGET_SYS= PS3
TARGET_ARCH+= -D__CELLOS_LV2__
TARGET_XCFLAGS+= -DLUAJIT_USE_SYSMALLOC
endif
ifneq (,$(findstring LJ_NO_UNWIND ,$(TARGET_TESTARCH)))
TARGET_ARCH+= -DLUAJIT_NO_UNWIND
endif
TARGET_XCFLAGS+= $(CCOPT_$(TARGET_LJARCH))
TARGET_ARCH+= $(patsubst %,-DLUAJIT_TARGET=LUAJIT_ARCH_%,$(TARGET_LJARCH))
@ -277,7 +286,7 @@ ifeq (Windows,$(HOST_SYS))
HOST_RM= del
endif
TARGET_SYS= $(HOST_SYS)
TARGET_SYS?= $(HOST_SYS)
ifeq (Windows,$(TARGET_SYS))
TARGET_STRIP+= --strip-unneeded
TARGET_XSHLDFLAGS= -shared
@ -310,7 +319,9 @@ else
TARGET_XCFLAGS+= -fno-stack-protector
endif
ifneq (SunOS,$(TARGET_SYS))
TARGET_XLDFLAGS+= -Wl,-E
ifneq (PS3,$(TARGET_SYS))
TARGET_XLDFLAGS+= -Wl,-E
endif
endif
ifeq (Linux,$(TARGET_SYS))
TARGET_XLIBS+= -ldl
@ -463,6 +474,9 @@ endif
ifeq (SunOS,$(TARGET_SYS))
BUILDMODE= static
endif
ifeq (PS3,$(TARGET_SYS))
BUILDMODE= static
endif
ifeq (static,$(BUILDMODE))
TARGET_DYNCC= @:

View File

@ -141,6 +141,24 @@ static void emit_asm_label(BuildCtx *ctx, const char *name, int size, int isfunc
{
switch (ctx->mode) {
case BUILD_elfasm:
#if LJ_TARGET_PS3
if (!strncmp(name, "lj_vm_", 6)) {
fprintf(ctx->fp,
"\n\t.globl %s\n"
"\n\t.section \".opd\",\"aw\"\n"
"%s:\n"
"\t.long .%s,.TOC.@tocbase32\n"
"\t.size %s,8\n"
"\t.previous\n"
"\t.globl .%s\n"
"\t.hidden .%s\n"
"\t.type .%s, " ELFASM_PX "function\n"
"\t.size .%s, %d\n"
".%s:\n",
name, name, name, name, name, name, name, name, size, name);
break;
}
#endif
fprintf(ctx->fp,
"\n\t.globl %s\n"
"\t.hidden %s\n"
@ -196,7 +214,7 @@ void emit_asm(BuildCtx *ctx)
if (ctx->mode != BUILD_machasm)
fprintf(ctx->fp, ".Lbegin:\n");
#if LJ_TARGET_ARM && defined(__GNUC__) && !defined(LUAJIT_NO_UNWIND)
#if LJ_TARGET_ARM && defined(__GNUC__) && !LJ_NO_UNWIND
/* This should really be moved into buildvm_arm.dasc. */
fprintf(ctx->fp,
".fnstart\n"
@ -210,8 +228,7 @@ void emit_asm(BuildCtx *ctx)
for (i = rel = 0; i < ctx->nsym; i++) {
int32_t ofs = ctx->sym[i].ofs;
int32_t next = ctx->sym[i+1].ofs;
#if LJ_TARGET_ARM && defined(__GNUC__) && !defined(LUAJIT_NO_UNWIND) && \
LJ_HASFFI
#if LJ_TARGET_ARM && defined(__GNUC__) && !LJ_NO_UNWIND && LJ_HASFFI
if (!strcmp(ctx->sym[i].name, "lj_vm_ffi_call"))
fprintf(ctx->fp,
".globl lj_err_unwind_arm\n"
@ -246,7 +263,7 @@ void emit_asm(BuildCtx *ctx)
#endif
}
#if LJ_TARGET_ARM && defined(__GNUC__) && !defined(LUAJIT_NO_UNWIND)
#if LJ_TARGET_ARM && defined(__GNUC__) && !LJ_NO_UNWIND
fprintf(ctx->fp,
#if !LJ_HASFFI
".globl lj_err_unwind_arm\n"
@ -262,7 +279,7 @@ void emit_asm(BuildCtx *ctx)
#if LJ_TARGET_PPCSPE
/* Soft-float ABI + SPE. */
fprintf(ctx->fp, "\t.gnu_attribute 4, 2\n\t.gnu_attribute 8, 3\n");
#elif LJ_TARGET_PPC
#elif LJ_TARGET_PPC && !LJ_TARGET_PS3
/* Hard-float ABI. */
fprintf(ctx->fp, "\t.gnu_attribute 4, 1\n");
#endif

View File

@ -405,7 +405,7 @@ LJLIB_CF(io_popen)
#endif
return iof->fp != NULL ? 1 : io_pushresult(L, 0, fname);
#else
luaL_error(L, LUA_QL("popen") " not supported");
return luaL_error(L, LUA_QL("popen") " not supported");
#endif
}

View File

@ -613,20 +613,13 @@ static uint32_t jit_cpudetect(lua_State *L)
#endif
#endif
#elif LJ_TARGET_PPC
#if LJ_ARCH_PPC64
flags |= JIT_F_PPC64;
#endif
#if LJ_HASJIT
#if LJ_ARCH_SQRT
flags |= JIT_F_SQRT;
#endif
#if LJ_ARCH_ROUND
flags |= JIT_F_ROUND;
#endif
#if LJ_ARCH_CELL
flags |= JIT_F_CELL;
#endif
#if LJ_ARCH_XENON
flags |= JIT_F_XENON;
#endif
#elif LJ_TARGET_PPCSPE
/* Nothing to do. */

View File

@ -70,6 +70,10 @@ LJLIB_CF(os_rename)
LJLIB_CF(os_tmpname)
{
#if LJ_TARGET_PS3
lj_err_caller(L, LJ_ERR_OSUNIQF);
return 0;
#else
#if LJ_TARGET_POSIX
char buf[15+1];
int fp;
@ -86,6 +90,7 @@ LJLIB_CF(os_tmpname)
#endif
lua_pushstring(L, buf);
return 1;
#endif
}
LJLIB_CF(os_getenv)

View File

@ -521,6 +521,7 @@ static void setpath(lua_State *L, const char *fieldname, const char *envname,
{
#if LJ_TARGET_CONSOLE
const char *path = NULL;
UNUSED(envname);
#else
const char *path = getenv(envname);
#endif

View File

@ -279,7 +279,7 @@
#if (__GNUC__ < 4) || ((__GNUC__ == 4) && __GNUC_MINOR__ < 2)
#error "Need at least GCC 4.2 or newer"
#endif
#else
#elif !LJ_TARGET_PS3
#if (__GNUC__ < 4) || ((__GNUC__ == 4) && __GNUC_MINOR__ < 3)
#error "Need at least GCC 4.3 or newer"
#endif
@ -379,8 +379,8 @@
#define LUAJIT_NO_EXP2
#endif
#if defined(__symbian__) || LJ_TARGET_IOS || LJ_TARGET_PS3
#define LUAJIT_NO_UNWIND
#if defined(LUAJIT_NO_UNWIND) || defined(__symbian__) || LJ_TARGET_IOS || LJ_TARGET_PS3
#define LJ_NO_UNWIND 1
#endif
#endif

View File

@ -197,7 +197,16 @@ static LJ_AINLINE uint64_t lj_bswap64(uint64_t x)
}
#endif
#else
#error "missing define for lj_bswap()"
static LJ_AINLINE uint32_t lj_bswap(uint32_t x)
{
return (x << 24) | ((x & 0xff00) << 8) | ((x >> 8) & 0xff00) | (x >> 24);
}
static LJ_AINLINE uint64_t lj_bswap64(uint64_t x)
{
return (uint64_t)lj_bswap((uint32_t)(x >> 32)) |
((uint64_t)lj_bswap((uint32_t)x) << 32);
}
#endif
typedef union __attribute__((packed)) Unaligned16 {

View File

@ -185,7 +185,7 @@ static void *err_unwind(lua_State *L, void *stopcf, int errcode)
/* -- External frame unwinding -------------------------------------------- */
#if defined(__GNUC__) && !defined(LUAJIT_NO_UNWIND)
#if defined(__GNUC__) && !LJ_NO_UNWIND
/*
** We have to use our own definitions instead of the mandatory (!) unwind.h,

View File

@ -35,15 +35,12 @@
#define JIT_F_CPU_FIRST JIT_F_ARMV6
#define JIT_F_CPUSTRING "\5ARMv6\7ARMv6T2\5ARMv7"
#elif LJ_TARGET_PPC
#define JIT_F_PPC64 0x00000010
#define JIT_F_SQRT 0x00000020
#define JIT_F_ROUND 0x00000040
#define JIT_F_CELL 0x00000080
#define JIT_F_XENON 0x00000100
#define JIT_F_SQRT 0x00000010
#define JIT_F_ROUND 0x00000020
/* Names for the CPU-specific flags. Must match the order above. */
#define JIT_F_CPU_FIRST JIT_F_PPC64
#define JIT_F_CPUSTRING "\5PPC64\4SQRT\5ROUND\4CELL\5XENON"
#define JIT_F_CPU_FIRST JIT_F_SQRT
#define JIT_F_CPUSTRING "\4SQRT\5ROUND"
#elif LJ_TARGET_MIPS
#define JIT_F_MIPS32R2 0x00000010

View File

@ -13,6 +13,8 @@
#include "lj_mcode.h"
#include "lj_trace.h"
#include "lj_dispatch.h"
#endif
#if LJ_HASJIT || LJ_HASFFI
#include "lj_vm.h"
#endif

View File

@ -4804,7 +4804,11 @@ static void emit_asm_debug(BuildCtx *ctx)
"\t.long .LEFDE1-.LASFDE1\n"
".LASFDE1:\n"
"\t.long .Lframe0\n"
#if LJ_TARGET_PS3
"\t.long .lj_vm_ffi_call\n"
#else
"\t.long lj_vm_ffi_call\n"
#endif
"\t.long %d\n"
"\t.byte 0x11\n\t.uleb128 65\n\t.sleb128 -1\n"
"\t.byte 0x8e\n\t.uleb128 2\n"
@ -4812,6 +4816,7 @@ static void emit_asm_debug(BuildCtx *ctx)
"\t.align 2\n"
".LEFDE1:\n\n", (int)ctx->codesz - fcofs);
#endif
#if !LJ_NO_UNWIND
fprintf(ctx->fp, "\t.section .eh_frame,\"a\",@progbits\n");
fprintf(ctx->fp,
".Lframe1:\n"
@ -4879,6 +4884,7 @@ static void emit_asm_debug(BuildCtx *ctx)
"\t.byte 0xd\n\t.uleb128 0xe\n"
"\t.align 2\n"
".LEFDE3:\n\n", (int)ctx->codesz - fcofs);
#endif
#endif
break;
default: