All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] share/mk/: CPPFLAGS: Only define _FORTIFY_SOURCE if it's not already defined
@ 2024-07-17 17:08 Alejandro Colomar
  2024-07-17 17:19 ` Alejandro Colomar
  0 siblings, 1 reply; 2+ messages in thread
From: Alejandro Colomar @ 2024-07-17 17:08 UTC (permalink / raw)
  To: liba2i; +Cc: Alejandro Colomar, Sam James

[-- Attachment #1: Type: text/plain, Size: 1776 bytes --]

Reported-by: Sam James <sam@gentoo.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
---

Hi Sam,

I've tested it and it seems to work as one would expect.

Cheers,
Alex

Range-diff against v0:
-:  --------- > 1:  1415c5704 share/mk/: CPPFLAGS: Only define _FORTIFY_SOURCE if it's not already defined

 share/mk/configure/build-depends/cpp/cpp.mk | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/share/mk/configure/build-depends/cpp/cpp.mk b/share/mk/configure/build-depends/cpp/cpp.mk
index 11ba5448d..ec8068458 100644
--- a/share/mk/configure/build-depends/cpp/cpp.mk
+++ b/share/mk/configure/build-depends/cpp/cpp.mk
@@ -6,15 +6,31 @@ ifndef MAKEFILE_CONFIGURE_BUILD_DEPENDS_CPP_CPP_INCLUDED
 MAKEFILE_CONFIGURE_BUILD_DEPENDS_CPP_CPP_INCLUDED := 1
 
 
+include $(MAKEFILEDIR)/configure/build-depends/coreutils/echo.mk
 include $(MAKEFILEDIR)/configure/build-depends/gcc/cc.mk
+include $(MAKEFILEDIR)/configure/build-depends/grep/grep.mk
 include $(MAKEFILEDIR)/configure/build-depends/pkgconf/pkgconf.mk
 include $(MAKEFILEDIR)/configure/verbose.mk
 
 
+CPP := $(CC) $(CFLAGS_) -E
+
+
+CPP_HAS_ALREADY_D_FORTIFY_SOURCE := \
+	$(shell \
+		$(CPP) -dM - -Wno-error </dev/null \
+		| $(GREP) '#define _FORTIFY_SOURCE ' >/dev/null \
+		&& $(ECHO) yes \
+		|| $(ECHO) no; \
+	)
+
+
 DEFAULT_CPPFLAGS := \
 	$(shell $(PKGCONF_CMD) --cflags $(pc) $(HIDE_ERR)) \
-	-D_FORTIFY_SOURCE=2 \
 	-I$(srcdir)/
+ifeq ($(CPP_HAS_ALREADY_D_FORTIFY_SOURCE),no)
+DEFAULT_CPPFLAGS += -D_FORTIFY_SOURCE=2
+endif
 CPPFLAGS         :=
 CPPFLAGS_        := $(DEFAULT_CPPFLAGS) $(CPPFLAGS)
 CPP              := $(CC) $(CFLAGS_) -E

base-commit: a264f9442e64d555451104257538124f831db854
-- 
2.45.2


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v1] share/mk/: CPPFLAGS: Only define _FORTIFY_SOURCE if it's not already defined
  2024-07-17 17:08 [PATCH v1] share/mk/: CPPFLAGS: Only define _FORTIFY_SOURCE if it's not already defined Alejandro Colomar
@ 2024-07-17 17:19 ` Alejandro Colomar
  0 siblings, 0 replies; 2+ messages in thread
From: Alejandro Colomar @ 2024-07-17 17:19 UTC (permalink / raw)
  To: liba2i; +Cc: Sam James

[-- Attachment #1: Type: text/plain, Size: 2074 bytes --]

On Wed, Jul 17, 2024 at 07:08:26PM GMT, Alejandro Colomar wrote:
> Reported-by: Sam James <sam@gentoo.org>
> Signed-off-by: Alejandro Colomar <alx@kernel.org>
> ---
> 
> Hi Sam,
> 
> I've tested it and it seems to work as one would expect.
> 
> Cheers,
> Alex
> 
> Range-diff against v0:
> -:  --------- > 1:  1415c5704 share/mk/: CPPFLAGS: Only define _FORTIFY_SOURCE if it's not already defined
> 
>  share/mk/configure/build-depends/cpp/cpp.mk | 18 +++++++++++++++++-
>  1 file changed, 17 insertions(+), 1 deletion(-)
> 
> diff --git a/share/mk/configure/build-depends/cpp/cpp.mk b/share/mk/configure/build-depends/cpp/cpp.mk
> index 11ba5448d..ec8068458 100644
> --- a/share/mk/configure/build-depends/cpp/cpp.mk
> +++ b/share/mk/configure/build-depends/cpp/cpp.mk
> @@ -6,15 +6,31 @@ ifndef MAKEFILE_CONFIGURE_BUILD_DEPENDS_CPP_CPP_INCLUDED
>  MAKEFILE_CONFIGURE_BUILD_DEPENDS_CPP_CPP_INCLUDED := 1
>  
>  
> +include $(MAKEFILEDIR)/configure/build-depends/coreutils/echo.mk
>  include $(MAKEFILEDIR)/configure/build-depends/gcc/cc.mk
> +include $(MAKEFILEDIR)/configure/build-depends/grep/grep.mk
>  include $(MAKEFILEDIR)/configure/build-depends/pkgconf/pkgconf.mk
>  include $(MAKEFILEDIR)/configure/verbose.mk
>  
>  
> +CPP := $(CC) $(CFLAGS_) -E
> +
> +
> +CPP_HAS_ALREADY_D_FORTIFY_SOURCE := \
> +	$(shell \
> +		$(CPP) -dM - -Wno-error </dev/null \
> +		| $(GREP) '#define _FORTIFY_SOURCE ' >/dev/null \
> +		&& $(ECHO) yes \
> +		|| $(ECHO) no; \
> +	)
> +
> +
>  DEFAULT_CPPFLAGS := \
>  	$(shell $(PKGCONF_CMD) --cflags $(pc) $(HIDE_ERR)) \
> -	-D_FORTIFY_SOURCE=2 \
>  	-I$(srcdir)/
> +ifeq ($(CPP_HAS_ALREADY_D_FORTIFY_SOURCE),no)
> +DEFAULT_CPPFLAGS += -D_FORTIFY_SOURCE=2
> +endif
>  CPPFLAGS         :=
>  CPPFLAGS_        := $(DEFAULT_CPPFLAGS) $(CPPFLAGS)
>  CPP              := $(CC) $(CFLAGS_) -E

Oops, I forgot to remove this line.  It's removed now in v2.

> 
> base-commit: a264f9442e64d555451104257538124f831db854
> -- 
> 2.45.2
> 



-- 
<https://www.alejandro-colomar.es/>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-07-17 17:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-17 17:08 [PATCH v1] share/mk/: CPPFLAGS: Only define _FORTIFY_SOURCE if it's not already defined Alejandro Colomar
2024-07-17 17:19 ` Alejandro Colomar

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.