mirror of
https://github.com/radareorg/radare2
synced 2026-08-22 20:23:32 -04:00
Compile with FilC and ship the artifacts ##ci
This commit is contained in:
parent
c91ba85164
commit
2b83e78bdf
17 changed files with 145 additions and 29 deletions
25
.github/workflows/build.yml
vendored
25
.github/workflows/build.yml
vendored
|
|
@ -11,7 +11,6 @@ concurrency:
|
|||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
# WASI
|
||||
linux-wasi:
|
||||
runs-on: ubuntu-22.04
|
||||
env:
|
||||
|
|
@ -111,6 +110,28 @@ jobs:
|
|||
name: tarball
|
||||
path: radare2-?.?.?.*
|
||||
|
||||
filc:
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
- name: Extract r2 version
|
||||
shell: bash
|
||||
run: echo "branch=`./configure -qV`" >> $GITHUB_OUTPUT
|
||||
id: r2v
|
||||
- name: Install dependencies
|
||||
run: sudo apt-get update && sudo apt-get install -y curl git gperf patchelf xz-utils
|
||||
- name: Build with filc
|
||||
run: ./sys/filc.sh --prefix=/opt/r2filc
|
||||
- name: Install filc build
|
||||
run: sudo make install
|
||||
- name: Create filc tarball
|
||||
run: tar -cJvf radare2-${{ steps.r2v.outputs.branch }}-filc.tar.xz /opt/r2filc
|
||||
- uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: filc
|
||||
path: radare2-*-filc.tar.xz
|
||||
|
||||
# Linux
|
||||
linux-static:
|
||||
strategy:
|
||||
|
|
@ -788,6 +809,7 @@ jobs:
|
|||
- linux-wasi-api
|
||||
- linux-wasi-browser
|
||||
- tarball
|
||||
- filc
|
||||
# - linux-static
|
||||
# - linux-acr-rpm-64
|
||||
- linux-acr-deb
|
||||
|
|
@ -827,6 +849,7 @@ jobs:
|
|||
env:
|
||||
ASSET_FILES: |
|
||||
dist/artifacts/tarball/*.tar.xz
|
||||
dist/artifacts/filc/*.tar.xz
|
||||
dist/artifacts/linux-acr-deb-*/radare2_*.deb
|
||||
dist/artifacts/w64-meson/*.zip
|
||||
dist/artifacts/w32-meson/*.zip
|
||||
|
|
|
|||
|
|
@ -103,6 +103,7 @@ HAVE_LIB_MAGIC=@HAVE_LIB_MAGIC@
|
|||
USE_LIB_MAGIC=@USE_LIB_MAGIC@
|
||||
HAVE_LIB_XXHASH=@HAVE_LIB_XXHASH@
|
||||
USE_LIB_XXHASH=@USE_LIB_XXHASH@
|
||||
WANT_ZIP=@WANT_ZIP@
|
||||
USE_LIB_ZIP=@USE_LIB_ZIP@
|
||||
LIBATOMIC=@LIBATOMIC@
|
||||
LIBMAGIC=@LIBMAGIC@
|
||||
|
|
|
|||
|
|
@ -1,9 +1,11 @@
|
|||
/* radare - LGPL - Copyright 2022-2025 - pancake */
|
||||
/* radare - LGPL - Copyright 2022-2026 - pancake */
|
||||
|
||||
#include <r_fs.h>
|
||||
#include <r_lib.h>
|
||||
#include <zip.h>
|
||||
#include <sys/stat.h>
|
||||
#include <r_userconf.h>
|
||||
#if WANT_ZIP
|
||||
#include <zip.h>
|
||||
|
||||
static RFSFile *fs_zip_open(RFSRoot *root, const char *path, bool create) {
|
||||
R_LOG_INFO ("zip.open (%s)", path);
|
||||
|
|
@ -94,13 +96,12 @@ static void fs_zip_close(RFSFile *file) {
|
|||
|
||||
static void append_file(RList *list, const char *name, int type, int time, ut64 size) {
|
||||
RFSFile *fsf = r_fs_file_new (NULL, name);
|
||||
if (!fsf) {
|
||||
return;
|
||||
if (fsf) {
|
||||
fsf->type = type;
|
||||
fsf->time = time;
|
||||
fsf->size = size;
|
||||
r_list_append (list, fsf);
|
||||
}
|
||||
fsf->type = type;
|
||||
fsf->time = time;
|
||||
fsf->size = size;
|
||||
r_list_append (list, fsf);
|
||||
}
|
||||
|
||||
static RList *fs_zip_dir(RFSRoot *root, const char *path, R_UNUSED int view) {
|
||||
|
|
@ -208,6 +209,16 @@ RFSPlugin r_fs_plugin_zip = {
|
|||
.close = fs_zip_close,
|
||||
.dir = &fs_zip_dir,
|
||||
};
|
||||
#else
|
||||
RFSPlugin r_fs_plugin_zip = {
|
||||
.meta = {
|
||||
.name = "zip",
|
||||
.author = "pancake",
|
||||
.desc = "access compressed zip contents (not available)",
|
||||
.license = "MIT",
|
||||
},
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifndef R2_PLUGIN_INCORE
|
||||
R_API RLibStruct radare_plugin = {
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
#include <kernel/scheduler.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_PTHREAD || R2__WINDOWS__
|
||||
#if R2__WINDOWS__
|
||||
static DWORD WINAPI _r_th_launcher(void *_th) {
|
||||
#else
|
||||
|
|
@ -93,6 +94,7 @@ static void *_r_th_launcher(void *_th) {
|
|||
#endif
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
R_API bool r_th_is_running(RThread *th) {
|
||||
r_th_lock_enter (th->lock);
|
||||
|
|
@ -124,8 +126,7 @@ R_API R_TH_TID r_th_self(void) {
|
|||
#elif R2__WINDOWS__
|
||||
return GetCurrentThread ();
|
||||
#else
|
||||
#pragma message("Not implemented on this platform")
|
||||
return (R_TH_TID)-1;
|
||||
return (R_TH_TID)0;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -209,7 +210,7 @@ R_API RThread *r_th_new(RThreadFunction fun, void *user, ut32 delay) {
|
|||
#elif R2__WINDOWS__
|
||||
th->tid = CreateThread (NULL, 0, _r_th_launcher, th, 0, 0);
|
||||
#endif
|
||||
th->running = true;
|
||||
th->running = !!th->tid;
|
||||
return th;
|
||||
}
|
||||
|
||||
|
|
|
|||
9
mk/filcc.mk
Normal file
9
mk/filcc.mk
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
ifeq (${_INCLUDE_MK_FILCC_},)
|
||||
_INCLUDE_MK_FILCC_=1
|
||||
include $(dir $(lastword $(MAKEFILE_LIST)))clang.mk
|
||||
CFLAGS:=$(filter-out -MD,$(CFLAGS))
|
||||
CC?=filcc
|
||||
AR?=ar
|
||||
RANLIB?=ranlib
|
||||
LD?=ld
|
||||
endif
|
||||
|
|
@ -257,13 +257,17 @@ bool bochs_open(libbochs_t* b, const char * pathBochs, const char * pathConfig)
|
|||
|
||||
if (pipe (aStdinPipe) < 0) {
|
||||
R_LOG_ERROR ("allocating pipe for child input redirect");
|
||||
goto done;
|
||||
R_FREE (b->data);
|
||||
R_FREE (lpTmpBuffer);
|
||||
return result;
|
||||
}
|
||||
if (pipe(aStdoutPipe) < 0) {
|
||||
if (pipe (aStdoutPipe) < 0) {
|
||||
close (aStdinPipe[PIPE_READ]);
|
||||
close (aStdinPipe[PIPE_WRITE]);
|
||||
R_LOG_ERROR ("allocating pipe for child output redirect");
|
||||
goto done;
|
||||
R_FREE (b->data);
|
||||
R_FREE (lpTmpBuffer);
|
||||
return result;
|
||||
}
|
||||
|
||||
nChild = fork ();
|
||||
|
|
@ -324,7 +328,6 @@ bool bochs_open(libbochs_t* b, const char * pathBochs, const char * pathConfig)
|
|||
close (aStdoutPipe[PIPE_WRITE]);
|
||||
}
|
||||
#endif
|
||||
done:
|
||||
R_FREE (b->data);
|
||||
R_FREE (lpTmpBuffer);
|
||||
return result;
|
||||
|
|
|
|||
|
|
@ -60,10 +60,10 @@ static int iob_pipe_write(void *p, const uint8_t *buf, const uint64_t count, con
|
|||
#include <sys/un.h>
|
||||
|
||||
static void *iob_pipe_open(const char *path) {
|
||||
#ifndef __wasi__
|
||||
int sock;
|
||||
struct sockaddr_un sa;
|
||||
|
||||
#ifndef __wasi__
|
||||
sock = socket (AF_UNIX, SOCK_STREAM, 0);
|
||||
if (sock == -1) {
|
||||
perror ("socket");
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ include ../../libr/config.mk
|
|||
include ../../mk/platform.mk
|
||||
include ../../mk/$(COMPILER).mk
|
||||
include ../../shlr/sdb.mk
|
||||
SHLR?=..
|
||||
|
||||
pre: all
|
||||
|
||||
|
|
@ -13,10 +14,14 @@ include deps.mk
|
|||
|
||||
all:
|
||||
rm -f librz.$(EXT_AR)
|
||||
ifneq ($(WANT_ZIP),1)
|
||||
@echo zip support disabled
|
||||
else
|
||||
ifeq ($(USE_LIB_ZIP),1)
|
||||
@echo no bundled zip to build
|
||||
else
|
||||
$(MAKE) $(OTEZIP_LIBA)
|
||||
$(MAKE) -C $(OTEZIP_ROOT) CC="$(CC)" EXT_AR="$(EXT_AR)" AR="$(AR)" RANLIB="$(RANLIB)" CFLAGS="$(CFLAGS) -fPIC" libotezip.$(EXT_AR)
|
||||
endif
|
||||
endif
|
||||
|
||||
clean:
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
ifneq (${_INCLUDE_ZIP_DEPS_MK},1)
|
||||
_INCLUDE_ZIP_DEPS_MK=1
|
||||
|
||||
# Link against system libzip when USE_LIB_ZIP=1
|
||||
# Otherwise link against bundled otezip from subprojects/otezip
|
||||
# Link against system libzip when USE_LIB_ZIP=1.
|
||||
# Otherwise link against bundled otezip from subprojects/otezip.
|
||||
ifeq ($(WANT_ZIP),1)
|
||||
ifeq ($(USE_LIB_ZIP),1)
|
||||
LINK+=$(LIBZIP)
|
||||
else
|
||||
|
|
@ -14,5 +15,6 @@ $(OTEZIP_LIBA):
|
|||
$(MAKE) -C $(OTEZIP_ROOT) CC="$(CC)" EXT_AR="$(EXT_AR)" AR="$(AR)" RANLIB="$(RANLIB)" CFLAGS="$(CFLAGS) -fPIC" libotezip.$(EXT_AR)
|
||||
LINK+=$(OTEZIP_LIBA)
|
||||
endif
|
||||
endif
|
||||
|
||||
endif
|
||||
|
|
|
|||
|
|
@ -2,7 +2,17 @@
|
|||
|
||||
-include ../config-user.mk
|
||||
|
||||
DEPS=sdb qjs otezip
|
||||
DEPS=sdb
|
||||
|
||||
ifeq ($(WANT_QJS),1)
|
||||
DEPS += qjs
|
||||
endif
|
||||
|
||||
ifeq ($(WANT_ZIP),1)
|
||||
ifeq ($(USE_LIB_ZIP),0)
|
||||
DEPS += otezip
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(WANT_V35),1)
|
||||
DEPS += binaryninja
|
||||
|
|
|
|||
45
sys/filc.sh
Executable file
45
sys/filc.sh
Executable file
|
|
@ -0,0 +1,45 @@
|
|||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
ROOT=$(CDPATH= cd -- "$(dirname "$0")/.." && pwd)
|
||||
FILC_DIR="$ROOT/sys/filc"
|
||||
FILC_VERSION=${FILC_VERSION:-0.678}
|
||||
FILC_NAME="filc-${FILC_VERSION}-linux-x86_64"
|
||||
FILC_ROOT=${FILC_ROOT:-$FILC_DIR/$FILC_NAME}
|
||||
|
||||
if [ "$(uname -s)-$(uname -m)" != "Linux-x86_64" ]; then
|
||||
echo "filc only supports linux-amd64, falling back to Docker..."
|
||||
docker build -t r2filc -f "$FILC_DIR/Dockerfile" "$FILC_DIR"
|
||||
exec docker run --rm -v "$ROOT:/r2" -w /r2 r2filc ./sys/filc.sh "$@"
|
||||
fi
|
||||
|
||||
command -v filcc || [ -x "$FILC_ROOT/build/bin/filcc" ] || {
|
||||
mkdir -p "$FILC_DIR"
|
||||
[ -f "$FILC_DIR/$FILC_NAME.tar.xz" ] || \
|
||||
curl -L --fail -o "$FILC_DIR/$FILC_NAME.tar.xz" \
|
||||
"https://github.com/pizlonator/fil-c/releases/download/v${FILC_VERSION}/${FILC_NAME}.tar.xz"
|
||||
[ -d "$FILC_ROOT" ] || \
|
||||
tar -C "$FILC_DIR" -xf "$FILC_DIR/$FILC_NAME.tar.xz"
|
||||
}
|
||||
|
||||
[ ! -x "$FILC_ROOT/setup.sh" ] || [ -L "$FILC_ROOT/pizfix/os-include/linux" ] || (cd "$FILC_ROOT" && ./setup.sh)
|
||||
|
||||
if [ -d "$FILC_ROOT/pizfix/lib" ] && command -v cc; then
|
||||
for obj in Scrt1.o crtbegin.o crtend.o crti.o crtn.o; do
|
||||
dst="$FILC_ROOT/pizfix/lib/$obj"
|
||||
[ -e "$dst" ] && continue
|
||||
src=$(cc -print-file-name="$obj" || true)
|
||||
[ -n "$src" ] && [ "$src" != "$obj" ] && [ -e "$src" ] && ln -s "$src" "$dst"
|
||||
done
|
||||
fi
|
||||
|
||||
FILC_BIN=$(dirname "$(command -v filcc || echo "$FILC_ROOT/build/bin/filcc")")
|
||||
export PATH="$FILC_BIN:$PATH" CC=filcc USERCC=filcc HOST_CC=${HOST_CC:-cc}
|
||||
|
||||
[ -z "${MAKE:-}" ] && MAKE=make
|
||||
cd "$ROOT"
|
||||
. ./sys/make-jobs.inc.sh
|
||||
${MAKE} mrproper || true
|
||||
[ -z "${KEEP_PLUGINS_CFG:-}" ] && rm -f plugins.cfg
|
||||
./configure --with-rpath "$@" || exit 1
|
||||
${MAKE} -j || exit 1
|
||||
6
sys/filc/Dockerfile
Normal file
6
sys/filc/Dockerfile
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
FROM ubuntu:24.04
|
||||
RUN apt-get update && DEBIAN_FRONTEND=noninteractive \
|
||||
apt-get install -y --no-install-recommends \
|
||||
ca-certificates curl gcc make patchelf pkg-config tar xz-utils \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
WORKDIR /r2
|
||||
|
|
@ -100,10 +100,10 @@ else
|
|||
cp -f dist/plugins-cfg/plugins.ios.cfg plugins.cfg
|
||||
if [ "$static" = 1 ]; then
|
||||
./configure --prefix="${PREFIX}" --with-ostype=darwin \
|
||||
--with-compiler=ios-sdk-clang --target=arm-unknown-darwin --with-libr --without-zip
|
||||
--with-compiler=ios-sdk-clang --target=arm-unknown-darwin --with-libr
|
||||
else
|
||||
./configure --prefix="${PREFIX}" --with-ostype=darwin \
|
||||
--with-compiler=ios-sdk-clang --target=arm-unknown-darwin --without-zip
|
||||
--with-compiler=ios-sdk-clang --target=arm-unknown-darwin
|
||||
fi
|
||||
RV=$?
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
[ -z "${MAKE_JOBS}" ] && MAKE_JOBS=12
|
||||
[ -z "${MAKE_JOBS:-}" ] && MAKE_JOBS=12
|
||||
export MAKE_JOBS
|
||||
|
||||
GetPlatform() {
|
||||
|
|
@ -26,7 +26,7 @@ BuildJobsThrottler(){
|
|||
FREE_RAM=$(grep MemAvailable /proc/meminfo | sed 's/[^0-9]//g')
|
||||
|
||||
DEFAULT_MAX_MEM_PER_JOB=200000
|
||||
[ -z "${MAX_MEM_PER_JOB}" ] && MAX_MEM_PER_JOB="$DEFAULT_MAX_MEM_PER_JOB" # Defensive, prevent division by 0
|
||||
[ -z "${MAX_MEM_PER_JOB:-}" ] && MAX_MEM_PER_JOB="$DEFAULT_MAX_MEM_PER_JOB" # Defensive, prevent division by 0
|
||||
|
||||
# Assuming we may have many 300MB compilation jobs running in parallel
|
||||
MEM_ALLOWED_JOBS=$((FREE_RAM / MAX_MEM_PER_JOB))
|
||||
|
|
@ -40,7 +40,7 @@ BuildJobsThrottler(){
|
|||
echo "So, the build will run on $MAKE_JOBS job(s)."
|
||||
}
|
||||
|
||||
if [ "${OSNAME}" = Linux ]; then
|
||||
if [ "${OSNAME:-}" = Linux ]; then
|
||||
# Identify current platform
|
||||
GetPlatform
|
||||
# Define number of parallel jobs depending on ncpus and memory
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ wasi_setup_sdk
|
|||
wasi_setup_plugins
|
||||
|
||||
# Configure and build
|
||||
./configure --with-static-themes --without-gperf --with-compiler=wasi --disable-debugger --without-fork --with-ostype=wasi-api --with-checks-level=0 --disable-threads --without-dylink --with-libr --without-gpl --without-zip || exit 1
|
||||
./configure --with-static-themes --without-gperf --with-compiler=wasi --disable-debugger --without-fork --with-ostype=wasi-api --with-checks-level=0 --disable-threads --without-dylink --with-libr --without-gpl || exit 1
|
||||
|
||||
make -s -j${MAKE_JOBS} || exit 1
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ wasi_setup_plugins
|
|||
# Configure and build
|
||||
# XXX gperf-builds are broken
|
||||
# ./configure --with-static-themes --with-compiler=wasi --disable-debugger --without-fork --with-ostype=wasi --with-checks-level=0 --disable-threads --without-dylink --with-libr --without-gpl
|
||||
./configure --with-static-themes --without-gperf --with-compiler=wasi --disable-debugger --without-fork --with-ostype=wasi --with-checks-level=0 --disable-threads --without-dylink --with-libr --without-gpl --with-wasm-browser --without-zip || exit 1
|
||||
./configure --with-static-themes --without-gperf --with-compiler=wasi --disable-debugger --without-fork --with-ostype=wasi --with-checks-level=0 --disable-threads --without-dylink --with-libr --without-gpl --with-wasm-browser || exit 1
|
||||
|
||||
make -s -j${MAKE_JOBS} || exit 1
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ wasi_setup_plugins
|
|||
# Configure and build
|
||||
# XXX gperf-builds are broken
|
||||
# ./configure --with-static-themes --with-compiler=wasi --disable-debugger --without-fork --with-ostype=wasi --with-checks-level=0 --disable-threads --without-dylink --with-libr --without-gpl
|
||||
./configure --with-static-themes --without-gperf --with-compiler=wasi --disable-debugger --without-fork --with-ostype=wasi --with-checks-level=0 --disable-threads --without-dylink --with-libr --without-gpl --without-zip || exit 1
|
||||
./configure --with-static-themes --without-gperf --with-compiler=wasi --disable-debugger --without-fork --with-ostype=wasi --with-checks-level=0 --disable-threads --without-dylink --with-libr --without-gpl || exit 1
|
||||
|
||||
make -s -j${MAKE_JOBS} || exit 1
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue