Skip to content

Commit

Permalink
Basic Build Improvements:
Browse files Browse the repository at this point in the history
- Remove Usage of System OpenSSL
- Update OpenSSL from GitHub as Submodule
- Update LuaJit from GitHub as Submodule
- Fixes for gettimeofday()
- Fixes to use x86 intrinsics only on x86
- Rename to wrk2

Integrate Improvements from GitHub:

- Fixes to Script Copy Value Order - PR giltene#113
- Add Fixes for Mutual TLS Authentication - PR giltene#99
- Add Fixes for TLS Ciphers - PR giltene#107
- Add EOF Handling Error - PR giltene#33
- Add JSON Example - PR giltene#51
- Make Rate Optional (use UINT64_MAX) - PR giltene#130
  • Loading branch information
guilt committed Mar 2, 2023
1 parent 44a94c1 commit bb1b6a8
Show file tree
Hide file tree
Showing 207 changed files with 271 additions and 114,052 deletions.
11 changes: 10 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
*.o
*.obj

*.a
wrk
*.lib

*.out
*.exe

wrk2

deps/luajit/src/host/buildvm
deps/luajit/src/host/buildvm_arch.h
Expand All @@ -16,3 +23,5 @@ deps/luajit/src/luajit

.idea
CMakeLists.txt

*Output
8 changes: 8 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[submodule "deps/luajit"]
path = deps/luajit
url = https://github.com/LuaJIT/LuaJIT
branch = v2.1
[submodule "deps/openssl"]
path = deps/openssl
url = https://github.com/openssl/openssl
branch = master
92 changes: 69 additions & 23 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
CFLAGS := -std=c99 -Wall -O2 -D_REENTRANT
LIBS := -lpthread -lm -lcrypto -lssl

CFLAGS := -Wall -O2 -D_REENTRANT
LIBS := -lpthread -lm
GIT := git
TARGET := $(shell uname -s | tr '[A-Z]' '[a-z]' 2>/dev/null || echo unknown)

ifeq ($(TARGET), sunos)
Expand All @@ -9,57 +9,103 @@ ifeq ($(TARGET), sunos)
else ifeq ($(TARGET), darwin)
# Per https://luajit.org/install.html: If MACOSX_DEPLOYMENT_TARGET
# 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
MACOSX_DEPLOYMENT_TARGET ?= $(shell sw_vers -productVersion)
export MACOSX_DEPLOYMENT_TARGET

CFLAGS += -I/usr/local/include

# Per macOS, the below options are deprecated and going to be removed.
# They cause host/minilua build process to fail, so please remove.
# LDFLAGS += -pagezero_size 10000 -image_base 100000000

else ifeq ($(TARGET), linux)
CFLAGS += -D_POSIX_C_SOURCE=200809L -D_BSD_SOURCE
CFLAGS += -D_POSIX_C_SOURCE=200809L -D_DEFAULT_SOURCE
LIBS += -ldl
LDFLAGS += -Wl,-E
else ifeq ($(TARGET), freebsd)
CFLAGS += -D_DECLARE_C99_LDBL_MATH
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
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 := wrk2

ODIR := obj
OBJ := $(patsubst %.c,$(ODIR)/%.o,$(SRC)) $(ODIR)/bytecode.o

LDIR = deps/luajit/src
LIBS := -lluajit $(LIBS)
CFLAGS += -I$(LDIR)
LDFLAGS += -L$(LDIR)
SDIR = deps/openssl

LDIRFLAGS= BUILDMODE=static
SDIRFLAGS=

# Please do not enable static linking because
# OpenSSL seems to cause issues. This should probably
# get built and tested with MUSL for Linux.
#
# We localize these flags so that they are
# not passed into dependent projects.

ifeq ($(DEBUG), true)
LOCCFLAGS += -O0 -g3
LOCLDFLAGS += -g3
endif

LOCLIBS := $(LDIR)/libluajit.a $(SDIR)/libssl.a $(SDIR)/libcrypto.a
CFLAGS += -I$(LDIR) -I$(SDIR)/include/
LDFLAGS += -L$(LDIR) -L$(SDIR)

all: $(BIN)
all: depends $(BIN)

depends:
$(GIT) submodule update --init --recursive --force

clean:
$(RM) $(BIN) obj/*
@$(MAKE) -C deps/luajit clean
@$(MAKE) -C deps/openssl clean

$(BIN): $(OBJ)
$(BIN): $(OBJ) $(LOCLIBS)
@echo LINK $(BIN)
@$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
@$(CC) $(LOCLDFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)

$(OBJ): config.h Makefile $(LDIR)/libluajit.a | $(ODIR)
$(OBJ): config.h Makefile | $(ODIR)

$(ODIR):
@mkdir -p $@

$(ODIR)/bytecode.o: src/wrk.lua
$(ODIR)/bytecode.o: src/wrk.lua $(LDIR)/luajit
@echo LUAJIT $<
@$(SHELL) -c 'cd $(LDIR) && ./luajit -b $(CURDIR)/$< $(CURDIR)/$@'

$(ODIR)/%.o : %.c
$(ODIR)/%.o : %.c | $(LOCLIBS)
@echo CC $<
@$(CC) $(CFLAGS) -c -o $@ $<
@$(CC) $(LOCCFLAGS) $(CFLAGS) -c -o $@ $<

$(LDIR) $(SDIR): depends

$(LDIR)/libluajit.a:
$(LDIR)/libluajit.a: $(LDIR)
@echo Building LuaJIT...
@$(MAKE) -C $(LDIR) BUILDMODE=static
@[ -f "$@" ] || $(MAKE) -C $(LDIR) $(LDIRFLAGS)

$(LDIR)/luajit: $(LDIR)/libluajit.a

$(SDIR)/libcrypto.a: $(SDIR)
@echo Building OpenSSL...
@[ -f "$@" ] || { cd $(SDIR) && ./config $(SDIRFLAGS) && $(MAKE) ; }

$(SDIR)/libssl.a: $(SDIR)/libcrypto.a

.PHONY: all clean
.SUFFIXES:
Expand Down
1 change: 1 addition & 0 deletions deps/luajit
Submodule luajit added at 505e2c
56 changes: 0 additions & 56 deletions deps/luajit/COPYRIGHT

This file was deleted.

151 changes: 0 additions & 151 deletions deps/luajit/Makefile

This file was deleted.

16 changes: 0 additions & 16 deletions deps/luajit/README

This file was deleted.

Loading

0 comments on commit bb1b6a8

Please sign in to comment.