* [PATCH] libselinux: Fix CFLAGS definition
@ 2017-05-09 14:54 Stephen Smalley
2017-05-09 16:19 ` William Roberts
0 siblings, 1 reply; 2+ messages in thread
From: Stephen Smalley @ 2017-05-09 14:54 UTC (permalink / raw)
To: selinux; +Cc: jwcart2, Stephen Smalley
commit 16c123f4b1f3c8d20b3f597df161d7e635620923 ("libselinux:
support ANDROID_HOST=1 on Mac") split up warning flags in
CFLAGS based on compiler support in a manner that could lead to
including a subset that is invalid, e.g. upon
make DESTDIR=/path/to/dest install. Fix it.
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
---
libselinux/src/Makefile | 21 +++++++++++----------
libselinux/utils/Makefile | 17 +++++++++--------
2 files changed, 20 insertions(+), 18 deletions(-)
diff --git a/libselinux/src/Makefile b/libselinux/src/Makefile
index f1b8bd9..4306dd0 100644
--- a/libselinux/src/Makefile
+++ b/libselinux/src/Makefile
@@ -55,6 +55,15 @@ SRCS= $(filter-out $(GENERATED) audit2why.c, $(sort $(wildcard *.c)))
MAX_STACK_SIZE=32768
+ifeq ($(COMPILER), gcc)
+EXTRA_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
+EXTRA_CFLAGS = -Wunused-command-line-argument
+endif
+
OBJS= $(patsubst %.c,%.o,$(SRCS))
LOBJS= $(patsubst %.c,%.lo,$(SRCS))
CFLAGS ?= -O -Wall -W -Wundef -Wformat-y2k -Wformat-security -Winit-self -Wmissing-include-dirs \
@@ -72,19 +81,11 @@ CFLAGS ?= -O -Wall -W -Wundef -Wformat-y2k -Wformat-security -Winit-self -Wmissi
-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 \
- -Werror -Wno-aggregate-return -Wno-redundant-decls
+ -Werror -Wno-aggregate-return -Wno-redundant-decls \
+ $(EXTRA_CFLAGS)
LD_SONAME_FLAGS=-soname,$(LIBSO),-z,defs,-z,relro
-ifeq ($(COMPILER), gcc)
-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
-CFLAGS += -Wunused-command-line-argument
-endif
-
ifeq ($(OS), Darwin)
override CFLAGS += -I/opt/local/include
override LDFLAGS += -L/opt/local/lib -undefined dynamic_lookup
diff --git a/libselinux/utils/Makefile b/libselinux/utils/Makefile
index 5d61031..14f94bd 100644
--- a/libselinux/utils/Makefile
+++ b/libselinux/utils/Makefile
@@ -12,6 +12,13 @@ else
COMPILER ?= clang
endif
+ifeq ($(COMPILER), gcc)
+EXTRA_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
+
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 \
@@ -28,17 +35,11 @@ CFLAGS ?= -O -Wall -W -Wundef -Wformat-y2k -Wformat-security -Winit-self -Wmissi
-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 \
- -Werror -Wno-aggregate-return -Wno-redundant-decls
+ -Werror -Wno-aggregate-return -Wno-redundant-decls \
+ $(EXTRA_CFLAGS)
LD_SONAME_FLAGS=-soname,$(LIBSO),-z,defs,-z,relro
-ifeq ($(COMPILER), gcc)
-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
--
2.9.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] libselinux: Fix CFLAGS definition
2017-05-09 14:54 [PATCH] libselinux: Fix CFLAGS definition Stephen Smalley
@ 2017-05-09 16:19 ` William Roberts
0 siblings, 0 replies; 2+ messages in thread
From: William Roberts @ 2017-05-09 16:19 UTC (permalink / raw)
To: Stephen Smalley; +Cc: selinux
[-- Attachment #1: Type: text/plain, Size: 4738 bytes --]
On Tue, May 9, 2017 at 7:54 AM, Stephen Smalley <sds@tycho.nsa.gov> wrote:
> commit 16c123f4b1f3c8d20b3f597df161d7e635620923 ("libselinux:
> support ANDROID_HOST=1 on Mac") split up warning flags in
> CFLAGS based on compiler support in a manner that could lead to
> including a subset that is invalid, e.g. upon
> make DESTDIR=/path/to/dest install. Fix it.
>
>
Ack + Review
> Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
> ---
> libselinux/src/Makefile | 21 +++++++++++----------
> libselinux/utils/Makefile | 17 +++++++++--------
> 2 files changed, 20 insertions(+), 18 deletions(-)
>
> diff --git a/libselinux/src/Makefile b/libselinux/src/Makefile
> index f1b8bd9..4306dd0 100644
> --- a/libselinux/src/Makefile
> +++ b/libselinux/src/Makefile
> @@ -55,6 +55,15 @@ SRCS= $(filter-out $(GENERATED) audit2why.c, $(sort
> $(wildcard *.c)))
>
> MAX_STACK_SIZE=32768
>
> +ifeq ($(COMPILER), gcc)
> +EXTRA_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
> +EXTRA_CFLAGS = -Wunused-command-line-argument
> +endif
> +
> OBJS= $(patsubst %.c,%.o,$(SRCS))
> LOBJS= $(patsubst %.c,%.lo,$(SRCS))
> CFLAGS ?= -O -Wall -W -Wundef -Wformat-y2k -Wformat-security -Winit-self
> -Wmissing-include-dirs \
> @@ -72,19 +81,11 @@ CFLAGS ?= -O -Wall -W -Wundef -Wformat-y2k
> -Wformat-security -Winit-self -Wmissi
> -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 \
> - -Werror -Wno-aggregate-return -Wno-redundant-decls
> + -Werror -Wno-aggregate-return -Wno-redundant-decls \
> + $(EXTRA_CFLAGS)
>
> LD_SONAME_FLAGS=-soname,$(LIBSO),-z,defs,-z,relro
>
> -ifeq ($(COMPILER), gcc)
> -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
> -CFLAGS += -Wunused-command-line-argument
> -endif
> -
> ifeq ($(OS), Darwin)
> override CFLAGS += -I/opt/local/include
> override LDFLAGS += -L/opt/local/lib -undefined dynamic_lookup
> diff --git a/libselinux/utils/Makefile b/libselinux/utils/Makefile
> index 5d61031..14f94bd 100644
> --- a/libselinux/utils/Makefile
> +++ b/libselinux/utils/Makefile
> @@ -12,6 +12,13 @@ else
> COMPILER ?= clang
> endif
>
> +ifeq ($(COMPILER), gcc)
> +EXTRA_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
> +
> 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 \
> @@ -28,17 +35,11 @@ CFLAGS ?= -O -Wall -W -Wundef -Wformat-y2k
> -Wformat-security -Winit-self -Wmissi
> -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 \
> - -Werror -Wno-aggregate-return -Wno-redundant-decls
> + -Werror -Wno-aggregate-return -Wno-redundant-decls \
> + $(EXTRA_CFLAGS)
>
> LD_SONAME_FLAGS=-soname,$(LIBSO),-z,defs,-z,relro
>
> -ifeq ($(COMPILER), gcc)
> -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
> --
> 2.9.3
>
>
--
Respectfully,
William C Roberts
[-- Attachment #2: Type: text/html, Size: 5826 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-05-09 16:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-09 14:54 [PATCH] libselinux: Fix CFLAGS definition Stephen Smalley
2017-05-09 16:19 ` William Roberts
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.