Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation fails on macos big sur #108

Closed
mseri opened this issue Apr 22, 2021 · 2 comments
Closed

Compilation fails on macos big sur #108

mseri opened this issue Apr 22, 2021 · 2 comments

Comments

@mseri
Copy link

mseri commented Apr 22, 2021

You can see the failure below:

[...]
CC src/script.c
src/script.c:30:37: error: array has incomplete element type 'const struct luaL_reg'
static const struct luaL_reg addrlib[] = {
                                    ^
src/script.c:30:21: note: forward declaration of 'struct luaL_reg'
static const struct luaL_reg addrlib[] = {
                    ^
src/script.c:36:38: error: array has incomplete element type 'const struct luaL_reg'
static const struct luaL_reg statslib[] = {
                                     ^
src/script.c:30:21: note: forward declaration of 'struct luaL_reg'
static const struct luaL_reg addrlib[] = {
                    ^
src/script.c:42:39: error: array has incomplete element type 'const struct luaL_reg'
static const struct luaL_reg threadlib[] = {
                                      ^
src/script.c:30:21: note: forward declaration of 'struct luaL_reg'
static const struct luaL_reg addrlib[] = {
                    ^
src/script.c:54:5: error: implicit declaration of function 'luaL_register' is invalid in C99
      [-Werror,-Wimplicit-function-declaration]
    luaL_register(L, NULL, addrlib);
    ^
src/script.c:111:20: error: implicit declaration of function 'lua_objlen' is invalid in C99
      [-Werror,-Wimplicit-function-declaration]
    size_t count = lua_objlen(L, -1);
                   ^
src/script.c:352:21: error: implicit declaration of function 'luaL_checkint' is invalid in C99
      [-Werror,-Wimplicit-function-declaration]
        int index = luaL_checkint(L, 2);
                    ^
src/script.c:352:21: note: did you mean 'luaL_checkany'?
/opt/local/include/lauxlib.h:60:18: note: 'luaL_checkany' declared here
LUALIB_API void (luaL_checkany) (lua_State *L, int arg);
                 ^
src/script.c:476:5: error: implicit declaration of function 'gettimeofday' is invalid in C99
      [-Werror,-Wimplicit-function-declaration]
    gettimeofday(&tv, NULL);
    ^
7 errors generated.
make: *** [obj/script.o] Error 1

The last issue, implicit declaration of function 'gettimeofday' is invalid in C99 can be fixed adding #include <sys/time.h>, but I don't know how I was not able to find an immediate fix the other failures.

@mseri
Copy link
Author

mseri commented Apr 22, 2021

I was preparing a PR for gettimeoftheday error, but it is already fixed here: #103

@mseri
Copy link
Author

mseri commented Apr 22, 2021

Oh sorry for the noise, the line before last spoiled it. I had already luajit from macports which took precedence in the includes, I fixed it by giving precedence to the local sources. A leave the patch here in case somebody will have the same issue

From 58e1adbc9e08988d219a04abb73f1c23cb9e10a7 Mon Sep 17 00:00:00 2001
From: Marcello Seri <[email protected]>
Date: Thu, 22 Apr 2021 09:42:11 +0200
Subject: [PATCH] Update Makefile to give precedence to local sources

Signed-off-by: Marcello Seri <[email protected]>
---
 Makefile | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/Makefile b/Makefile
index a537a68..e25d7e9 100644
--- a/Makefile
+++ b/Makefile
@@ -1,8 +1,20 @@
-CFLAGS  := -std=c99 -Wall -O2 -D_REENTRANT
+FLAGS  := -std=c99 -Wall -O2 -D_REENTRANT
 LIBS    := -lpthread -lm -lcrypto -lssl
 
 TARGET  := $(shell uname -s | tr '[A-Z]' '[a-z]' 2>/dev/null || echo unknown)
 
+SRC  := wrk.c net.c ssl.c aprintf.c stats.c script.c units.c \
+		ae.c zmalloc.c http_parser.c tinymt64.c hdr_histogram.c
+BIN  := wrk
+
+ODIR := obj
+OBJ  := $(patsubst %.c,$(ODIR)/%.o,$(SRC)) $(ODIR)/bytecode.o
+
+LDIR     = deps/luajit/src
+LIBS    := -lluajit $(LIBS)
+CFLAGS  += -I$(LDIR)
+LDFLAGS += -L$(LDIR)
+
 ifeq ($(TARGET), sunos)
 	CFLAGS += -D_PTHREADS -D_POSIX_C_SOURCE=200112L
 	LIBS   += -lsocket
@@ -11,8 +23,8 @@ else ifeq ($(TARGET), darwin)
 	# is not set then it's forced to 10.4, which breaks compile on Mojave.
 	export MACOSX_DEPLOYMENT_TARGET = $(shell sw_vers -productVersion)
 	LDFLAGS += -pagezero_size 10000 -image_base 100000000
-	LIBS += -L/usr/local/opt/openssl/lib
-	CFLAGS += -I/usr/local/include -I/usr/local/opt/openssl/include
+	LIBS += -L/opt/local/lib
+	CFLAGS += -I/usr/local/include -I/opt/local/include
 else ifeq ($(TARGET), linux)
         CFLAGS  += -D_POSIX_C_SOURCE=200809L -D_BSD_SOURCE
 	LIBS    += -ldl
@@ -22,18 +34,6 @@ else ifeq ($(TARGET), freebsd)
 	LDFLAGS += -Wl,-E
 endif
 
-SRC  := wrk.c net.c ssl.c aprintf.c stats.c script.c units.c \
-		ae.c zmalloc.c http_parser.c tinymt64.c hdr_histogram.c
-BIN  := wrk
-
-ODIR := obj
-OBJ  := $(patsubst %.c,$(ODIR)/%.o,$(SRC)) $(ODIR)/bytecode.o
-
-LDIR     = deps/luajit/src
-LIBS    := -lluajit $(LIBS)
-CFLAGS  += -I$(LDIR)
-LDFLAGS += -L$(LDIR)
-
 all: $(BIN)
 
 clean:
-- 
2.24.3 (Apple Git-128)

@mseri mseri closed this as completed Apr 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant