Skip to content

Commit c4eae8a

Browse files
committed
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
1 parent 350d43f commit c4eae8a

File tree

3 files changed

+40
-41
lines changed

3 files changed

+40
-41
lines changed

Diff for: llvm/lib/Support/BLAKE3/CMakeLists.txt

+25-20
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
set(LLVM_BLAKE3_FILES
2-
BLAKE3/blake3.c
3-
BLAKE3/blake3_dispatch.c
4-
BLAKE3/blake3_portable.c
2+
blake3.c
3+
blake3_dispatch.c
4+
blake3_portable.c
55
)
66

77
# The BLAKE3 team recommends using the assembly versions, from the README:
@@ -12,38 +12,43 @@ set(LLVM_BLAKE3_FILES
1212
# preferred. They perform better, they perform more consistently across
1313
# different compilers, and they build more quickly."
1414
# FIXME: Figure out what is wrong with the builders when using the assembly files and neon.
15+
if (MSVC)
16+
enable_language(ASM_MASM)
17+
endif()
18+
1519
if (FALSE)#CMAKE_SYSTEM_PROCESSOR MATCHES "^(x86_64|AMD64)$")
1620
if (MSVC)
1721
list(APPEND LLVM_BLAKE3_FILES
18-
BLAKE3/blake3_sse2_x86-64_windows_msvc.asm
19-
BLAKE3/blake3_sse41_x86-64_windows_msvc.asm
20-
BLAKE3/blake3_avx2_x86-64_windows_msvc.asm
21-
BLAKE3/blake3_avx512_x86-64_windows_msvc.asm
22+
blake3_sse2_x86-64_windows_msvc.asm
23+
blake3_sse41_x86-64_windows_msvc.asm
24+
blake3_avx2_x86-64_windows_msvc.asm
25+
blake3_avx512_x86-64_windows_msvc.asm
2226
)
2327
elseif(WIN32)
2428
list(APPEND LLVM_BLAKE3_FILES
25-
BLAKE3/blake3_sse2_x86-64_windows_gnu.S
26-
BLAKE3/blake3_sse41_x86-64_windows_gnu.S
27-
BLAKE3/blake3_avx2_x86-64_windows_gnu.S
28-
BLAKE3/blake3_avx512_x86-64_windows_gnu.S
29+
blake3_sse2_x86-64_windows_gnu.S
30+
blake3_sse41_x86-64_windows_gnu.S
31+
blake3_avx2_x86-64_windows_gnu.S
32+
blake3_avx512_x86-64_windows_gnu.S
2933
)
3034
else()
3135
list(APPEND LLVM_BLAKE3_FILES
32-
BLAKE3/blake3_sse2_x86-64_unix.S
33-
BLAKE3/blake3_sse41_x86-64_unix.S
34-
BLAKE3/blake3_avx2_x86-64_unix.S
35-
BLAKE3/blake3_avx512_x86-64_unix.S
36+
blake3_sse2_x86-64_unix.S
37+
blake3_sse41_x86-64_unix.S
38+
blake3_avx2_x86-64_unix.S
39+
blake3_avx512_x86-64_unix.S
3640
)
3741
endif()
3842
endif()
3943

4044
if (FALSE)#CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm|aarch)")
4145
list(APPEND LLVM_BLAKE3_FILES
42-
BLAKE3/blake3_neon.c
46+
blake3_neon.c
4347
)
4448
endif()
4549

46-
set(LLVM_BLAKE3_FILES
47-
${LLVM_BLAKE3_FILES}
48-
PARENT_SCOPE
49-
)
50+
# FIXME: Figure out what is wrong with the builders when using the assembly files.
51+
add_definitions(-DBLAKE3_NO_AVX512 -DBLAKE3_NO_AVX2 -DBLAKE3_NO_SSE41 -DBLAKE3_NO_SSE2 -DBLAKE3_USE_NEON=0)
52+
53+
add_library(LLVMSupportBlake3 OBJECT EXCLUDE_FROM_ALL ${LLVM_BLAKE3_FILES})
54+
llvm_update_compile_flags(LLVMSupportBlake3)

Diff for: llvm/lib/Support/CMakeLists.txt

+1-8
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,7 @@ if(LLVM_INTEGRATED_CRT_ALLOC)
101101
endif()
102102
endif()
103103

104-
# Sets up the LLVM_BLAKE3_FILES variable with the files to compile.
105104
add_subdirectory(BLAKE3)
106-
if (MSVC)
107-
enable_language(ASM_MASM)
108-
endif()
109-
# FIXME: Figure out what is wrong with the builders when using the assembly files.
110-
add_definitions(-DBLAKE3_NO_AVX512 -DBLAKE3_NO_AVX2 -DBLAKE3_NO_SSE41 -DBLAKE3_NO_SSE2 -DBLAKE3_USE_NEON=0)
111-
112105

113106
add_llvm_component_library(LLVMSupport
114107
AArch64TargetParser.cpp
@@ -244,7 +237,7 @@ add_llvm_component_library(LLVMSupport
244237
Z3Solver.cpp
245238

246239
${ALLOCATOR_FILES}
247-
${LLVM_BLAKE3_FILES}
240+
$<TARGET_OBJECTS:LLVMSupportBlake3>
248241

249242
# System
250243
Atomic.cpp
+14-13
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
static_library("BLAKE3") {
22
output_name = "LLVMSupportBlake3"
3-
sources = [ "blake3.c", "blake3_dispatch.c", "blake3_portable.c" ]
3+
sources = [
4+
"blake3.c",
5+
"blake3_dispatch.c",
6+
"blake3_portable.c",
7+
]
48
defines = [
59
"BLAKE3_NO_AVX512",
610
"BLAKE3_NO_AVX2",
@@ -12,17 +16,14 @@ static_library("BLAKE3") {
1216

1317
source_set("hack") {
1418
sources = [
15-
"BLAKE3/blake3.c",
16-
"BLAKE3/blake3_avx2_x86-64_unix.S",
17-
"BLAKE3/blake3_avx2_x86-64_windows_gnu.S",
18-
"BLAKE3/blake3_avx512_x86-64_unix.S",
19-
"BLAKE3/blake3_avx512_x86-64_windows_gnu.S",
20-
"BLAKE3/blake3_dispatch.c",
21-
"BLAKE3/blake3_neon.c",
22-
"BLAKE3/blake3_portable.c",
23-
"BLAKE3/blake3_sse2_x86-64_unix.S",
24-
"BLAKE3/blake3_sse2_x86-64_windows_gnu.S",
25-
"BLAKE3/blake3_sse41_x86-64_unix.S",
26-
"BLAKE3/blake3_sse41_x86-64_windows_gnu.S",
19+
"blake3_avx2_x86-64_unix.S",
20+
"blake3_avx2_x86-64_windows_gnu.S",
21+
"blake3_avx512_x86-64_unix.S",
22+
"blake3_avx512_x86-64_windows_gnu.S",
23+
"blake3_neon.c",
24+
"blake3_sse2_x86-64_unix.S",
25+
"blake3_sse2_x86-64_windows_gnu.S",
26+
"blake3_sse41_x86-64_unix.S",
27+
"blake3_sse41_x86-64_windows_gnu.S",
2728
]
2829
}

0 commit comments

Comments
 (0)