summaryrefslogtreecommitdiff
path: root/sys-devel/m4/files/m4-1.4.19-fortify-source.patch
blob: d07fe620c3df0b3de3905ec808c7977df9bbb813 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
https://lists.gnu.org/archive/html/m4-patches/2023-01/msg00001.html
https://bugs.gentoo.org/890273

From 960b9b4d0774f78d286932251d6f53f638aefb19 Mon Sep 17 00:00:00 2001
From: Sam James <sam@gentoo.org>
Date: Mon, 9 Jan 2023 08:00:34 +0000
Subject: [PATCH] build: Don't add _FORTIFY_SOURCE if already set by
 user/toolchain

Newer toolchains (GCC 12+ or Clang 9+, glibc-2.34) allow _FORTIFY_SOURCE=3.

The current macro used in configure.ac will forcefully downgrade to F_S=2
and emit a warning if the user set something else:
```
x86_64-pc-linux-gnu-gcc -DEXEEXT=\"\" -I. -I../lib  -DIN_M4_GNULIB_TESTS=1 -I. -I. -I.. -I./.. -I../lib -I./../lib   -O2 -pipe -march=native -fdiagnostics-color=always -frecord-gcc-switches -Wreturn-type      -ggdb3 -Werror=implicit-function-declaration -Werror=implicit-int -c -o glthread/thread.o glthread/thread.c
In file included from glthread/thread.c:20:
../lib/config.h:202: warning: "_FORTIFY_SOURCE" redefined
  202 |    # define _FORTIFY_SOURCE 2
      |
<built-in>: note: this is the location of the previous definition
```

See: 390d259efe8e1c7e4b6babb4738fef7427416857
Signed-off-by: Sam James <sam@gentoo.org>
--- a/configure.ac
+++ b/configure.ac
@@ -133,7 +133,9 @@ if test "$gl_gcc_warnings" = yes; then
   [/* Enable compile-time and run-time bounds-checking, and some warnings,
       without upsetting newer glibc. */
    #if defined __OPTIMIZE__ && __OPTIMIZE__
-   # define _FORTIFY_SOURCE 2
+   # ifndef _FORTIFY_SOURCE
+   #  define _FORTIFY_SOURCE 2
+   # endif
    #endif
   ])
 fi
--- a/lib/config.hin
+++ b/lib/config.hin
@@ -198,7 +198,9 @@
 /* Enable compile-time and run-time bounds-checking, and some warnings,
       without upsetting newer glibc. */
    #if defined __OPTIMIZE__ && __OPTIMIZE__
-   # define _FORTIFY_SOURCE 2
+   # ifndef _FORTIFY_SOURCE
+   #  define _FORTIFY_SOURCE 2
+   # endif
    #endif