[llvm] c4eae8a - Make BLAKE3 a component library

Nico Weber via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 24 18:17:15 PDT 2022


Author: Nico Weber
Date: 2022-03-24T21:16:55-04:00
New Revision: c4eae8a4ebfef5778720bf1ef0568665932f65ef

URL: https://github.com/llvm/llvm-project/commit/c4eae8a4ebfef5778720bf1ef0568665932f65ef
DIFF: https://github.com/llvm/llvm-project/commit/c4eae8a4ebfef5778720bf1ef0568665932f65ef.diff

LOG: Make BLAKE3 a component library

It's unusual that BLAKE3/CMakeLists.txt just defines a list of
files that it injects into its parent scope. The list should either
be defined in llvm/lib/Support/CMakeLists.txt, or
llvm/lib/Support/BLAKE3/CMakeLists.txt should define an object
library.

This does the latter. It makes llvm/lib/Support/BLAKE3/CMakeLists.txt
more self-contained.

No behavior change.

Differential Revision: https://reviews.llvm.org/D122428

Added: 
    

Modified: 
    llvm/lib/Support/BLAKE3/CMakeLists.txt
    llvm/lib/Support/CMakeLists.txt
    llvm/utils/gn/secondary/llvm/lib/Support/BLAKE3/BUILD.gn

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Support/BLAKE3/CMakeLists.txt b/llvm/lib/Support/BLAKE3/CMakeLists.txt
index 51a6ee84768db..718dd6421648d 100644
--- a/llvm/lib/Support/BLAKE3/CMakeLists.txt
+++ b/llvm/lib/Support/BLAKE3/CMakeLists.txt
@@ -1,7 +1,7 @@
 set(LLVM_BLAKE3_FILES
-  BLAKE3/blake3.c
-  BLAKE3/blake3_dispatch.c
-  BLAKE3/blake3_portable.c
+  blake3.c
+  blake3_dispatch.c
+  blake3_portable.c
 )
 
 # The BLAKE3 team recommends using the assembly versions, from the README:
@@ -12,38 +12,43 @@ set(LLVM_BLAKE3_FILES
 # preferred. They perform better, they perform more consistently across
 # 
diff erent compilers, and they build more quickly."
 # FIXME: Figure out what is wrong with the builders when using the assembly files and neon.
+if (MSVC)
+  enable_language(ASM_MASM)
+endif()
+
 if (FALSE)#CMAKE_SYSTEM_PROCESSOR MATCHES "^(x86_64|AMD64)$")
   if (MSVC)
     list(APPEND LLVM_BLAKE3_FILES
-      BLAKE3/blake3_sse2_x86-64_windows_msvc.asm
-      BLAKE3/blake3_sse41_x86-64_windows_msvc.asm
-      BLAKE3/blake3_avx2_x86-64_windows_msvc.asm
-      BLAKE3/blake3_avx512_x86-64_windows_msvc.asm
+      blake3_sse2_x86-64_windows_msvc.asm
+      blake3_sse41_x86-64_windows_msvc.asm
+      blake3_avx2_x86-64_windows_msvc.asm
+      blake3_avx512_x86-64_windows_msvc.asm
     )
   elseif(WIN32)
     list(APPEND LLVM_BLAKE3_FILES
-      BLAKE3/blake3_sse2_x86-64_windows_gnu.S
-      BLAKE3/blake3_sse41_x86-64_windows_gnu.S
-      BLAKE3/blake3_avx2_x86-64_windows_gnu.S
-      BLAKE3/blake3_avx512_x86-64_windows_gnu.S
+      blake3_sse2_x86-64_windows_gnu.S
+      blake3_sse41_x86-64_windows_gnu.S
+      blake3_avx2_x86-64_windows_gnu.S
+      blake3_avx512_x86-64_windows_gnu.S
     )
   else()
     list(APPEND LLVM_BLAKE3_FILES
-      BLAKE3/blake3_sse2_x86-64_unix.S
-      BLAKE3/blake3_sse41_x86-64_unix.S
-      BLAKE3/blake3_avx2_x86-64_unix.S
-      BLAKE3/blake3_avx512_x86-64_unix.S
+      blake3_sse2_x86-64_unix.S
+      blake3_sse41_x86-64_unix.S
+      blake3_avx2_x86-64_unix.S
+      blake3_avx512_x86-64_unix.S
     )
   endif()
 endif()
 
 if (FALSE)#CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm|aarch)")
   list(APPEND LLVM_BLAKE3_FILES
-    BLAKE3/blake3_neon.c
+    blake3_neon.c
   )
 endif()
 
-set(LLVM_BLAKE3_FILES
-  ${LLVM_BLAKE3_FILES}
-  PARENT_SCOPE
-)
+# FIXME: Figure out what is wrong with the builders when using the assembly files.
+add_definitions(-DBLAKE3_NO_AVX512 -DBLAKE3_NO_AVX2 -DBLAKE3_NO_SSE41 -DBLAKE3_NO_SSE2 -DBLAKE3_USE_NEON=0)
+
+add_library(LLVMSupportBlake3 OBJECT EXCLUDE_FROM_ALL ${LLVM_BLAKE3_FILES})
+llvm_update_compile_flags(LLVMSupportBlake3)

diff  --git a/llvm/lib/Support/CMakeLists.txt b/llvm/lib/Support/CMakeLists.txt
index edaf5db2867e9..7cbff3dddbcdf 100644
--- a/llvm/lib/Support/CMakeLists.txt
+++ b/llvm/lib/Support/CMakeLists.txt
@@ -101,14 +101,7 @@ if(LLVM_INTEGRATED_CRT_ALLOC)
   endif()
 endif()
 
-# Sets up the LLVM_BLAKE3_FILES variable with the files to compile.
 add_subdirectory(BLAKE3)
-if (MSVC)
-  enable_language(ASM_MASM)
-endif()
-# FIXME: Figure out what is wrong with the builders when using the assembly files.
-add_definitions(-DBLAKE3_NO_AVX512 -DBLAKE3_NO_AVX2 -DBLAKE3_NO_SSE41 -DBLAKE3_NO_SSE2 -DBLAKE3_USE_NEON=0)
-
 
 add_llvm_component_library(LLVMSupport
   AArch64TargetParser.cpp
@@ -244,7 +237,7 @@ add_llvm_component_library(LLVMSupport
   Z3Solver.cpp
 
   ${ALLOCATOR_FILES}
-  ${LLVM_BLAKE3_FILES}
+  $<TARGET_OBJECTS:LLVMSupportBlake3>
 
 # System
   Atomic.cpp

diff  --git a/llvm/utils/gn/secondary/llvm/lib/Support/BLAKE3/BUILD.gn b/llvm/utils/gn/secondary/llvm/lib/Support/BLAKE3/BUILD.gn
index 9076cb95d02c1..01a85ba249e55 100644
--- a/llvm/utils/gn/secondary/llvm/lib/Support/BLAKE3/BUILD.gn
+++ b/llvm/utils/gn/secondary/llvm/lib/Support/BLAKE3/BUILD.gn
@@ -1,6 +1,10 @@
 static_library("BLAKE3") {
   output_name = "LLVMSupportBlake3"
-  sources = [ "blake3.c", "blake3_dispatch.c", "blake3_portable.c" ]
+  sources = [
+    "blake3.c",
+    "blake3_dispatch.c",
+    "blake3_portable.c",
+  ]
   defines = [
    "BLAKE3_NO_AVX512",
    "BLAKE3_NO_AVX2",
@@ -12,17 +16,14 @@ static_library("BLAKE3") {
 
 source_set("hack") {
   sources = [
-    "BLAKE3/blake3.c",
-    "BLAKE3/blake3_avx2_x86-64_unix.S",
-    "BLAKE3/blake3_avx2_x86-64_windows_gnu.S",
-    "BLAKE3/blake3_avx512_x86-64_unix.S",
-    "BLAKE3/blake3_avx512_x86-64_windows_gnu.S",
-    "BLAKE3/blake3_dispatch.c",
-    "BLAKE3/blake3_neon.c",
-    "BLAKE3/blake3_portable.c",
-    "BLAKE3/blake3_sse2_x86-64_unix.S",
-    "BLAKE3/blake3_sse2_x86-64_windows_gnu.S",
-    "BLAKE3/blake3_sse41_x86-64_unix.S",
-    "BLAKE3/blake3_sse41_x86-64_windows_gnu.S",
+    "blake3_avx2_x86-64_unix.S",
+    "blake3_avx2_x86-64_windows_gnu.S",
+    "blake3_avx512_x86-64_unix.S",
+    "blake3_avx512_x86-64_windows_gnu.S",
+    "blake3_neon.c",
+    "blake3_sse2_x86-64_unix.S",
+    "blake3_sse2_x86-64_windows_gnu.S",
+    "blake3_sse41_x86-64_unix.S",
+    "blake3_sse41_x86-64_windows_gnu.S",
   ]
 }


        


More information about the llvm-commits mailing list