Skip to content

Commit dfc385c

Browse files
authored
Merge pull request emscripten-core#16 from rstz/fix-early-syscalls
Fix early syscall use by adding a Clang attribute.
2 parents 1202327 + 8396aef commit dfc385c

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

pthreadfs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ See `pthreadfs/examples/emscripten-tests/fsafs.cpp` for exemplary usage.
7373
- Some functionality of the Emscripten File System API is missing, such as sockets, IndexedDB integration and support for XHRequests.
7474
- PThreadFS depends on C++ libraries. `EM_PTHREADFS_ASM()` cannot be used within C files.
7575
- Performance is good if and only if optimizations (compiler option `-O2`) are enabled and DevTools are closed.
76-
- Accessing the file system before `main()` is called may not work.
76+
- Accessing the file system before `main()` requires linker option `PTHREAD_POOL_SIZE=<expression>` to be active. Doing so may lead to some blocking of the main thread, which is risky. Check out `examples/early_syscall.cpp` for an example.
7777
- The Storage Foundation backend requires case-insensitive file names.
7878
- Compiling with the Closure Compiler is not supported.
7979
- Compiling with optimization `-O3` is not yet supported and may lead to a faulty build.

pthreadfs/examples/emscripten-tests/FAIL_early_stat64.cpp renamed to pthreadfs/examples/emscripten-tests/early_syscall.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ int main() {
1919
class EarlyObject {
2020
public:
2121
EarlyObject() {
22-
puts("This test is a warning: Do not use syscalls in objects before main is called!");
22+
puts("This test will fail unless compiled with PTHREAD_POOL_SIZE=2 (or higher).");
2323
puts("Start constructing EarlyObject.");
2424
int err;
2525
struct stat s;

pthreadfs/pthreadfs.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ SYS_CAPI_DEF(
311311

312312
// Define global variables to be populated by resume;
313313
std::function<void()> g_resumeFct;
314-
emscripten::sync_to_async g_sync_to_async_helper;
314+
emscripten::sync_to_async g_sync_to_async_helper __attribute__((init_priority(102)));
315315

316316
// Other helper code
317317

0 commit comments

Comments
 (0)