Build fixes to make emscripten builds happy (#16406) ##build

This commit is contained in:
radare 2020-04-02 17:52:03 +02:00 committed by GitHub
parent ec49299cb5
commit 5a1df188f6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 45 additions and 31 deletions

View file

@ -98,6 +98,10 @@ jobs:
env: COMPILER_NAME=gcc CXX=g++ CC=gcc INSTALL_SYSTEM=meson R2_SYS_CAPSTONE=true R2_TESTS_DISABLE=1
allow_failures:
# Emscripten
- os: linux
name: EMCC-WASM-JS
env: EMSCRIPTEN=1
# Linux with GCC on PowerPC
- os: linux
arch: ppc64le

View file

@ -1,7 +1,7 @@
/* radare - LGPL - Copyright 2009-2019 - pancake */
/* radare - LGPL - Copyright 2009-2020 - pancake */
#include <r_main.h>
int main(int argc, char **argv) {
int main(int argc, const char **argv) {
return r_main_rabin2 (argc, argv);
}

View file

@ -1,9 +1,9 @@
/* radare - LGPL - Copyright 2009-2019 - pancake */
/* radare - LGPL - Copyright 2009-2020 - pancake */
#include <r_main.h>
#include <r_util.h>
#if EMSCRIPTEN
#if EMSCRIPTEN__TODO
#include <emscripten.h>
static RCore *core = NULL;

View file

@ -1,7 +1,7 @@
/* radare - LGPL - Copyright 2009-2019 - pancake */
/* radare - LGPL - Copyright 2009-2020 - pancake */
#include <r_main.h>
int main (int argc, char *argv[]) {
int main (int argc, const char *argv[]) {
return r_main_rasm2 (argc, argv);
}

View file

@ -8,7 +8,7 @@ endif
CFLAGS+=-I$(LTOP)/include
ifeq (${COMPILER},emscripten)
LINK+=$(SHLR)/libr/libr.a
LINK+=$(SHLR)/libr_shlr.a
LINK+=$(SHLR)/sdb/src/libsdb.a
include $(SHLR)/capstone.mk
CFLAGS+= -s SIDE_MODULE=1
@ -63,7 +63,11 @@ ${BINS}: ${OBJS}
${CC} ${CFLAGS} $@.c ${OBJS} ../../libr/libr.a -o $@ $(LDFLAGS)
${BEXE}: ${OBJ} ${SHARED_OBJ}
ifeq ($(CC),emcc)
emcc $(BIN).c ../../shlr/libr_shlr.a ../../shlr/capstone/libcapstone.a ../../libr/libr.a ../../shlr/gdb/lib/libgdbr.a ../../shlr/zip/librz.a -I ../../libr/include -o $(BIN).js
else
${CC} ${CFLAGS} $+ -L.. -o $@ ../../libr/libr.a $(LDFLAGS)
endif
else
${BINS}: ${OBJS}

View file

@ -52,6 +52,9 @@ endif
ifeq ($(WITH_LIBR),1)
ifeq ($(CC),emcc)
MLFLAGS=
else
ifeq ($(OSTYPE),darwin)
MLFLAGS+=-install_name @rpath/libr2.dylib
endif
@ -59,6 +62,7 @@ ifeq ($(OSTYPE),ios)
MLFLAGS+=-install_name @rpath/libr2.dylib
MLFLAGS+=-fembed-bitcode
endif
endif
LDFLAGS+=${SSL_LDFLAGS}
# XXX version-script only works with shlib as output
#ifeq ($(OSTYPE),linux)
@ -66,6 +70,7 @@ LDFLAGS+=${SSL_LDFLAGS}
#endif
# from env: ALFLAGS+=$(ALFLAGS)
# ${PARTIALLD} $(ALFLAGS) $(MLFLAGS) $(PLFLAGS) -o .libr/$$(basename $${LIB}.a).o $${LIB}
.libr: $(wildcard */libr_*.${EXT_AR}) ../shlr/libr_shlr.${EXT_AR}
rm -rf .libr
mkdir -p .libr

View file

@ -1,5 +1,4 @@
STATIC="
asm.java
asm.arm_cs
asm.dalvik
asm.x86_cs
@ -11,13 +10,12 @@ anal.avr
anal.mips_cs
anal.x86_cs
anal.arm_cs
anal.java
anal.dalvik
anal.wasm
fs.posix
bin.any
bin.elf
bin.elf64
bin.java
bin.dex
bin.pe
bin.mz
@ -27,7 +25,6 @@ bin.mach064
bin.wasm
bin_xtr.xtr_fatmach0
bin_xtr.xtr_sep64
core.java
core.a2f
bp.arm
bp.x86
@ -64,23 +61,6 @@ io.gdb
io.bochs
io.haret
bin_xtr.dyldcache
fs.fat
fs.ntfs
fs.ext2
fs.hfs
fs.hfsplus
fs.reiserfs
fs.tar
fs.cpio
fs.xfs
fs.iso9660
fs.udf
fs.ufs
fs.posix
fs.jfs
fs.minix
fs.fb
fs.sfs
io.ptrace
io.procpid
io.shm

View file

@ -1,5 +1,5 @@
include ../global.mk
include ../config-user.mk
include ../global.mk
# for EXT_EXE
include ../libr/config.mk
include ../mk/platform.mk
@ -409,10 +409,19 @@ SHLRS+=zip/librz.a
libr_shlr.${EXT_AR}:
rm -rf .libr
mkdir .libr
ifeq ($(CC),emcc)
for LIB in ${SHLRS} ; do \
if [ -f "$${LIB}" ]; then emcc -emit-llvm -nostdlib -Wl,--whole-archive -o .libr/$$(basename $${LIB}.a).o $${LIB} ; fi ; \
done
${AR} crs $@ .libr/*.o
$(RANLIB) $@
else
for LIB in ${SHLRS} ; do \
if [ -f "$${LIB}" ]; then ${PARTIALLD} -o .libr/$$(basename $${LIB}.a).o $${LIB} ; fi ; \
done
${AR} crs $@ .libr/*.o
$(RANLIB) $@
endif
.PHONY: spp

View file

@ -4,7 +4,7 @@
#include "code.h"
#include "ops.h"
R_IPI struct java_op JAVA_OPS[JAVA_OPS_COUNT] = {
R_API struct java_op JAVA_OPS[JAVA_OPS_COUNT] = {
{ "nop" , 0x00, 1, R_ANAL_JAVA_NOP },
{ "aconst_null" , 0x01, 1, R_ANAL_JAVA_LDST_LOAD_FROM_CONST_REF_TO_STACK },
{ "iconst_m1" , 0x02, 1, R_ANAL_JAVA_LDST_LOAD_FROM_CONST_TO_STACK },

View file

@ -13,7 +13,8 @@ export CC="emcc --ignore-dynamic-linking -Oz"
export AR="emar"
CFGFLAGS="--prefix=/usr --with-compiler=emscripten"
CFGFLAGS="${CFGFLAGS} --disable-debugger --with-libr"
CFGFLAGS="${CFGFLAGS} --host x86_64-unknown-linux"
CFGFLAGS="${CFGFLAGS} --disable-debugger --with-libr --without-gpl"
CFGFLAGS="${CFGFLAGS} --without-libuv --without-jemalloc"
CFGFLAGS="${CFGFLAGS} --without-fork" # no process support in Emscripten

View file

@ -4,6 +4,17 @@ set -x
export PATH=${TRAVIS_BUILD_DIR}/install/bin:${PATH}
export LD_LIBRARY_PATH=${TRAVIS_BUILD_DIR}/install/lib/$(uname -m)-linux-gnu:${TRAVIS_BUILD_DIR}/install/lib:${TRAVIS_BUILD_DIR}/install/lib64:${LD_LIBRARY_PATH}
if [ "${EMSCRIPTEN}" = "1" ] ; then
git clone https://github.com/emscripten-core/emsdk.git || exit 1
cd emsdk || exit 1
./emsdk install latest || exit 1
./emsdk activate latest || exit 1
source ./emsdk_env.sh
cd ..
sys/emscripten.sh
exit $?
fi
if [ "${INSTALL_SYSTEM}" == "meson" ] ; then
echo "Installing with meson + ninja"