diff options
author | Thomas Lively <tlively@google.com> | 2020-09-24 20:35:29 -0700 |
---|---|---|
committer | Thomas Lively <tlively@google.com> | 2020-09-24 20:35:29 -0700 |
commit | 15a5e86fb387359f736e919eeb5cc2b9f4477d48 (patch) | |
tree | a8a0f148a2b41d76b77a9c88d40694e20ac68e06 /lld | |
parent | 64b8a633a872f25c8b3f9414c22165405400ea10 (diff) | |
download | llvm-15a5e86fb387359f736e919eeb5cc2b9f4477d48.zip llvm-15a5e86fb387359f736e919eeb5cc2b9f4477d48.tar.gz llvm-15a5e86fb387359f736e919eeb5cc2b9f4477d48.tar.bz2 |
[lld][WebAssembly] Allow `atomics` feature with unshared memory
https://github.com/WebAssembly/threads/issues/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
Diffstat (limited to 'lld')
-rw-r--r-- | lld/test/wasm/shared-memory.yaml | 4 | ||||
-rw-r--r-- | lld/wasm/Writer.cpp | 9 |
2 files changed, 0 insertions, 13 deletions
diff --git a/lld/test/wasm/shared-memory.yaml b/lld/test/wasm/shared-memory.yaml index 8a03e0e..1c238a5 100644 --- a/lld/test/wasm/shared-memory.yaml +++ b/lld/test/wasm/shared-memory.yaml @@ -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 @@ -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 diff --git a/lld/wasm/Writer.cpp b/lld/wasm/Writer.cpp index b7adec7..3d49417 100644 --- a/lld/wasm/Writer.cpp +++ b/lld/wasm/Writer.cpp @@ -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; |