Skip to content

Commit

Permalink
Fix compilation on macos. Add macos to CI
Browse files Browse the repository at this point in the history
  • Loading branch information
813gan committed Aug 12, 2024
1 parent febd6ee commit b7d708c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ jobs:
matrix:
os: [ubuntu-latest]
emacs_version: [27.2, 28.2, 29.3, snapshot]
python_version: [3.12.4]
python_version: [3.12.4, 3.x]
include:
- os: macos-latest
emacs_version: snapshot
steps:
- uses: actions/checkout@v4
- uses: purcell/setup-emacs@master
Expand Down
16 changes: 11 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ ifeq ("$(EMACS)","")
EMACS := emacs
endif

HARDENING_FLAGS=-fstack-protector -fstack-clash-protection -fcf-protection \
-D_FORTIFY_SOURCE=2 -ftrapv

UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S), Darwin) # Clang does not support some gcc options
GCC_NO_WARN=-Wno-unused-command-line-argument
HARDENING_FLAGS=''
endif

.PHONY: all clean test_module_assertions test

Expand All @@ -20,12 +28,10 @@ emacspy.so: LIBPYTHON_NAME=$(shell ${PYTHON} -c \
'import sysconfig; print(sysconfig.get_config_var("LDLIBRARY"))')
emacspy.so: emacspy.c stub.c subinterpreter.c
gcc -O2 -fPIC -g -DCYTHON_FAST_THREAD_STATE=0 -DCYTHON_PEP489_MULTI_PHASE_INIT=0 \
-Wall -Wextra -Werror -fstack-protector -fstack-clash-protection -fcf-protection \
-D_FORTIFY_SOURCE=2 -ftrapv \
emacspy.c stub.c \
-Wall -Wextra -Werror ${GCC_NO_WARN} ${HARDENING_FLAGS} \
${BLDLIBRARY} -DLIBPYTHON_NAME=$(LIBPYTHON_NAME) \
-shared $(shell pkg-config --cflags --libs $(PKGCONFIG_PATH)"/python3.pc") \
-o emacspy.so
-shared $(shell pkg-config --cflags --libs $(PKGCONFIG_PATH)"/python3-embed.pc") \
emacspy.c stub.c -o emacspy.so

clean:
rm -vf emacspy.c emacspy.so
Expand Down
4 changes: 2 additions & 2 deletions subinterpreter.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ struct interpr *get_interpreter(char *name) {
}

void make_interpreter(char *inter_name) {
u_int name_len = strnlen(inter_name, MAX_INTERPRETER_NAME_LEN) + 1;
unsigned int name_len = strnlen(inter_name, MAX_INTERPRETER_NAME_LEN) + 1;
char *name = malloc(name_len);
strncpy(name, inter_name, name_len);

Expand Down Expand Up @@ -157,7 +157,7 @@ PyObject* call_method(PyObject *obj_name, PyObject *method_name, PyObject *args_
goto finish;
}

for (u_int i = 0; i < nargs; ++i) {
for (unsigned int i = 0; i < nargs; ++i) {
obj_with_args[1 + i] = PyList_GetItem(args_pylist, i);
}

Expand Down

0 comments on commit b7d708c

Please sign in to comment.