Skip to contentSkip to conversation

perf: Remove libcrypto dependency

PATCH Applied Eric Biggers 3 participants 8 messages Jun 25, 2025 – Jun 27, 2025 perf events

lore
Share & tools
lore
#0 lore raw

v3 cover perf: Remove libcrypto dependency

This is a reworked version of
https://lore.kernel.org/all/[email protected]/.
I've changed it to add a new minimal SHA-1 implementation, instead of trying to pull in the kernel's SHA-1 implementation which is not really designed to be extracted into userspace programs. I also added a test.

Changed in v3:
- Rebased onto perf-tools-next
- Removed unnecessary parentheses in array indices in sha1.c
- Updated my email address. I've started consistently using my kernel.org email address.

Eric Biggers (2):
perf build: enable -fno-strict-aliasing
perf util: add a basic SHA-1 implementation

Yuzhuo Jing (2):
perf genelf: Remove libcrypto dependency and use built-in sha1()
tools: Remove libcrypto dependency

 tools/build/Makefile.feature            |  2 -
 tools/build/feature/Makefile            |  4 -
 tools/build/feature/test-all.c          |  5 --
 tools/build/feature/test-libcrypto.c    | 25 -------
 tools/perf/Documentation/perf-check.txt |  1 -
 tools/perf/Makefile.config              | 17 +----
 tools/perf/Makefile.perf                |  3 -
 tools/perf/builtin-check.c              |  1 -
 tools/perf/tests/make                   |  4 +-
 tools/perf/tests/util.c                 | 45 +++++++++++-
 tools/perf/util/Build                   |  1 +
 tools/perf/util/genelf.c                | 85 +---------------------
 tools/perf/util/sha1.c                  | 97 +++++++++++++++++++++++++
 tools/perf/util/sha1.h                  |  6 ++
 14 files changed, 156 insertions(+), 140 deletions(-)
 delete mode 100644 tools/build/feature/test-libcrypto.c
 create mode 100644 tools/perf/util/sha1.c
 create mode 100644 tools/perf/util/sha1.h

base-commit: 9c9f4a27eb1096beb650f312a1ce996a9960b56c

Signature · 1 line
2.50.0
#1 lore raw

PATCH v3 1/4 perf build: enable -fno-strict-aliasing

perf pulls in code from kernel headers that assumes it is being built with -fno-strict-aliasing, namely put_unaligned_*() from <linux/unaligned.h> which write the data using packed structs that lack the may_alias attribute. Enable -fno-strict-aliasing to prevent miscompilations in sha1.c which would otherwise occur due to this issue.

---
 tools/perf/Makefile.config | 4 ++++
 1 file changed, 4 insertions(+)
tools/perf/Makefile.config +4 -0
index 24736b0bbb302..70a3e771c7c08 100644
@@ -17,10 +17,14 @@ detected     = $(shell echo "$(1)=y"       >> $(OUTPUT).config-detected)
 detected_var = $(shell echo "$(1)=$($(1))" >> $(OUTPUT).config-detected)
 
 CFLAGS := $(EXTRA_CFLAGS) $(filter-out -Wnested-externs,$(EXTRA_WARNINGS))
 HOSTCFLAGS := $(filter-out -Wnested-externs,$(EXTRA_WARNINGS))
 
+# This is required because the kernel is built with this and some of the code
+# borrowed from kernel headers depends on it, e.g. put_unaligned_*().
+CFLAGS += -fno-strict-aliasing
+
 # Enabled Wthread-safety analysis for clang builds.
 ifeq ($(CC_NO_CLANG), 0)
   CFLAGS += -Wthread-safety
 endif
 
Signature · 1 line
2.50.0
maintainer
#2 lore raw

Re: [PATCH v3 1/4] perf build: enable -fno-strict-aliasing

Quoted 16 lines · Eric Biggers

perf pulls in code from kernel headers that assumes it is being built with -fno-strict-aliasing, namely put_unaligned_*() from <linux/unaligned.h> which write the data using packed structs that lack the may_alias attribute. Enable -fno-strict-aliasing to prevent miscompilations in sha1.c which would otherwise occur due to this issue.

---
 tools/perf/Makefile.config | 4 ++++
 1 file changed, 4 insertions(+)
tools/perf/Makefile.config +0 -0
index 24736b0bbb302..70a3e771c7c08 100644

tools/perf/Makefile.config detected = $(shell echo "$(1)=y" >> $(OUTPUT).config-detected) · line 24

Quoted 8 lines
tools/perf/Makefile.config +3 -0
@@ -17,10 +17,14 @@ detected     = $(shell echo "$(1)=y"       >> $(OUTPUT).config-detected)
 detected_var = $(shell echo "$(1)=$($(1))" >> $(OUTPUT).config-detected)
 
 CFLAGS := $(EXTRA_CFLAGS) $(filter-out -Wnested-externs,$(EXTRA_WARNINGS))
 HOSTCFLAGS := $(filter-out -Wnested-externs,$(EXTRA_WARNINGS))
 
+# This is required because the kernel is built with this and some of the code
+# borrowed from kernel headers depends on it, e.g. put_unaligned_*().
+CFLAGS += -fno-strict-aliasing

This makes a build error with REFCNT_CHECKING=1.

In file included from util/symbol.c:27:
In function ‘dso__set_symbol_names_len’,
inlined from ‘dso__sort_by_name’ at util/symbol.c:638:4:
util/dso.h:654:46: error: ‘len’ may be used uninitialized [-Werror=maybe-uninitialized]

    654 |         RC_CHK_ACCESS(dso)->symbol_names_len = len;
        |                                              ^
  util/symbol.c: In function ‘dso__sort_by_name’:
  util/symbol.c:634:24: note: ‘len’ was declared here
    634 |                 size_t len;
        |                        ^~~

I'll simply add this to work around it:

tools/perf/util/symbol.c +1 -1
index 8b30c6f16a9eeac1..73dab94fab74e829 100644
@@ -631,7 +631,7 @@ void dso__sort_by_name(struct dso *dso)
 {
        mutex_lock(dso__lock(dso));
        if (!dso__sorted_by_name(dso)) {
-               size_t len;
+               size_t len = 0;
 
                dso__set_symbol_names(dso, symbols__sort_by_name(dso__symbols(dso), &len));
                if (dso__symbol_names(dso)) {

Thanks,
Namhyung

Quoted 9 lines
tools/perf/Makefile.config +1 -0
+
 # Enabled Wthread-safety analysis for clang builds.
 ifeq ($(CC_NO_CLANG), 0)
   CFLAGS += -Wthread-safety
 endif
 
Signature · 1 line
2.50.0
#3 lore raw

PATCH v3 2/4 perf util: add a basic SHA-1 implementation

In reply to Eric Biggers

SHA-1 can be written in fewer than 100 lines of code. Just add a basic SHA-1 implementation so that there's no need to use an external library or try to pull in the kernel's SHA-1 implementation. The kernel's SHA-1 implementation is not really intended to be pulled into userspace programs in the way that it was proposed to do so for perf
(https://lore.kernel.org/r/[email protected]/),
and it's also likely to undergo some refactoring in the future. There's no need to tie userspace tools to it.

Include a test for sha1() in the util test suite.

---
 tools/perf/tests/util.c | 45 ++++++++++++++++++-
 tools/perf/util/Build   |  1 +
 tools/perf/util/sha1.c  | 97 +++++++++++++++++++++++++++++++++++++++++
 tools/perf/util/sha1.h  |  6 +++
 4 files changed, 148 insertions(+), 1 deletion(-)
 create mode 100644 tools/perf/util/sha1.c
 create mode 100644 tools/perf/util/sha1.h
tools/perf/tests/util.c +44 -1
index 6366db5cbf8ce..b273d287e1649 100644
@@ -1,8 +1,9 @@
 // SPDX-License-Identifier: GPL-2.0
 #include "tests.h"
 #include "util/debug.h"
+#include "util/sha1.h"
 
 #include <linux/compiler.h>
 #include <stdlib.h>
 #include <string2.h>
 
@@ -14,18 +15,60 @@ static int test_strreplace(char needle, const char *haystack,
 
 	free(new);
 	return ret == 0;
 }
 
+#define MAX_LEN 512
+
+/* Test sha1() for all lengths from 0 to MAX_LEN inclusively. */
+static int test_sha1(void)
+{
+	u8 data[MAX_LEN];
+	size_t digests_size = (MAX_LEN + 1) * SHA1_DIGEST_SIZE;
+	u8 *digests;
+	u8 digest_of_digests[SHA1_DIGEST_SIZE];
+	/*
+	 * The correctness of this value was verified by running this test with
+	 * sha1() replaced by OpenSSL's SHA1().
+	 */
+	static const u8 expected_digest_of_digests[SHA1_DIGEST_SIZE] = {
+		0x74, 0xcd, 0x4c, 0xb9, 0xd8, 0xa6, 0xd5, 0x95, 0x22, 0x8b,
+		0x7e, 0xd6, 0x8b, 0x7e, 0x46, 0x95, 0x31, 0x9b, 0xa2, 0x43,
+	};
+	size_t i;
+
+	digests = malloc(digests_size);
+	TEST_ASSERT_VAL("failed to allocate digests", digests != NULL);
+
+	/* Generate MAX_LEN bytes of data. */
+	for (i = 0; i < MAX_LEN; i++)
+		data[i] = i;
+
+	/* Calculate a SHA-1 for each length 0 through MAX_LEN inclusively. */
+	for (i = 0; i <= MAX_LEN; i++)
+		sha1(data, i, &digests[i * SHA1_DIGEST_SIZE]);
+
+	/* Calculate digest of all digests calculated above. */
+	sha1(digests, digests_size, digest_of_digests);
+
+	free(digests);
+
+	/* Check for the expected result. */
+	TEST_ASSERT_VAL("wrong output from sha1()",
+			memcmp(digest_of_digests, expected_digest_of_digests,
+			       SHA1_DIGEST_SIZE) == 0);
+	return 0;
+}
+
 static int test__util(struct test_suite *t __maybe_unused, int subtest __maybe_unused)
 {
 	TEST_ASSERT_VAL("empty string", test_strreplace(' ', "", "123", ""));
 	TEST_ASSERT_VAL("no match", test_strreplace('5', "123", "4", "123"));
 	TEST_ASSERT_VAL("replace 1", test_strreplace('3', "123", "4", "124"));
 	TEST_ASSERT_VAL("replace 2", test_strreplace('a', "abcabc", "ef", "efbcefbc"));
 	TEST_ASSERT_VAL("replace long", test_strreplace('a', "abcabc", "longlong",
 							"longlongbclonglongbc"));
 
-	return 0;
+	return test_sha1();
 }
 
 DEFINE_SUITE("util", util);
tools/perf/util/Build +1 -0
index 7910d908c814f..70b6c5f045472 100644
@@ -39,10 +39,11 @@ perf-util-y += rlimit.o
 perf-util-y += argv_split.o
 perf-util-y += rbtree.o
 perf-util-y += libstring.o
 perf-util-y += bitmap.o
 perf-util-y += hweight.o
+perf-util-y += sha1.o
 perf-util-y += smt.o
 perf-util-y += strbuf.o
 perf-util-y += string.o
 perf-util-y += strlist.o
 perf-util-y += strfilter.o
tools/perf/util/sha1.c new file +97 -0

97 lines not on this page · raw message

tools/perf/util/sha1.h new file +6 -0
new file mode 100644
index 0000000000000..e92c9966e1d50
@@ -0,0 +1,6 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#include <linux/types.h>
+
+#define SHA1_DIGEST_SIZE 20
+
+void sha1(const void *data, size_t len, u8 out[SHA1_DIGEST_SIZE]);
Signature · 1 line
2.50.0
#4 lore raw

PATCH v3 3/4 perf genelf: Remove libcrypto dependency and use built-in sha1()

In reply to Eric Biggers

From: Yuzhuo Jing <[email protected]>

genelf is the only file in perf that depends on libcrypto (or openssl) which only calculates a Build ID (SHA1, MD5, or URANDOM). SHA1 was expected to be the default option, but MD5 was used by default due to previous issues when linking against Java. This commit switches genelf to use the in-house sha1(), and also removes MD5 and URANDOM options since we have a reliable SHA1 implementation to rely on. It passes the tools/perf/tests/shell/test_java_symbol.sh test.

---
 tools/perf/util/genelf.c | 85 ++--------------------------------------
 1 file changed, 3 insertions(+), 82 deletions(-)
tools/perf/util/genelf.c +3 -82
index cdce7f173d00a..fcf86a27f69e1 100644
@@ -10,45 +10,25 @@
 #include <sys/types.h>
 #include <stddef.h>
 #include <libelf.h>
 #include <string.h>
 #include <stdlib.h>
-#include <unistd.h>
 #include <inttypes.h>
-#include <fcntl.h>
 #include <err.h>
 #ifdef HAVE_LIBDW_SUPPORT
 #include <dwarf.h>
 #endif
 
 #include "genelf.h"
+#include "sha1.h"
 #include "../util/jitdump.h"
 #include <linux/compiler.h>
 
 #ifndef NT_GNU_BUILD_ID
 #define NT_GNU_BUILD_ID 3
 #endif
 
-#define BUILD_ID_URANDOM /* different uuid for each run */
-
-#ifdef HAVE_LIBCRYPTO_SUPPORT
-
-#define BUILD_ID_MD5
-#undef BUILD_ID_SHA	/* does not seem to work well when linked with Java */
-#undef BUILD_ID_URANDOM /* different uuid for each run */
-
-#ifdef BUILD_ID_SHA
-#include <openssl/sha.h>
-#endif
-
-#ifdef BUILD_ID_MD5
-#include <openssl/evp.h>
-#include <openssl/md5.h>
-#endif
-#endif
-
-
 typedef struct {
   unsigned int namesz;  /* Size of entry's owner string */
   unsigned int descsz;  /* Size of the note descriptor */
   unsigned int type;    /* Interpretation of the descriptor */
   char         name[0]; /* Start of the name+desc data */
@@ -69,11 +49,11 @@ static char shd_string_table[] = {
 };
 
 static struct buildid_note {
 	Elf_Note desc;		/* descsz: size of build-id, must be multiple of 4 */
 	char	 name[4];	/* GNU\0 */
-	char	 build_id[20];
+	u8	 build_id[SHA1_DIGEST_SIZE];
 } bnote;
 
 static Elf_Sym symtab[]={
 	/* symbol 0 MUST be the undefined symbol */
 	{ .st_name  = 0, /* index in sym_string table */
@@ -90,69 +70,10 @@ static Elf_Sym symtab[]={
 	  .st_other = ELF_ST_VIS(STV_DEFAULT),
 	  .st_size  = 0, /* for now */
 	}
 };
 
-#ifdef BUILD_ID_URANDOM
-static void
-gen_build_id(struct buildid_note *note,
-	     unsigned long load_addr __maybe_unused,
-	     const void *code __maybe_unused,
-	     size_t csize __maybe_unused)
-{
-	int fd;
-	size_t sz = sizeof(note->build_id);
-	ssize_t sret;
-
-	fd = open("/dev/urandom", O_RDONLY);
-	if (fd == -1)
-		err(1, "cannot access /dev/urandom for buildid");
-
-	sret = read(fd, note->build_id, sz);
-
-	close(fd);
-
-	if (sret != (ssize_t)sz)
-		memset(note->build_id, 0, sz);
-}
-#endif
-
-#ifdef BUILD_ID_SHA
-static void
-gen_build_id(struct buildid_note *note,
-	     unsigned long load_addr __maybe_unused,
-	     const void *code,
-	     size_t csize)
-{
-	if (sizeof(note->build_id) < SHA_DIGEST_LENGTH)
-		errx(1, "build_id too small for SHA1");
-
-	SHA1(code, csize, (unsigned char *)note->build_id);
-}
-#endif
-
-#ifdef BUILD_ID_MD5
-static void
-gen_build_id(struct buildid_note *note, unsigned long load_addr, const void *code, size_t csize)
-{
-	EVP_MD_CTX *mdctx;
-
-	if (sizeof(note->build_id) < 16)
-		errx(1, "build_id too small for MD5");
-
-	mdctx = EVP_MD_CTX_new();
-	if (!mdctx)
-		errx(2, "failed to create EVP_MD_CTX");
-
-	EVP_DigestInit_ex(mdctx, EVP_md5(), NULL);
-	EVP_DigestUpdate(mdctx, &load_addr, sizeof(load_addr));
-	EVP_DigestUpdate(mdctx, code, csize);
-	EVP_DigestFinal_ex(mdctx, (unsigned char *)note->build_id, NULL);
-	EVP_MD_CTX_free(mdctx);
-}
-#endif
-
 static int
 jit_add_eh_frame_info(Elf *e, void* unwinding, uint64_t unwinding_header_size,
 		      uint64_t unwinding_size, uint64_t base_offset)
 {
 	Elf_Data *d;
@@ -471,11 +392,11 @@ jit_write_elf(int fd, uint64_t load_addr, const char *sym,
 	}
 
 	/*
 	 * build-id generation
 	 */
-	gen_build_id(&bnote, load_addr, code, csize);
+	sha1(code, csize, bnote.build_id);
 	bnote.desc.namesz = sizeof(bnote.name); /* must include 0 termination */
 	bnote.desc.descsz = sizeof(bnote.build_id);
 	bnote.desc.type   = NT_GNU_BUILD_ID;
 	strcpy(bnote.name, "GNU");
 
Signature · 1 line
2.50.0
#5 lore raw

PATCH v3 4/4 tools: Remove libcrypto dependency

In reply to Eric Biggers

From: Yuzhuo Jing <[email protected]>

Remove all occurrence of libcrypto in the build system.

---
 tools/build/Makefile.feature            |  2 --
 tools/build/feature/Makefile            |  4 ----
 tools/build/feature/test-all.c          |  5 -----
 tools/build/feature/test-libcrypto.c    | 25 -------------------------
 tools/perf/Documentation/perf-check.txt |  1 -
 tools/perf/Makefile.config              | 13 -------------
 tools/perf/Makefile.perf                |  3 ---
 tools/perf/builtin-check.c              |  1 -
 tools/perf/tests/make                   |  4 +---
 9 files changed, 1 insertion(+), 57 deletions(-)
 delete mode 100644 tools/build/feature/test-libcrypto.c
tools/build/Makefile.feature +0 -2
index 2e5f4c8b65476..649c5ab8e8f26 100644
@@ -84,11 +84,10 @@ FEATURE_TESTS_BASIC :=                  \
         libpython                       \
         libslang                        \
         libtraceevent                   \
         libtracefs                      \
         libcpupower                     \
-        libcrypto                       \
         pthread-attr-setaffinity-np     \
         pthread-barrier     		\
         reallocarray                    \
         stackprotector-all              \
         timerfd                         \
@@ -145,11 +144,10 @@ FEATURE_DISPLAY ?=              \
          libelf                 \
          libnuma                \
          numa_num_possible_cpus \
          libperl                \
          libpython              \
-         libcrypto              \
          libcapstone            \
          llvm-perf              \
          zlib                   \
          lzma                   \
          get_cpuid              \
tools/build/feature/Makefile +0 -4
index 0c4e541ed56e8..b41a42818d8ac 100644
@@ -36,11 +36,10 @@ FILES=                                          \
          test-libslang.bin                      \
          test-libslang-include-subdir.bin       \
          test-libtraceevent.bin                 \
          test-libcpupower.bin                   \
          test-libtracefs.bin                    \
-         test-libcrypto.bin                     \
          test-libunwind.bin                     \
          test-libunwind-debug-frame.bin         \
          test-libunwind-x86.bin                 \
          test-libunwind-x86_64.bin              \
          test-libunwind-arm.bin                 \
@@ -245,13 +244,10 @@ $(OUTPUT)test-libcpupower.bin:
 	$(BUILD) -lcpupower
 
 $(OUTPUT)test-libtracefs.bin:
 	 $(BUILD) $(shell $(PKG_CONFIG) --cflags libtracefs 2>/dev/null) -ltracefs
 
-$(OUTPUT)test-libcrypto.bin:
-	$(BUILD) -lcrypto
-
 $(OUTPUT)test-gtk2.bin:
 	$(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null) -Wno-deprecated-declarations
 
 $(OUTPUT)test-gtk2-infobar.bin:
 	$(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
tools/build/feature/test-all.c +0 -5
index 1010f233d9c1a..4419fb4710bd1 100644
@@ -128,14 +128,10 @@
 
 #define main main_test_bpf
 # include "test-bpf.c"
 #undef main
 
-#define main main_test_libcrypto
-# include "test-libcrypto.c"
-#undef main
-
 #define main main_test_sdt
 # include "test-sdt.c"
 #undef main
 
 #define main main_test_setns
@@ -186,11 +182,10 @@ int main(int argc, char *argv[])
 	main_test_pthread_attr_setaffinity_np();
 	main_test_pthread_barrier();
 	main_test_lzma();
 	main_test_get_cpuid();
 	main_test_bpf();
-	main_test_libcrypto();
 	main_test_scandirat();
 	main_test_sched_getcpu();
 	main_test_sdt();
 	main_test_setns();
 	main_test_libaio();
tools/build/feature/test-libcrypto.c deleted +0 -25
deleted file mode 100644
index bc34a5bbb5049..0000000000000
@@ -1,25 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-#include <openssl/evp.h>
-#include <openssl/sha.h>
-#include <openssl/md5.h>
-
-int main(void)
-{
-	EVP_MD_CTX *mdctx;
-	unsigned char md[MD5_DIGEST_LENGTH + SHA_DIGEST_LENGTH];
-	unsigned char dat[] = "12345";
-	unsigned int digest_len;
-
-	mdctx = EVP_MD_CTX_new();
-	if (!mdctx)
-		return 0;
-
-	EVP_DigestInit_ex(mdctx, EVP_md5(), NULL);
-	EVP_DigestUpdate(mdctx, &dat[0], sizeof(dat));
-	EVP_DigestFinal_ex(mdctx, &md[0], &digest_len);
-	EVP_MD_CTX_free(mdctx);
-
-	SHA1(&dat[0], sizeof(dat), &md[0]);
-
-	return 0;
-}
tools/perf/Documentation/perf-check.txt +0 -1
index 799982d8d8687..ee92042082f73 100644
@@ -52,11 +52,10 @@ feature::
                 dwarf-unwind            /  HAVE_DWARF_UNWIND_SUPPORT
                 auxtrace                /  HAVE_AUXTRACE_SUPPORT
                 libbfd                  /  HAVE_LIBBFD_SUPPORT
                 libbpf-strings          /  HAVE_LIBBPF_STRINGS_SUPPORT
                 libcapstone             /  HAVE_LIBCAPSTONE_SUPPORT
-                libcrypto               /  HAVE_LIBCRYPTO_SUPPORT
                 libdw-dwarf-unwind      /  HAVE_LIBDW_SUPPORT
                 libelf                  /  HAVE_LIBELF_SUPPORT
                 libnuma                 /  HAVE_LIBNUMA_SUPPORT
                 libopencsd              /  HAVE_CSTRACE_SUPPORT
                 libperl                 /  HAVE_LIBPERL_SUPPORT
tools/perf/Makefile.config +0 -13
index 70a3e771c7c08..5a5832ee7b53c 100644
@@ -132,12 +132,10 @@ ifndef NO_LIBUNWIND
   FEATURE_CHECK_LDFLAGS-libunwind-aarch64 += -lunwind -lunwind-aarch64
   FEATURE_CHECK_LDFLAGS-libunwind-x86 += -lunwind -llzma -lunwind-x86
   FEATURE_CHECK_LDFLAGS-libunwind-x86_64 += -lunwind -llzma -lunwind-x86_64
 endif
 
-FEATURE_CHECK_LDFLAGS-libcrypto = -lcrypto
-
 ifdef CSINCLUDES
   LIBOPENCSD_CFLAGS := -I$(CSINCLUDES)
 endif
 OPENCSDLIBS := -lopencsd_c_api -lopencsd
 ifeq ($(findstring -static,${LDFLAGS}),-static)
@@ -782,21 +780,10 @@ endif
 
 ifneq ($(NO_LIBTRACEEVENT),1)
   $(call detected,CONFIG_TRACE)
 endif
 
-ifndef NO_LIBCRYPTO
-  ifneq ($(feature-libcrypto), 1)
-    $(warning No libcrypto.h found, disables jitted code injection, please install openssl-devel or libssl-dev)
-    NO_LIBCRYPTO := 1
-  else
-    CFLAGS += -DHAVE_LIBCRYPTO_SUPPORT
-    EXTLIBS += -lcrypto
-    $(call detected,CONFIG_CRYPTO)
-  endif
-endif
-
 ifndef NO_SLANG
   ifneq ($(feature-libslang), 1)
     ifneq ($(feature-libslang-include-subdir), 1)
       $(warning slang not found, disables TUI support. Please install slang-devel, libslang-dev or libslang2-dev)
       NO_SLANG := 1
tools/perf/Makefile.perf +0 -3
index 4f292edeca5a8..62697d62f7060 100644
@@ -59,13 +59,10 @@ include ../scripts/utilities.mak
 #
 # Define NO_LIBNUMA if you do not want numa perf benchmark
 #
 # Define NO_LIBBIONIC if you do not want bionic support
 #
-# Define NO_LIBCRYPTO if you do not want libcrypto (openssl) support
-# used for generating build-ids for ELFs generated by jitdump.
-#
 # Define NO_LIBDW_DWARF_UNWIND if you do not want libdw support
 # for dwarf backtrace post unwind.
 #
 # Define NO_LIBTRACEEVENT=1 if you don't want libtraceevent to be linked,
 # this will remove multiple features and tools, such as 'perf trace',
tools/perf/builtin-check.c +0 -1
index f4827f0ddb471..b1e205871ab17 100644
@@ -43,11 +43,10 @@ struct feature_status supported_features[] = {
 	FEATURE_STATUS("dwarf-unwind", HAVE_DWARF_UNWIND_SUPPORT),
 	FEATURE_STATUS("auxtrace", HAVE_AUXTRACE_SUPPORT),
 	FEATURE_STATUS_TIP("libbfd", HAVE_LIBBFD_SUPPORT, "Deprecated, license incompatibility, use BUILD_NONDISTRO=1 and install binutils-dev[el]"),
 	FEATURE_STATUS("libbpf-strings", HAVE_LIBBPF_STRINGS_SUPPORT),
 	FEATURE_STATUS("libcapstone", HAVE_LIBCAPSTONE_SUPPORT),
-	FEATURE_STATUS("libcrypto", HAVE_LIBCRYPTO_SUPPORT),
 	FEATURE_STATUS("libdw-dwarf-unwind", HAVE_LIBDW_SUPPORT),
 	FEATURE_STATUS("libelf", HAVE_LIBELF_SUPPORT),
 	FEATURE_STATUS("libnuma", HAVE_LIBNUMA_SUPPORT),
 	FEATURE_STATUS("libopencsd", HAVE_CSTRACE_SUPPORT),
 	FEATURE_STATUS("libperl", HAVE_LIBPERL_SUPPORT),
tools/perf/tests/make +1 -3
index 0ee94caf9ec19..e3651e5b195a4 100644
@@ -89,11 +89,10 @@ make_no_libnuma     := NO_LIBNUMA=1
 make_no_libbionic   := NO_LIBBIONIC=1
 make_no_auxtrace    := NO_AUXTRACE=1
 make_no_libbpf	    := NO_LIBBPF=1
 make_libbpf_dynamic := LIBBPF_DYNAMIC=1
 make_no_libbpf_DEBUG := NO_LIBBPF=1 DEBUG=1
-make_no_libcrypto   := NO_LIBCRYPTO=1
 make_no_libllvm     := NO_LIBLLVM=1
 make_with_babeltrace:= LIBBABELTRACE=1
 make_with_coresight := CORESIGHT=1
 make_no_sdt	    := NO_SDT=1
 make_no_libpfm4     := NO_LIBPFM4=1
@@ -120,11 +119,11 @@ make_static         := LDFLAGS=-static NO_PERF_READ_VDSO32=1 NO_PERF_READ_VDSOX3
 # all the NO_* variable combined
 make_minimal        := NO_LIBPERL=1 NO_LIBPYTHON=1 NO_GTK2=1
 make_minimal        += NO_DEMANGLE=1 NO_LIBELF=1 NO_BACKTRACE=1
 make_minimal        += NO_LIBNUMA=1 NO_LIBBIONIC=1
 make_minimal        += NO_LIBDW_DWARF_UNWIND=1 NO_AUXTRACE=1 NO_LIBBPF=1
-make_minimal        += NO_LIBCRYPTO=1 NO_SDT=1 NO_JVMTI=1 NO_LIBZSTD=1
+make_minimal        += NO_SDT=1 NO_JVMTI=1 NO_LIBZSTD=1
 make_minimal        += NO_LIBCAP=1 NO_CAPSTONE=1
 
 # $(run) contains all available tests
 run := make_pure
 # Targets 'clean all' can be run together only through top level
@@ -158,11 +157,10 @@ run += make_no_libcapstone
 run += make_no_libnuma
 run += make_no_libbionic
 run += make_no_auxtrace
 run += make_no_libbpf
 run += make_no_libbpf_DEBUG
-run += make_no_libcrypto
 run += make_no_libllvm
 run += make_no_sdt
 run += make_no_syscall_tbl
 run += make_with_babeltrace
 run += make_with_coresight
Signature · 1 line
2.50.0
reviewer Reviewed-by on the v3 series
#6 lore raw
In reply to Eric Biggers
Quoted 13 lines · Eric Biggers

This is a reworked version of
https://lore.kernel.org/all/[email protected]/.
I've changed it to add a new minimal SHA-1 implementation, instead of trying to pull in the kernel's SHA-1 implementation which is not really designed to be extracted into userspace programs. I also added a test.

Changed in v3:
- Rebased onto perf-tools-next
- Removed unnecessary parentheses in array indices in sha1.c
- Updated my email address. I've started consistently using my kernel.org email address.

Quoted 7 lines

Eric Biggers (2):
perf build: enable -fno-strict-aliasing
perf util: add a basic SHA-1 implementation

Yuzhuo Jing (2):
perf genelf: Remove libcrypto dependency and use built-in sha1()
tools: Remove libcrypto dependency

I'm trying to make it so that the -fno-strict-aliasing is unnecessary but we can remove that when the changes land.

Thanks!
Ian

Quoted 24 lines
 tools/build/Makefile.feature            |  2 -
 tools/build/feature/Makefile            |  4 -
 tools/build/feature/test-all.c          |  5 --
 tools/build/feature/test-libcrypto.c    | 25 -------
 tools/perf/Documentation/perf-check.txt |  1 -
 tools/perf/Makefile.config              | 17 +----
 tools/perf/Makefile.perf                |  3 -
 tools/perf/builtin-check.c              |  1 -
 tools/perf/tests/make                   |  4 +-
 tools/perf/tests/util.c                 | 45 +++++++++++-
 tools/perf/util/Build                   |  1 +
 tools/perf/util/genelf.c                | 85 +---------------------
 tools/perf/util/sha1.c                  | 97 +++++++++++++++++++++++++
 tools/perf/util/sha1.h                  |  6 ++
 14 files changed, 156 insertions(+), 140 deletions(-)
 delete mode 100644 tools/build/feature/test-libcrypto.c
 create mode 100644 tools/perf/util/sha1.c
 create mode 100644 tools/perf/util/sha1.h

base-commit: 9c9f4a27eb1096beb650f312a1ce996a9960b56c --
2.50.0

maintainer Applied
#7 lore raw
In reply to Eric Biggers
Quoted 6 lines · Eric Biggers

This is a reworked version of
https://lore.kernel.org/all/[email protected]/.
I've changed it to add a new minimal SHA-1 implementation, instead of trying to pull in the kernel's SHA-1 implementation which is not really designed to be extracted into userspace programs. I also added a test.

Quoted 7 lines

Changed in v3:
- Rebased onto perf-tools-next
- Removed unnecessary parentheses in array indices in sha1.c
- Updated my email address. I've started consistently using my kernel.org email address.

[...]

Applied to perf-tools-next, thanks!

Best regards,
Namhyung