From: Thomas Petazzoni Date: Sat, 18 Aug 2018 19:31:40 +0000 (+0200) Subject: libselinux: use correct name and content for patch 0004 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=cb8d1743cab1449b91afbabe38c64cbb85bef6ba;p=buildroot.git libselinux: use correct name and content for patch 0004 Commit 6288409642d8368104f916bd264d2cb042942dfa ("libselinux: add patch to fix build with gcc < 4.7") introduced a patch, but its file name was incorrect, so it was never applied. In addition, the patch was generated against the Git repository of SELinux, which includes all projects, and therefore it doesn't apply to the libselinux source code extracted from the tarball: the "libselinux/" component path needs to be removed from the patch. This commit fixes both problems, which should finally and really fix: http://autobuild.buildroot.net/results/c3272566bb808e43bb77ec59cfe596f7e0fe9a64/ Signed-off-by: Thomas Petazzoni --- diff --git a/package/libselinux/0004-Fix-build-break-around-__atomic_-with-GCC-4.7.patch b/package/libselinux/0004-Fix-build-break-around-__atomic_-with-GCC-4.7.patch new file mode 100644 index 0000000000..88e3a79332 --- /dev/null +++ b/package/libselinux/0004-Fix-build-break-around-__atomic_-with-GCC-4.7.patch @@ -0,0 +1,70 @@ +From abe76789f8e7ce61b357f693eaed5b28feab5ce2 Mon Sep 17 00:00:00 2001 +From: Hollis Blanchard +Date: Mon, 13 Aug 2018 12:11:33 -0700 +Subject: [PATCH] Fix build break around __atomic_*() with GCC<4.7 + +The __atomic_* GCC primitives were introduced in GCC 4.7, but Red Hat +Enterprise Linux 6.x (for example) provides GCC 4.4. Tweak the current code to +use the (most conservative) __sync_synchronize() primitive provided by those +older GCC versions. + +(Really, no __atomic or __sync operations are needed here at all, since POSIX +4.12 "Memory Synchronization" says pthread_mutex_lock() and +pthread_mutex_unlock() "synchronize memory with respect to other threads"...) + +Signed-off-by: Hollis Blanchard +--- + src/label_file.h | 18 ++++++++++++++++++ + 1 file changed, 18 insertions(+) + +diff --git a/src/label_file.h b/src/label_file.h +index 2fa85474..47859baf 100644 +--- a/src/label_file.h ++++ b/src/label_file.h +@@ -351,8 +351,14 @@ static inline int compile_regex(struct saved_data *data, struct spec *spec, + * init_routine does not take a parameter, it's not possible + * to use, so we generate the same effect with atomics and a + * mutex */ ++#ifdef __ATOMIC_RELAXED + regex_compiled = + __atomic_load_n(&spec->regex_compiled, __ATOMIC_ACQUIRE); ++#else ++ /* GCC <4.7 */ ++ __sync_synchronize(); ++ regex_compiled = spec->regex_compiled; ++#endif + if (regex_compiled) { + return 0; /* already done */ + } +@@ -360,8 +366,14 @@ static inline int compile_regex(struct saved_data *data, struct spec *spec, + __pthread_mutex_lock(&spec->regex_lock); + /* Check if another thread compiled the regex while we waited + * on the mutex */ ++#ifdef __ATOMIC_RELAXED + regex_compiled = + __atomic_load_n(&spec->regex_compiled, __ATOMIC_ACQUIRE); ++#else ++ /* GCC <4.7 */ ++ __sync_synchronize(); ++ regex_compiled = spec->regex_compiled; ++#endif + if (regex_compiled) { + __pthread_mutex_unlock(&spec->regex_lock); + return 0; +@@ -404,7 +416,13 @@ static inline int compile_regex(struct saved_data *data, struct spec *spec, + } + + /* Done. */ ++#ifdef __ATOMIC_RELAXED + __atomic_store_n(&spec->regex_compiled, true, __ATOMIC_RELEASE); ++#else ++ /* GCC <4.7 */ ++ spec->regex_compiled = true; ++ __sync_synchronize(); ++#endif + __pthread_mutex_unlock(&spec->regex_lock); + return 0; + } +-- +2.13.0 + diff --git a/package/libselinux/0004-Fix-build-break-around-__atomic_-with-GCC-4.7.patch.txt b/package/libselinux/0004-Fix-build-break-around-__atomic_-with-GCC-4.7.patch.txt deleted file mode 100644 index 85bd064066..0000000000 --- a/package/libselinux/0004-Fix-build-break-around-__atomic_-with-GCC-4.7.patch.txt +++ /dev/null @@ -1,70 +0,0 @@ -From abe76789f8e7ce61b357f693eaed5b28feab5ce2 Mon Sep 17 00:00:00 2001 -From: Hollis Blanchard -Date: Mon, 13 Aug 2018 12:11:33 -0700 -Subject: [PATCH] Fix build break around __atomic_*() with GCC<4.7 - -The __atomic_* GCC primitives were introduced in GCC 4.7, but Red Hat -Enterprise Linux 6.x (for example) provides GCC 4.4. Tweak the current code to -use the (most conservative) __sync_synchronize() primitive provided by those -older GCC versions. - -(Really, no __atomic or __sync operations are needed here at all, since POSIX -4.12 "Memory Synchronization" says pthread_mutex_lock() and -pthread_mutex_unlock() "synchronize memory with respect to other threads"...) - -Signed-off-by: Hollis Blanchard ---- - libselinux/src/label_file.h | 18 ++++++++++++++++++ - 1 file changed, 18 insertions(+) - -diff --git a/libselinux/src/label_file.h b/libselinux/src/label_file.h -index 2fa85474..47859baf 100644 ---- a/libselinux/src/label_file.h -+++ b/libselinux/src/label_file.h -@@ -351,8 +351,14 @@ static inline int compile_regex(struct saved_data *data, struct spec *spec, - * init_routine does not take a parameter, it's not possible - * to use, so we generate the same effect with atomics and a - * mutex */ -+#ifdef __ATOMIC_RELAXED - regex_compiled = - __atomic_load_n(&spec->regex_compiled, __ATOMIC_ACQUIRE); -+#else -+ /* GCC <4.7 */ -+ __sync_synchronize(); -+ regex_compiled = spec->regex_compiled; -+#endif - if (regex_compiled) { - return 0; /* already done */ - } -@@ -360,8 +366,14 @@ static inline int compile_regex(struct saved_data *data, struct spec *spec, - __pthread_mutex_lock(&spec->regex_lock); - /* Check if another thread compiled the regex while we waited - * on the mutex */ -+#ifdef __ATOMIC_RELAXED - regex_compiled = - __atomic_load_n(&spec->regex_compiled, __ATOMIC_ACQUIRE); -+#else -+ /* GCC <4.7 */ -+ __sync_synchronize(); -+ regex_compiled = spec->regex_compiled; -+#endif - if (regex_compiled) { - __pthread_mutex_unlock(&spec->regex_lock); - return 0; -@@ -404,7 +416,13 @@ static inline int compile_regex(struct saved_data *data, struct spec *spec, - } - - /* Done. */ -+#ifdef __ATOMIC_RELAXED - __atomic_store_n(&spec->regex_compiled, true, __ATOMIC_RELEASE); -+#else -+ /* GCC <4.7 */ -+ spec->regex_compiled = true; -+ __sync_synchronize(); -+#endif - __pthread_mutex_unlock(&spec->regex_lock); - return 0; - } --- -2.13.0 -