Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support wasm64 #444

Open
wants to merge 57 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
37122df
make api.h to support wasm64
trcrsired Oct 25, 2023
8d11df7
wasilibc_real support wasm64
trcrsired Oct 25, 2023
37702e7
fix api.h
trcrsired Oct 25, 2023
59a8228
fix atomic_arch for wasm64
trcrsired Oct 25, 2023
10dd8a7
initial attempt to fix c_header.rs
trcrsired Oct 26, 2023
d146432
Add support for 64 bits
trcrsired Oct 26, 2023
2659f2a
fix __wasi_thread_spawn's return type
trcrsired Oct 26, 2023
3b15bd1
change header of api.h to temporarily manually maintained
trcrsired Oct 26, 2023
48e8b25
Fix formatting issue for rustfmt
trcrsired Oct 26, 2023
a5ad684
Remove all signal apis
trcrsired Oct 30, 2023
b9d2738
Fix symbol of thread_spawn
trcrsired Oct 31, 2023
72d9602
Add wasi64 and wasi64+thread to CI
trcrsired Oct 31, 2023
dfc09f2
Change comment for CI for wasi64 and thread
trcrsired Oct 31, 2023
c9ad745
Merge wasm32 code with wasm64 code
trcrsired Oct 31, 2023
8a294b8
change comment in main.yml from wasi64 to wasm64
trcrsired Oct 31, 2023
46ed3a8
Fix c_header.rs issue with rust fmt
trcrsired Oct 31, 2023
7bd36bb
Merge branch 'WebAssembly:main' into main
trcrsired Nov 18, 2023
4877ea7
support dlfcn.h for wasm64
trcrsired Nov 18, 2023
56fdd62
Merge branch 'WebAssembly:main' into main
trcrsired Dec 11, 2023
a814fa8
add import name for wasi64 with _i64 postfix
trcrsired Dec 13, 2023
d6aac51
generate __wasilibc_real.c from rust code
trcrsired Dec 13, 2023
9703cc1
should be _i64 not -i64
trcrsired Dec 13, 2023
d2884b2
fix __wasilibc_real.c
trcrsired Dec 13, 2023
26f0de5
__WASI_NOEXCEPT missing in the definition of function
trcrsired Dec 13, 2023
3f36fea
fix __WASI_NOEXCEPT missing issue
trcrsired Dec 13, 2023
c8352f8
fix the issue that the definition of one_polloff isn't right on wasm64
trcrsired Dec 13, 2023
4f01294
fix the issue with rustfmt
trcrsired Dec 13, 2023
c889960
change _i64 postfix to _wasm64
trcrsired Dec 14, 2023
3289596
Merge branch 'WebAssembly:main' into main
trcrsired Dec 16, 2023
b08a02c
Merge remote-tracking branch 'parent/main'
trcrsired Jan 7, 2024
e6abb3c
add wasm64-wasi-preview2
trcrsired Jan 7, 2024
5c5b14e
Add wasm64-wasi-preview2 expected
trcrsired Jan 7, 2024
c94c0c6
fix CI and wasm32-wasi-preview2 predefined-macros
trcrsired Jan 7, 2024
01e6ed3
prevent clang 10 from crashing
trcrsired Jan 7, 2024
79184bf
Merge remote-tracking branch 'parent/main'
trcrsired Jan 15, 2024
84472d9
recompile to fix CI
trcrsired Jan 15, 2024
b40e999
Merge branch 'WebAssembly:main' into main
trcrsired Feb 3, 2024
12fc7a2
Merge remote-tracking branch 'parent/main'
trcrsired Mar 17, 2024
96b3d9e
fix
trcrsired Mar 17, 2024
34e1985
fix stdint.h on 64 bit wasm
trcrsired Mar 17, 2024
ce67b68
Fix makefile for new the p2 update
trcrsired Mar 17, 2024
3c387fa
Remove old preview triple
trcrsired Mar 17, 2024
2672d35
fix wasi32-wasi
trcrsired Mar 17, 2024
e027353
Merge branch 'WebAssembly:main' into main
trcrsired Mar 22, 2024
cabd676
Merge branch 'WebAssembly:main' into main
trcrsired May 30, 2024
3fa33a2
Merge branch 'WebAssembly:main' into main
trcrsired May 31, 2024
45b8471
Merge remote-tracking branch 'parent/main'
trcrsired Oct 29, 2024
bc5755d
remove -D_WASI_EMULATED_PTHREAD since it breaks llvm even we enable p…
trcrsired Oct 29, 2024
66491d2
give back shit
trcrsired Oct 29, 2024
0705ecf
force enable feature
trcrsired Oct 29, 2024
b129381
this is dogshit
trcrsired Oct 29, 2024
3992e73
fix
trcrsired Oct 29, 2024
0873325
fix
trcrsired Oct 29, 2024
8f8dfe7
fix issues
trcrsired Oct 29, 2024
6966fb5
Merge remote-tracking branch 'parent/main'
trcrsired Nov 24, 2024
bb8e70a
fix .s not .S
trcrsired Nov 24, 2024
e813115
Fix thread build
trcrsired Nov 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,18 @@ jobs:
shell: bash
run: make -j4 THREAD_MODEL=posix

- name: Build wasi64 + libc
# Build wasi64
if: matrix.clang_version != '10.0.0'
shell: bash
run: make -j4 BUILD_WASI64=yes

- name: Build wasi64 + libc + threads
# Build wasi64 with thread support
if: matrix.clang_version != '10.0.0'
shell: bash
run: make -j4 BUILD_WASI64=yes THREAD_MODEL=posix

# Disable the headerstest job for now, while WASI transitions from the
# witx snapshots to wit proposals, and we have a few manual edits to the
# generated header to make life easier for folks.
Expand Down
23 changes: 21 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ BUILD_LIBC_TOP_HALF ?= yes
# The directory where we will store intermediate artifacts.
OBJDIR ?= build/$(TARGET_TRIPLE)

BUILD_WASI64 ?= no
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe BUILD_WASM64 would better match the target name?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about just WASI64?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But WASI64 is not a thing as far as I know. It doesn't mean much to me as the reader.. whereas WASM64 is the name of the llvm target.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but wasm64 is not wasi64, because you also have wasm64-emscripten.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But WASI64 is not a thing as far as I know. It doesn't mean much to me as the reader.. whereas WASM64 is the name of the llvm target.

what about just allowing users to set TRIPLE?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to WASM64


# When the length is no larger than this threshold, we consider the
# overhead of bulk memory opcodes to outweigh the performance benefit,
# and fall back to the original musl implementation. See
Expand All @@ -33,12 +35,20 @@ BULK_MEMORY_THRESHOLD ?= 32
# make command-line.

# Set the default WASI target triple.
ifeq (${BUILD_WASI64}, yes)
TARGET_TRIPLE = wasm64-wasi
else
TARGET_TRIPLE = wasm32-wasi
endif

# Threaded version necessitates a different traget, as objects from different
# targets can't be mixed together while linking.
ifeq ($(THREAD_MODEL), posix)
TARGET_TRIPLE = wasm32-wasi-threads
ifeq (${BUILD_WASI64}, yes)
TARGET_TRIPLE = wasm64-wasi-threads
else
TARGET_TRIPLE = wasm32-wasi-threads
endif
endif

BUILTINS_LIB ?= $(shell ${CC} --print-libgcc-file-name)
Expand Down Expand Up @@ -197,6 +207,15 @@ LIBC_TOP_HALF_MUSL_SOURCES = \
$(wildcard $(LIBC_TOP_HALF_MUSL_SRC_DIR)/crypt/*.c)

ifeq ($(THREAD_MODEL), posix)


ifeq (${BUILD_WASI64}, yes)
WASM_THREAD_ASM_FILE = thread/wasm64/wasi_thread_start.s
else
WASM_THREAD_ASM_FILE = thread/wasm32/wasi_thread_start.s
endif


LIBC_TOP_HALF_MUSL_SOURCES += \
$(addprefix $(LIBC_TOP_HALF_MUSL_SRC_DIR)/, \
env/__init_tls.c \
Expand Down Expand Up @@ -277,7 +296,7 @@ LIBC_TOP_HALF_MUSL_SOURCES += \
thread/sem_timedwait.c \
thread/sem_trywait.c \
thread/sem_wait.c \
thread/wasm32/wasi_thread_start.s \
${WASM_THREAD_ASM_FILE} \
)
endif

Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,18 @@ build directions with one addition: `make ... THREAD_MODEL=posix`. This creates
additional artifacts in `sysroot/lib/wasm32-wasi-threads` to support `--target
wasm32-wasi-threads`.

## 64 bits support

To enable 64 bits support, follow the above
build directions with one addition: `make ... BUILD_WASI64=yes`. This creates
artifacts in `sysroot/lib/wasm64-wasi` to support `--target
wasm64-wasi`.

You can build 64 bits with pthread support together with
'make ... BUILD_WASI64=yes THREAD_MODEL=posix'. This creates
artifacts in `sysroot/lib/wasm64-wasi-threads` to support `--target
wasm64-wasi-threads`.

## Arch Linux AUR package

For Arch Linux users, there's an official [wasi-libc] package tracking this Git
Expand Down
1 change: 1 addition & 0 deletions expected/wasm32-wasi-threads/predefined-macros.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2956,6 +2956,7 @@
#define __WASI_FSTFLAGS_MTIM ((__wasi_fstflags_t)(1 << 2))
#define __WASI_FSTFLAGS_MTIM_NOW ((__wasi_fstflags_t)(1 << 3))
#define __WASI_LOOKUPFLAGS_SYMLINK_FOLLOW ((__wasi_lookupflags_t)(1 << 0))
#define __WASI_NOEXCEPT
#define __WASI_OFLAGS_CREAT ((__wasi_oflags_t)(1 << 0))
#define __WASI_OFLAGS_DIRECTORY ((__wasi_oflags_t)(1 << 1))
#define __WASI_OFLAGS_EXCL ((__wasi_oflags_t)(1 << 2))
Expand Down
1 change: 1 addition & 0 deletions expected/wasm32-wasi/predefined-macros.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2919,6 +2919,7 @@
#define __WASI_FSTFLAGS_MTIM ((__wasi_fstflags_t)(1 << 2))
#define __WASI_FSTFLAGS_MTIM_NOW ((__wasi_fstflags_t)(1 << 3))
#define __WASI_LOOKUPFLAGS_SYMLINK_FOLLOW ((__wasi_lookupflags_t)(1 << 0))
#define __WASI_NOEXCEPT
#define __WASI_OFLAGS_CREAT ((__wasi_oflags_t)(1 << 0))
#define __WASI_OFLAGS_DIRECTORY ((__wasi_oflags_t)(1 << 1))
#define __WASI_OFLAGS_EXCL ((__wasi_oflags_t)(1 << 2))
Expand Down
Loading