Skip to content
Snippets Groups Projects
Commit 8adcd8b1 authored by Vladimír Čunát's avatar Vladimír Čunát
Browse files

Merge !466: osx and other fixes

parents 07a0703a 7b90e4f4
No related branches found
No related tags found
1 merge request!466osx and other fixes
Pipeline #
...@@ -40,11 +40,6 @@ BUILD_CFLAGS += -I$(abspath .) -I$(abspath lib/generic) -I$(abspath contrib) ...@@ -40,11 +40,6 @@ BUILD_CFLAGS += -I$(abspath .) -I$(abspath lib/generic) -I$(abspath contrib)
BUILD_CFLAGS += -DPACKAGE_VERSION="\"$(VERSION)\"" -DPREFIX="\"$(PREFIX)\"" -DMODULEDIR="\"$(MODULEDIR)\"" BUILD_CFLAGS += -DPACKAGE_VERSION="\"$(VERSION)\"" -DPREFIX="\"$(PREFIX)\"" -DMODULEDIR="\"$(MODULEDIR)\""
BUILD_CFLAGS += -fvisibility=hidden BUILD_CFLAGS += -fvisibility=hidden
# Otherwise Fedora is making kresd symbols inaccessible for modules
# TODO: clang needs different flag name, etc.
BUILD_CFLAGS += -rdynamic
BUILD_LDFLAGS += -export-dynamic
ifeq (,$(findstring -O,$(CFLAGS))) ifeq (,$(findstring -O,$(CFLAGS)))
BUILD_CFLAGS += -O2 BUILD_CFLAGS += -O2
endif endif
......
...@@ -475,7 +475,10 @@ static void args_init(struct args *args) ...@@ -475,7 +475,10 @@ static void args_init(struct args *args)
args->quiet = false; args->quiet = false;
} }
int parse_args(int argc, char **argv, struct args *args) /** Process arguments into struct args.
* @return >=0 if main() should be exited immediately.
*/
static int parse_args(int argc, char **argv, struct args *args)
{ {
/* Long options. */ /* Long options. */
int c = 0, li = 0; int c = 0, li = 0;
...@@ -554,11 +557,11 @@ int parse_args(int argc, char **argv, struct args *args) ...@@ -554,11 +557,11 @@ int parse_args(int argc, char **argv, struct args *args)
help(argc, argv); help(argc, argv);
return EXIT_FAILURE; return EXIT_FAILURE;
} }
} }
if (optind < argc) { if (optind < argc) {
args->rundir = argv[optind]; args->rundir = argv[optind];
} }
return EXIT_SUCCESS; return -1;
} }
static int bind_fds(struct network *net, fd_array_t *fd_set, bool tls) { static int bind_fds(struct network *net, fd_array_t *fd_set, bool tls) {
...@@ -595,7 +598,7 @@ int main(int argc, char **argv) ...@@ -595,7 +598,7 @@ int main(int argc, char **argv)
int ret = 0; int ret = 0;
struct args args; struct args args;
args_init(&args); args_init(&args);
if ((ret = parse_args(argc, argv, &args)) != EXIT_SUCCESS) { if ((ret = parse_args(argc, argv, &args)) >= 0) {
return ret; return ret;
} }
...@@ -651,7 +654,7 @@ int main(int argc, char **argv) ...@@ -651,7 +654,7 @@ int main(int argc, char **argv)
* sockets etc. before forking, but at the same time can't touch it before * sockets etc. before forking, but at the same time can't touch it before
* forking otherwise it crashes, so it's a chicken and egg problem. * forking otherwise it crashes, so it's a chicken and egg problem.
* Disabling until https://github.com/libuv/libuv/pull/846 is done. */ * Disabling until https://github.com/libuv/libuv/pull/846 is done. */
if (forks > 1 && fd_set.len == 0 && tls_fd_set.len == 0) { if (args.forks > 1 && args.fd_set.len == 0 && args.tls_fd_set.len == 0) {
kr_log_error("[system] forking >1 workers supported only on Linux 3.9+ or with supervisor\n"); kr_log_error("[system] forking >1 workers supported only on Linux 3.9+ or with supervisor\n");
return EXIT_FAILURE; return EXIT_FAILURE;
} }
......
...@@ -36,6 +36,7 @@ else ...@@ -36,6 +36,7 @@ else
PLATFORM := Darwin PLATFORM := Darwin
LIBEXT := .dylib LIBEXT := .dylib
MODTYPE := dynamiclib MODTYPE := dynamiclib
LDFLAGS += -Wl,-export_dynamic
# OS X specific hardening since -pie doesn't work # OS X specific hardening since -pie doesn't work
ifneq ($(HARDENING),no) ifneq ($(HARDENING),no)
BINFLAGS += -Wl,-pie BINFLAGS += -Wl,-pie
...@@ -45,14 +46,18 @@ else ...@@ -45,14 +46,18 @@ else
SOVER = $(if $(1), -compatibility_version $(2) -current_version $(1),) SOVER = $(if $(1), -compatibility_version $(2) -current_version $(1),)
else else
PLATFORM := POSIX PLATFORM := POSIX
LDFLAGS += -pthread -lm -Wl,-E LDFLAGS += -pthread -lm -Wl,--export-dynamic
# ELF hardening options # ELF hardening options
ifneq ($(HARDENING),no) ifneq ($(HARDENING),no)
BINFLAGS += -pie BINFLAGS += -pie
LDFLAGS += -Wl,-z,relro,-z,now LDFLAGS += -Wl,-z,relro,-z,now
endif endif
ifeq ($(UNAME),Linux) ifeq ($(UNAME),Linux)
LDFLAGS += -ldl LDFLAGS += -ldl
endif
ifeq ($(firstword $(shell $(CC) --version)),gcc)
# Otherwise Fedora is making kresd symbols inaccessible for modules?
CFLAGS += -rdynamic
endif endif
endif endif
endif endif
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment