diff --git a/packages/gcc/10.4.0/0010-fixinc-don-t-fix-machine-names-in-__has_include-.PR.patch b/packages/gcc/10.4.0/0010-fixinc-don-t-fix-machine-names-in-__has_include-.PR.patch new file mode 100644 index 00000000..2f8ad877 --- /dev/null +++ b/packages/gcc/10.4.0/0010-fixinc-don-t-fix-machine-names-in-__has_include-.PR.patch @@ -0,0 +1,123 @@ +From a6eedb593ca068d0ad8655dbb97fcd6371cba682 Mon Sep 17 00:00:00 2001 +From: Xi Ruoyao +Date: Mon, 28 Jun 2021 13:54:58 +0800 +Subject: [PATCH] fixinc: don't "fix" machine names in __has_include(...) + [PR91085] + +fixincludes/ + + PR other/91085 + * fixfixes.c (check_has_inc): New static function. + (machine_name_fix): Don't replace header names in + __has_include(...). + * inclhack.def (machine_name): Adjust test. + * tests/base/testing.h: Update. + +Upstream: 6bf383c37e6131a8e247e8a0997d55d65c830b6d +Signed-off-by: Thomas Petazzoni +--- + fixincludes/fixfixes.c | 45 ++++++++++++++++++++++++++++++-- + fixincludes/inclhack.def | 3 ++- + fixincludes/tests/base/testing.h | 2 +- + 3 files changed, 46 insertions(+), 4 deletions(-) + +diff --git a/fixincludes/fixfixes.c b/fixincludes/fixfixes.c +index 034e15d9985..3ff87812036 100644 +--- a/fixincludes/fixfixes.c ++++ b/fixincludes/fixfixes.c +@@ -477,6 +477,39 @@ FIX_PROC_HEAD( char_macro_def_fix ) + fputs (text, stdout); + } + ++/* Check if the pattern at pos is actually in a "__has_include(...)" ++ directive. Return the pointer to the ')' of this ++ "__has_include(...)" if it is, NULL otherwise. */ ++static const char * ++check_has_inc (const char *begin, const char *pos, const char *end) ++{ ++ static const char has_inc[] = "__has_include"; ++ const size_t has_inc_len = sizeof (has_inc) - 1; ++ const char *p; ++ ++ for (p = memmem (begin, pos - begin, has_inc, has_inc_len); ++ p != NULL; ++ p = memmem (p, pos - p, has_inc, has_inc_len)) ++ { ++ p += has_inc_len; ++ while (p < end && ISSPACE (*p)) ++ p++; ++ ++ /* "__has_include" may appear as "defined(__has_include)", ++ search for the next appearance then. */ ++ if (*p != '(') ++ continue; ++ ++ /* To avoid too much complexity, just hope there is never a ++ ')' in a header name. */ ++ p = memchr (p, ')', end - p); ++ if (p == NULL || p > pos) ++ return p; ++ } ++ ++ return NULL; ++} ++ + /* Fix for machine name #ifdefs that are not in the namespace reserved + by the C standard. They won't be defined if compiling with -ansi, + and the headers will break. We go to some trouble to only change +@@ -524,7 +557,7 @@ FIX_PROC_HEAD( machine_name_fix ) + /* If the 'name_pat' matches in between base and limit, we have + a bogon. It is not worth the hassle of excluding comments + because comments on #if/#ifdef lines are rare, and strings on +- such lines are illegal. ++ such lines are only legal in a "__has_include" directive. + + REG_NOTBOL means 'base' is not at the beginning of a line, which + shouldn't matter since the name_re has no ^ anchor, but let's +@@ -544,8 +577,16 @@ FIX_PROC_HEAD( machine_name_fix ) + break; + + p = base + match[0].rm_so; +- base += match[0].rm_eo; + ++ /* Check if the match is in __has_include(...) (PR 91085). */ ++ q = check_has_inc (base, p, limit); ++ if (q) ++ { ++ base = q + 1; ++ goto again; ++ } ++ ++ base += match[0].rm_eo; + /* One more test: if on the same line we have the same string + with the appropriate underscores, then leave it alone. + We want exactly two leading and trailing underscores. */ +diff --git a/fixincludes/inclhack.def b/fixincludes/inclhack.def +index f58e7771e1c..71bd717c233 100644 +--- a/fixincludes/inclhack.def ++++ b/fixincludes/inclhack.def +@@ -3114,7 +3114,8 @@ fix = { + c_fix = machine_name; + + test_text = "/* MACH_DIFF: */\n" +- "#if defined( i386 ) || defined( sparc ) || defined( vax )" ++ "#if defined( i386 ) || defined( sparc ) || defined( vax ) || " ++ "defined( linux ) || __has_include ( )" + "\n/* no uniform test, so be careful :-) */"; + }; + +diff --git a/fixincludes/tests/base/testing.h b/fixincludes/tests/base/testing.h +index cf95321fb86..8b3accaf04e 100644 +--- a/fixincludes/tests/base/testing.h ++++ b/fixincludes/tests/base/testing.h +@@ -64,7 +64,7 @@ BSD43__IOWR('T', 1) /* Some are multi-line */ + + #if defined( MACHINE_NAME_CHECK ) + /* MACH_DIFF: */ +-#if defined( i386 ) || defined( sparc ) || defined( vax ) ++#if defined( i386 ) || defined( sparc ) || defined( vax ) || defined( linux ) || __has_include ( ) + /* no uniform test, so be careful :-) */ + #endif /* MACHINE_NAME_CHECK */ + +-- +2.37.3 diff --git a/packages/gcc/11.3.0/0010-fixinc-don-t-fix-machine-names-in-__has_include-.PR.patch b/packages/gcc/11.3.0/0010-fixinc-don-t-fix-machine-names-in-__has_include-.PR.patch new file mode 100644 index 00000000..5e657bd2 --- /dev/null +++ b/packages/gcc/11.3.0/0010-fixinc-don-t-fix-machine-names-in-__has_include-.PR.patch @@ -0,0 +1,123 @@ +From de3f4ee9a5bd2adcb5ff2e1690db2567fda1473c Mon Sep 17 00:00:00 2001 +From: Xi Ruoyao +Date: Mon, 28 Jun 2021 13:54:58 +0800 +Subject: [PATCH] fixinc: don't "fix" machine names in __has_include(...) + [PR91085] + +fixincludes/ + + PR other/91085 + * fixfixes.c (check_has_inc): New static function. + (machine_name_fix): Don't replace header names in + __has_include(...). + * inclhack.def (machine_name): Adjust test. + * tests/base/testing.h: Update. + +Upstream: 6bf383c37e6131a8e247e8a0997d55d65c830b6d +Signed-off-by: Thomas Petazzoni +--- + fixincludes/fixfixes.c | 45 ++++++++++++++++++++++++++++++-- + fixincludes/inclhack.def | 3 ++- + fixincludes/tests/base/testing.h | 2 +- + 3 files changed, 46 insertions(+), 4 deletions(-) + +diff --git a/fixincludes/fixfixes.c b/fixincludes/fixfixes.c +index 5b23a8b640d..404b420f302 100644 +--- a/fixincludes/fixfixes.c ++++ b/fixincludes/fixfixes.c +@@ -477,6 +477,39 @@ FIX_PROC_HEAD( char_macro_def_fix ) + fputs (text, stdout); + } + ++/* Check if the pattern at pos is actually in a "__has_include(...)" ++ directive. Return the pointer to the ')' of this ++ "__has_include(...)" if it is, NULL otherwise. */ ++static const char * ++check_has_inc (const char *begin, const char *pos, const char *end) ++{ ++ static const char has_inc[] = "__has_include"; ++ const size_t has_inc_len = sizeof (has_inc) - 1; ++ const char *p; ++ ++ for (p = memmem (begin, pos - begin, has_inc, has_inc_len); ++ p != NULL; ++ p = memmem (p, pos - p, has_inc, has_inc_len)) ++ { ++ p += has_inc_len; ++ while (p < end && ISSPACE (*p)) ++ p++; ++ ++ /* "__has_include" may appear as "defined(__has_include)", ++ search for the next appearance then. */ ++ if (*p != '(') ++ continue; ++ ++ /* To avoid too much complexity, just hope there is never a ++ ')' in a header name. */ ++ p = memchr (p, ')', end - p); ++ if (p == NULL || p > pos) ++ return p; ++ } ++ ++ return NULL; ++} ++ + /* Fix for machine name #ifdefs that are not in the namespace reserved + by the C standard. They won't be defined if compiling with -ansi, + and the headers will break. We go to some trouble to only change +@@ -524,7 +557,7 @@ FIX_PROC_HEAD( machine_name_fix ) + /* If the 'name_pat' matches in between base and limit, we have + a bogon. It is not worth the hassle of excluding comments + because comments on #if/#ifdef lines are rare, and strings on +- such lines are illegal. ++ such lines are only legal in a "__has_include" directive. + + REG_NOTBOL means 'base' is not at the beginning of a line, which + shouldn't matter since the name_re has no ^ anchor, but let's +@@ -544,8 +577,16 @@ FIX_PROC_HEAD( machine_name_fix ) + break; + + p = base + match[0].rm_so; +- base += match[0].rm_eo; + ++ /* Check if the match is in __has_include(...) (PR 91085). */ ++ q = check_has_inc (base, p, limit); ++ if (q) ++ { ++ base = q + 1; ++ goto again; ++ } ++ ++ base += match[0].rm_eo; + /* One more test: if on the same line we have the same string + with the appropriate underscores, then leave it alone. + We want exactly two leading and trailing underscores. */ +diff --git a/fixincludes/inclhack.def b/fixincludes/inclhack.def +index 066bef99162..b7ad6982e96 100644 +--- a/fixincludes/inclhack.def ++++ b/fixincludes/inclhack.def +@@ -3154,7 +3154,8 @@ fix = { + c_fix = machine_name; + + test_text = "/* MACH_DIFF: */\n" +- "#if defined( i386 ) || defined( sparc ) || defined( vax )" ++ "#if defined( i386 ) || defined( sparc ) || defined( vax ) || " ++ "defined( linux ) || __has_include ( )" + "\n/* no uniform test, so be careful :-) */"; + }; + +diff --git a/fixincludes/tests/base/testing.h b/fixincludes/tests/base/testing.h +index cf95321fb86..8b3accaf04e 100644 +--- a/fixincludes/tests/base/testing.h ++++ b/fixincludes/tests/base/testing.h +@@ -64,7 +64,7 @@ BSD43__IOWR('T', 1) /* Some are multi-line */ + + #if defined( MACHINE_NAME_CHECK ) + /* MACH_DIFF: */ +-#if defined( i386 ) || defined( sparc ) || defined( vax ) ++#if defined( i386 ) || defined( sparc ) || defined( vax ) || defined( linux ) || __has_include ( ) + /* no uniform test, so be careful :-) */ + #endif /* MACHINE_NAME_CHECK */ + +-- +2.37.3 diff --git a/packages/glibc/2.36/0002-Mimic-kernel-defition-for-BLOCK_SIZE.patch b/packages/glibc/2.36/0002-Mimic-kernel-defition-for-BLOCK_SIZE.patch new file mode 100644 index 00000000..bcebfe21 --- /dev/null +++ b/packages/glibc/2.36/0002-Mimic-kernel-defition-for-BLOCK_SIZE.patch @@ -0,0 +1,30 @@ +From 4dad97e2a2e510c6b53a0add29a2188714fcf4ab Mon Sep 17 00:00:00 2001 +From: Adhemerval Zanella +Date: Wed, 10 Aug 2022 14:24:45 -0300 +Subject: [PATCH] linux: Mimic kernel defition for BLOCK_SIZE + +To avoid possible warnings if the kernel header is included before +sys/mount.h. + +Reviewed-by: Florian Weimer +(cherry picked from commit c68b6044bc7945716431f1adc091b17c39b80a06) +--- + sysdeps/unix/sysv/linux/sys/mount.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/sysdeps/unix/sysv/linux/sys/mount.h b/sysdeps/unix/sysv/linux/sys/mount.h +index f965986ba8..df6b0dbb42 100644 +--- a/sysdeps/unix/sysv/linux/sys/mount.h ++++ b/sysdeps/unix/sysv/linux/sys/mount.h +@@ -27,8 +27,8 @@ + #include + #include + +-#define BLOCK_SIZE 1024 + #define BLOCK_SIZE_BITS 10 ++#define BLOCK_SIZE (1< +Date: Wed, 10 Aug 2022 14:24:46 -0300 +Subject: [PATCH] linux: Use compile_c_snippet to check linux/mount.h + availability + +Checked on x86_64-linux-gnu. + +Reviewed-by: Florian Weimer +(cherry picked from commit e1226cdc6b209539a92d32d5b620ba53fd35abf3) +--- + sysdeps/unix/sysv/linux/tst-mount-consts.py | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/sysdeps/unix/sysv/linux/tst-mount-consts.py b/sysdeps/unix/sysv/linux/tst-mount-consts.py +index a62f803123..be2ef2daf1 100755 +--- a/sysdeps/unix/sysv/linux/tst-mount-consts.py ++++ b/sysdeps/unix/sysv/linux/tst-mount-consts.py +@@ -33,6 +33,11 @@ def main(): + help='C compiler (including options) to use') + args = parser.parse_args() + ++ if glibcextract.compile_c_snippet( ++ '#include ', ++ args.cc).returncode != 0: ++ sys.exit (77) ++ + linux_version_headers = glibcsyscalls.linux_kernel_version(args.cc) + # Constants in glibc were updated to match Linux v5.16. When glibc + # constants are updated this value should be updated to match the +-- +2.31.1 diff --git a/packages/glibc/2.36/0004-Fix_sys_mount.h_usage_with_kernel_headers.patch b/packages/glibc/2.36/0004-Fix_sys_mount.h_usage_with_kernel_headers.patch new file mode 100644 index 00000000..a9cdc5b1 --- /dev/null +++ b/packages/glibc/2.36/0004-Fix_sys_mount.h_usage_with_kernel_headers.patch @@ -0,0 +1,336 @@ +From bb1e8b0ca99b5cbedfae3e6245528a87d95ff3e2 Mon Sep 17 00:00:00 2001 +From: Adhemerval Zanella +Date: Wed, 10 Aug 2022 14:24:47 -0300 +Subject: [PATCH] linux: Fix sys/mount.h usage with kernel headers + +Now that kernel exports linux/mount.h and includes it on linux/fs.h, +its definitions might clash with glibc exports sys/mount.h. To avoid +the need to rearrange the Linux header to be always after glibc one, +the glibc sys/mount.h is changed to: + + 1. Undefine the macros also used as enum constants. This covers prior + inclusion of (for instance MS_RDONLY). + + 2. Include based on the usual __has_include check + (needs to use __has_include ("linux/mount.h") to paper over GCC + bugs. + + 3. Define enum fsconfig_command only if FSOPEN_CLOEXEC is not defined. + (FSOPEN_CLOEXEC should be a very close proxy.) + + 4. Define struct mount_attr if MOUNT_ATTR_SIZE_VER0 is not defined. + (Added in the same commit on the Linux side.) + +This patch also adds some tests to check if including linux/fs.h and +linux/mount.h after and before sys/mount.h does work. + +Checked on x86_64-linux-gnu. + +Reviewed-by: Florian Weimer +(cherry picked from commit 774058d72942249f71d74e7f2b639f77184160a6) +--- + sysdeps/unix/sysv/linux/Makefile | 8 +++ + sysdeps/unix/sysv/linux/sys/mount.h | 71 +++++++++++++++++--- + sysdeps/unix/sysv/linux/tst-mount-compile.py | 66 ++++++++++++++++++ + 3 files changed, 137 insertions(+), 8 deletions(-) + create mode 100755 sysdeps/unix/sysv/linux/tst-mount-compile.py + +diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile +index a139a16532..3ceda9fdbf 100644 +--- a/sysdeps/unix/sysv/linux/Makefile ++++ b/sysdeps/unix/sysv/linux/Makefile +@@ -265,6 +265,14 @@ $(objpfx)tst-mount-consts.out: ../sysdeps/unix/sysv/linux/tst-mount-consts.py + < /dev/null > $@ 2>&1; $(evaluate-test) + $(objpfx)tst-mount-consts.out: $(sysdeps-linux-python-deps) + ++tests-special += $(objpfx)tst-mount-compile.out ++$(objpfx)tst-mount-compile.out: ../sysdeps/unix/sysv/linux/tst-mount-compile.py ++ $(sysdeps-linux-python) \ ++ ../sysdeps/unix/sysv/linux/tst-mount-compile.py \ ++ $(sysdeps-linux-python-cc) \ ++ < /dev/null > $@ 2>&1; $(evaluate-test) ++$(objpfx)tst-mount-compile.out: $(sysdeps-linux-python-deps) ++ + tst-rseq-disable-ENV = GLIBC_TUNABLES=glibc.pthread.rseq=0 + + endif # $(subdir) == misc +diff --git a/sysdeps/unix/sysv/linux/sys/mount.h b/sysdeps/unix/sysv/linux/sys/mount.h +index df6b0dbb42..2e3fd6a7fe 100644 +--- a/sysdeps/unix/sysv/linux/sys/mount.h ++++ b/sysdeps/unix/sysv/linux/sys/mount.h +@@ -27,6 +27,13 @@ + #include + #include + ++#ifdef __has_include ++# if __has_include ("linux/mount.h") ++# include "linux/mount.h" ++# endif ++#endif ++ ++ + #define BLOCK_SIZE_BITS 10 + #define BLOCK_SIZE (1<. ++ ++import argparse ++import sys ++ ++import glibcextract ++ ++ ++def main(): ++ """The main entry point.""" ++ parser = argparse.ArgumentParser( ++ description='Check if glibc provided sys/mount.h can be ' ++ ' used along related kernel headers.') ++ parser.add_argument('--cc', metavar='CC', ++ help='C compiler (including options) to use') ++ args = parser.parse_args() ++ ++ if glibcextract.compile_c_snippet( ++ '#include ', ++ args.cc).returncode != 0: ++ sys.exit (77) ++ ++ def check(testname, snippet): ++ # Add -Werror to catch macro redefinitions and _ISOMAC to avoid ++ # internal glibc definitions. ++ r = glibcextract.compile_c_snippet(snippet, args.cc, ++ '-Werror -D_ISOMAC') ++ if r.returncode != 0: ++ print('error: test {}:\n{}'.format(testname, r.output.decode())) ++ return r.returncode ++ ++ status = max( ++ check("sys/mount.h + linux/mount.h", ++ "#include \n" ++ "#include "), ++ check("sys/mount.h + linux/fs.h", ++ "#include \n" ++ "#include "), ++ check("linux/mount.h + sys/mount.h", ++ "#include \n" ++ "#include "), ++ check("linux/fs.h + sys/mount.h", ++ "#include \n" ++ "#include ")) ++ sys.exit(status) ++ ++if __name__ == '__main__': ++ main() +-- +2.31.1 diff --git a/packages/glibc/2.36/0005-Fix-enum-fsconfig_command-detection-in-sys_mount.h.patch b/packages/glibc/2.36/0005-Fix-enum-fsconfig_command-detection-in-sys_mount.h.patch new file mode 100644 index 00000000..da249f36 --- /dev/null +++ b/packages/glibc/2.36/0005-Fix-enum-fsconfig_command-detection-in-sys_mount.h.patch @@ -0,0 +1,43 @@ +From 3bd3c612e98a53ce60ed972f5cd2b90628b3cba5 Mon Sep 17 00:00:00 2001 +From: Florian Weimer +Date: Tue, 16 Aug 2022 09:25:23 +0200 +Subject: [PATCH] Linux: Fix enum fsconfig_command detection in + +The #ifdef FSOPEN_CLOEXEC check did not work because the macro +was always defined in this header prior to the check, so that +the contents did not matter. + +Fixes commit 774058d72942249f71d74e7f2b639f77184160a6 +("linux: Fix sys/mount.h usage with kernel headers"). + +(cherry picked from commit 2955ef4b7c9b56fcd7abfeddef7ee83c60abff98) +--- + sysdeps/unix/sysv/linux/sys/mount.h | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/sysdeps/unix/sysv/linux/sys/mount.h b/sysdeps/unix/sysv/linux/sys/mount.h +index 2e3fd6a7fe..19841d0738 100644 +--- a/sysdeps/unix/sysv/linux/sys/mount.h ++++ b/sysdeps/unix/sysv/linux/sys/mount.h +@@ -188,9 +188,6 @@ enum + }; + + +-/* fsopen flags. */ +-#define FSOPEN_CLOEXEC 0x00000001 +- + /* fsmount flags. */ + #define FSMOUNT_CLOEXEC 0x00000001 + +@@ -261,6 +258,9 @@ enum fsconfig_command + }; + #endif + ++/* fsopen flags. */ ++#define FSOPEN_CLOEXEC 0x00000001 ++ + /* open_tree flags. */ + #define OPEN_TREE_CLONE 1 /* Clone the target tree and attach the clone */ + #define OPEN_TREE_CLOEXEC O_CLOEXEC /* Close the file on execve() */ +-- +2.31.1