File tree Expand file tree Collapse file tree 2 files changed +23
-6
lines changed Expand file tree Collapse file tree 2 files changed +23
-6
lines changed Original file line number Diff line number Diff line change @@ -1075,15 +1075,18 @@ void Writer::writeUuid() {
1075
1075
// Round-up integer division
1076
1076
size_t chunkSize = (data.size () + chunkCount - 1 ) / chunkCount;
1077
1077
std::vector<ArrayRef<uint8_t >> chunks = split (data, chunkSize);
1078
- std::vector<uint64_t > hashes (chunks.size ());
1078
+ // Leave one slot for filename
1079
+ std::vector<uint64_t > hashes (chunks.size () + 1 );
1079
1080
SmallVector<std::shared_future<void >> threadFutures;
1080
1081
threadFutures.reserve (chunks.size ());
1081
1082
for (size_t i = 0 ; i < chunks.size (); ++i)
1082
1083
threadFutures.emplace_back (threadPool.async (
1083
1084
[&](size_t j) { hashes[j] = xxHash64 (chunks[j]); }, i));
1084
1085
for (std::shared_future<void > &future : threadFutures)
1085
1086
future.wait ();
1086
-
1087
+ // Append the output filename so that identical binaries with different names
1088
+ // don't get the same UUID.
1089
+ hashes[chunks.size ()] = xxHash64 (sys::path::filename (config->finalOutput ));
1087
1090
uint64_t digest = xxHash64 ({reinterpret_cast <uint8_t *>(hashes.data ()),
1088
1091
hashes.size () * sizeof (uint64_t )});
1089
1092
uuidCommand->writeUuid (digest);
Original file line number Diff line number Diff line change 1
1
# REQUIRES: x86
2
- # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t.o
3
- # RUN: %lld -lSystem %t.o -o %t
4
- # RUN: llvm-dwarfdump --uuid %t | FileCheck %s
5
- # CHECK: 4C4C44{{([[:xdigit:]]{2})}}-5555-{{([[:xdigit:]]{4})}}-A1{{([[:xdigit:]]{2})}}-{{([[:xdigit:]]{12})}} (x86_64)
2
+ # RUN: rm -rf %t && mkdir -p %t
3
+ # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t/test.o
4
+ # RUN: %lld -lSystem %t/test.o -o %t/a
5
+ # RUN: %lld -lSystem %t/test.o -o %t/b
6
+ # RUN: llvm-dwarfdump --uuid %t/a | awk '{print $2}' > %t/uuida
7
+ # RUN: llvm-dwarfdump --uuid %t/b | awk '{print $2}' > %t/uuidb
8
+ # RUN: FileCheck %s < %t/uuida
9
+ # RUN: FileCheck %s < %t/uuidb
10
+ # RUN: not cmp %t/uuida %t/uuidb
11
+
12
+ ## Ensure -final_output is used for universal binaries, which may be linked with
13
+ ## temporary output file names
14
+ # RUN: %lld -lSystem %t/test.o -o %t/c -final_output %t/a
15
+ # RUN: llvm-dwarfdump --uuid %t/c | awk '{print $2}' > %t/uuidc
16
+ # RUN: cmp %t/uuida %t/uuidc
17
+
18
+
19
+ # CHECK: 4C4C44{{([[:xdigit:]]{2})}}-5555-{{([[:xdigit:]]{4})}}-A1{{([[:xdigit:]]{2})}}-{{([[:xdigit:]]{12})}}
6
20
7
21
.globl _main
8
22
_main:
You can’t perform that action at this time.
0 commit comments