[llvm-branch-commits] [lld] [llvm] release/20.x: [lld][WebAssembly] Support for the custom-page-sizes WebAssembly proposal (#128942) (PR #129762)

2025-06-19 Thread Dan Gohman via llvm-branch-commits

sunfishcode wrote:

The patch changes LLVM's public API, so it's not suitable for backporting. This 
feature will ship in the next release, LLVM 21.

https://github.com/llvm/llvm-project/pull/129762
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [lld] [llvm] release/20.x: [lld][WebAssembly] Support for the custom-page-sizes WebAssembly proposal (#128942) (PR #129762)

2025-06-19 Thread Dan Gohman via llvm-branch-commits

https://github.com/sunfishcode closed 
https://github.com/llvm/llvm-project/pull/129762
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [lld] [llvm] release/20.x: [lld][WebAssembly] Support for the custom-page-sizes WebAssembly proposal (#128942) (PR #129762)

2025-06-17 Thread Sam Clegg via llvm-branch-commits

sbc100 wrote:

> How is the status on this? Is there any workaround to compile to wasm with 
> memories smaller than 64KiB for embedded systems for demonstration purposes?

Yes, isn't that exactly what https://github.com/llvm/llvm-project/pull/128942 
does?You would link with `-Wl,--page-size=1` and then you could get 
arbitrary sized memories.   

You currently need to use LLVM tip-of-tree to try out this flag.   If this 
backport is landed it would end up in the next 20.X point release.


https://github.com/llvm/llvm-project/pull/129762
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [lld] [llvm] release/20.x: [lld][WebAssembly] Support for the custom-page-sizes WebAssembly proposal (#128942) (PR #129762)

2025-06-17 Thread via llvm-branch-commits

BilelGho wrote:

How is the status on this? Is there any workaround to compile to wasm with 
memories smaller than 64KiB for embedded systems for demonstration purposes? 

https://github.com/llvm/llvm-project/pull/129762
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [lld] [llvm] release/20.x: [lld][WebAssembly] Support for the custom-page-sizes WebAssembly proposal (#128942) (PR #129762)

2025-03-14 Thread via llvm-branch-commits

https://github.com/llvmbot updated 
https://github.com/llvm/llvm-project/pull/129762

>From 03fdc56648c828794749d6d9e8a7a0d28e26a4c6 Mon Sep 17 00:00:00 2001
From: Nick Fitzgerald 
Date: Tue, 4 Mar 2025 09:39:30 -0800
Subject: [PATCH] [lld][WebAssembly] Support for the custom-page-sizes
 WebAssembly proposal (#128942)

This commit adds support for WebAssembly's custom-page-sizes proposal to
`wasm-ld`. An overview of the proposal can be found
[here](https://github.com/WebAssembly/custom-page-sizes/blob/main/proposals/custom-page-sizes/Overview.md).
In a sentence, it allows customizing a Wasm memory's page size, enabling
Wasm to target environments with less than 64KiB of memory (the default
Wasm page size) available for Wasm memories.

This commit contains the following:

* Adds a `--page-size=N` CLI flag to `wasm-ld` for configuring the
linked Wasm binary's linear memory's page size.

* When the page size is configured to a non-default value, then the
final Wasm binary will use the encodings defined in the
custom-page-sizes proposal to declare the linear memory's page size.

* Defines a `__wasm_first_page_end` symbol, whose address points to the
first page in the Wasm linear memory, a.k.a. is the Wasm memory's page
size. This allows writing code that is compatible with any page size,
and doesn't require re-compiling its object code. At the same time,
because it just lowers to a constant rather than a memory access or
something, it enables link-time optimization.

* Adds tests for these new features.

r? @sbc100

cc @sunfishcode

(cherry picked from commit 6018930ef1fa62315c3e02b8b8b775056bd5224d)
---
 lld/test/wasm/initial-heap.test   |  2 +-
 lld/test/wasm/mutable-global-exports.s|  4 +-
 lld/test/wasm/page-size.s | 43 +++
 lld/test/wasm/shared-memory.yaml  |  2 +-
 lld/wasm/Config.h |  1 +
 lld/wasm/Driver.cpp   | 10 -
 lld/wasm/Options.td   |  3 ++
 lld/wasm/SymbolTable.cpp  |  4 +-
 lld/wasm/Symbols.cpp  |  1 +
 lld/wasm/Symbols.h|  4 ++
 lld/wasm/SyntheticSections.cpp|  4 ++
 lld/wasm/Writer.cpp   | 23 +-
 lld/wasm/WriterUtils.cpp  |  4 ++
 llvm/include/llvm/BinaryFormat/Wasm.h | 12 --
 llvm/include/llvm/BinaryFormat/WasmTraits.h   |  4 +-
 llvm/include/llvm/MC/MCSymbolWasm.h   |  2 +-
 llvm/include/llvm/ObjectYAML/WasmYAML.h   |  1 +
 llvm/lib/MC/WasmObjectWriter.cpp  |  3 +-
 llvm/lib/Object/WasmObjectFile.cpp|  6 +++
 llvm/lib/ObjectYAML/WasmYAML.cpp  |  3 ++
 .../AsmParser/WebAssemblyAsmParser.cpp|  2 +-
 .../WebAssembly/WebAssemblyUtilities.cpp  |  2 +-
 llvm/tools/obj2yaml/wasm2yaml.cpp |  1 +
 23 files changed, 116 insertions(+), 25 deletions(-)
 create mode 100644 lld/test/wasm/page-size.s

diff --git a/lld/test/wasm/initial-heap.test b/lld/test/wasm/initial-heap.test
index 3e8bbd36535d3..5129ff4d09d7b 100644
--- a/lld/test/wasm/initial-heap.test
+++ b/lld/test/wasm/initial-heap.test
@@ -20,7 +20,7 @@ RUN: not wasm-ld %t.o -o %t5.wasm --stack-first -z 
stack-size=131072 --initial-h
 RUN: not wasm-ld %t.o -o %t6.wasm --stack-first -z stack-size=65536 
--initial-heap=131072 --initial-memory=131072 2>&1 | FileCheck %s 
--check-prefix INITIAL-MEMORY-TOO-SMALL
 RUN: not wasm-ld %t.o -o %t7.wasm --stack-first -z stack-size=65536 
--initial-heap=131072 --max-memory=131072 2>&1 | FileCheck %s --check-prefix 
MAX-MEMORY-TOO-SMALL
 
-NOT-PAGE-MULTIPLE: initial heap must be 65536-byte aligned
+NOT-PAGE-MULTIPLE: initial heap must be aligned to the page size (65536 bytes)
 TOO-LARGE-BY-ITSELF: initial heap too large, cannot be greater than 4294901760
 TOO-LARGE-WITH-STACK: initial heap too large, cannot be greater than 4294836224
 INITIAL-MEMORY-TOO-SMALL: initial memory too small, 196608 bytes needed
diff --git a/lld/test/wasm/mutable-global-exports.s 
b/lld/test/wasm/mutable-global-exports.s
index 135559d5249bc..59308496ab4cc 100644
--- a/lld/test/wasm/mutable-global-exports.s
+++ b/lld/test/wasm/mutable-global-exports.s
@@ -101,6 +101,9 @@ _start:
 # CHECK-ALL-NEXT:  - Name:__table_base
 # CHECK-ALL-NEXT:Kind:GLOBAL
 # CHECK-ALL-NEXT:Index:   10
+# CHECK-ALL-NEXT:  - Name:__wasm_first_page_end
+# CHECK-ALL-NEXT:Kind:GLOBAL
+# CHECK-ALL-NEXT:Index:   11
 # CHECK-ALL-NEXT:  - Type:CODE
 
 # CHECK-ALL: Name:target_features
@@ -110,4 +113,3 @@ _start:
 # CHECK-ALL-NEXT:  - Prefix:  USED
 # CHECK-ALL-NEXT:Name:mutable-globals
 # CHECK-ALL-NEXT: ...
-
diff --git a/lld/test/wasm/page-size.s b/lld/test/wasm/page-size.s
new file mode 100644
index 0..9f5826109d27c
--- /

[llvm-branch-commits] [lld] [llvm] release/20.x: [lld][WebAssembly] Support for the custom-page-sizes WebAssembly proposal (#128942) (PR #129762)

2025-03-14 Thread Nikita Popov via llvm-branch-commits

nikic wrote:

> @nikic Are you talking about the additions to the structures ?

Yes, the change to WasmLimits and the rename of WasmPageSize.

https://github.com/llvm/llvm-project/pull/129762
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [lld] [llvm] release/20.x: [lld][WebAssembly] Support for the custom-page-sizes WebAssembly proposal (#128942) (PR #129762)

2025-03-13 Thread Nikita Popov via llvm-branch-commits

https://github.com/nikic requested changes to this pull request.

This has multiple ABI and API breaking changes. I wonder why the ABI job 
doesn't flag this.

https://github.com/llvm/llvm-project/pull/129762
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits