diff mbox series

[meta-oe,v4] cryptopp: add a recipe for version 8.9.0

Message ID 20250604-add-cryptopp-v4-1-9e9400a9e877@bootlin.com
State Under Review
Headers show
Series [meta-oe,v4] cryptopp: add a recipe for version 8.9.0 | expand

Commit Message

Antonin Godard June 4, 2025, 8:54 a.m. UTC
Cryptopp is a library of cryptographic schemes written in C++.

Signed-off-by: Antonin Godard <antonin.godard@bootlin.com>
---
Note: I had no issue building with MACHINE to "qemux86-64" and TCLIBC =
"musl", as reported here:
https://lore.kernel.org/r/CAMKF1sreBnjjX0GW-G9+15Y+EgFQUmKUPX_cqYE7J3WaZ9=94g@mail.gmail.com
Any extra steps to reproduce the issue would be appreciated.
---
Changes in v4:
- Make the recipe inherit dos2unix as it was preventing the patch from
  applied after going through the mailing list. Remove the CRLF from the
  patch file accordingly.
- Link to v3: https://lore.kernel.org/r/20250528-add-cryptopp-v3-1-6ad49cdb41bb@bootlin.com

Changes in v3:
- Add 0001-Fix-arm-crypto-logic-issue-in-config_asm.h.patch to fix the
  arm64 build issue.
- Revert UNPACKDIR -> WORKDIR.
- Use += not append.
- Link to v2: https://lore.kernel.org/r/20241122-add-cryptopp-v2-1-19456062f791@bootlin.com

Changes in v2:
- WORKDIR -> UNPACKDIR in S
- remove bb.utils.contains in CXXFLAGS:append:aarch64 (forgot to remove
  after adding aarch64 override)
- Link to v1: https://lore.kernel.org/r/20241121-add-cryptopp-v1-1-36382a60cecb@bootlin.com
---
 ...ix-arm-crypto-logic-issue-in-config_asm.h.patch | 57 ++++++++++++++++++++++
 meta-oe/recipes-crypto/cryptopp/cryptopp_8.9.0.bb  | 45 +++++++++++++++++
 2 files changed, 102 insertions(+)


---
base-commit: 5df267759c953b9615290ea6b8d9051b83863bf9
change-id: 20241121-add-cryptopp-f78794be963c

Best regards,

Comments

Gyorgy Sarvari June 4, 2025, 10:33 a.m. UTC | #1
On 6/4/25 10:54, Antonin Godard via lists.openembedded.org wrote:
> Cryptopp is a library of cryptographic schemes written in C++.
>
> Signed-off-by: Antonin Godard <antonin.godard@bootlin.com>
> ---
> Note: I had no issue building with MACHINE to "qemux86-64" and TCLIBC =
> "musl", as reported here:
> https://lore.kernel.org/r/CAMKF1sreBnjjX0GW-G9+15Y+EgFQUmKUPX_cqYE7J3WaZ9=94g@mail.gmail.com
> Any extra steps to reproduce the issue would be appreciated.
Looking at the linked logs, Khem was using clang - and indeed,
'TOOLCHAIN = "clang"' reproduces the error on my end.
If there will be a v5, could you also add "tag" to the SRC_URI?
Antonin Godard June 4, 2025, 1:16 p.m. UTC | #2
On Wed Jun 4, 2025 at 12:33 PM CEST, Gyorgy Sarvari wrote:
> On 6/4/25 10:54, Antonin Godard via lists.openembedded.org wrote:
>> Cryptopp is a library of cryptographic schemes written in C++.
>>
>> Signed-off-by: Antonin Godard <antonin.godard@bootlin.com>
>> ---
>> Note: I had no issue building with MACHINE to "qemux86-64" and TCLIBC =
>> "musl", as reported here:
>> https://lore.kernel.org/r/CAMKF1sreBnjjX0GW-G9+15Y+EgFQUmKUPX_cqYE7J3WaZ9=94g@mail.gmail.com
>> Any extra steps to reproduce the issue would be appreciated.
> Looking at the linked logs, Khem was using clang - and indeed,
> 'TOOLCHAIN = "clang"' reproduces the error on my end.

Thanks for the hint, I'll try that.

> If there will be a v5, could you also add "tag" to the SRC_URI?

And thanks for the reminder!

Antonin
Khem Raj June 4, 2025, 11:23 p.m. UTC | #3
it also fails to compile with clang

https://termbin.com/b66s

On Wed, Jun 4, 2025 at 6:17 AM Antonin Godard via
lists.openembedded.org
<antonin.godard=bootlin.com@lists.openembedded.org> wrote:
>
> On Wed Jun 4, 2025 at 12:33 PM CEST, Gyorgy Sarvari wrote:
> > On 6/4/25 10:54, Antonin Godard via lists.openembedded.org wrote:
> >> Cryptopp is a library of cryptographic schemes written in C++.
> >>
> >> Signed-off-by: Antonin Godard <antonin.godard@bootlin.com>
> >> ---
> >> Note: I had no issue building with MACHINE to "qemux86-64" and TCLIBC =
> >> "musl", as reported here:
> >> https://lore.kernel.org/r/CAMKF1sreBnjjX0GW-G9+15Y+EgFQUmKUPX_cqYE7J3WaZ9=94g@mail.gmail.com
> >> Any extra steps to reproduce the issue would be appreciated.
> > Looking at the linked logs, Khem was using clang - and indeed,
> > 'TOOLCHAIN = "clang"' reproduces the error on my end.
>
> Thanks for the hint, I'll try that.
>
> > If there will be a v5, could you also add "tag" to the SRC_URI?
>
> And thanks for the reminder!
>
> Antonin
>
> --
> Antonin Godard, Bootlin
> Embedded Linux and Kernel engineering
> https://bootlin.com
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#117739): https://lists.openembedded.org/g/openembedded-devel/message/117739
> Mute This Topic: https://lists.openembedded.org/mt/113462853/1997914
> Group Owner: openembedded-devel+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [raj.khem@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
diff mbox series

Patch

diff --git a/meta-oe/recipes-crypto/cryptopp/cryptopp-8.9.0/0001-Fix-arm-crypto-logic-issue-in-config_asm.h.patch b/meta-oe/recipes-crypto/cryptopp/cryptopp-8.9.0/0001-Fix-arm-crypto-logic-issue-in-config_asm.h.patch
new file mode 100644
index 0000000000..ec040bc1cd
--- /dev/null
+++ b/meta-oe/recipes-crypto/cryptopp/cryptopp-8.9.0/0001-Fix-arm-crypto-logic-issue-in-config_asm.h.patch
@@ -0,0 +1,57 @@ 
+From 9cbe7e5165e8bfa1bbb632682e049e2f92f79717 Mon Sep 17 00:00:00 2001
+From: Antonin Godard <antonin.godard@bootlin.com>
+Date: Fri, 30 May 2025 13:33:39 +0200
+Subject: [PATCH] Fix arm crypto logic issue in config_asm.h
+
+The current logic for enabling or disabling the CRYPTOPP_ARM_*_AVAILABLE
+macros seems wrong, because we do an OR between all of the conditions
+following `defined(__ARM_FEATURE_CRYPTO)`. Fix the logic so that the
+CRYPTOPP_ARM_*_AVAILABLE macros are set if __ARM_FEATURE_CRYPTO is set
+_AND_ any of the following condition is true.
+
+Upstream-Status: Submitted [https://github.com/weidai11/cryptopp/pull/1324]
+Signed-off-by: Antonin Godard <antonin.godard@bootlin.com>
+---
+ config_asm.h | 12 ++++++------
+ 1 file changed, 6 insertions(+), 6 deletions(-)
+
+diff --git a/config_asm.h b/config_asm.h
+index 71ffb9f8..d388124f 100644
+--- a/config_asm.h
++++ b/config_asm.h
+@@ -278,9 +278,9 @@
+ // Requires GCC 4.8, Clang 3.3 or Visual Studio 2017
+ #if !defined(CRYPTOPP_ARM_AES_AVAILABLE) && !defined(CRYPTOPP_DISABLE_ARM_AES)
+ # if defined(__aarch32__) || defined(__aarch64__) || defined(_M_ARM64)
+-#  if defined(__ARM_FEATURE_CRYPTO) || (CRYPTOPP_GCC_VERSION >= 40800) || \
++#  if defined(__ARM_FEATURE_CRYPTO) && ((CRYPTOPP_GCC_VERSION >= 40800) || \
+       (CRYPTOPP_LLVM_CLANG_VERSION >= 30300) || (CRYPTOPP_APPLE_CLANG_VERSION >= 40300) || \
+-      (CRYPTOPP_MSC_VERSION >= 1916)
++      (CRYPTOPP_MSC_VERSION >= 1916))
+ #   define CRYPTOPP_ARM_AES_AVAILABLE 1
+ #  endif  // Compilers
+ # endif  // Platforms
+@@ -290,9 +290,9 @@
+ // Requires GCC 4.8, Clang 3.3 or Visual Studio 2017
+ #if !defined(CRYPTOPP_ARM_PMULL_AVAILABLE) && !defined(CRYPTOPP_DISABLE_ARM_PMULL)
+ # if defined(__aarch32__) || defined(__aarch64__) || defined(_M_ARM64)
+-#  if defined(__ARM_FEATURE_CRYPTO) || (CRYPTOPP_GCC_VERSION >= 40800) || \
++#  if defined(__ARM_FEATURE_CRYPTO) && ((CRYPTOPP_GCC_VERSION >= 40800) || \
+       (CRYPTOPP_LLVM_CLANG_VERSION >= 30300) || (CRYPTOPP_APPLE_CLANG_VERSION >= 40300) || \
+-      (CRYPTOPP_MSC_VERSION >= 1916)
++      (CRYPTOPP_MSC_VERSION >= 1916))
+ #   define CRYPTOPP_ARM_PMULL_AVAILABLE 1
+ #  endif  // Compilers
+ # endif  // Platforms
+@@ -302,9 +302,9 @@
+ // Requires GCC 4.8, Clang 3.3 or Visual Studio 2017
+ #if !defined(CRYPTOPP_ARM_SHA_AVAILABLE) && !defined(CRYPTOPP_DISABLE_ARM_SHA)
+ # if defined(__aarch32__) || defined(__aarch64__) || defined(_M_ARM64)
+-#  if defined(__ARM_FEATURE_CRYPTO) || (CRYPTOPP_GCC_VERSION >= 40800) || \
++#  if defined(__ARM_FEATURE_CRYPTO) && ((CRYPTOPP_GCC_VERSION >= 40800) || \
+       (CRYPTOPP_LLVM_CLANG_VERSION >= 30300) || (CRYPTOPP_APPLE_CLANG_VERSION >= 40300) || \
+-      (CRYPTOPP_MSC_VERSION >= 1916)
++      (CRYPTOPP_MSC_VERSION >= 1916))
+ #   define CRYPTOPP_ARM_SHA1_AVAILABLE 1
+ #   define CRYPTOPP_ARM_SHA2_AVAILABLE 1
+ #  endif  // Compilers
diff --git a/meta-oe/recipes-crypto/cryptopp/cryptopp_8.9.0.bb b/meta-oe/recipes-crypto/cryptopp/cryptopp_8.9.0.bb
new file mode 100644
index 0000000000..4e34c60888
--- /dev/null
+++ b/meta-oe/recipes-crypto/cryptopp/cryptopp_8.9.0.bb
@@ -0,0 +1,45 @@ 
+SUMMARY = "A C++ class library of cryptographic schemes"
+DESCRIPTION = "Crypto++ Library is a C++ class library of cryptographic schemes"
+CVE_PRODUCT = "cryptopp"
+HOMEPAGE = "http://www.cryptopp.com/"
+SECTION = "libs"
+LICENSE = "BSL-1.0"
+LIC_FILES_CHKSUM = "file://License.txt;md5=51c7d279a47eba5246eb5a5123bc1b77"
+
+SRC_URI = "git://github.com/weidai11/cryptopp.git;protocol=https;branch=master \
+           file://0001-Fix-arm-crypto-logic-issue-in-config_asm.h.patch \
+           "
+SRCREV = "843d74c7c97f9e19a615b8ff3c0ca06599ca501b"
+
+S = "${WORKDIR}/git"
+
+inherit pkgconfig dos2unix
+
+CXXFLAGS += "-fPIC"
+EXTRA_OEMAKE += "HAS_SOLIB_VERSION=1"
+
+do_compile() {
+    oe_runmake -f GNUmakefile-cross libcryptopp.a libcryptopp.so cryptest.exe
+}
+
+do_install() {
+    DESTDIR="${D}" \
+        BINDIR="${bindir}" \
+        DATADIR="${datadir}" \
+        INCLUDEDIR="${includedir}" \
+        LIBDIR="${libdir}" \
+        oe_runmake install
+
+    # Rename cryptest.exe to cryptest
+    if [ -f "${D}${bindir}/cryptest.exe" ]; then
+        mv "${D}${bindir}/cryptest.exe" "${D}${bindir}/cryptest"
+    fi
+}
+
+PACKAGE_BEFORE_PN += "${PN}-cryptest ${PN}-testdata ${PN}-testvectors"
+
+FILES:${PN}-cryptest = "${bindir}/cryptest"
+FILES:${PN}-testdata = "${datadir}/cryptopp/TestData"
+FILES:${PN}-testvectors = "${datadir}/cryptopp/TestVectors"
+
+BBCLASSEXTEND = "native nativesdk"