Skip to content

Commit

Permalink
[lld][WebAssembly] Allow atomics feature with unshared memory
Browse files Browse the repository at this point in the history
 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
  • Loading branch information
tlively authored and arichardson committed Mar 24, 2021
2 parents 60da9f0 + 15a5e86 commit 264e429
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 13 deletions.
4 changes: 0 additions & 4 deletions lld/test/wasm/shared-memory.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

# 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

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

# RUN: wasm-ld --relocatable --features=atomics %t1.o -o - | obj2yaml | FileCheck %s --check-prefix ATOMICS-RELOCATABLE

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

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

# ATOMICS-NO-SHARED: 'atomics' feature is used, so --shared-memory must be used{{$}}

# ATOMICS-RELOCATABLE: - Type: MEMORY
# ATOMICS-RELOCATABLE-NEXT: Memories:
# ATOMICS-RELOCATABLE-NEXT: Initial: 0x00000001
Expand Down
9 changes: 0 additions & 9 deletions lld/wasm/Writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -450,15 +450,6 @@ void Writer::populateTargetFeatures() {
for (const auto &key : used.keys())
allowed.insert(std::string(key));

if (!config->relocatable && allowed.count("atomics") &&
!config->sharedMemory) {
if (inferFeatures)
error(Twine("'atomics' feature is used by ") + used["atomics"] +
", so --shared-memory must be used");
else
error("'atomics' feature is used, so --shared-memory must be used");
}

if (!config->checkFeatures)
return;

Expand Down

0 comments on commit 264e429

Please sign in to comment.