A first hackthrough to get nacl compiling working

This commit is contained in:
Stefanos Kornilios Mitsis Poiitidis 2015-07-28 13:09:27 +02:00
parent 718cace9a7
commit 2eb9d7908f
6 changed files with 85 additions and 63 deletions

View File

@ -18,7 +18,7 @@
#include <string>
#include <sstream>
#if HOST_OS == OS_LINUX || HOST_OS == OS_DARWIN
#if FEAT_HAS_COREIO_HTTP
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/ip.h>
@ -27,6 +27,7 @@
#include <unistd.h>
#endif
#if FEAT_HAS_COREIO_HTTP
string url_encode(const string &value) {
ostringstream escaped;
escaped.fill('0');
@ -186,6 +187,7 @@ _data:
return rv;
}
#endif
struct CORE_FILE {
FILE* f;
@ -203,7 +205,7 @@ core_file* core_fopen(const char* filename)
CORE_FILE* rv = new CORE_FILE();
rv->f = 0;
rv->path = p;
#if FEAT_HAS_COREIO_HTTP
if (p.substr(0,7)=="http://") {
rv->host = p.substr(7,p.npos);
rv->host = rv->host.substr(0, rv->host.find_first_of("/"));
@ -217,7 +219,9 @@ core_file* core_fopen(const char* filename)
rv->host = rv->host.substr(0, rv->host.find_first_of(":"));
sscanf(port.c_str(),"%d",&rv->port);
}
} else {
} else
#endif
{
rv->f = fopen(filename, "rb");
if (!rv->f) {
@ -257,7 +261,9 @@ int core_fread(core_file* fc, void* buff, size_t len)
if (f->f) {
fread(buff,1,len,f->f);
} else {
#if FEAT_HAS_COREIO_HTTP
HTTP_GET(f->host, f->port, f->path, f->seek_ptr, len, buff);
#endif
}
f->seek_ptr += len;
@ -293,6 +299,8 @@ size_t core_fsize(core_file* fc)
return rv;
}
else {
#if FEAT_HAS_COREIO_HTTP
return HTTP_GET(f->host, f->port, f->path, 0, 0,0);
#endif
}
}

View File

@ -6,8 +6,10 @@
#define _XOPEN_SOURCE 1
#define __USE_GNU 1
#endif
#if !defined(TARGET_NACL32)
#include <poll.h>
#include <termios.h>
#endif
//#include <curses.h>
#include <fcntl.h>
#include <semaphore.h>
@ -16,10 +18,10 @@
#include <sys/param.h>
#include <sys/mman.h>
#include <sys/time.h>
#if !defined(_ANDROID) && !TARGET_OS_IPHONE
#if !defined(_ANDROID) && !defined(TARGET_OS_IPHONE) && !defined(TARGET_NACL32) && !defined(TARGET_EMSCRIPTEN)
#include <sys/personality.h>
#include <dlfcn.h>
#endif
#include <dlfcn.h>
#include <unistd.h>
#include "hw/sh4/dyna/blockmanager.h"
@ -52,6 +54,7 @@ void sigill_handler(int sn, siginfo_t * si, void *segfault_ctx) {
}
#endif
#if defined(TARGET_NO_EXCEPTIONS)
void fault_handler (int sn, siginfo_t * si, void *segfault_ctx)
{
rei_host_context_t ctx;
@ -99,6 +102,7 @@ void fault_handler (int sn, siginfo_t * si, void *segfault_ctx)
}
#endif
#endif
void install_fault_handler (void)
{
#if !defined(TARGET_NO_EXCEPTIONS)
@ -281,7 +285,7 @@ void enable_runfast()
}
void linux_fix_personality() {
#if HOST_OS == OS_LINUX && !defined(_ANDROID)
#if HOST_OS == OS_LINUX && !defined(_ANDROID) && !defined(TARGET_OS_IPHONE) && !defined(TARGET_NACL32) && !defined(TARGET_EMSCRIPTEN)
printf("Personality: %08X\n", personality(0xFFFFFFFF));
personality(~READ_IMPLIES_EXEC & personality(0xFFFFFFFF));
printf("Updated personality: %08X\n", personality(0xFFFFFFFF));
@ -289,6 +293,7 @@ void linux_fix_personality() {
}
void linux_rpi2_init() {
#if HOST_OS == OS_LINUX && !defined(TARGET_NACL32) && !defined(TARGET_EMSCRIPTEN)
void* handle;
void (*rpi_bcm_init)(void);
@ -302,6 +307,7 @@ void linux_rpi2_init() {
rpi_bcm_init();
}
}
#endif
}
void common_linux_setup()

View File

@ -8,7 +8,9 @@
#define __USE_GNU 1
#endif
#include <ucontext.h>
#if !defined(TARGET_NO_EXCEPTIONS)
#include <ucontext.h>
#endif
#endif
@ -27,6 +29,7 @@ void bicopy(Ta& rei, Tb& seg, bool to_segfault) {
void context_segfault(rei_host_context_t* reictx, void* segfault_ctx, bool to_segfault) {
#if !defined(TARGET_NO_EXCEPTIONS)
#if HOST_CPU == CPU_ARM
#if HOST_OS == OS_LINUX
bicopy(reictx->pc, MCTX(.arm_pc), to_segfault);
@ -64,6 +67,7 @@ void context_segfault(rei_host_context_t* reictx, void* segfault_ctx, bool to_se
#else
#error Unsupported HOST_CPU
#endif
#endif
}

View File

@ -89,4 +89,34 @@ namespace pp {
Module* CreateModule() {
return new hello_world::HelloWorldModule();
}
} // namespace pp
} // namespace pp
u16 kcode[4];
u32 vks[4];
s8 joyx[4],joyy[4];
u8 rt[4],lt[4];
int get_mic_data(u8* buffer) { return 0; }
int push_vmu_screen(u8* buffer) { return 0; }
void os_SetWindowText(const char * text) {
}
void os_DoEvents() {
}
void UpdateInputState(u32 port) {
}
void os_CreateWindow() {
}
void os_DebugBreak() {
exit(1);
}

View File

@ -3,12 +3,14 @@
#ifdef GLES
#ifdef TARGET_IPHONE //apple-specific ogles2 headers
#if defined(TARGET_IPHONE) //apple-specific ogles2 headers
//#include <APPLE/egl.h>
#include <OpenGLES/ES2/gl.h>
#include <OpenGLES/ES2/glext.h>
#else
#if !defined(TARGET_NACL32)
#include <EGL/egl.h>
#endif
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#endif

View File

@ -1,73 +1,45 @@
VALID_TOOLCHAINS := pnacl newlib glibc
include $(NACL_SDK_ROOT)/tools/common.mk
LOCAL_PATH := $(call my-dir)
FOR_LINUX :=1
#FOR_LINUX :=1
NOT_ARM := 1
NO_REC := 1
#NO_REND := 1
NO_REND := 1
RZDCY_SRC_DIR = ../../core
include $(RZDCY_SRC_DIR)/core.mk
PROJECT:=reicast
LDFLAGS:=-lppapi_gles2 -lppapi_cpp -lppapi
#CXX_SOURCES := $(foreach dir,$(SOURCES),$(wildcard $(dir)*.cpp))
#CC_SOURCES += $(foreach dir,$(SOURCES),$(wildcard $(dir)*.c))
TARGET = reicast
LIBS = ppapi_gles2 ppapi_cpp ppapi pthread
CFLAGS = -Wno-error -Wno-ignored-attributes
CFLAGS += -I$(RZDCY_SRC_DIR) -I$(RZDCY_SRC_DIR)/deps
CFLAGS += -D RELEASE -D TARGET_NO_REC -D TARGET_NACL32 -DNO_REND
SOURCES = $(RZDCY_FILES) ../../core/nacl/nacl.cpp
# Project Build flags
WARNINGS:=-Wno-long-long -Wswitch-enum
CXXFLAGS:=-pthread -std=gnu++0x $(WARNINGS)
CXXFLAGS += -I$(RZDCY_SRC_DIR) -I$(RZDCY_SRC_DIR)/deps -I$(RZDCY_SRC_DIR)/khronos -I../linux-deps/include -D RELEASE -D TARGET_NO_REC -D TARGET_NACL32
#
# Compute tool paths
#
#
OSNAME:=$(shell python $(NACL_SDK_ROOT)/tools/getos.py)
TC_PATH:=$(NACL_SDK_ROOT)/toolchain/$(OSNAME)_x86_newlib
CXX:=$(TC_PATH)/bin/i686-nacl-g++
CC:=$(TC_PATH)/bin/i686-nacl-gcc
#
# Disable DOS PATH warning when using Cygwin based tools Windows
#
CYGWIN ?= nodosfilewarning
export CYGWIN
WARNINGS ?=-Wno-long-long -Wno-switch-enum
CXXFLAGS += -std=gnu++0x $(WARNINGS)
# Declare the ALL target first, to make the 'all' target the default build
all: $(PROJECT)_x86_32.nexe
# Build rules generated by macros from common.mk:
# Define 32 bit compile and link rules for C++ sources
CXX_32_OBJSX:=$(patsubst %.cpp,%.nacl_86x32_build_obj,$(RZDCY_FILES))
CXX_32_OBJSY:=$(patsubst %.c,%.nacl_86x32_build_obj,$(CXX_32_OBJSX))
CXX_32_OBJS:=$(patsubst %.S,%.nacl_86x32_build_obj,$(CXX_32_OBJSY))
#CC_32_OBJS:=$(patsubst %.c,%.build_obj_nacl_32,$(CC_SOURCES))
x86_32_OBJS:=$(CXX_32_OBJS) $(CC_32_OBJS)
$(foreach src,$(SOURCES),$(eval $(call COMPILE_RULE,$(src),$(CFLAGS))))
%.nacl_86x32_build_obj : %.cpp $(THIS_MAKE)
$(CXX) -o $@ -c $< -m32 -O0 -g $(CXXFLAGS)
%.nacl_86x32_build_obj : %.c $(THIS_MAKE)
$(CC) -o $@ -c $< -m32 -O0 -g $(CXXFLAGS)
$(PROJECT)_x86_32.nexe : $(x86_32_OBJS)
echo $(x86_32_OBJS)
$(CXX) -o $@ $^ -m32 -O0 -g $(CXXFLAGS) $(LDFLAGS)
clean:
rm $(x86_32_OBJS)
# Define a phony rule so it always runs, to build nexe and start up server.
.PHONY: RUN
RUN: all
python ../httpd.py
# The PNaCl workflow uses both an unstripped and finalized/stripped binary.
# On NaCl, only produce a stripped binary for Release configs (not Debug).
ifneq (,$(or $(findstring pnacl,$(TOOLCHAIN)),$(findstring Release,$(CONFIG))))
$(eval $(call LINK_RULE,$(TARGET)_unstripped,$(SOURCES),$(LIBS),$(DEPS)))
$(eval $(call STRIP_RULE,$(TARGET),$(TARGET)_unstripped))
else
$(eval $(call LINK_RULE,$(TARGET),$(SOURCES),$(LIBS),$(DEPS)))
endif
SHELL = sh
$(eval $(call NMF_RULE,$(TARGET),))