bitwalker / picosat_elixir

Elixir + Erlang bindings for the PicoSAT solver
Apache License 2.0
25 stars 5 forks source link

Issue compiling using Burrito and Zig #10

Open m0rt3nlund opened 8 months ago

m0rt3nlund commented 8 months ago

Hi!

I am trying to compile this project as it is part of the Elixir Ash library.

I am compiling it using Burrito which is using Zig (Mingw)

I have tried to make my own .h files that link to the files inside Zig but it is a never ending rabit hole as file x links to y and y to z and so on...

This is the output I get:

52.41 --> Going to recompile NIF for cross-build: picosat_elixir -> x86_64-windows
52.58 rm -f /app/deps/picosat_elixir/priv/lib/picosat_elixir/priv/picosat_nif.so
52.58 rm -f /app/deps/picosat_elixir/priv/*.o
52.58 zig cc -target x86_64-windows -O2 -dynamic -shared -Wl,-undefined=dynamic_lookup -std=c99 -finline-functions -Wall -O3 -DNDEBUG -fPIC -I /tmp/unpacked_erts_F32707FEA96460E8/otp-windows/erts-14.2.2/include -o /app/deps/picosat_elixir/priv/picosat.o -c /app/deps/picosat_elixir/c_src/picosat.c
52.60 /app/deps/picosat_elixir/c_src/picosat.c:2282:50: warning: variable 'count_resolved' set but not used [-Wunused-but-set-variable]
52.60   unsigned num_true, num_undef, num_false, size, count_resolved;
52.60                                                  ^
52.61 /app/deps/picosat_elixir/c_src/picosat.c:5334:12: warning: variable 'collect' set but not used [-Wunused-but-set-variable]
52.61   unsigned collect, delta;
52.61            ^
52.61 /app/deps/picosat_elixir/c_src/picosat.c:6467:12: warning: variable 'num_non_false' set but not used [-Wunused-but-set-variable]
52.61   unsigned num_non_false;
52.61            ^
52.63 /app/deps/picosat_elixir/c_src/picosat.c:8149:10: fatal error: 'sys/resource.h' file not found
52.63 #include <sys/resource.h>
52.63          ^~~~~~~~~~~~~~~~
52.63 3 warnings and 1 error generated.
52.63 make: *** [Makefile:49: /app/deps/picosat_elixir/priv/picosat.o] Error 1
m0rt3nlund commented 8 months ago

I was able to compile it when I added -DNGETRUSAGE=1 to the CFLAGS for Linux

I am not sure how to fix this in a way to allow it to be compiled by Zig though.. I guess this is happening because the Makefilx.win does not apply when compiling picosat_elixir when the host is linux and the target is Windows. Somehow..

UNAME_SYS := $(shell uname -s)
ifeq ($(UNAME_SYS), Darwin)
    CFLAGS := -std=c99 -finline-functions -Wall
    LDFLAGS := -flat_namespace -undefined suppress
else ifeq ($(UNAME_SYS), FreeBSD)
    CFLAGS := -std=c99 -finline-functions -Wall
else ifeq ($(UNAME_SYS), Linux)
    CFLAGS := -std=c99 -finline-functions -Wall -DNGETRUSAGE=1
endif