Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .clangd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CompileFlags:
Add: [-DUMKA_BUILD -DUMKA_EXT_LIBS]
Add: [-DUMKA_BUILD -DUMKA_EXT_LIBS -DUMKA_FFI -I../libffi/build/include]
InlayHints:
Enabled: No
42 changes: 42 additions & 0 deletions .github/workflows/main-ffi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# This is a basic workflow to help you get started with Actions

name: CI (FFI)

# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [ master ]
pull_request:
branches: [ master ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
build:
strategy:
fail-fast: false
matrix:
os: [ macos-latest, ubuntu-latest ]

# The operating system of the runner the job will run on
runs-on: ${{ matrix.os }}

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
with:
submodules: true

# prepare system for libffi build
- name: install dependencies
run: libffi/.ci/install.sh

# Build it
- name: build
run: make all
env:
UMKA_LIBFFI: 1
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "libffi"]
path = libffi
url = https://github.com/libffi/libffi
49 changes: 42 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ BINDIR ?= $(PREFIX)/bin

# platform specific settings:
ifeq ($(PLATFORM), Linux)
LDFLAGS = -lm -ldl
LDFLAGS = -lm -ldl $(LIBFFI_LD)
RANLIB = ar -crs
LIBEXT = so
DYNAMIC_CFLAGS_EXTRA = -shared -fvisibility=hidden
Expand All @@ -29,12 +29,28 @@ else ifneq ($(findstring MINGW64_NT,$(PLATFORM)),)
DYNAMIC_CFLAGS_EXTRA = -shared -fvisibility=hidden
endif

ifeq ($(UMKA_LIBFFI),)
LIBFFI_LIBS =
LIBFFI_LIB =
LIBFFI_LD =
LIBFFI_STATIC =
LIBFFI_INCLUDE =
else
LIBFFI_LIBS = ./libffi/build/.libs
LIBFFI_LIB = libffi.a
LIBFFI_LD = -L$(LIBFFI_LIBS) -l:$(LIBFFI_LIB)
LIBFFI_STATIC = $(LIBFFI_LIBS)/$(LIBFFI_LIB)
LIBFFI_INCLUDE = ./libffi/build/include
LIBFFI_CFLAGS = -I$(LIBFFI_INCLUDE) -DUMKA_FFI
endif

# identical for all platforms:
UMKA_LIB_STATIC = $(BUILD_PATH)/libumka.a
UMKA_LIB_DYNAMIC = $(BUILD_PATH)/libumka.$(LIBEXT)
UMKA_EXE = $(BUILD_PATH)/umka

CFLAGS = -s -fPIC -O3 -Wall -Wno-format-security -malign-double -fno-strict-aliasing -DUMKA_EXT_LIBS
#CFLAGS = -s -fPIC -O3 -Wall -Wno-format-security -malign-double -fno-strict-aliasing -DUMKA_EXT_LIBS
CFLAGS = -fPIC -ggdb -Wall -Wno-format-security -malign-double -fno-strict-aliasing -DUMKA_EXT_LIBS $(LIBFFI_CFLAGS)
STATIC_CFLAGS = $(CFLAGS) -DUMKA_STATIC
DYNAMIC_CFLAGS = $(CFLAGS) -DUMKA_BUILD $(DYNAMIC_CFLAGS_EXTRA)

Expand Down Expand Up @@ -80,29 +96,48 @@ uninstall:
@rm -f -- $(DESTDIR)$(INCLUDEDIR)/umka_api.h
@echo "Uninstallation complete!"

$(UMKA_LIB_STATIC): $(OBJS_STATIC)
$(UMKA_LIB_STATIC): $(OBJS_STATIC) $(LIBFFI_STATIC)
@echo AR $@
@mkdir -p -- $(BUILD_PATH)/include/
@$(RANLIB) $(UMKA_LIB_STATIC) $^
@cp $(APIS) $(BUILD_PATH)/include/

$(UMKA_LIB_DYNAMIC): $(OBJS_DYNAMIC)
$(UMKA_LIB_DYNAMIC): $(OBJS_DYNAMIC) $(LIBFFI_STATIC)
@echo LD $@
@mkdir -p -- $(BUILD_PATH)/include/
@$(CC) $(DYNAMIC_CFLAGS) -o $(UMKA_LIB_DYNAMIC) $^ $(LDFLAGS)
@cp $(APIS) $(BUILD_PATH)/include/

$(UMKA_EXE): $(OBJS_EXE) $(UMKA_LIB_STATIC)
$(UMKA_EXE): $(OBJS_EXE) $(UMKA_LIB_STATIC) $(LIBFFI_STATIC)
@echo LD $@
@mkdir -p -- $(dir $@)
@$(CC) $(STATIC_CFLAGS) -o $(UMKA_EXE) $^ $(LDFLAGS)

$(OBJ_PATH)/%_static.o: src/%.c
$(OBJ_PATH)/%_static.o: src/%.c $(LIBFFI_INCLUDE)
@echo CC $@
@mkdir -p -- $(dir $@)
@$(CC) $(STATIC_CFLAGS) -o $@ -c $^

$(OBJ_PATH)/%_dynamic.o: src/%.c
$(OBJ_PATH)/%_dynamic.o: src/%.c $(LIBFFI_INCLUDE)
@echo CC $@
@mkdir -p -- $(dir $@)
@$(CC) $(DYNAMIC_CFLAGS) -o $@ -c $^

.PHONY: libffi/clean
libffi/clean:
rm -rf libffi/build

libffi/build/.libs/libffi.a: libffi/build/Makefile
@cd libffi/build && make

libffi/build/include: libffi/build/Makefile
libffi/build/Makefile: libffi/configure
@mkdir -p -- libffi/build/
@cd libffi/build && CC=-fPIC ../configure --enable-pic

libffi/configure: libffi/autogen.sh
@cd libffi && ./autogen.sh

libffi/autogen.sh:
@git submodule init
@git submodule update
1 change: 1 addition & 0 deletions libffi
Submodule libffi added at e2eda0
1 change: 0 additions & 1 deletion src/umka_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,6 @@ void moduleAddSource(Modules *modules, const char *path, const char *source, boo
modules->moduleSource[modules->numModuleSources++] = moduleSource;
}


void *moduleGetImplLibFunc(const Module *module, const char *name)
{
if (module->implLib)
Expand Down
Loading