diff options
| author | Alex Kiernan <alex.kiernan@gmail.com> | 2026-06-13 08:30:27 +0100 |
|---|---|---|
| committer | Khem Raj <khem.raj@oss.qualcomm.com> | 2026-06-14 23:13:33 -0700 |
| commit | 71b74a4b26eb958e6462f3b8ff7f7b5b253814f5 (patch) | |
| tree | 4552cd3a8239ccfdaf06662e29dd43cc7f0e7b3a | |
| parent | 3787cdf982b0fd85f9782f68c12b6a927f5ea5b1 (diff) | |
| download | meta-openembedded-71b74a4b26eb958e6462f3b8ff7f7b5b253814f5.tar.gz | |
android-libboringssl: Fix build on glibc >= 2.41
Backport fix to avoid redefining constants introduced in glibc 2.41.
Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
2 files changed, 178 insertions, 6 deletions
diff --git a/meta-oe/recipes-devtools/android-libboringssl/android-libboringssl/0001-Avoid-redefining-constants-introduced-in-glibc-2.41.patch b/meta-oe/recipes-devtools/android-libboringssl/android-libboringssl/0001-Avoid-redefining-constants-introduced-in-glibc-2.41.patch new file mode 100644 index 0000000000..f4133572ca --- /dev/null +++ b/meta-oe/recipes-devtools/android-libboringssl/android-libboringssl/0001-Avoid-redefining-constants-introduced-in-glibc-2.41.patch | |||
| @@ -0,0 +1,172 @@ | |||
| 1 | From 950b8565e333e2ed1a515e2b342009a33ef51733 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: =?UTF-8?q?Sergio=20G=C3=B3mez?= | ||
| 3 | <sergio.gdr@collabora.corp-partner.google.com> | ||
| 4 | Date: Tue, 15 Apr 2025 17:57:46 -0500 | ||
| 5 | Subject: [PATCH] Avoid redefining constants introduced in glibc 2.41. | ||
| 6 | |||
| 7 | These constants are now available through <sys/auxv.h> when using | ||
| 8 | glibc >= 2.41, so we get re-define compilation errors. | ||
| 9 | Just rename them by prefixing them with "CRYPTO_" to avoid the | ||
| 10 | collision. | ||
| 11 | |||
| 12 | Change-Id: I61807d8dfc8b5f482ec6191cb41aebfa5676c5b6 | ||
| 13 | Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/78527 | ||
| 14 | Commit-Queue: David Benjamin <davidben@google.com> | ||
| 15 | Reviewed-by: David Benjamin <davidben@google.com> | ||
| 16 | Reviewed-by: Adam Langley <agl@google.com> | ||
| 17 | Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com> | ||
| 18 | Upstream-Status: Backport [https://github.com/google/boringssl/commit/ff9475331e72936bc1c00fcda6d4820ba67d4dae] | ||
| 19 | Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com> | ||
| 20 | --- | ||
| 21 | src/crypto/cpu_arm_linux.c | 33 +++++++++++++++++++++++++++----- | ||
| 22 | src/crypto/cpu_arm_linux.h | 20 ++++++++++--------- | ||
| 23 | src/crypto/cpu_arm_linux_test.cc | 12 +++++++----- | ||
| 24 | 3 files changed, 46 insertions(+), 19 deletions(-) | ||
| 25 | |||
| 26 | diff --git a/src/crypto/cpu_arm_linux.c b/src/crypto/cpu_arm_linux.c | ||
| 27 | index d13ac215c4df..7c7cd9dd93f4 100644 | ||
| 28 | --- a/src/crypto/cpu_arm_linux.c | ||
| 29 | +++ b/src/crypto/cpu_arm_linux.c | ||
| 30 | @@ -112,7 +112,11 @@ void OPENSSL_cpuid_setup(void) { | ||
| 31 | |||
| 32 | // Matching OpenSSL, only report other features if NEON is present. | ||
| 33 | unsigned long hwcap = getauxval(AT_HWCAP); | ||
| 34 | - if (hwcap & HWCAP_NEON) { | ||
| 35 | + if (hwcap & CRYPTO_HWCAP_NEON) { | ||
| 36 | +#if defined(HWCAP_ARM_NEON) | ||
| 37 | + static_assert(HWCAP_ARM_NEON == CRYPTO_HWCAP_NEON, | ||
| 38 | + "CRYPTO_HWCAP values must match Linux"); | ||
| 39 | +#endif | ||
| 40 | OPENSSL_armcap_P |= ARMV7_NEON; | ||
| 41 | |||
| 42 | // Some ARMv8 Android devices don't expose AT_HWCAP2. Fall back to | ||
| 43 | @@ -126,16 +130,35 @@ void OPENSSL_cpuid_setup(void) { | ||
| 44 | g_needs_hwcap2_workaround = hwcap2 != 0; | ||
| 45 | } | ||
| 46 | |||
| 47 | - if (hwcap2 & HWCAP2_AES) { | ||
| 48 | + // HWCAP2_* values, without the "CRYPTO_" prefix, are exposed through | ||
| 49 | + // <sys/auxv.h> in some versions of glibc(>= 2.41). Assert that we don't | ||
| 50 | + // diverge from those values. | ||
| 51 | + if (hwcap2 & CRYPTO_HWCAP2_AES) { | ||
| 52 | +#if defined(HWCAP2_AES) | ||
| 53 | + static_assert(HWCAP2_AES == CRYPTO_HWCAP2_AES, | ||
| 54 | + "CRYPTO_HWCAP2 values must match Linux"); | ||
| 55 | +#endif | ||
| 56 | OPENSSL_armcap_P |= ARMV8_AES; | ||
| 57 | } | ||
| 58 | - if (hwcap2 & HWCAP2_PMULL) { | ||
| 59 | + if (hwcap2 & CRYPTO_HWCAP2_PMULL) { | ||
| 60 | +#if defined(HWCAP2_PMULL) | ||
| 61 | + static_assert(HWCAP2_PMULL == CRYPTO_HWCAP2_PMULL, | ||
| 62 | + "CRYPTO_HWCAP2 values must match Linux"); | ||
| 63 | +#endif | ||
| 64 | OPENSSL_armcap_P |= ARMV8_PMULL; | ||
| 65 | } | ||
| 66 | - if (hwcap2 & HWCAP2_SHA1) { | ||
| 67 | + if (hwcap2 & CRYPTO_HWCAP2_SHA1) { | ||
| 68 | +#if defined(HWCAP2_SHA1) | ||
| 69 | + static_assert(HWCAP2_SHA1 == CRYPTO_HWCAP2_SHA1, | ||
| 70 | + "CRYPTO_HWCAP2 values must match Linux"); | ||
| 71 | +#endif | ||
| 72 | OPENSSL_armcap_P |= ARMV8_SHA1; | ||
| 73 | } | ||
| 74 | - if (hwcap2 & HWCAP2_SHA2) { | ||
| 75 | + if (hwcap2 & CRYPTO_HWCAP2_SHA2) { | ||
| 76 | +#if defined(HWCAP2_SHA2) | ||
| 77 | + static_assert(HWCAP2_SHA2 == CRYPTO_HWCAP2_SHA2, | ||
| 78 | + "CRYPTO_HWCAP2 values must match Linux"); | ||
| 79 | +#endif | ||
| 80 | OPENSSL_armcap_P |= ARMV8_SHA256; | ||
| 81 | } | ||
| 82 | } | ||
| 83 | diff --git a/src/crypto/cpu_arm_linux.h b/src/crypto/cpu_arm_linux.h | ||
| 84 | index 895099787439..4b0ecfc77b49 100644 | ||
| 85 | --- a/src/crypto/cpu_arm_linux.h | ||
| 86 | +++ b/src/crypto/cpu_arm_linux.h | ||
| 87 | @@ -29,14 +29,16 @@ extern "C" { | ||
| 88 | // The cpuinfo parser lives in a header file so it may be accessible from | ||
| 89 | // cross-platform fuzzers without adding code to those platforms normally. | ||
| 90 | |||
| 91 | -#define HWCAP_NEON (1 << 12) | ||
| 92 | +#define CRYPTO_HWCAP_NEON (1 << 12) | ||
| 93 | |||
| 94 | // See /usr/include/asm/hwcap.h on an ARM installation for the source of | ||
| 95 | // these values. | ||
| 96 | -#define HWCAP2_AES (1 << 0) | ||
| 97 | -#define HWCAP2_PMULL (1 << 1) | ||
| 98 | -#define HWCAP2_SHA1 (1 << 2) | ||
| 99 | -#define HWCAP2_SHA2 (1 << 3) | ||
| 100 | +// We add the prefix "CRYPTO_" to the definitions so as not to collide with | ||
| 101 | +// some versions of glibc (>= 2.41) that expose them through <sys/auxv.h>. | ||
| 102 | +#define CRYPTO_HWCAP2_AES (1 << 0) | ||
| 103 | +#define CRYPTO_HWCAP2_PMULL (1 << 1) | ||
| 104 | +#define CRYPTO_HWCAP2_SHA1 (1 << 2) | ||
| 105 | +#define CRYPTO_HWCAP2_SHA2 (1 << 3) | ||
| 106 | |||
| 107 | typedef struct { | ||
| 108 | const char *data; | ||
| 109 | @@ -141,16 +143,16 @@ static unsigned long crypto_get_arm_hwcap2_from_cpuinfo( | ||
| 110 | |||
| 111 | unsigned long ret = 0; | ||
| 112 | if (has_list_item(&features, "aes")) { | ||
| 113 | - ret |= HWCAP2_AES; | ||
| 114 | + ret |= CRYPTO_HWCAP2_AES; | ||
| 115 | } | ||
| 116 | if (has_list_item(&features, "pmull")) { | ||
| 117 | - ret |= HWCAP2_PMULL; | ||
| 118 | + ret |= CRYPTO_HWCAP2_PMULL; | ||
| 119 | } | ||
| 120 | if (has_list_item(&features, "sha1")) { | ||
| 121 | - ret |= HWCAP2_SHA1; | ||
| 122 | + ret |= CRYPTO_HWCAP2_SHA1; | ||
| 123 | } | ||
| 124 | if (has_list_item(&features, "sha2")) { | ||
| 125 | - ret |= HWCAP2_SHA2; | ||
| 126 | + ret |= CRYPTO_HWCAP2_SHA2; | ||
| 127 | } | ||
| 128 | return ret; | ||
| 129 | } | ||
| 130 | diff --git a/src/crypto/cpu_arm_linux_test.cc b/src/crypto/cpu_arm_linux_test.cc | ||
| 131 | index 0b6b02fbe4d1..cd626a90512e 100644 | ||
| 132 | --- a/src/crypto/cpu_arm_linux_test.cc | ||
| 133 | +++ b/src/crypto/cpu_arm_linux_test.cc | ||
| 134 | @@ -93,7 +93,8 @@ TEST(ARMLinuxTest, CPUInfo) { | ||
| 135 | // (Extra processors omitted.) | ||
| 136 | "\n" | ||
| 137 | "Hardware : Qualcomm Technologies, Inc MSM8998\n", | ||
| 138 | - HWCAP2_AES | HWCAP2_PMULL | HWCAP2_SHA1 | HWCAP2_SHA2, | ||
| 139 | + CRYPTO_HWCAP2_AES | CRYPTO_HWCAP2_PMULL | CRYPTO_HWCAP2_SHA1 | | ||
| 140 | + CRYPTO_HWCAP2_SHA2, | ||
| 141 | }, | ||
| 142 | // Garbage should be tolerated. | ||
| 143 | { | ||
| 144 | @@ -105,23 +106,24 @@ TEST(ARMLinuxTest, CPUInfo) { | ||
| 145 | { | ||
| 146 | "Features : aes pmull sha1 sha2\n" | ||
| 147 | "CPU architecture: 8\n", | ||
| 148 | - HWCAP2_AES | HWCAP2_PMULL | HWCAP2_SHA1 | HWCAP2_SHA2, | ||
| 149 | + CRYPTO_HWCAP2_AES | CRYPTO_HWCAP2_PMULL | CRYPTO_HWCAP2_SHA1 | | ||
| 150 | + CRYPTO_HWCAP2_SHA2, | ||
| 151 | }, | ||
| 152 | // Various combinations of ARMv8 flags. | ||
| 153 | { | ||
| 154 | "Features : aes sha1 sha2\n" | ||
| 155 | "CPU architecture: 8\n", | ||
| 156 | - HWCAP2_AES | HWCAP2_SHA1 | HWCAP2_SHA2, | ||
| 157 | + CRYPTO_HWCAP2_AES | CRYPTO_HWCAP2_SHA1 | CRYPTO_HWCAP2_SHA2, | ||
| 158 | }, | ||
| 159 | { | ||
| 160 | "Features : pmull sha2\n" | ||
| 161 | "CPU architecture: 8\n", | ||
| 162 | - HWCAP2_PMULL | HWCAP2_SHA2, | ||
| 163 | + CRYPTO_HWCAP2_PMULL | CRYPTO_HWCAP2_SHA2, | ||
| 164 | }, | ||
| 165 | { | ||
| 166 | "Features : aes aes aes not_aes aes aes \n" | ||
| 167 | "CPU architecture: 8\n", | ||
| 168 | - HWCAP2_AES, | ||
| 169 | + CRYPTO_HWCAP2_AES, | ||
| 170 | }, | ||
| 171 | { | ||
| 172 | "Features : \n" | ||
diff --git a/meta-oe/recipes-devtools/android-libboringssl/android-libboringssl_14.0.0+r45.bb b/meta-oe/recipes-devtools/android-libboringssl/android-libboringssl_14.0.0+r45.bb index fccf6e0dff..ebf125c735 100644 --- a/meta-oe/recipes-devtools/android-libboringssl/android-libboringssl_14.0.0+r45.bb +++ b/meta-oe/recipes-devtools/android-libboringssl/android-libboringssl_14.0.0+r45.bb | |||
| @@ -8,12 +8,12 @@ SECTION = "libs" | |||
| 8 | LICENSE = "OpenSSL & ISC" | 8 | LICENSE = "OpenSSL & ISC" |
| 9 | LIC_FILES_CHKSUM = "file://LICENSE;md5=2ca501bc96ce9ed0814e2c592c3f9593" | 9 | LIC_FILES_CHKSUM = "file://LICENSE;md5=2ca501bc96ce9ed0814e2c592c3f9593" |
| 10 | 10 | ||
| 11 | SRC_URI = " \ | 11 | SRC_URI = "https://deb.debian.org/debian/pool/main/a/android-platform-external-boringssl/android-platform-external-boringssl_${PV}.orig.tar.xz \ |
| 12 | https://deb.debian.org/debian/pool/main/a/android-platform-external-boringssl/android-platform-external-boringssl_${PV}.orig.tar.xz \ | 12 | file://boringssl-go-stub \ |
| 13 | file://boringssl-go-stub \ | 13 | file://boringssl-gtest-stub.cc \ |
| 14 | file://boringssl-gtest-stub.cc \ | 14 | file://0001-cmake-add-SOVERSION-0-to-crypto-and-ssl-shared-libra.patch \ |
| 15 | file://0001-cmake-add-SOVERSION-0-to-crypto-and-ssl-shared-libra.patch \ | 15 | file://0001-Avoid-redefining-constants-introduced-in-glibc-2.41.patch;patchdir=.. \ |
| 16 | " | 16 | " |
| 17 | SRC_URI[md5sum] = "83d24d2f3136ba6a486b5464369b91b4" | 17 | SRC_URI[md5sum] = "83d24d2f3136ba6a486b5464369b91b4" |
| 18 | SRC_URI[sha256sum] = "f9223e8c15ad5d9e3f1cd50861f4c272658864661e2332bea5d60952aa0930cd" | 18 | SRC_URI[sha256sum] = "f9223e8c15ad5d9e3f1cd50861f4c272658864661e2332bea5d60952aa0930cd" |
| 19 | 19 | ||
