Skip to content

Commit 264e429

Browse files
tlivelyarichardson
authored andcommitted
[lld][WebAssembly] Allow atomics feature with unshared memory
WebAssembly/threads#144 updated the WebAssembly threads proposal to make atomic operations on unshared memories valid. This change updates the feature checking in the linker accordingly. Production WebAssembly engines have recently been updated to allow this behvaior, but after this change users who accidentally use atomics with unshared memories on older versions of the engines will get validation errors at runtime rather than link errors. Differential Revision: https://reviews.llvm.org/D79530
2 parents 60da9f0 + 15a5e86 commit 264e429

File tree

2 files changed

+0
-13
lines changed

2 files changed

+0
-13
lines changed

lld/test/wasm/shared-memory.yaml

-4
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
# RUN: not wasm-ld --no-entry --shared-memory --max-memory=131072 --features=atomics %t1.o -o - 2>&1 | FileCheck %s --check-prefix SHARED-NO-BULK-MEM
1010

11-
# RUN: not wasm-ld --no-entry --features=atomics %t1.o -o - 2>&1 | FileCheck %s --check-prefix ATOMICS-NO-SHARED
12-
1311
# RUN: wasm-ld --relocatable --features=atomics %t1.o -o - | obj2yaml | FileCheck %s --check-prefix ATOMICS-RELOCATABLE
1412

1513
# RUN: wasm-ld --no-entry --shared-memory --max-memory=131072 --features=atomics,bulk-memory %t1.o -o - | obj2yaml | FileCheck %s --check-prefix SHARED
@@ -65,8 +63,6 @@ Sections:
6563

6664
# SHARED-NO-BULK-MEM: 'bulk-memory' feature must be used in order to use shared memory
6765

68-
# ATOMICS-NO-SHARED: 'atomics' feature is used, so --shared-memory must be used{{$}}
69-
7066
# ATOMICS-RELOCATABLE: - Type: MEMORY
7167
# ATOMICS-RELOCATABLE-NEXT: Memories:
7268
# ATOMICS-RELOCATABLE-NEXT: Initial: 0x00000001

lld/wasm/Writer.cpp

-9
Original file line numberDiff line numberDiff line change
@@ -450,15 +450,6 @@ void Writer::populateTargetFeatures() {
450450
for (const auto &key : used.keys())
451451
allowed.insert(std::string(key));
452452

453-
if (!config->relocatable && allowed.count("atomics") &&
454-
!config->sharedMemory) {
455-
if (inferFeatures)
456-
error(Twine("'atomics' feature is used by ") + used["atomics"] +
457-
", so --shared-memory must be used");
458-
else
459-
error("'atomics' feature is used, so --shared-memory must be used");
460-
}
461-
462453
if (!config->checkFeatures)
463454
return;
464455

0 commit comments

Comments
 (0)