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

Fix make THREAD_MODEL=posix #311

Merged
merged 24 commits into from
Aug 9, 2022
Merged
Changes from 14 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
626362a
Fixes for the THREAD_MODEL=posix build
sbc100 Jul 18, 2022
384da08
Fix expected symbols from previous commit
abrown Jul 26, 2022
0e7956a
Enable `lock` in `random.c` when threads are enabled
abrown Jul 26, 2022
2ab390a
Disable `aio.h` when compiling for threads
abrown Jul 26, 2022
b2f40de
Specify the TLS model until LLVM 15 is released
abrown Jul 27, 2022
9d3b1e4
Rename `__wasi_libc_pthread_self` to `__wasilibc_pthread_self`
abrown Jul 28, 2022
04f6c3f
Add different sets of expected output based on THREAD_MODEL
abrown Jul 28, 2022
d2d3e5c
Re-add trailing whitespace to `predefined-macros.txt`
abrown Jul 28, 2022
83a80a7
Protect `preopens.c` against concurrent access
abrown Jul 28, 2022
247bfeb
Only build thread-capable wasi-libc on latest version of Clang
abrown Jul 28, 2022
0acb15f
Use `thrd_sleep` from MUSL instead of aliasing `nanosleep`
abrown Jul 28, 2022
240c35f
Define `pthread_setcancelstate` in `THREAD_MODEL=posix` builds
abrown Jul 28, 2022
e74d263
Define a Wasm global to store `pthread_self`
abrown Aug 1, 2022
0878de7
Remove `g_needs_dynamic_alloc` global
abrown Aug 1, 2022
db89382
Document the state of pthread support
abrown Aug 1, 2022
53a4091
review: de-duplicate symbols based on #314
abrown Aug 1, 2022
6539705
review: only define `__wasilibc_cwd_{un}lock` when needed
abrown Aug 1, 2022
3784170
review: add #ifdefs to `__pthread_setcancelstate`
abrown Aug 1, 2022
2339e18
review: add additional #ifdefs to `pthread_self.c`
abrown Aug 1, 2022
80d9a43
review: put lock definition behind #ifdef _REENTRANT
abrown Aug 8, 2022
d5bf750
review: remove pthread_setcancelstate.c
abrown Aug 8, 2022
eb50290
review: re-fix indentation
abrown Aug 8, 2022
1d6a27c
review: alias __clock_nanosleep in bottom half
abrown Aug 8, 2022
831de19
review: remove extra line
abrown Aug 9, 2022
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
8 changes: 8 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -66,6 +66,14 @@ jobs:
name: ${{ format( 'sysroot-{0}.tgz', matrix.os) }}
path: sysroot

- name: Build libc + threads
# Only build the thread-capable wasi-libc in the latest supported Clang
# version; the earliest version does not have all necessary builtins
# (e.g., `__builtin_wasm_memory_atomic_notify`).
if: matrix.clang_version != '10.0.0'
shell: bash
run: make -j4 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.
20 changes: 16 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -146,6 +146,7 @@ LIBC_TOP_HALF_MUSL_SOURCES = \
unistd/posix_close.c \
stat/futimesat.c \
legacy/getpagesize.c \
thread/thrd_sleep.c \
) \
$(filter-out %/procfdname.c %/syscall.c %/syscall_ret.c %/vdso.c %/version.c, \
$(wildcard $(LIBC_TOP_HALF_MUSL_SRC_DIR)/internal/*.c)) \
@@ -184,6 +185,14 @@ LIBC_TOP_HALF_MUSL_SOURCES = \
%/cimagf.c %/cimag.c %cimagl.c, \
$(wildcard $(LIBC_TOP_HALF_MUSL_SRC_DIR)/complex/*.c)) \
$(wildcard $(LIBC_TOP_HALF_MUSL_SRC_DIR)/crypt/*.c)

# Add some additional sources when threads are enabled.
ifeq ($(THREAD_MODEL), posix)
LIBC_TOP_HALF_MUSL_SOURCES += $(addprefix $(LIBC_TOP_HALF_MUSL_SRC_DIR)/, \
thread/pthread_setcancelstate.c \
)
endif

MUSL_PRINTSCAN_SOURCES = \
$(LIBC_TOP_HALF_MUSL_SRC_DIR)/internal/floatscan.c \
$(LIBC_TOP_HALF_MUSL_SRC_DIR)/stdio/vfprintf.c \
@@ -226,7 +235,9 @@ ifeq ($(THREAD_MODEL), single)
CFLAGS += -mthread-model single
endif
ifeq ($(THREAD_MODEL), posix)
CFLAGS += -mthread-model posix -pthread
# Specify the tls-model until LLVM 15 is released (which should contain
# https://reviews.llvm.org/D130053).
CFLAGS += -mthread-model posix -pthread -ftls-model=local-exec
endif

# Expose the public headers to the implementation. We use `-isystem` for
@@ -355,11 +366,12 @@ MUSL_OMIT_HEADERS += \
"netinet/ether.h" \
"sys/timerfd.h" \
"libintl.h" \
"sys/sysmacros.h"
"sys/sysmacros.h" \
"aio.h"

ifeq ($(THREAD_MODEL), single)
# Remove headers not supported in single-threaded mode.
MUSL_OMIT_HEADERS += "aio.h" "pthread.h"
MUSL_OMIT_HEADERS += "pthread.h"
endif

default: finish
@@ -594,7 +606,7 @@ check-symbols: startup_files libc

# Check that the computed metadata matches the expected metadata.
# This ignores whitespace because on Windows the output has CRLF line endings.
diff -wur "$(CURDIR)/expected/$(MULTIARCH_TRIPLE)" "$(SYSROOT_SHARE)"
diff -wur "$(CURDIR)/expected/$(MULTIARCH_TRIPLE)/$(THREAD_MODEL)" "$(SYSROOT_SHARE)"

install: finish
mkdir -p "$(INSTALL_DIR)"
Loading