Skip to content

Commit

Permalink
[Support/BLAKE3] Rename blake3_* -> llvm_blake3_* to avoid symbol col…
Browse files Browse the repository at this point in the history
…lisions

While some blake3 symbols are already prefixed, a number of symbols with hidden visibility have been left without an `llvm_` prefix.  This results in symbol collisions when statically linking llvm into a binary that also uses the external blake3 library.

Reviewed By: akyrtzi, MaskRay

Differential Revision: https://reviews.llvm.org/D143981
  • Loading branch information
jbms authored and seanyoung committed Sep 24, 2023
1 parent 7b8db05 commit 0a7f783
Show file tree
Hide file tree
Showing 14 changed files with 118 additions and 69 deletions.
2 changes: 2 additions & 0 deletions llvm/lib/Support/BLAKE3/blake3_avx2_x86-64_unix.S
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#if defined(__x86_64__)

#include "llvm_blake3_prefix.h"

#if defined(__ELF__) && defined(__linux__)
.section .note.GNU-stack,"",%progbits
#endif
Expand Down
2 changes: 2 additions & 0 deletions llvm/lib/Support/BLAKE3/blake3_avx2_x86-64_windows_gnu.S
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include "llvm_blake3_prefix.h"

.intel_syntax noprefix
.global _blake3_hash_many_avx2
.global blake3_hash_many_avx2
Expand Down
12 changes: 6 additions & 6 deletions llvm/lib/Support/BLAKE3/blake3_avx2_x86-64_windows_msvc.asm
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
public _blake3_hash_many_avx2
public blake3_hash_many_avx2
public _llvm_blake3_hash_many_avx2
public llvm_blake3_hash_many_avx2

_TEXT SEGMENT ALIGN(16) 'CODE'

ALIGN 16
blake3_hash_many_avx2 PROC
_blake3_hash_many_avx2 PROC
llvm_blake3_hash_many_avx2 PROC
_llvm_blake3_hash_many_avx2 PROC
push r15
push r14
push r13
Expand Down Expand Up @@ -1785,8 +1785,8 @@ endroundloop1:
vmovdqu xmmword ptr [rbx+10H], xmm1
jmp unwind

_blake3_hash_many_avx2 ENDP
blake3_hash_many_avx2 ENDP
_llvm_blake3_hash_many_avx2 ENDP
llvm_blake3_hash_many_avx2 ENDP
_TEXT ENDS

_RDATA SEGMENT READONLY PAGE ALIAS(".rdata") 'CONST'
Expand Down
2 changes: 2 additions & 0 deletions llvm/lib/Support/BLAKE3/blake3_avx512_x86-64_unix.S
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#if defined(__x86_64__)

#include "llvm_blake3_prefix.h"

#if defined(__ELF__) && defined(__linux__)
.section .note.GNU-stack,"",%progbits
#endif
Expand Down
2 changes: 2 additions & 0 deletions llvm/lib/Support/BLAKE3/blake3_avx512_x86-64_windows_gnu.S
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include "llvm_blake3_prefix.h"

.intel_syntax noprefix

.global _blake3_hash_many_avx512
Expand Down
36 changes: 18 additions & 18 deletions llvm/lib/Support/BLAKE3/blake3_avx512_x86-64_windows_msvc.asm
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
public _blake3_hash_many_avx512
public blake3_hash_many_avx512
public blake3_compress_in_place_avx512
public _blake3_compress_in_place_avx512
public blake3_compress_xof_avx512
public _blake3_compress_xof_avx512
public _llvm_blake3_hash_many_avx512
public llvm_blake3_hash_many_avx512
public llvm_blake3_compress_in_place_avx512
public _llvm_blake3_compress_in_place_avx512
public llvm_blake3_compress_xof_avx512
public _llvm_blake3_compress_xof_avx512

_TEXT SEGMENT ALIGN(16) 'CODE'

ALIGN 16
blake3_hash_many_avx512 PROC
_blake3_hash_many_avx512 PROC
llvm_blake3_hash_many_avx512 PROC
_llvm_blake3_hash_many_avx512 PROC
push r15
push r14
push r13
Expand Down Expand Up @@ -2404,12 +2404,12 @@ endroundloop1:
vmovdqu xmmword ptr [rbx+10H], xmm1
jmp unwind

_blake3_hash_many_avx512 ENDP
blake3_hash_many_avx512 ENDP
_llvm_blake3_hash_many_avx512 ENDP
llvm_blake3_hash_many_avx512 ENDP

ALIGN 16
blake3_compress_in_place_avx512 PROC
_blake3_compress_in_place_avx512 PROC
llvm_blake3_compress_in_place_avx512 PROC
_llvm_blake3_compress_in_place_avx512 PROC
sub rsp, 72
vmovdqa xmmword ptr [rsp], xmm6
vmovdqa xmmword ptr [rsp+10H], xmm7
Expand Down Expand Up @@ -2498,12 +2498,12 @@ _blake3_compress_in_place_avx512 PROC
vmovdqa xmm9, xmmword ptr [rsp+30H]
add rsp, 72
ret
_blake3_compress_in_place_avx512 ENDP
blake3_compress_in_place_avx512 ENDP
_llvm_blake3_compress_in_place_avx512 ENDP
llvm_blake3_compress_in_place_avx512 ENDP

ALIGN 16
blake3_compress_xof_avx512 PROC
_blake3_compress_xof_avx512 PROC
llvm_blake3_compress_xof_avx512 PROC
_llvm_blake3_compress_xof_avx512 PROC
sub rsp, 72
vmovdqa xmmword ptr [rsp], xmm6
vmovdqa xmmword ptr [rsp+10H], xmm7
Expand Down Expand Up @@ -2597,8 +2597,8 @@ _blake3_compress_xof_avx512 PROC
vmovdqa xmm9, xmmword ptr [rsp+30H]
add rsp, 72
ret
_blake3_compress_xof_avx512 ENDP
blake3_compress_xof_avx512 ENDP
_llvm_blake3_compress_xof_avx512 ENDP
llvm_blake3_compress_xof_avx512 ENDP

_TEXT ENDS

Expand Down
10 changes: 1 addition & 9 deletions llvm/lib/Support/BLAKE3/blake3_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,7 @@
// For \p LLVM_LIBRARY_VISIBILITY
#include "llvm/Support/Compiler.h"

// Remove the 'llvm_' prefix for the rest of the internal implementation.
#define BLAKE3_VERSION_STRING LLVM_BLAKE3_VERSION_STRING
#define BLAKE3_KEY_LEN LLVM_BLAKE3_KEY_LEN
#define BLAKE3_OUT_LEN LLVM_BLAKE3_OUT_LEN
#define BLAKE3_BLOCK_LEN LLVM_BLAKE3_BLOCK_LEN
#define BLAKE3_CHUNK_LEN LLVM_BLAKE3_CHUNK_LEN
#define BLAKE3_MAX_DEPTH LLVM_BLAKE3_MAX_DEPTH
#define blake3_hasher llvm_blake3_hasher
#define blake3_chunk_state llvm_blake3_chunk_state
#include "llvm_blake3_prefix.h"

// internal flags
enum blake3_flags {
Expand Down
2 changes: 2 additions & 0 deletions llvm/lib/Support/BLAKE3/blake3_sse2_x86-64_unix.S
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#if defined(__x86_64__)

#include "llvm_blake3_prefix.h"

#if defined(__ELF__) && defined(__linux__)
.section .note.GNU-stack,"",%progbits
#endif
Expand Down
2 changes: 2 additions & 0 deletions llvm/lib/Support/BLAKE3/blake3_sse2_x86-64_windows_gnu.S
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include "llvm_blake3_prefix.h"

.intel_syntax noprefix
.global blake3_hash_many_sse2
.global _blake3_hash_many_sse2
Expand Down
36 changes: 18 additions & 18 deletions llvm/lib/Support/BLAKE3/blake3_sse2_x86-64_windows_msvc.asm
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
public _blake3_hash_many_sse2
public blake3_hash_many_sse2
public blake3_compress_in_place_sse2
public _blake3_compress_in_place_sse2
public blake3_compress_xof_sse2
public _blake3_compress_xof_sse2
public _llvm_blake3_hash_many_sse2
public llvm_blake3_hash_many_sse2
public llvm_blake3_compress_in_place_sse2
public _llvm_blake3_compress_in_place_sse2
public llvm_blake3_compress_xof_sse2
public _llvm_blake3_compress_xof_sse2

_TEXT SEGMENT ALIGN(16) 'CODE'

ALIGN 16
blake3_hash_many_sse2 PROC
_blake3_hash_many_sse2 PROC
llvm_blake3_hash_many_sse2 PROC
_llvm_blake3_hash_many_sse2 PROC
push r15
push r14
push r13
Expand Down Expand Up @@ -2034,11 +2034,11 @@ endroundloop1:
movups xmmword ptr [rbx], xmm0
movups xmmword ptr [rbx+10H], xmm1
jmp unwind
_blake3_hash_many_sse2 ENDP
blake3_hash_many_sse2 ENDP
_llvm_blake3_hash_many_sse2 ENDP
llvm_blake3_hash_many_sse2 ENDP

blake3_compress_in_place_sse2 PROC
_blake3_compress_in_place_sse2 PROC
llvm_blake3_compress_in_place_sse2 PROC
_llvm_blake3_compress_in_place_sse2 PROC
sub rsp, 120
movdqa xmmword ptr [rsp], xmm6
movdqa xmmword ptr [rsp+10H], xmm7
Expand Down Expand Up @@ -2164,12 +2164,12 @@ _blake3_compress_in_place_sse2 PROC
movdqa xmm15, xmmword ptr [rsp+60H]
add rsp, 120
ret
_blake3_compress_in_place_sse2 ENDP
blake3_compress_in_place_sse2 ENDP
_llvm_blake3_compress_in_place_sse2 ENDP
llvm_blake3_compress_in_place_sse2 ENDP

ALIGN 16
blake3_compress_xof_sse2 PROC
_blake3_compress_xof_sse2 PROC
llvm_blake3_compress_xof_sse2 PROC
_llvm_blake3_compress_xof_sse2 PROC
sub rsp, 120
movdqa xmmword ptr [rsp], xmm6
movdqa xmmword ptr [rsp+10H], xmm7
Expand Down Expand Up @@ -2302,8 +2302,8 @@ _blake3_compress_xof_sse2 PROC
movdqa xmm15, xmmword ptr [rsp+60H]
add rsp, 120
ret
_blake3_compress_xof_sse2 ENDP
blake3_compress_xof_sse2 ENDP
_llvm_blake3_compress_xof_sse2 ENDP
llvm_blake3_compress_xof_sse2 ENDP

_TEXT ENDS

Expand Down
2 changes: 2 additions & 0 deletions llvm/lib/Support/BLAKE3/blake3_sse41_x86-64_unix.S
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#if defined(__x86_64__)

#include "llvm_blake3_prefix.h"

#if defined(__ELF__) && defined(__linux__)
.section .note.GNU-stack,"",%progbits
#endif
Expand Down
2 changes: 2 additions & 0 deletions llvm/lib/Support/BLAKE3/blake3_sse41_x86-64_windows_gnu.S
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include "llvm_blake3_prefix.h"

.intel_syntax noprefix
.global blake3_hash_many_sse41
.global _blake3_hash_many_sse41
Expand Down
36 changes: 18 additions & 18 deletions llvm/lib/Support/BLAKE3/blake3_sse41_x86-64_windows_msvc.asm
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
public _blake3_hash_many_sse41
public blake3_hash_many_sse41
public blake3_compress_in_place_sse41
public _blake3_compress_in_place_sse41
public blake3_compress_xof_sse41
public _blake3_compress_xof_sse41
public _llvm_blake3_hash_many_sse41
public llvm_blake3_hash_many_sse41
public llvm_blake3_compress_in_place_sse41
public _llvm_blake3_compress_in_place_sse41
public llvm_blake3_compress_xof_sse41
public _llvm_blake3_compress_xof_sse41

_TEXT SEGMENT ALIGN(16) 'CODE'

ALIGN 16
blake3_hash_many_sse41 PROC
_blake3_hash_many_sse41 PROC
llvm_blake3_hash_many_sse41 PROC
_llvm_blake3_hash_many_sse41 PROC
push r15
push r14
push r13
Expand Down Expand Up @@ -1797,11 +1797,11 @@ endroundloop1:
movups xmmword ptr [rbx], xmm0
movups xmmword ptr [rbx+10H], xmm1
jmp unwind
_blake3_hash_many_sse41 ENDP
blake3_hash_many_sse41 ENDP
_llvm_blake3_hash_many_sse41 ENDP
llvm_blake3_hash_many_sse41 ENDP

blake3_compress_in_place_sse41 PROC
_blake3_compress_in_place_sse41 PROC
llvm_blake3_compress_in_place_sse41 PROC
_llvm_blake3_compress_in_place_sse41 PROC
sub rsp, 120
movdqa xmmword ptr [rsp], xmm6
movdqa xmmword ptr [rsp+10H], xmm7
Expand Down Expand Up @@ -1916,12 +1916,12 @@ _blake3_compress_in_place_sse41 PROC
movdqa xmm15, xmmword ptr [rsp+60H]
add rsp, 120
ret
_blake3_compress_in_place_sse41 ENDP
blake3_compress_in_place_sse41 ENDP
_llvm_blake3_compress_in_place_sse41 ENDP
llvm_blake3_compress_in_place_sse41 ENDP

ALIGN 16
blake3_compress_xof_sse41 PROC
_blake3_compress_xof_sse41 PROC
llvm_blake3_compress_xof_sse41 PROC
_llvm_blake3_compress_xof_sse41 PROC
sub rsp, 120
movdqa xmmword ptr [rsp], xmm6
movdqa xmmword ptr [rsp+10H], xmm7
Expand Down Expand Up @@ -2043,8 +2043,8 @@ _blake3_compress_xof_sse41 PROC
movdqa xmm15, xmmword ptr [rsp+60H]
add rsp, 120
ret
_blake3_compress_xof_sse41 ENDP
blake3_compress_xof_sse41 ENDP
_llvm_blake3_compress_xof_sse41 ENDP
llvm_blake3_compress_xof_sse41 ENDP

_TEXT ENDS

Expand Down
41 changes: 41 additions & 0 deletions llvm/lib/Support/BLAKE3/llvm_blake3_prefix.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#ifndef LLVM_BLAKE3_PREFIX_H
#define LLVM_BLAKE3_PREFIX_H

#define BLAKE3_VERSION_STRING LLVM_BLAKE3_VERSION_STRING
#define BLAKE3_KEY_LEN LLVM_BLAKE3_KEY_LEN
#define BLAKE3_OUT_LEN LLVM_BLAKE3_OUT_LEN
#define BLAKE3_BLOCK_LEN LLVM_BLAKE3_BLOCK_LEN
#define BLAKE3_CHUNK_LEN LLVM_BLAKE3_CHUNK_LEN
#define BLAKE3_MAX_DEPTH LLVM_BLAKE3_MAX_DEPTH
#define blake3_hasher llvm_blake3_hasher
#define blake3_chunk_state llvm_blake3_chunk_state
#define blake3_compress_in_place llvm_blake3_compress_in_place
#define blake3_compress_xof llvm_blake3_compress_xof
#define blake3_hash_many llvm_blake3_hash_many
#define blake3_simd_degree llvm_blake3_simd_degree
#define blake3_compress_in_place_portable llvm_blake3_compress_in_place_portable
#define blake3_compress_xof_portable llvm_blake3_compress_xof_portable
#define blake3_hash_many_portable llvm_blake3_hash_many_portable
#define blake3_compress_in_place_sse2 llvm_blake3_compress_in_place_sse2
#define _blake3_compress_in_place_sse2 _llvm_blake3_compress_in_place_sse2
#define blake3_compress_xof_sse2 llvm_blake3_compress_xof_sse2
#define _blake3_compress_xof_sse2 _llvm_blake3_compress_xof_sse2
#define blake3_hash_many_sse2 llvm_blake3_hash_many_sse2
#define _blake3_hash_many_sse2 _llvm_blake3_hash_many_sse2
#define blake3_compress_in_place_sse41 llvm_blake3_compress_in_place_sse41
#define _blake3_compress_in_place_sse41 _llvm_blake3_compress_in_place_sse41
#define blake3_compress_xof_sse41 llvm_blake3_compress_xof_sse41
#define _blake3_compress_xof_sse41 _llvm_blake3_compress_xof_sse41
#define blake3_hash_many_sse41 llvm_blake3_hash_many_sse41
#define _blake3_hash_many_sse41 _llvm_blake3_hash_many_sse41
#define blake3_hash_many_avx2 llvm_blake3_hash_many_avx2
#define _blake3_hash_many_avx2 _llvm_blake3_hash_many_avx2
#define blake3_compress_in_place_avx512 llvm_blake3_compress_in_place_avx512
#define _blake3_compress_in_place_avx512 _llvm_blake3_compress_in_place_avx512
#define blake3_compress_xof_avx512 llvm_blake3_compress_xof_avx512
#define _blake3_compress_xof_avx512 _llvm_blake3_compress_xof_avx512
#define blake3_hash_many_avx512 llvm_blake3_hash_many_avx512
#define _blake3_hash_many_avx512 _llvm_blake3_hash_many_avx512
#define blake3_hash_many_neon llvm_blake3_hash_many_neon

#endif /* LLVM_BLAKE3_PREFIX_H */

0 comments on commit 0a7f783

Please sign in to comment.