libsepol/cil: disable symver on Mac builds
PATCH 1/8 libsepol/cil: disable symver on Mac builds
From: William Roberts <[email protected]>
symver does not work on Mac, so like Android, just disable it.
--- libsepol/cil/src/dso.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
libsepol/cil/src/dso.h +1 -1
@@ -1,7 +1,7 @@#ifndef _SEPOL_DSO_H#define _SEPOL_DSO_H 1 -#if !defined(SHARED ) || defined(ANDROID ) +#if !defined(SHARED ) || defined(ANDROID ) || defined(__APPLE__)#define DISABLE_SYMVER 1#endif
Signature · 1 line
1.9.1
PATCH 2/8 libsepol: build on mac
From: William Roberts <[email protected]>
Correct the build issues on mac, mostly flags for tools. libsepol and cil now build completley on Mac with a simple make command.
--- libsepol/src/Makefile | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
libsepol/src/Makefile +8 -1
@@ -30,6 +30,13 @@ LOBJS += $(sort $(patsubst %.c,%.lo,$(sort $(wildcard $(CILDIR)/src/*.c)) $(CIL_ override CFLAGS += -I$(CILDIR)/include endif +LD_SONAME_FLAGS=-soname,$(LIBSO),--version-script=$(LIBMAP),-z,defs + +OS := $(shell uname) +ifeq ($(OS), Darwin) +LD_SONAME_FLAGS=-install_name,$(LIBSO) +LDFLAGS += -undefined dynamic_lookup +endif all: $(LIBA) $(LIBSO) $(LIBPC)
@@ -39,7 +46,7 @@ $(LIBA): $(OBJS) $(RANLIB) $@ $(LIBSO): $(LOBJS) $(LIBMAP) - $(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $(LOBJS) -Wl,-soname,$(LIBSO),--version-script=$(LIBMAP),-z,defs + $(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $(LOBJS) -Wl,$(LD_SONAME_FLAGS) ln -sf $@ $(TARGET) $(LIBPC): $(LIBPC).in ../VERSION
Signature · 1 line
1.9.1
PATCH 3/8 libselinux: fix mac build warning when ANDROID_HOST=y
In reply to [email protected]From: William Roberts <[email protected]>
When building on Mac, outside of the Android tree, with ANDROID_HOST=y, this warning is observed:
label.c:102:9: warning: implicit declaration of function 'fgets_unlocked' is invalid in C99 [-Wimplicit-function-declaration]
while (fgets_unlocked(buf, sizeof(buf) - 1, cfg)) {Fix it by using the fgets_unlocked define that was introduced for Android, just apply it for mac builds as well.
--- libselinux/src/label_internal.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
libselinux/src/label_internal.h +2 -2
@@ -16,8 +16,8 @@#include "dso.h" #include "sha1.h" -#ifdef ANDROID -// Android does not have fgets_unlocked() +#if defined(ANDROID ) || defined(__APPLE__) +// Android and Mac do not have fgets_unlocked() #define fgets_unlocked (buf, size, fp) fgets(buf, size, fp)#endif
Signature · 1 line
1.9.1
PATCH 4/8 libselinux: fix required alignment for sha1.c on mac
In reply to [email protected]From: William Roberts <[email protected]>
When building on mac with ANDROID_HOST=y, clang complains:
sha1.c:73:33: error: cast from 'uint8_t *' (aka 'unsigned char *') to 'CHAR64LONG16 *' increases required alignment from 1 to 4 [-Werror,-Wcast-align]
CHAR64LONG16* block = (CHAR64LONG16*) workspace;
Rather then casting the bytearray to the CHAR64LONG16 union, just create a stack workspace of type CHAR64LONG16.
This will prevent alignment issues with the data accesses.
--- libselinux/src/sha1.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
libselinux/src/sha1.c +9 -3
@@ -8,8 +8,14 @@// Modified by WaterJuice retaining Public Domain license. // // This is free and unencumbered software released into the public domain - June 2013 waterjuice.org -// Modified to stop symbols being exported for libselinux shared library - October 2015 +// Modified to: +// - stop symbols being exported for libselinux shared library - October 2015 // Richard Haines <[email protected]> +// - Not cast the workspace from a byte array to a CHAR64LONG16 due to allignment isses. +// Fixes: +// sha1.c:73:33: error: cast from 'uint8_t *' (aka 'unsigned char *') to 'CHAR64LONG16 *' increases required alignment from 1 to 4 [-Werror,-Wcast-align] +// CHAR64LONG16* block = (CHAR64LONG16*) workspace; +// William Roberts <[email protected]> /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -69,8 +75,8 @@ voiduint32_t c;uint32_t d;uint32_t e; -uint8_t workspace[64 ]; -CHAR64LONG16 * block = (CHAR64LONG16 *) workspace; +CHAR64LONG16 workspace; +CHAR64LONG16 * block = &workspace;memcpy ( block, buffer,64 );
Signature · 1 line
1.9.1
PATCH 5/8 libselinux/utils: add noreturn to sefcontext_compile
In reply to [email protected]From: William Roberts <[email protected]>
When building on mac, one encounters this error:
sefcontext_compile.c:270:1: error: function 'usage' could be declared with attribute 'noreturn' [-Werror,-Wmissing-noreturn]
To correct this, add the attribute noreturn to the function.
--- libselinux/utils/sefcontext_compile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
libselinux/utils/sefcontext_compile.c +1 -1
@@ -266,7 +266,7 @@ static void free_specs(struct saved_data *data)memset (data,0 ,sizeof (*data)); } -static void usage (const char *progname) +static __attribute__ ((__noreturn__))void usage (const char *progname) {fprintf (stderr, "usage: %s [-o out_file] [-p policy_file] fc_file\n"
Signature · 1 line
1.9.1
PATCH 6/8 libselinux: support ANDROID_HOST=1 on Mac
In reply to [email protected]From: William Roberts <[email protected]>
To build on mac, first build libsepol with
DISABLE_CIL=y and no DESTDIR set.
Secondly, build libselinux with ANDROID_HOST=y
This configuration can be used to test the Android host build on Mac.
--- libselinux/Makefile | 10 ++++++++++ libselinux/src/Makefile | 36 ++++++++++++++++++++++++++---------- libselinux/utils/Makefile | 29 +++++++++++++++++++++-------- 3 files changed, 57 insertions(+), 18 deletions(-)
libselinux/Makefile +10 -0
@@ -27,6 +27,16 @@ else endif export PCRE_CFLAGS PCRE_LDFLAGS +OS := $(shell uname) +export OS + +ifeq ($(shell $(CC) -v 2>&1 | grep "clang"),) +COMPILER := gcc +else +COMPILER := clang +endif +export COMPILER + all install relabel clean distclean indent: @for subdir in $(SUBDIRS); do \ (cd $$subdir && $(MAKE) $@) || exit 1; \
libselinux/src/Makefile +26 -10
@@ -48,23 +48,39 @@ OBJS= $(patsubst %.c,%.o,$(SRCS)) LOBJS= $(patsubst %.c,%.lo,$(SRCS)) CFLAGS ?= -O -Wall -W -Wundef -Wformat-y2k -Wformat-security -Winit-self -Wmissing-include-dirs \ -Wunused -Wunknown-pragmas -Wstrict-aliasing -Wshadow -Wpointer-arith \ - -Wbad-function-cast -Wcast-align -Wwrite-strings -Wlogical-op -Waggregate-return \ + -Wbad-function-cast -Wcast-align -Wwrite-strings -Waggregate-return \ -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes \ -Wmissing-declarations -Wmissing-noreturn -Wmissing-format-attribute \ -Wredundant-decls -Wnested-externs -Winline -Winvalid-pch -Wvolatile-register-var \ - -Wdisabled-optimization -Wbuiltin-macro-redefined -Wpacked-bitfield-compat \ - -Wsync-nand -Wattributes -Wcoverage-mismatch -Wmultichar -Wcpp \ + -Wdisabled-optimization -Wbuiltin-macro-redefined \ + -Wattributes -Wmultichar \ -Wdeprecated-declarations -Wdiv-by-zero -Wdouble-promotion -Wendif-labels -Wextra \ - -Wformat-contains-nul -Wformat-extra-args -Wformat-zero-length -Wformat=2 -Wmultichar \ - -Wnormalized=nfc -Woverflow -Wpointer-to-int-cast -Wpragmas -Wsuggest-attribute=const \ - -Wsuggest-attribute=noreturn -Wsuggest-attribute=pure -Wtrampolines \ - -Wno-missing-field-initializers -Wno-sign-compare -Wjump-misses-init \ - -Wno-format-nonliteral -Wframe-larger-than=$(MAX_STACK_SIZE) -Wp,-D_FORTIFY_SOURCE=2 \ + -Wformat-extra-args -Wformat-zero-length -Wformat=2 -Wmultichar \ + -Woverflow -Wpointer-to-int-cast -Wpragmas \ + -Wno-missing-field-initializers -Wno-sign-compare \ + -Wno-format-nonliteral -Wframe-larger-than=$(MAX_STACK_SIZE) \ -fstack-protector-all --param=ssp-buffer-size=4 -fexceptions \ -fasynchronous-unwind-tables -fdiagnostics-show-option -funit-at-a-time \ - -fipa-pure-const -Wno-suggest-attribute=pure -Wno-suggest-attribute=const \ -Werror -Wno-aggregate-return -Wno-redundant-decls +LD_SONAME_FLAGS=-soname,$(LIBSO),-z,defs,-z,relro + +ifeq ($(COMPILER), gcc) +override CFLAGS += -fipa-pure-const -Wlogical-op -Wpacked-bitfield-compat -Wsync-nand \ + -Wcoverage-mismatch -Wcpp -Wformat-contains-nul -Wnormalized=nfc -Wsuggest-attribute=const \ + -Wsuggest-attribute=noreturn -Wsuggest-attribute=pure -Wtrampolines -Wjump-misses-init \ + -Wno-suggest-attribute=pure -Wno-suggest-attribute=const -Wp,-D_FORTIFY_SOURCE=2 +else +override CFLAGS += -Wunused-command-line-argument +override LDFLAGS += -L/opt/local/lib -undefined dynamic_lookup +LD_SONAME_FLAGS=-install_name,$(LIBSO) +endif + +ifeq ($(OS), Darwin) +override CFLAGS += -I/opt/local/include +override LDFLAGS += -L/opt/local/lib -undefined dynamic_lookup +endif + PCRE_LDFLAGS ?= -lpcre override CFLAGS += -I../include -I$(INCLUDEDIR) -D_GNU_SOURCE $(DISABLE_FLAGS) $(PCRE_CFLAGS)
@@ -117,7 +133,7 @@ $(LIBA): $(OBJS) $(RANLIB) $@ $(LIBSO): $(LOBJS) - $(CC) $(CFLAGS) -shared -o $@ $^ $(PCRE_LDFLAGS) -ldl $(LDFLAGS) -L$(LIBDIR) -Wl,-soname,$(LIBSO),-z,defs,-z,relro + $(CC) $(CFLAGS) -shared -o $@ $^ $(PCRE_LDFLAGS) -ldl $(LDFLAGS) -L$(LIBDIR) -Wl,$(LD_SONAME_FLAGS) ln -sf $@ $(TARGET) $(LIBPC): $(LIBPC).in ../VERSION
libselinux/utils/Makefile +21 -8
@@ -8,22 +8,35 @@ INCLUDEDIR ?= $(PREFIX)/include MAX_STACK_SIZE=8192 CFLAGS ?= -O -Wall -W -Wundef -Wformat-y2k -Wformat-security -Winit-self -Wmissing-include-dirs \ -Wunused -Wunknown-pragmas -Wstrict-aliasing -Wshadow -Wpointer-arith \ - -Wbad-function-cast -Wcast-align -Wwrite-strings -Wlogical-op -Waggregate-return \ + -Wbad-function-cast -Wcast-align -Wwrite-strings -Waggregate-return \ -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes \ -Wmissing-declarations -Wmissing-noreturn -Wmissing-format-attribute \ -Wredundant-decls -Wnested-externs -Winline -Winvalid-pch -Wvolatile-register-var \ - -Wdisabled-optimization -Wbuiltin-macro-redefined -Wpacked-bitfield-compat \ - -Wsync-nand -Wattributes -Wcoverage-mismatch -Wmultichar -Wcpp \ + -Wdisabled-optimization -Wbuiltin-macro-redefined \ + -Wattributes -Wmultichar \ -Wdeprecated-declarations -Wdiv-by-zero -Wdouble-promotion -Wendif-labels -Wextra \ - -Wformat-contains-nul -Wformat-extra-args -Wformat-zero-length -Wformat=2 -Wmultichar \ - -Wnormalized=nfc -Woverflow -Wpointer-to-int-cast -Wpragmas -Wsuggest-attribute=const \ - -Wsuggest-attribute=noreturn -Wsuggest-attribute=pure -Wtrampolines \ - -Wno-missing-field-initializers -Wno-sign-compare -Wjump-misses-init \ + -Wformat-extra-args -Wformat-zero-length -Wformat=2 -Wmultichar \ + -Woverflow -Wpointer-to-int-cast -Wpragmas \ + -Wno-missing-field-initializers -Wno-sign-compare \ -Wno-format-nonliteral -Wframe-larger-than=$(MAX_STACK_SIZE) -Wp,-D_FORTIFY_SOURCE=2 \ -fstack-protector-all --param=ssp-buffer-size=4 -fexceptions \ -fasynchronous-unwind-tables -fdiagnostics-show-option -funit-at-a-time \ - -fipa-pure-const -Wno-suggest-attribute=pure -Wno-suggest-attribute=const \ -Werror -Wno-aggregate-return -Wno-redundant-decls + +LD_SONAME_FLAGS=-soname,$(LIBSO),-z,defs,-z,relro + +ifeq ($(COMPILER), gcc) +override CFLAGS += -fipa-pure-const -Wpacked-bitfield-compat -Wsync-nand -Wcoverage-mismatch \ + -Wcpp -Wformat-contains-nul -Wnormalized=nfc -Wsuggest-attribute=const \ + -Wsuggest-attribute=noreturn -Wsuggest-attribute=pure -Wtrampolines -Wjump-misses-init \ + -Wno-suggest-attribute=pure -Wno-suggest-attribute=const +endif + +ifeq ($(OS), Darwin) +override CFLAGS += -I/opt/local/include -I../../libsepol/include +override LDFLAGS += -L../../libsepol/src -undefined dynamic_lookup +endif + override CFLAGS += -I../include -I$(INCLUDEDIR) -D_GNU_SOURCE $(DISABLE_FLAGS) $(PCRE_CFLAGS) LDLIBS += -L../src -lselinux -L$(LIBDIR) PCRE_LDFLAGS ?= -lpcre
Signature · 1 line
1.9.1
Re: [PATCH 6/8] libselinux: support ANDROID_HOST=1 on Mac
Quoted 4 lines · On 10/17/2016 04:24 PM, [email protected] wrote:
From: William Roberts <[email protected]>
To build on mac, first build libsepol with
DISABLE_CIL=y and no DESTDIR set.
DISABLE_CIL=y isn't required after the earlier patches, right?
Quoted 145 lines
Secondly, build libselinux with ANDROID_HOST=y
This configuration can be used to test the Android host build on Mac.
Signed-off-by William Roberts <[email protected]>--- libselinux/Makefile | 10 ++++++++++ libselinux/src/Makefile | 36 ++++++++++++++++++++++++++---------- libselinux/utils/Makefile | 29 +++++++++++++++++++++-------- 3 files changed, 57 insertions(+), 18 deletions(-)libselinux/Makefile +10
-0@@ -27,6 +27,16 @@ else endif export PCRE_CFLAGS PCRE_LDFLAGS +OS := $(shell uname) +export OS + +ifeq ($(shell $(CC) -v 2>&1 | grep "clang"),) +COMPILER := gcc +else +COMPILER := clang +endif +export COMPILER + all install relabel clean distclean indent: @for subdir in $(SUBDIRS); do \ (cd $$subdir && $(MAKE) $@) || exit 1; \libselinux/src/Makefile +26
-10@@ -48,23 +48,39 @@ OBJS= $(patsubst %.c,%.o,$(SRCS)) LOBJS= $(patsubst %.c,%.lo,$(SRCS)) CFLAGS ?= -O -Wall -W -Wundef -Wformat-y2k -Wformat-security -Winit-self -Wmissing-include-dirs \ -Wunused -Wunknown-pragmas -Wstrict-aliasing -Wshadow -Wpointer-arith \ - -Wbad-function-cast -Wcast-align -Wwrite-strings -Wlogical-op -Waggregate-return \ + -Wbad-function-cast -Wcast-align -Wwrite-strings -Waggregate-return \ -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes \ -Wmissing-declarations -Wmissing-noreturn -Wmissing-format-attribute \ -Wredundant-decls -Wnested-externs -Winline -Winvalid-pch -Wvolatile-register-var \ - -Wdisabled-optimization -Wbuiltin-macro-redefined -Wpacked-bitfield-compat \ - -Wsync-nand -Wattributes -Wcoverage-mismatch -Wmultichar -Wcpp \ + -Wdisabled-optimization -Wbuiltin-macro-redefined \ + -Wattributes -Wmultichar \ -Wdeprecated-declarations -Wdiv-by-zero -Wdouble-promotion -Wendif-labels -Wextra \ - -Wformat-contains-nul -Wformat-extra-args -Wformat-zero-length -Wformat=2 -Wmultichar \ - -Wnormalized=nfc -Woverflow -Wpointer-to-int-cast -Wpragmas -Wsuggest-attribute=const \ - -Wsuggest-attribute=noreturn -Wsuggest-attribute=pure -Wtrampolines \ - -Wno-missing-field-initializers -Wno-sign-compare -Wjump-misses-init \ - -Wno-format-nonliteral -Wframe-larger-than=$(MAX_STACK_SIZE) -Wp,-D_FORTIFY_SOURCE=2 \ + -Wformat-extra-args -Wformat-zero-length -Wformat=2 -Wmultichar \ + -Woverflow -Wpointer-to-int-cast -Wpragmas \ + -Wno-missing-field-initializers -Wno-sign-compare \ + -Wno-format-nonliteral -Wframe-larger-than=$(MAX_STACK_SIZE) \ -fstack-protector-all --param=ssp-buffer-size=4 -fexceptions \ -fasynchronous-unwind-tables -fdiagnostics-show-option -funit-at-a-time \ - -fipa-pure-const -Wno-suggest-attribute=pure -Wno-suggest-attribute=const \ -Werror -Wno-aggregate-return -Wno-redundant-decls +LD_SONAME_FLAGS=-soname,$(LIBSO),-z,defs,-z,relro + +ifeq ($(COMPILER), gcc) +override CFLAGS += -fipa-pure-const -Wlogical-op -Wpacked-bitfield-compat -Wsync-nand \ + -Wcoverage-mismatch -Wcpp -Wformat-contains-nul -Wnormalized=nfc -Wsuggest-attribute=const \ + -Wsuggest-attribute=noreturn -Wsuggest-attribute=pure -Wtrampolines -Wjump-misses-init \ + -Wno-suggest-attribute=pure -Wno-suggest-attribute=const -Wp,-D_FORTIFY_SOURCE=2 +else +override CFLAGS += -Wunused-command-line-argument +override LDFLAGS += -L/opt/local/lib -undefined dynamic_lookup +LD_SONAME_FLAGS=-install_name,$(LIBSO) +endif + +ifeq ($(OS), Darwin) +override CFLAGS += -I/opt/local/include +override LDFLAGS += -L/opt/local/lib -undefined dynamic_lookup +endif + PCRE_LDFLAGS ?= -lpcre override CFLAGS += -I../include -I$(INCLUDEDIR) -D_GNU_SOURCE $(DISABLE_FLAGS) $(PCRE_CFLAGS)@@ -117,7 +133,7 @@ $(LIBA): $(OBJS) $(RANLIB) $@ $(LIBSO): $(LOBJS) - $(CC) $(CFLAGS) -shared -o $@ $^ $(PCRE_LDFLAGS) -ldl $(LDFLAGS) -L$(LIBDIR) -Wl,-soname,$(LIBSO),-z,defs,-z,relro + $(CC) $(CFLAGS) -shared -o $@ $^ $(PCRE_LDFLAGS) -ldl $(LDFLAGS) -L$(LIBDIR) -Wl,$(LD_SONAME_FLAGS) ln -sf $@ $(TARGET) $(LIBPC): $(LIBPC).in ../VERSIONlibselinux/utils/Makefile +21
-8@@ -8,22 +8,35 @@ INCLUDEDIR ?= $(PREFIX)/include MAX_STACK_SIZE=8192 CFLAGS ?= -O -Wall -W -Wundef -Wformat-y2k -Wformat-security -Winit-self -Wmissing-include-dirs \ -Wunused -Wunknown-pragmas -Wstrict-aliasing -Wshadow -Wpointer-arith \ - -Wbad-function-cast -Wcast-align -Wwrite-strings -Wlogical-op -Waggregate-return \ + -Wbad-function-cast -Wcast-align -Wwrite-strings -Waggregate-return \ -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes \ -Wmissing-declarations -Wmissing-noreturn -Wmissing-format-attribute \ -Wredundant-decls -Wnested-externs -Winline -Winvalid-pch -Wvolatile-register-var \ - -Wdisabled-optimization -Wbuiltin-macro-redefined -Wpacked-bitfield-compat \ - -Wsync-nand -Wattributes -Wcoverage-mismatch -Wmultichar -Wcpp \ + -Wdisabled-optimization -Wbuiltin-macro-redefined \ + -Wattributes -Wmultichar \ -Wdeprecated-declarations -Wdiv-by-zero -Wdouble-promotion -Wendif-labels -Wextra \ - -Wformat-contains-nul -Wformat-extra-args -Wformat-zero-length -Wformat=2 -Wmultichar \ - -Wnormalized=nfc -Woverflow -Wpointer-to-int-cast -Wpragmas -Wsuggest-attribute=const \ - -Wsuggest-attribute=noreturn -Wsuggest-attribute=pure -Wtrampolines \ - -Wno-missing-field-initializers -Wno-sign-compare -Wjump-misses-init \ + -Wformat-extra-args -Wformat-zero-length -Wformat=2 -Wmultichar \ + -Woverflow -Wpointer-to-int-cast -Wpragmas \ + -Wno-missing-field-initializers -Wno-sign-compare \ -Wno-format-nonliteral -Wframe-larger-than=$(MAX_STACK_SIZE) -Wp,-D_FORTIFY_SOURCE=2 \ -fstack-protector-all --param=ssp-buffer-size=4 -fexceptions \ -fasynchronous-unwind-tables -fdiagnostics-show-option -funit-at-a-time \ - -fipa-pure-const -Wno-suggest-attribute=pure -Wno-suggest-attribute=const \ -Werror -Wno-aggregate-return -Wno-redundant-decls + +LD_SONAME_FLAGS=-soname,$(LIBSO),-z,defs,-z,relro + +ifeq ($(COMPILER), gcc) +override CFLAGS += -fipa-pure-const -Wpacked-bitfield-compat -Wsync-nand -Wcoverage-mismatch \ + -Wcpp -Wformat-contains-nul -Wnormalized=nfc -Wsuggest-attribute=const \ + -Wsuggest-attribute=noreturn -Wsuggest-attribute=pure -Wtrampolines -Wjump-misses-init \ + -Wno-suggest-attribute=pure -Wno-suggest-attribute=const +endif + +ifeq ($(OS), Darwin) +override CFLAGS += -I/opt/local/include -I../../libsepol/include +override LDFLAGS += -L../../libsepol/src -undefined dynamic_lookup +endif + override CFLAGS += -I../include -I$(INCLUDEDIR) -D_GNU_SOURCE $(DISABLE_FLAGS) $(PCRE_CFLAGS) LDLIBS += -L../src -lselinux -L$(LIBDIR) PCRE_LDFLAGS ?= -lpcre
Re: [PATCH 6/8] libselinux: support ANDROID_HOST=1 on Mac
Quoted 8 lines · Stephen Smalley
Quoted 4 lines · On 10/17/2016 04:24 PM, [email protected] wrote:
From: William Roberts <[email protected]>
To build on mac, first build libsepol with
DISABLE_CIL=y and no DESTDIR set.DISABLE_CIL=y isn't required after the earlier patches, right?
Correct libsepol builds, I forgot to edit the commit message. I'm flying, so if that's your only issue could you please rewrite the message?
Quoted 34 lines
Quoted 34 lines
Secondly, build libselinux with ANDROID_HOST=y
This configuration can be used to test the Android host build on Mac.
Signed-off-by William Roberts <[email protected]>--- libselinux/Makefile | 10 ++++++++++ libselinux/src/Makefile | 36 ++++++++++++++++++++++++++---------- libselinux/utils/Makefile | 29 +++++++++++++++++++++-------- 3 files changed, 57 insertions(+), 18 deletions(-)libselinux/Makefile +10
-0@@ -27,6 +27,16 @@ else endif export PCRE_CFLAGS PCRE_LDFLAGS +OS := $(shell uname) +export OS + +ifeq ($(shell $(CC) -v 2>&1 | grep "clang"),) +COMPILER := gcc +else +COMPILER := clang +endif +export COMPILER + all install relabel clean distclean indent: @for subdir in $(SUBDIRS); do \
Quoted 8 lines
libselinux/src/Makefile OBJS= $(patsubst %.c,%.o,$(SRCS)) · line 49
Quoted 8 lines
libselinux/Makefile +0
-0(cd $$subdir && $(MAKE) $@) || exit 1; \libselinux/src/Makefile +0
-0@@ -48,23 +48,39 @@ OBJS= $(patsubst %.c,%.o,$(SRCS)) LOBJS= $(patsubst %.c,%.lo,$(SRCS)) CFLAGS ?= -O -Wall -W -Wundef -Wformat-y2k -Wformat-security
-Winit-self -Wmissing-include-dirs \
Quoted 1 line
libselinux/src/Makefile OBJS= $(patsubst %.c,%.o,$(SRCS)) · line 50
Quoted 1 line
libselinux/src/Makefile +0
-0-Wunused -Wunknown-pragmas -Wstrict-aliasing -Wshadow
-Wpointer-arith \
Quoted 1 line
libselinux/src/Makefile OBJS= $(patsubst %.c,%.o,$(SRCS)) · line 51
Quoted 1 line
libselinux/src/Makefile +0
-1- -Wbad-function-cast -Wcast-align -Wwrite-strings
-Wlogical-op -Waggregate-return \
Quoted 1 line
libselinux/src/Makefile OBJS= $(patsubst %.c,%.o,$(SRCS)) · line 51
Quoted 1 line
libselinux/src/Makefile +1
-0+ -Wbad-function-cast -Wcast-align -Wwrite-strings
-Waggregate-return \
Quoted 1 line
libselinux/src/Makefile OBJS= $(patsubst %.c,%.o,$(SRCS)) · line 52
Quoted 1 line
libselinux/src/Makefile +0
-0-Wstrict-prototypes -Wold-style-definition
-Wmissing-prototypes \
Quoted 1 line
libselinux/src/Makefile OBJS= $(patsubst %.c,%.o,$(SRCS)) · line 53
Quoted 1 line
libselinux/src/Makefile +0
-0-Wmissing-declarations -Wmissing-noreturn
-Wmissing-format-attribute \
Quoted 1 line
libselinux/src/Makefile OBJS= $(patsubst %.c,%.o,$(SRCS)) · line 54
Quoted 1 line
libselinux/src/Makefile +0
-0-Wredundant-decls -Wnested-externs -Winline -Winvalid-pch
-Wvolatile-register-var \
Quoted 1 line
libselinux/src/Makefile OBJS= $(patsubst %.c,%.o,$(SRCS)) · line 55
Quoted 1 line
libselinux/src/Makefile +0
-1- -Wdisabled-optimization -Wbuiltin-macro-redefined
-Wpacked-bitfield-compat \
Quoted 1 line
libselinux/src/Makefile OBJS= $(patsubst %.c,%.o,$(SRCS)) · line 56
Quoted 1 line
libselinux/src/Makefile +0
-1- -Wsync-nand -Wattributes -Wcoverage-mismatch -Wmultichar
-Wcpp \
Quoted 3 lines
libselinux/src/Makefile OBJS= $(patsubst %.c,%.o,$(SRCS))
Quoted 3 lines
libselinux/src/Makefile +2
-0+ -Wdisabled-optimization -Wbuiltin-macro-redefined \ + -Wattributes -Wmultichar \ -Wdeprecated-declarations -Wdiv-by-zero -Wdouble-promotion
-Wendif-labels -Wextra \
Quoted 1 line
libselinux/src/Makefile OBJS= $(patsubst %.c,%.o,$(SRCS)) · line 58
Quoted 1 line
libselinux/src/Makefile +0
-1- -Wformat-contains-nul -Wformat-extra-args
-Wformat-zero-length -Wformat=2 -Wmultichar \
Quoted 1 line
libselinux/src/Makefile OBJS= $(patsubst %.c,%.o,$(SRCS)) · line 59
Quoted 1 line
libselinux/src/Makefile +0
-1- -Wnormalized=nfc -Woverflow -Wpointer-to-int-cast -Wpragmas
-Wsuggest-attribute=const \
Quoted 1 line
libselinux/src/Makefile OBJS= $(patsubst %.c,%.o,$(SRCS)) · line 60
Quoted 1 line
libselinux/src/Makefile +0
-1- -Wsuggest-attribute=noreturn -Wsuggest-attribute=pure
-Wtrampolines \
Quoted 1 line
libselinux/src/Makefile OBJS= $(patsubst %.c,%.o,$(SRCS)) · line 61
Quoted 1 line
libselinux/src/Makefile +0
-1- -Wno-missing-field-initializers -Wno-sign-compare
-Wjump-misses-init \
Quoted 1 line
libselinux/src/Makefile OBJS= $(patsubst %.c,%.o,$(SRCS)) · line 62
Quoted 1 line
libselinux/src/Makefile +0
-1- -Wno-format-nonliteral -Wframe-larger-than=$(MAX_STACK_SIZE)
-Wp,-D_FORTIFY_SOURCE=2 \
Quoted 1 line
libselinux/src/Makefile OBJS= $(patsubst %.c,%.o,$(SRCS)) · line 58
Quoted 1 line
libselinux/src/Makefile +1
-0+ -Wformat-extra-args -Wformat-zero-length -Wformat=2
-Wmultichar \
Quoted 3 lines
libselinux/src/Makefile OBJS= $(patsubst %.c,%.o,$(SRCS))
Quoted 3 lines
libselinux/src/Makefile +3
-0+ -Woverflow -Wpointer-to-int-cast -Wpragmas \ + -Wno-missing-field-initializers -Wno-sign-compare \ + -Wno-format-nonliteral -Wframe-larger-than=$(MAX_STACK_SIZE)
\
Quoted 1 line
libselinux/src/Makefile OBJS= $(patsubst %.c,%.o,$(SRCS)) · line 62
Quoted 1 line
libselinux/src/Makefile +0
-0-fstack-protector-all --param=ssp-buffer-size=4 -fexceptions
\
Quoted 1 line
libselinux/src/Makefile OBJS= $(patsubst %.c,%.o,$(SRCS)) · line 63
Quoted 1 line
libselinux/src/Makefile +0
-0-fasynchronous-unwind-tables -fdiagnostics-show-option
-funit-at-a-time \
Quoted 1 line
libselinux/src/Makefile OBJS= $(patsubst %.c,%.o,$(SRCS)) · line 65
Quoted 1 line
libselinux/src/Makefile +0
-1- -fipa-pure-const -Wno-suggest-attribute=pure
-Wno-suggest-attribute=const \
Quoted 6 lines
libselinux/src/Makefile OBJS= $(patsubst %.c,%.o,$(SRCS))
Quoted 6 lines
libselinux/src/Makefile +4
-0-Werror -Wno-aggregate-return -Wno-redundant-decls +LD_SONAME_FLAGS=-soname,$(LIBSO),-z,defs,-z,relro + +ifeq ($(COMPILER), gcc) +override CFLAGS += -fipa-pure-const -Wlogical-op
-Wpacked-bitfield-compat -Wsync-nand \
Quoted 1 line
libselinux/src/Makefile OBJS= $(patsubst %.c,%.o,$(SRCS)) · line 70
Quoted 1 line
libselinux/src/Makefile +1
-0+ -Wcoverage-mismatch -Wcpp -Wformat-contains-nul -Wnormalized=nfc
-Wsuggest-attribute=const \
Quoted 1 line
libselinux/src/Makefile OBJS= $(patsubst %.c,%.o,$(SRCS)) · line 71
Quoted 1 line
libselinux/src/Makefile +1
-0+ -Wsuggest-attribute=noreturn -Wsuggest-attribute=pure
-Wtrampolines -Wjump-misses-init \
Quoted 1 line
libselinux/src/Makefile OBJS= $(patsubst %.c,%.o,$(SRCS)) · line 72
Quoted 1 line
libselinux/src/Makefile +1
-0+ -Wno-suggest-attribute=pure -Wno-suggest-attribute=const
-Wp,-D_FORTIFY_SOURCE=2
Quoted 13 lines
Quoted 13 lines
libselinux/src/Makefile +11
-0+else +override CFLAGS += -Wunused-command-line-argument +override LDFLAGS += -L/opt/local/lib -undefined dynamic_lookup +LD_SONAME_FLAGS=-install_name,$(LIBSO) +endif + +ifeq ($(OS), Darwin) +override CFLAGS += -I/opt/local/include +override LDFLAGS += -L/opt/local/lib -undefined dynamic_lookup +endif + PCRE_LDFLAGS ?= -lpcre
Quoted 1 line
libselinux/src/Makefile OBJS= $(patsubst %.c,%.o,$(SRCS)) · line 86
Quoted 1 line
libselinux/src/Makefile +0
-0override CFLAGS += -I../include -I$(INCLUDEDIR) -D_GNU_SOURCE
$(DISABLE_FLAGS) $(PCRE_CFLAGS)
Quoted 5 lines
libselinux/src/Makefile $(LIBA): $(OBJS) · line 120
Quoted 5 lines
libselinux/src/Makefile +0
-1@@ -117,7 +133,7 @@ $(LIBA): $(OBJS) $(RANLIB) $@ $(LIBSO): $(LOBJS) - $(CC) $(CFLAGS) -shared -o $@ $^ $(PCRE_LDFLAGS) -ldl $(LDFLAGS)
-L$(LIBDIR) -Wl,-soname,$(LIBSO),-z,defs,-z,relro
Quoted 1 line
libselinux/src/Makefile $(LIBA): $(OBJS) · line 136
Quoted 1 line
libselinux/src/Makefile +1
-0+ $(CC) $(CFLAGS) -shared -o $@ $^ $(PCRE_LDFLAGS) -ldl $(LDFLAGS)
-L$(LIBDIR) -Wl,$(LD_SONAME_FLAGS)
Quoted 10 lines
libselinux/utils/Makefile INCLUDEDIR ?= $(PREFIX)/include · line 9
Quoted 10 lines
libselinux/src/Makefile +0
-0ln -sf $@ $(TARGET) $(LIBPC): $(LIBPC).in ../VERSIONlibselinux/utils/Makefile +0
-0@@ -8,22 +8,35 @@ INCLUDEDIR ?= $(PREFIX)/include MAX_STACK_SIZE=8192 CFLAGS ?= -O -Wall -W -Wundef -Wformat-y2k -Wformat-security
-Winit-self -Wmissing-include-dirs \
Quoted 1 line
libselinux/utils/Makefile INCLUDEDIR ?= $(PREFIX)/include · line 10
Quoted 1 line
libselinux/utils/Makefile +0
-0-Wunused -Wunknown-pragmas -Wstrict-aliasing -Wshadow
-Wpointer-arith \
Quoted 1 line
libselinux/utils/Makefile INCLUDEDIR ?= $(PREFIX)/include · line 11
Quoted 1 line
libselinux/utils/Makefile +0
-1- -Wbad-function-cast -Wcast-align -Wwrite-strings
-Wlogical-op -Waggregate-return \
Quoted 1 line
libselinux/utils/Makefile INCLUDEDIR ?= $(PREFIX)/include · line 11
Quoted 1 line
libselinux/utils/Makefile +1
-0+ -Wbad-function-cast -Wcast-align -Wwrite-strings
-Waggregate-return \
Quoted 1 line
libselinux/utils/Makefile INCLUDEDIR ?= $(PREFIX)/include · line 12
Quoted 1 line
libselinux/utils/Makefile +0
-0-Wstrict-prototypes -Wold-style-definition
-Wmissing-prototypes \
Quoted 1 line
libselinux/utils/Makefile INCLUDEDIR ?= $(PREFIX)/include · line 13
Quoted 1 line
libselinux/utils/Makefile +0
-0-Wmissing-declarations -Wmissing-noreturn
-Wmissing-format-attribute \
Quoted 1 line
libselinux/utils/Makefile INCLUDEDIR ?= $(PREFIX)/include · line 14
Quoted 1 line
libselinux/utils/Makefile +0
-0-Wredundant-decls -Wnested-externs -Winline -Winvalid-pch
-Wvolatile-register-var \
Quoted 1 line
libselinux/utils/Makefile INCLUDEDIR ?= $(PREFIX)/include · line 15
Quoted 1 line
libselinux/utils/Makefile +0
-1- -Wdisabled-optimization -Wbuiltin-macro-redefined
-Wpacked-bitfield-compat \
Quoted 1 line
libselinux/utils/Makefile INCLUDEDIR ?= $(PREFIX)/include · line 16
Quoted 1 line
libselinux/utils/Makefile +0
-1- -Wsync-nand -Wattributes -Wcoverage-mismatch -Wmultichar
-Wcpp \
Quoted 3 lines
libselinux/utils/Makefile INCLUDEDIR ?= $(PREFIX)/include · line 17
Quoted 3 lines
libselinux/utils/Makefile +2
-0+ -Wdisabled-optimization -Wbuiltin-macro-redefined \ + -Wattributes -Wmultichar \ -Wdeprecated-declarations -Wdiv-by-zero -Wdouble-promotion
-Wendif-labels -Wextra \
Quoted 1 line
libselinux/utils/Makefile INCLUDEDIR ?= $(PREFIX)/include · line 18
Quoted 1 line
libselinux/utils/Makefile +0
-1- -Wformat-contains-nul -Wformat-extra-args
-Wformat-zero-length -Wformat=2 -Wmultichar \
Quoted 1 line
libselinux/utils/Makefile INCLUDEDIR ?= $(PREFIX)/include · line 19
Quoted 1 line
libselinux/utils/Makefile +0
-1- -Wnormalized=nfc -Woverflow -Wpointer-to-int-cast -Wpragmas
-Wsuggest-attribute=const \
Quoted 1 line
libselinux/utils/Makefile INCLUDEDIR ?= $(PREFIX)/include · line 20
Quoted 1 line
libselinux/utils/Makefile +0
-1- -Wsuggest-attribute=noreturn -Wsuggest-attribute=pure
-Wtrampolines \
Quoted 1 line
libselinux/utils/Makefile INCLUDEDIR ?= $(PREFIX)/include · line 21
Quoted 1 line
libselinux/utils/Makefile +0
-1- -Wno-missing-field-initializers -Wno-sign-compare
-Wjump-misses-init \
Quoted 1 line
libselinux/utils/Makefile INCLUDEDIR ?= $(PREFIX)/include · line 18
Quoted 1 line
libselinux/utils/Makefile +1
-0+ -Wformat-extra-args -Wformat-zero-length -Wformat=2
-Wmultichar \
Quoted 3 lines
libselinux/utils/Makefile INCLUDEDIR ?= $(PREFIX)/include · line 21
Quoted 3 lines
libselinux/utils/Makefile +2
-0+ -Woverflow -Wpointer-to-int-cast -Wpragmas \ + -Wno-missing-field-initializers -Wno-sign-compare \ -Wno-format-nonliteral -Wframe-larger-than=$(MAX_STACK_SIZE)
-Wp,-D_FORTIFY_SOURCE=2 \
Quoted 1 line
libselinux/utils/Makefile INCLUDEDIR ?= $(PREFIX)/include · line 22
Quoted 1 line
libselinux/utils/Makefile +0
-0-fstack-protector-all --param=ssp-buffer-size=4 -fexceptions
\
Quoted 1 line
libselinux/utils/Makefile INCLUDEDIR ?= $(PREFIX)/include · line 23
Quoted 1 line
libselinux/utils/Makefile +0
-0-fasynchronous-unwind-tables -fdiagnostics-show-option
-funit-at-a-time \
Quoted 1 line
libselinux/utils/Makefile INCLUDEDIR ?= $(PREFIX)/include · line 25
Quoted 1 line
libselinux/utils/Makefile +0
-1- -fipa-pure-const -Wno-suggest-attribute=pure
-Wno-suggest-attribute=const \
Quoted 6 lines
libselinux/utils/Makefile INCLUDEDIR ?= $(PREFIX)/include
Quoted 6 lines
libselinux/utils/Makefile +5
-0-Werror -Wno-aggregate-return -Wno-redundant-decls + +LD_SONAME_FLAGS=-soname,$(LIBSO),-z,defs,-z,relro + +ifeq ($(COMPILER), gcc) +override CFLAGS += -fipa-pure-const -Wpacked-bitfield-compat
-Wsync-nand -Wcoverage-mismatch \
Quoted 1 line
libselinux/utils/Makefile INCLUDEDIR ?= $(PREFIX)/include · line 30
Quoted 1 line
libselinux/utils/Makefile +1
-0+ -Wcpp -Wformat-contains-nul -Wnormalized=nfc
-Wsuggest-attribute=const \
Quoted 1 line
libselinux/utils/Makefile INCLUDEDIR ?= $(PREFIX)/include · line 31
Quoted 1 line
libselinux/utils/Makefile +1
-0+ -Wsuggest-attribute=noreturn -Wsuggest-attribute=pure
-Wtrampolines -Wjump-misses-init \
Quoted 9 lines
libselinux/utils/Makefile INCLUDEDIR ?= $(PREFIX)/include
Quoted 9 lines
libselinux/utils/Makefile +8
-0+ -Wno-suggest-attribute=pure -Wno-suggest-attribute=const +endif + +ifeq ($(OS), Darwin) +override CFLAGS += -I/opt/local/include -I../../libsepol/include +override LDFLAGS += -L../../libsepol/src -undefined dynamic_lookup +endif + override CFLAGS += -I../include -I$(INCLUDEDIR) -D_GNU_SOURCE
$(DISABLE_FLAGS) $(PCRE_CFLAGS)
Quoted 9 lines
libselinux/utils/Makefile INCLUDEDIR ?= $(PREFIX)/include · line 42
Quoted 3 lines
libselinux/utils/Makefile +0
-0LDLIBS += -L../src -lselinux -L$(LIBDIR) PCRE_LDFLAGS ?= -lpcre_______________________________________________
Seandroid-list mailing list [email protected]
To unsubscribe, send email to [email protected]. To get help, send an email containing "help" to
Re: [PATCH 6/8] libselinux: support ANDROID_HOST=1 on Mac
In reply to [email protected]Hello,
After this commit, libselinux fails to build with clang on Linux:
clang-3.9: warning: argument unused during compilation: '-undefineddynamic_lookup'
/usr/bin/ld: unrecognised option: -install_name clang-3.9: error: linker command failed with exit code 1 (use -v to
see invocation)
It seems clang 3.9.0 does not like "-undefined dynamic_lookup" and binutils 2.27 does not know about "-install_name". Would it be possible to put the lines which add these two options to the compiler command lines into a "ifeq ($(OS), Darwin)" block, if they are indeed targeted to MacOS?
Thanks,
Nicolas
Quoted 149 lines · On 17/10/16 22:24, [email protected] wrote:
From: William Roberts <[email protected]>
To build on mac, first build libsepol with
DISABLE_CIL=y and no DESTDIR set.Secondly, build libselinux with ANDROID_HOST=y
This configuration can be used to test the Android host build on Mac.
Signed-off-by William Roberts <[email protected]>--- libselinux/Makefile | 10 ++++++++++ libselinux/src/Makefile | 36 ++++++++++++++++++++++++++---------- libselinux/utils/Makefile | 29 +++++++++++++++++++++-------- 3 files changed, 57 insertions(+), 18 deletions(-)libselinux/Makefile +10
-0@@ -27,6 +27,16 @@ else endif export PCRE_CFLAGS PCRE_LDFLAGS +OS := $(shell uname) +export OS + +ifeq ($(shell $(CC) -v 2>&1 | grep "clang"),) +COMPILER := gcc +else +COMPILER := clang +endif +export COMPILER + all install relabel clean distclean indent: @for subdir in $(SUBDIRS); do \ (cd $$subdir && $(MAKE) $@) || exit 1; \libselinux/src/Makefile +26
-10@@ -48,23 +48,39 @@ OBJS= $(patsubst %.c,%.o,$(SRCS)) LOBJS= $(patsubst %.c,%.lo,$(SRCS)) CFLAGS ?= -O -Wall -W -Wundef -Wformat-y2k -Wformat-security -Winit-self -Wmissing-include-dirs \ -Wunused -Wunknown-pragmas -Wstrict-aliasing -Wshadow -Wpointer-arith \ - -Wbad-function-cast -Wcast-align -Wwrite-strings -Wlogical-op -Waggregate-return \ + -Wbad-function-cast -Wcast-align -Wwrite-strings -Waggregate-return \ -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes \ -Wmissing-declarations -Wmissing-noreturn -Wmissing-format-attribute \ -Wredundant-decls -Wnested-externs -Winline -Winvalid-pch -Wvolatile-register-var \ - -Wdisabled-optimization -Wbuiltin-macro-redefined -Wpacked-bitfield-compat \ - -Wsync-nand -Wattributes -Wcoverage-mismatch -Wmultichar -Wcpp \ + -Wdisabled-optimization -Wbuiltin-macro-redefined \ + -Wattributes -Wmultichar \ -Wdeprecated-declarations -Wdiv-by-zero -Wdouble-promotion -Wendif-labels -Wextra \ - -Wformat-contains-nul -Wformat-extra-args -Wformat-zero-length -Wformat=2 -Wmultichar \ - -Wnormalized=nfc -Woverflow -Wpointer-to-int-cast -Wpragmas -Wsuggest-attribute=const \ - -Wsuggest-attribute=noreturn -Wsuggest-attribute=pure -Wtrampolines \ - -Wno-missing-field-initializers -Wno-sign-compare -Wjump-misses-init \ - -Wno-format-nonliteral -Wframe-larger-than=$(MAX_STACK_SIZE) -Wp,-D_FORTIFY_SOURCE=2 \ + -Wformat-extra-args -Wformat-zero-length -Wformat=2 -Wmultichar \ + -Woverflow -Wpointer-to-int-cast -Wpragmas \ + -Wno-missing-field-initializers -Wno-sign-compare \ + -Wno-format-nonliteral -Wframe-larger-than=$(MAX_STACK_SIZE) \ -fstack-protector-all --param=ssp-buffer-size=4 -fexceptions \ -fasynchronous-unwind-tables -fdiagnostics-show-option -funit-at-a-time \ - -fipa-pure-const -Wno-suggest-attribute=pure -Wno-suggest-attribute=const \ -Werror -Wno-aggregate-return -Wno-redundant-decls +LD_SONAME_FLAGS=-soname,$(LIBSO),-z,defs,-z,relro + +ifeq ($(COMPILER), gcc) +override CFLAGS += -fipa-pure-const -Wlogical-op -Wpacked-bitfield-compat -Wsync-nand \ + -Wcoverage-mismatch -Wcpp -Wformat-contains-nul -Wnormalized=nfc -Wsuggest-attribute=const \ + -Wsuggest-attribute=noreturn -Wsuggest-attribute=pure -Wtrampolines -Wjump-misses-init \ + -Wno-suggest-attribute=pure -Wno-suggest-attribute=const -Wp,-D_FORTIFY_SOURCE=2 +else +override CFLAGS += -Wunused-command-line-argument +override LDFLAGS += -L/opt/local/lib -undefined dynamic_lookup +LD_SONAME_FLAGS=-install_name,$(LIBSO) +endif + +ifeq ($(OS), Darwin) +override CFLAGS += -I/opt/local/include +override LDFLAGS += -L/opt/local/lib -undefined dynamic_lookup +endif + PCRE_LDFLAGS ?= -lpcre override CFLAGS += -I../include -I$(INCLUDEDIR) -D_GNU_SOURCE $(DISABLE_FLAGS) $(PCRE_CFLAGS)@@ -117,7 +133,7 @@ $(LIBA): $(OBJS) $(RANLIB) $@ $(LIBSO): $(LOBJS) - $(CC) $(CFLAGS) -shared -o $@ $^ $(PCRE_LDFLAGS) -ldl $(LDFLAGS) -L$(LIBDIR) -Wl,-soname,$(LIBSO),-z,defs,-z,relro + $(CC) $(CFLAGS) -shared -o $@ $^ $(PCRE_LDFLAGS) -ldl $(LDFLAGS) -L$(LIBDIR) -Wl,$(LD_SONAME_FLAGS) ln -sf $@ $(TARGET) $(LIBPC): $(LIBPC).in ../VERSIONlibselinux/utils/Makefile +21
-8@@ -8,22 +8,35 @@ INCLUDEDIR ?= $(PREFIX)/include MAX_STACK_SIZE=8192 CFLAGS ?= -O -Wall -W -Wundef -Wformat-y2k -Wformat-security -Winit-self -Wmissing-include-dirs \ -Wunused -Wunknown-pragmas -Wstrict-aliasing -Wshadow -Wpointer-arith \ - -Wbad-function-cast -Wcast-align -Wwrite-strings -Wlogical-op -Waggregate-return \ + -Wbad-function-cast -Wcast-align -Wwrite-strings -Waggregate-return \ -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes \ -Wmissing-declarations -Wmissing-noreturn -Wmissing-format-attribute \ -Wredundant-decls -Wnested-externs -Winline -Winvalid-pch -Wvolatile-register-var \ - -Wdisabled-optimization -Wbuiltin-macro-redefined -Wpacked-bitfield-compat \ - -Wsync-nand -Wattributes -Wcoverage-mismatch -Wmultichar -Wcpp \ + -Wdisabled-optimization -Wbuiltin-macro-redefined \ + -Wattributes -Wmultichar \ -Wdeprecated-declarations -Wdiv-by-zero -Wdouble-promotion -Wendif-labels -Wextra \ - -Wformat-contains-nul -Wformat-extra-args -Wformat-zero-length -Wformat=2 -Wmultichar \ - -Wnormalized=nfc -Woverflow -Wpointer-to-int-cast -Wpragmas -Wsuggest-attribute=const \ - -Wsuggest-attribute=noreturn -Wsuggest-attribute=pure -Wtrampolines \ - -Wno-missing-field-initializers -Wno-sign-compare -Wjump-misses-init \ + -Wformat-extra-args -Wformat-zero-length -Wformat=2 -Wmultichar \ + -Woverflow -Wpointer-to-int-cast -Wpragmas \ + -Wno-missing-field-initializers -Wno-sign-compare \ -Wno-format-nonliteral -Wframe-larger-than=$(MAX_STACK_SIZE) -Wp,-D_FORTIFY_SOURCE=2 \ -fstack-protector-all --param=ssp-buffer-size=4 -fexceptions \ -fasynchronous-unwind-tables -fdiagnostics-show-option -funit-at-a-time \ - -fipa-pure-const -Wno-suggest-attribute=pure -Wno-suggest-attribute=const \ -Werror -Wno-aggregate-return -Wno-redundant-decls + +LD_SONAME_FLAGS=-soname,$(LIBSO),-z,defs,-z,relro + +ifeq ($(COMPILER), gcc) +override CFLAGS += -fipa-pure-const -Wpacked-bitfield-compat -Wsync-nand -Wcoverage-mismatch \ + -Wcpp -Wformat-contains-nul -Wnormalized=nfc -Wsuggest-attribute=const \ + -Wsuggest-attribute=noreturn -Wsuggest-attribute=pure -Wtrampolines -Wjump-misses-init \ + -Wno-suggest-attribute=pure -Wno-suggest-attribute=const +endif + +ifeq ($(OS), Darwin) +override CFLAGS += -I/opt/local/include -I../../libsepol/include +override LDFLAGS += -L../../libsepol/src -undefined dynamic_lookup +endif + override CFLAGS += -I../include -I$(INCLUDEDIR) -D_GNU_SOURCE $(DISABLE_FLAGS) $(PCRE_CFLAGS) LDLIBS += -L../src -lselinux -L$(LIBDIR) PCRE_LDFLAGS ?= -lpcre
Re: [PATCH 6/8] libselinux: support ANDROID_HOST=1 on Mac
Quoted 10 lines · Nicolas Iooss
Hello,
After this commit, libselinux fails to build with clang on Linux:
clang-3.9: warning: argument unused during compilation: '-undefined
dynamic_lookup'
/usr/bin/ld: unrecognised option: -install_name clang-3.9: error: linker command failed with exit code 1 (use -v to
see invocation)
Quoted 5 lines
It seems clang 3.9.0 does not like "-undefined
dynamic_lookup" and binutils 2.27 does not know about "-install_name". Would it be possible to put the lines which add these two options to the compiler command lines into a "ifeq ($(OS), Darwin)" block, if they are indeed targeted to MacOS?
I'll look into this, likely needs to be Darwin and clang
Quoted 159 lines
Thanks,
NicolasQuoted 139 lines · On 17/10/16 22:24, [email protected] wrote:
From: William Roberts <[email protected]>
To build on mac, first build libsepol with
DISABLE_CIL=y and no DESTDIR set.Secondly, build libselinux with ANDROID_HOST=y
This configuration can be used to test the Android host build on Mac.
Signed-off-by William Roberts <[email protected]>--- libselinux/Makefile | 10 ++++++++++ libselinux/src/Makefile | 36 ++++++++++++++++++++++++++---------- libselinux/utils/Makefile | 29 +++++++++++++++++++++-------- 3 files changed, 57 insertions(+), 18 deletions(-)libselinux/Makefile +10
-0@@ -27,6 +27,16 @@ else endif export PCRE_CFLAGS PCRE_LDFLAGS +OS := $(shell uname) +export OS + +ifeq ($(shell $(CC) -v 2>&1 | grep "clang"),) +COMPILER := gcc +else +COMPILER := clang +endif +export COMPILER + all install relabel clean distclean indent: @for subdir in $(SUBDIRS); do \ (cd $$subdir && $(MAKE) $@) || exit 1; \libselinux/src/Makefile +26
-10@@ -48,23 +48,39 @@ OBJS= $(patsubst %.c,%.o,$(SRCS)) LOBJS= $(patsubst %.c,%.lo,$(SRCS)) CFLAGS ?= -O -Wall -W -Wundef -Wformat-y2k -Wformat-security -Winit-self -Wmissing-include-dirs \ -Wunused -Wunknown-pragmas -Wstrict-aliasing -Wshadow -Wpointer-arith \ - -Wbad-function-cast -Wcast-align -Wwrite-strings -Wlogical-op -Waggregate-return \ + -Wbad-function-cast -Wcast-align -Wwrite-strings -Waggregate-return \ -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes \ -Wmissing-declarations -Wmissing-noreturn -Wmissing-format-attribute \ -Wredundant-decls -Wnested-externs -Winline -Winvalid-pch -Wvolatile-register-var \ - -Wdisabled-optimization -Wbuiltin-macro-redefined -Wpacked-bitfield-compat \ - -Wsync-nand -Wattributes -Wcoverage-mismatch -Wmultichar -Wcpp \ + -Wdisabled-optimization -Wbuiltin-macro-redefined \ + -Wattributes -Wmultichar \ -Wdeprecated-declarations -Wdiv-by-zero -Wdouble-promotion -Wendif-labels -Wextra \ - -Wformat-contains-nul -Wformat-extra-args -Wformat-zero-length -Wformat=2 -Wmultichar \ - -Wnormalized=nfc -Woverflow -Wpointer-to-int-cast -Wpragmas -Wsuggest-attribute=const \ - -Wsuggest-attribute=noreturn -Wsuggest-attribute=pure -Wtrampolines \ - -Wno-missing-field-initializers -Wno-sign-compare -Wjump-misses-init \ - -Wno-format-nonliteral -Wframe-larger-than=$(MAX_STACK_SIZE) -Wp,-D_FORTIFY_SOURCE=2 \ + -Wformat-extra-args -Wformat-zero-length -Wformat=2 -Wmultichar \ + -Woverflow -Wpointer-to-int-cast -Wpragmas \ + -Wno-missing-field-initializers -Wno-sign-compare \ + -Wno-format-nonliteral -Wframe-larger-than=$(MAX_STACK_SIZE) \ -fstack-protector-all --param=ssp-buffer-size=4 -fexceptions \ -fasynchronous-unwind-tables -fdiagnostics-show-option -funit-at-a-time \ - -fipa-pure-const -Wno-suggest-attribute=pure -Wno-suggest-attribute=const \ -Werror -Wno-aggregate-return -Wno-redundant-decls +LD_SONAME_FLAGS=-soname,$(LIBSO),-z,defs,-z,relro + +ifeq ($(COMPILER), gcc) +override CFLAGS += -fipa-pure-const -Wlogical-op -Wpacked-bitfield-compat -Wsync-nand \ + -Wcoverage-mismatch -Wcpp -Wformat-contains-nul -Wnormalized=nfc -Wsuggest-attribute=const \ + -Wsuggest-attribute=noreturn -Wsuggest-attribute=pure -Wtrampolines -Wjump-misses-init \ + -Wno-suggest-attribute=pure -Wno-suggest-attribute=const -Wp,-D_FORTIFY_SOURCE=2 +else +override CFLAGS += -Wunused-command-line-argument +override LDFLAGS += -L/opt/local/lib -undefined dynamic_lookup +LD_SONAME_FLAGS=-install_name,$(LIBSO) +endif + +ifeq ($(OS), Darwin) +override CFLAGS += -I/opt/local/include +override LDFLAGS += -L/opt/local/lib -undefined dynamic_lookup +endif + PCRE_LDFLAGS ?= -lpcre override CFLAGS += -I../include -I$(INCLUDEDIR) -D_GNU_SOURCE $(DISABLE_FLAGS) $(PCRE_CFLAGS)@@ -117,7 +133,7 @@ $(LIBA): $(OBJS) $(RANLIB) $@ $(LIBSO): $(LOBJS) - $(CC) $(CFLAGS) -shared -o $@ $^ $(PCRE_LDFLAGS) -ldl $(LDFLAGS) -L$(LIBDIR) -Wl,-soname,$(LIBSO),-z,defs,-z,relro + $(CC) $(CFLAGS) -shared -o $@ $^ $(PCRE_LDFLAGS) -ldl $(LDFLAGS) -L$(LIBDIR) -Wl,$(LD_SONAME_FLAGS) ln -sf $@ $(TARGET) $(LIBPC): $(LIBPC).in ../VERSIONlibselinux/utils/Makefile +14
-8@@ -8,22 +8,35 @@ INCLUDEDIR ?= $(PREFIX)/include MAX_STACK_SIZE=8192 CFLAGS ?= -O -Wall -W -Wundef -Wformat-y2k -Wformat-security -Winit-self -Wmissing-include-dirs \ -Wunused -Wunknown-pragmas -Wstrict-aliasing -Wshadow -Wpointer-arith \ - -Wbad-function-cast -Wcast-align -Wwrite-strings -Wlogical-op -Waggregate-return \ + -Wbad-function-cast -Wcast-align -Wwrite-strings -Waggregate-return \ -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes \ -Wmissing-declarations -Wmissing-noreturn -Wmissing-format-attribute \ -Wredundant-decls -Wnested-externs -Winline -Winvalid-pch -Wvolatile-register-var \ - -Wdisabled-optimization -Wbuiltin-macro-redefined -Wpacked-bitfield-compat \ - -Wsync-nand -Wattributes -Wcoverage-mismatch -Wmultichar -Wcpp \ + -Wdisabled-optimization -Wbuiltin-macro-redefined \ + -Wattributes -Wmultichar \ -Wdeprecated-declarations -Wdiv-by-zero -Wdouble-promotion -Wendif-labels -Wextra \ - -Wformat-contains-nul -Wformat-extra-args -Wformat-zero-length -Wformat=2 -Wmultichar \ - -Wnormalized=nfc -Woverflow -Wpointer-to-int-cast -Wpragmas -Wsuggest-attribute=const \ - -Wsuggest-attribute=noreturn -Wsuggest-attribute=pure -Wtrampolines \ - -Wno-missing-field-initializers -Wno-sign-compare -Wjump-misses-init \ + -Wformat-extra-args -Wformat-zero-length -Wformat=2 -Wmultichar \ + -Woverflow -Wpointer-to-int-cast -Wpragmas \ + -Wno-missing-field-initializers -Wno-sign-compare \ -Wno-format-nonliteral -Wframe-larger-than=$(MAX_STACK_SIZE) -Wp,-D_FORTIFY_SOURCE=2 \ -fstack-protector-all --param=ssp-buffer-size=4 -fexceptions \ -fasynchronous-unwind-tables -fdiagnostics-show-option -funit-at-a-time \ - -fipa-pure-const -Wno-suggest-attribute=pure -Wno-suggest-attribute=const \ -Werror -Wno-aggregate-return -Wno-redundant-decls + +LD_SONAME_FLAGS=-soname,$(LIBSO),-z,defs,-z,relro + +ifeq ($(COMPILER), gcc) +override CFLAGS += -fipa-pure-const -Wpacked-bitfield-compat -Wsync-nand -Wcoverage-mismatch \ + -Wcpp -Wformat-contains-nul -Wnormalized=nfc -Wsuggest-attribute=const \ + -Wsuggest-attribute=noreturn -Wsuggest-attribute=pure -Wtrampolines -Wjump-misses-init \ + -Wno-suggest-attribute=pure -Wno-suggest-attribute=constlibselinux/utils/Makefile INCLUDEDIR ?= $(PREFIX)/include · line 42
Quoted 10 lines
libselinux/utils/Makefile +7
-0+endif + +ifeq ($(OS), Darwin) +override CFLAGS += -I/opt/local/include -I../../libsepol/include +override LDFLAGS += -L../../libsepol/src -undefined dynamic_lookup +endif + override CFLAGS += -I../include -I$(INCLUDEDIR) -D_GNU_SOURCE $(DISABLE_FLAGS) $(PCRE_CFLAGS) LDLIBS += -L../src -lselinux -L$(LIBDIR) PCRE_LDFLAGS ?= -lpcre_______________________________________________
Selinux mailing list
[email protected]
To unsubscribe, send email to [email protected].
To get help, send an email containing "help" to [email protected].
Signature · 3 lines
Respectfully, William C Roberts
Re: [PATCH 6/8] libselinux: support ANDROID_HOST=1 on Mac
On the current tip of master, with clang 3.8.0 on my Ubuntu box I get:
avc_internal.c:105:25: error: cast from 'char *' to 'struct nlmsghdr *' increases required alignment from 1 to 4 [-Werror,-Wcast-align]
struct nlmsghdr *nlh = (struct nlmsghdr *)buf;
^~~~~~~~~~~~~~~~~~~~~~
avc_internal.c:161:25: error: cast from 'char *' to 'struct nlmsghdr
*' increases required alignment from 1 to 4 [-Werror,-Wcast-align]
struct nlmsghdr *nlh = (struct nlmsghdr *)buf;I'm not sure of the best way to handle that, considering we don't unsure that buf is bigger than a nlmsghdr...
I'll send a test patch out in bit.
Quoted 185 lines · William Roberts
Quoted 10 lines · Nicolas Iooss
Hello,
After this commit, libselinux fails to build with clang on Linux:
clang-3.9: warning: argument unused during compilation: '-undefined
dynamic_lookup'
/usr/bin/ld: unrecognised option: -install_name clang-3.9: error: linker command failed with exit code 1 (use -v to
see invocation)Quoted 5 lines
It seems clang 3.9.0 does not like "-undefined
dynamic_lookup" and binutils 2.27 does not know about "-install_name". Would it be possible to put the lines which add these two options to the compiler command lines into a "ifeq ($(OS), Darwin)" block, if they are indeed targeted to MacOS?I'll look into this, likely needs to be Darwin and clang
Quoted 151 lines
Thanks,
NicolasQuoted 146 lines · On 17/10/16 22:24, [email protected] wrote:
From: William Roberts <[email protected]>
To build on mac, first build libsepol with
DISABLE_CIL=y and no DESTDIR set.Secondly, build libselinux with ANDROID_HOST=y
This configuration can be used to test the Android host build on Mac.
Signed-off-by William Roberts <[email protected]>--- libselinux/Makefile | 10 ++++++++++ libselinux/src/Makefile | 36 ++++++++++++++++++++++++++---------- libselinux/utils/Makefile | 29 +++++++++++++++++++++-------- 3 files changed, 57 insertions(+), 18 deletions(-)libselinux/Makefile +10
-0@@ -27,6 +27,16 @@ else endif export PCRE_CFLAGS PCRE_LDFLAGS +OS := $(shell uname) +export OS + +ifeq ($(shell $(CC) -v 2>&1 | grep "clang"),) +COMPILER := gcc +else +COMPILER := clang +endif +export COMPILER + all install relabel clean distclean indent: @for subdir in $(SUBDIRS); do \ (cd $$subdir && $(MAKE) $@) || exit 1; \libselinux/src/Makefile +26
-10@@ -48,23 +48,39 @@ OBJS= $(patsubst %.c,%.o,$(SRCS)) LOBJS= $(patsubst %.c,%.lo,$(SRCS)) CFLAGS ?= -O -Wall -W -Wundef -Wformat-y2k -Wformat-security -Winit-self -Wmissing-include-dirs \ -Wunused -Wunknown-pragmas -Wstrict-aliasing -Wshadow -Wpointer-arith \ - -Wbad-function-cast -Wcast-align -Wwrite-strings -Wlogical-op -Waggregate-return \ + -Wbad-function-cast -Wcast-align -Wwrite-strings -Waggregate-return \ -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes \ -Wmissing-declarations -Wmissing-noreturn -Wmissing-format-attribute \ -Wredundant-decls -Wnested-externs -Winline -Winvalid-pch -Wvolatile-register-var \ - -Wdisabled-optimization -Wbuiltin-macro-redefined -Wpacked-bitfield-compat \ - -Wsync-nand -Wattributes -Wcoverage-mismatch -Wmultichar -Wcpp \ + -Wdisabled-optimization -Wbuiltin-macro-redefined \ + -Wattributes -Wmultichar \ -Wdeprecated-declarations -Wdiv-by-zero -Wdouble-promotion -Wendif-labels -Wextra \ - -Wformat-contains-nul -Wformat-extra-args -Wformat-zero-length -Wformat=2 -Wmultichar \ - -Wnormalized=nfc -Woverflow -Wpointer-to-int-cast -Wpragmas -Wsuggest-attribute=const \ - -Wsuggest-attribute=noreturn -Wsuggest-attribute=pure -Wtrampolines \ - -Wno-missing-field-initializers -Wno-sign-compare -Wjump-misses-init \ - -Wno-format-nonliteral -Wframe-larger-than=$(MAX_STACK_SIZE) -Wp,-D_FORTIFY_SOURCE=2 \ + -Wformat-extra-args -Wformat-zero-length -Wformat=2 -Wmultichar \ + -Woverflow -Wpointer-to-int-cast -Wpragmas \ + -Wno-missing-field-initializers -Wno-sign-compare \ + -Wno-format-nonliteral -Wframe-larger-than=$(MAX_STACK_SIZE) \ -fstack-protector-all --param=ssp-buffer-size=4 -fexceptions \ -fasynchronous-unwind-tables -fdiagnostics-show-option -funit-at-a-time \ - -fipa-pure-const -Wno-suggest-attribute=pure -Wno-suggest-attribute=const \ -Werror -Wno-aggregate-return -Wno-redundant-decls +LD_SONAME_FLAGS=-soname,$(LIBSO),-z,defs,-z,relro + +ifeq ($(COMPILER), gcc) +override CFLAGS += -fipa-pure-const -Wlogical-op -Wpacked-bitfield-compat -Wsync-nand \ + -Wcoverage-mismatch -Wcpp -Wformat-contains-nul -Wnormalized=nfc -Wsuggest-attribute=const \ + -Wsuggest-attribute=noreturn -Wsuggest-attribute=pure -Wtrampolines -Wjump-misses-init \ + -Wno-suggest-attribute=pure -Wno-suggest-attribute=const -Wp,-D_FORTIFY_SOURCE=2 +else +override CFLAGS += -Wunused-command-line-argument +override LDFLAGS += -L/opt/local/lib -undefined dynamic_lookup +LD_SONAME_FLAGS=-install_name,$(LIBSO) +endif + +ifeq ($(OS), Darwin) +override CFLAGS += -I/opt/local/include +override LDFLAGS += -L/opt/local/lib -undefined dynamic_lookup +endif + PCRE_LDFLAGS ?= -lpcre override CFLAGS += -I../include -I$(INCLUDEDIR) -D_GNU_SOURCE $(DISABLE_FLAGS) $(PCRE_CFLAGS)@@ -117,7 +133,7 @@ $(LIBA): $(OBJS) $(RANLIB) $@ $(LIBSO): $(LOBJS) - $(CC) $(CFLAGS) -shared -o $@ $^ $(PCRE_LDFLAGS) -ldl $(LDFLAGS) -L$(LIBDIR) -Wl,-soname,$(LIBSO),-z,defs,-z,relro + $(CC) $(CFLAGS) -shared -o $@ $^ $(PCRE_LDFLAGS) -ldl $(LDFLAGS) -L$(LIBDIR) -Wl,$(LD_SONAME_FLAGS) ln -sf $@ $(TARGET) $(LIBPC): $(LIBPC).in ../VERSIONlibselinux/utils/Makefile +21
-8@@ -8,22 +8,35 @@ INCLUDEDIR ?= $(PREFIX)/include MAX_STACK_SIZE=8192 CFLAGS ?= -O -Wall -W -Wundef -Wformat-y2k -Wformat-security -Winit-self -Wmissing-include-dirs \ -Wunused -Wunknown-pragmas -Wstrict-aliasing -Wshadow -Wpointer-arith \ - -Wbad-function-cast -Wcast-align -Wwrite-strings -Wlogical-op -Waggregate-return \ + -Wbad-function-cast -Wcast-align -Wwrite-strings -Waggregate-return \ -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes \ -Wmissing-declarations -Wmissing-noreturn -Wmissing-format-attribute \ -Wredundant-decls -Wnested-externs -Winline -Winvalid-pch -Wvolatile-register-var \ - -Wdisabled-optimization -Wbuiltin-macro-redefined -Wpacked-bitfield-compat \ - -Wsync-nand -Wattributes -Wcoverage-mismatch -Wmultichar -Wcpp \ + -Wdisabled-optimization -Wbuiltin-macro-redefined \ + -Wattributes -Wmultichar \ -Wdeprecated-declarations -Wdiv-by-zero -Wdouble-promotion -Wendif-labels -Wextra \ - -Wformat-contains-nul -Wformat-extra-args -Wformat-zero-length -Wformat=2 -Wmultichar \ - -Wnormalized=nfc -Woverflow -Wpointer-to-int-cast -Wpragmas -Wsuggest-attribute=const \ - -Wsuggest-attribute=noreturn -Wsuggest-attribute=pure -Wtrampolines \ - -Wno-missing-field-initializers -Wno-sign-compare -Wjump-misses-init \ + -Wformat-extra-args -Wformat-zero-length -Wformat=2 -Wmultichar \ + -Woverflow -Wpointer-to-int-cast -Wpragmas \ + -Wno-missing-field-initializers -Wno-sign-compare \ -Wno-format-nonliteral -Wframe-larger-than=$(MAX_STACK_SIZE) -Wp,-D_FORTIFY_SOURCE=2 \ -fstack-protector-all --param=ssp-buffer-size=4 -fexceptions \ -fasynchronous-unwind-tables -fdiagnostics-show-option -funit-at-a-time \ - -fipa-pure-const -Wno-suggest-attribute=pure -Wno-suggest-attribute=const \ -Werror -Wno-aggregate-return -Wno-redundant-decls + +LD_SONAME_FLAGS=-soname,$(LIBSO),-z,defs,-z,relro + +ifeq ($(COMPILER), gcc) +override CFLAGS += -fipa-pure-const -Wpacked-bitfield-compat -Wsync-nand -Wcoverage-mismatch \ + -Wcpp -Wformat-contains-nul -Wnormalized=nfc -Wsuggest-attribute=const \ + -Wsuggest-attribute=noreturn -Wsuggest-attribute=pure -Wtrampolines -Wjump-misses-init \ + -Wno-suggest-attribute=pure -Wno-suggest-attribute=const +endif + +ifeq ($(OS), Darwin) +override CFLAGS += -I/opt/local/include -I../../libsepol/include +override LDFLAGS += -L../../libsepol/src -undefined dynamic_lookup +endif + override CFLAGS += -I../include -I$(INCLUDEDIR) -D_GNU_SOURCE $(DISABLE_FLAGS) $(PCRE_CFLAGS)Quoted 8 lines
libselinux/utils/Makefile INCLUDEDIR ?= $(PREFIX)/include · line 42
Quoted 3 lines
libselinux/utils/Makefile +0
-0LDLIBS += -L../src -lselinux -L$(LIBDIR) PCRE_LDFLAGS ?= -lpcre_______________________________________________
Selinux mailing list
[email protected]
To unsubscribe, send email to [email protected].
To get help, send an email containing "help" to [email protected].--
Respectfully,William C Roberts
Signature · 3 lines
Respectfully, William C Roberts
Re: [PATCH 6/8] libselinux: support ANDROID_HOST=1 on Mac
Actually this is the kind of error that clang reports that I find kind of useless, so I disabled this warning with some other ones in my build configuration. The full list of warnings I disabled is at the beginning of https://github.com/fishilico/selinux/blob/master/Makefile.
Also, the last time I tried to compile the Python modules (in policycoreutils) with CC=clang only, I encountered linking-time issues which were solved by also defining LDSHARED=clang (I spent some time figuring out that this variable was needed).
Finally I also have some patches which may fix some issues which I have not send to the list yet. If you are interested in taking a look to them, they are on https://github.com/fishilico/selinux/commits/master.
Thanks,
Nicolas
Quoted 207 lines · William Roberts
On the current tip of master, with clang 3.8.0 on my Ubuntu box I get:
avc_internal.c:105:25: error: cast from 'char *' to 'struct nlmsghdr *' increases required alignment from 1 to 4 [-Werror,-Wcast-align]
struct nlmsghdr *nlh = (struct nlmsghdr *)buf; ^~~~~~~~~~~~~~~~~~~~~~ avc_internal.c:161:25: error: cast from 'char *' to 'struct nlmsghdr *' increases required alignment from 1 to 4 [-Werror,-Wcast-align] struct nlmsghdr *nlh = (struct nlmsghdr *)buf;I'm not sure of the best way to handle that, considering we don't unsure that buf is bigger than a nlmsghdr...
I'll send a test patch out in bit.
Quoted 185 lines · William Roberts
Quoted 10 lines · Nicolas Iooss
Hello,
After this commit, libselinux fails to build with clang on Linux:
clang-3.9: warning: argument unused during compilation: '-undefined
dynamic_lookup'
/usr/bin/ld: unrecognised option: -install_name clang-3.9: error: linker command failed with exit code 1 (use -v to
see invocation)Quoted 5 lines
It seems clang 3.9.0 does not like "-undefined
dynamic_lookup" and binutils 2.27 does not know about "-install_name". Would it be possible to put the lines which add these two options to the compiler command lines into a "ifeq ($(OS), Darwin)" block, if they are indeed targeted to MacOS?I'll look into this, likely needs to be Darwin and clang
Quoted 151 lines
Thanks,
NicolasQuoted 146 lines · On 17/10/16 22:24, [email protected] wrote:
From: William Roberts <[email protected]>
To build on mac, first build libsepol with
DISABLE_CIL=y and no DESTDIR set.Secondly, build libselinux with ANDROID_HOST=y
This configuration can be used to test the Android host build on Mac.
Signed-off-by William Roberts <[email protected]>--- libselinux/Makefile | 10 ++++++++++ libselinux/src/Makefile | 36 ++++++++++++++++++++++++++---------- libselinux/utils/Makefile | 29 +++++++++++++++++++++-------- 3 files changed, 57 insertions(+), 18 deletions(-)libselinux/Makefile +10
-0@@ -27,6 +27,16 @@ else endif export PCRE_CFLAGS PCRE_LDFLAGS +OS := $(shell uname) +export OS + +ifeq ($(shell $(CC) -v 2>&1 | grep "clang"),) +COMPILER := gcc +else +COMPILER := clang +endif +export COMPILER + all install relabel clean distclean indent: @for subdir in $(SUBDIRS); do \ (cd $$subdir && $(MAKE) $@) || exit 1; \libselinux/src/Makefile +26
-10@@ -48,23 +48,39 @@ OBJS= $(patsubst %.c,%.o,$(SRCS)) LOBJS= $(patsubst %.c,%.lo,$(SRCS)) CFLAGS ?= -O -Wall -W -Wundef -Wformat-y2k -Wformat-security -Winit-self -Wmissing-include-dirs \ -Wunused -Wunknown-pragmas -Wstrict-aliasing -Wshadow -Wpointer-arith \ - -Wbad-function-cast -Wcast-align -Wwrite-strings -Wlogical-op -Waggregate-return \ + -Wbad-function-cast -Wcast-align -Wwrite-strings -Waggregate-return \ -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes \ -Wmissing-declarations -Wmissing-noreturn -Wmissing-format-attribute \ -Wredundant-decls -Wnested-externs -Winline -Winvalid-pch -Wvolatile-register-var \ - -Wdisabled-optimization -Wbuiltin-macro-redefined -Wpacked-bitfield-compat \ - -Wsync-nand -Wattributes -Wcoverage-mismatch -Wmultichar -Wcpp \ + -Wdisabled-optimization -Wbuiltin-macro-redefined \ + -Wattributes -Wmultichar \ -Wdeprecated-declarations -Wdiv-by-zero -Wdouble-promotion -Wendif-labels -Wextra \ - -Wformat-contains-nul -Wformat-extra-args -Wformat-zero-length -Wformat=2 -Wmultichar \ - -Wnormalized=nfc -Woverflow -Wpointer-to-int-cast -Wpragmas -Wsuggest-attribute=const \ - -Wsuggest-attribute=noreturn -Wsuggest-attribute=pure -Wtrampolines \ - -Wno-missing-field-initializers -Wno-sign-compare -Wjump-misses-init \ - -Wno-format-nonliteral -Wframe-larger-than=$(MAX_STACK_SIZE) -Wp,-D_FORTIFY_SOURCE=2 \ + -Wformat-extra-args -Wformat-zero-length -Wformat=2 -Wmultichar \ + -Woverflow -Wpointer-to-int-cast -Wpragmas \ + -Wno-missing-field-initializers -Wno-sign-compare \ + -Wno-format-nonliteral -Wframe-larger-than=$(MAX_STACK_SIZE) \ -fstack-protector-all --param=ssp-buffer-size=4 -fexceptions \ -fasynchronous-unwind-tables -fdiagnostics-show-option -funit-at-a-time \ - -fipa-pure-const -Wno-suggest-attribute=pure -Wno-suggest-attribute=const \ -Werror -Wno-aggregate-return -Wno-redundant-decls +LD_SONAME_FLAGS=-soname,$(LIBSO),-z,defs,-z,relro + +ifeq ($(COMPILER), gcc) +override CFLAGS += -fipa-pure-const -Wlogical-op -Wpacked-bitfield-compat -Wsync-nand \ + -Wcoverage-mismatch -Wcpp -Wformat-contains-nul -Wnormalized=nfc -Wsuggest-attribute=const \ + -Wsuggest-attribute=noreturn -Wsuggest-attribute=pure -Wtrampolines -Wjump-misses-init \ + -Wno-suggest-attribute=pure -Wno-suggest-attribute=const -Wp,-D_FORTIFY_SOURCE=2 +else +override CFLAGS += -Wunused-command-line-argument +override LDFLAGS += -L/opt/local/lib -undefined dynamic_lookup +LD_SONAME_FLAGS=-install_name,$(LIBSO) +endif + +ifeq ($(OS), Darwin) +override CFLAGS += -I/opt/local/include +override LDFLAGS += -L/opt/local/lib -undefined dynamic_lookup +endif + PCRE_LDFLAGS ?= -lpcre override CFLAGS += -I../include -I$(INCLUDEDIR) -D_GNU_SOURCE $(DISABLE_FLAGS) $(PCRE_CFLAGS)@@ -117,7 +133,7 @@ $(LIBA): $(OBJS) $(RANLIB) $@ $(LIBSO): $(LOBJS) - $(CC) $(CFLAGS) -shared -o $@ $^ $(PCRE_LDFLAGS) -ldl $(LDFLAGS) -L$(LIBDIR) -Wl,-soname,$(LIBSO),-z,defs,-z,relro + $(CC) $(CFLAGS) -shared -o $@ $^ $(PCRE_LDFLAGS) -ldl $(LDFLAGS) -L$(LIBDIR) -Wl,$(LD_SONAME_FLAGS) ln -sf $@ $(TARGET) $(LIBPC): $(LIBPC).in ../VERSIONlibselinux/utils/Makefile +21
-8@@ -8,22 +8,35 @@ INCLUDEDIR ?= $(PREFIX)/include MAX_STACK_SIZE=8192 CFLAGS ?= -O -Wall -W -Wundef -Wformat-y2k -Wformat-security -Winit-self -Wmissing-include-dirs \ -Wunused -Wunknown-pragmas -Wstrict-aliasing -Wshadow -Wpointer-arith \ - -Wbad-function-cast -Wcast-align -Wwrite-strings -Wlogical-op -Waggregate-return \ + -Wbad-function-cast -Wcast-align -Wwrite-strings -Waggregate-return \ -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes \ -Wmissing-declarations -Wmissing-noreturn -Wmissing-format-attribute \ -Wredundant-decls -Wnested-externs -Winline -Winvalid-pch -Wvolatile-register-var \ - -Wdisabled-optimization -Wbuiltin-macro-redefined -Wpacked-bitfield-compat \ - -Wsync-nand -Wattributes -Wcoverage-mismatch -Wmultichar -Wcpp \ + -Wdisabled-optimization -Wbuiltin-macro-redefined \ + -Wattributes -Wmultichar \ -Wdeprecated-declarations -Wdiv-by-zero -Wdouble-promotion -Wendif-labels -Wextra \ - -Wformat-contains-nul -Wformat-extra-args -Wformat-zero-length -Wformat=2 -Wmultichar \ - -Wnormalized=nfc -Woverflow -Wpointer-to-int-cast -Wpragmas -Wsuggest-attribute=const \ - -Wsuggest-attribute=noreturn -Wsuggest-attribute=pure -Wtrampolines \ - -Wno-missing-field-initializers -Wno-sign-compare -Wjump-misses-init \ + -Wformat-extra-args -Wformat-zero-length -Wformat=2 -Wmultichar \ + -Woverflow -Wpointer-to-int-cast -Wpragmas \ + -Wno-missing-field-initializers -Wno-sign-compare \ -Wno-format-nonliteral -Wframe-larger-than=$(MAX_STACK_SIZE) -Wp,-D_FORTIFY_SOURCE=2 \ -fstack-protector-all --param=ssp-buffer-size=4 -fexceptions \ -fasynchronous-unwind-tables -fdiagnostics-show-option -funit-at-a-time \ - -fipa-pure-const -Wno-suggest-attribute=pure -Wno-suggest-attribute=const \ -Werror -Wno-aggregate-return -Wno-redundant-decls + +LD_SONAME_FLAGS=-soname,$(LIBSO),-z,defs,-z,relro + +ifeq ($(COMPILER), gcc) +override CFLAGS += -fipa-pure-const -Wpacked-bitfield-compat -Wsync-nand -Wcoverage-mismatch \ + -Wcpp -Wformat-contains-nul -Wnormalized=nfc -Wsuggest-attribute=const \ + -Wsuggest-attribute=noreturn -Wsuggest-attribute=pure -Wtrampolines -Wjump-misses-init \ + -Wno-suggest-attribute=pure -Wno-suggest-attribute=const +endif + +ifeq ($(OS), Darwin) +override CFLAGS += -I/opt/local/include -I../../libsepol/include +override LDFLAGS += -L../../libsepol/src -undefined dynamic_lookup +endif + override CFLAGS += -I../include -I$(INCLUDEDIR) -D_GNU_SOURCE $(DISABLE_FLAGS) $(PCRE_CFLAGS)Quoted 8 lines
libselinux/utils/Makefile INCLUDEDIR ?= $(PREFIX)/include · line 42
Quoted 3 lines
libselinux/utils/Makefile +0
-0LDLIBS += -L../src -lselinux -L$(LIBDIR) PCRE_LDFLAGS ?= -lpcre_______________________________________________
Selinux mailing list
[email protected]
To unsubscribe, send email to [email protected].
To get help, send an email containing "help" to [email protected].--
Respectfully,William C Roberts
PATCH 7/8 libselinux: DISABLE_BOOL move to include headers
In reply to [email protected]From: William Roberts <[email protected]>
Some systems, like Mac, don't have stdio_ext.h. Since we're building with DISABLE_BOOL=y on Mac, just include the header files with the DISABLE define, and use the bare minimum headers for DISABLE_BOOL=y.
--- libselinux/src/booleans.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
libselinux/src/booleans.c +6 -2
@@ -5,6 +5,8 @@* Dan Walsh <[email protected]> - Added security_load_booleans(). */ +#ifndef DISABLE_BOOL +#include <assert.h> #include <sys/types.h> #include <sys/stat.h>
@@ -25,8 +27,6 @@#define SELINUX_BOOL_DIR "/booleans/" -#ifndef DISABLE_BOOL -static int filename_select (const struct dirent *d) { if (d->d_name[0] == '.'
@@ -561,6 +561,10 @@ int security_load_booleans(char *path) }#else + +#include <stdlib.h> +#include "selinux_internal.h" +int security_set_boolean_list (size_t boolcnt __attribute__((unused)),SELboolean * boollist __attribute__((unused)),int permanent __attribute__((unused)))
Signature · 1 line
1.9.1
PATCH 8/8 libselinux: add booleans.c to ANDROID_HOST=y recipe
In reply to [email protected]From: William Roberts <[email protected]>
We build booleans.c with DISABLE_BOOL set on Android host and target. Add that file to the upstream Makefile.
--- libselinux/src/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
libselinux/src/Makefile +1 -1
@@ -100,7 +100,7 @@ DISABLE_FLAGS+= -DNO_MEDIA_BACKEND -DNO_DB_BACKEND -DNO_X_BACKEND \ -DBUILD_HOST SRCS= callbacks.c freecon.c label.c label_file.c \ label_backends_android.c regex.c label_support.c \ - matchpathcon.c setrans_client.c sha1.c + matchpathcon.c setrans_client.c sha1.c booleans.c else DISABLE_FLAGS+= -DNO_ANDROID_BACKEND SRCS:= $(filter-out label_backends_android.c, $(SRCS))
Signature · 1 line
1.9.1
Stephen Smalley
AppliedRe: [PATCH 8/8] libselinux: add booleans.c to ANDROID_HOST=y recipe
Quoted 6 lines · On 10/17/2016 04:24 PM, [email protected] wrote:
From: William Roberts <[email protected]>
We build
booleans.cwithDISABLE_BOOLset on Android host and target. Add that file to the upstreamMakefile.Signed-off-by William Roberts <[email protected]>
Thanks, applied the series.
Quoted 18 lines
--- libselinux/src/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)libselinux/src/Makefile +1
-1@@ -100,7 +100,7 @@ DISABLE_FLAGS+= -DNO_MEDIA_BACKEND -DNO_DB_BACKEND -DNO_X_BACKEND \ -DBUILD_HOST SRCS= callbacks.c freecon.c label.c label_file.c \ label_backends_android.c regex.c label_support.c \ - matchpathcon.c setrans_client.c sha1.c + matchpathcon.c setrans_client.c sha1.c booleans.c else DISABLE_FLAGS+= -DNO_ANDROID_BACKEND SRCS:= $(filter-out label_backends_android.c, $(SRCS))