Description
Please include the following in your bug report:
Version of emscripten/emsdk:
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 4.0.6 (1ddaae4)
clang version 21.0.0git (https:/github.com/llvm/llvm-project 4775e6d9099467df9363e1a3cd5950cc3d2fde05)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: /Users/richardgillaspy/GitHubOpen/emsdk/upstream/bin
Failing command line in full:
Full link command and output with -v
appended:
emcc -g -v -s WASMFS -pthread -s PROXY_TO_PTHREAD=1 -sFORCE_FILESYSTEM -sEXPORTED_FUNCTIONS='malloc,free' wasmfs_opefs_rename.c -o test.html
/Users/richardgillaspy/GitHubOpen/emsdk/upstream/bin/clang -target wasm32-unknown-emscripten -fignore-exceptions -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr --sysroot=/Users/richardgillaspy/GitHubOpen/emsdk/upstream/emscripten/cache/sysroot -D__EMSCRIPTEN_SHARED_MEMORY=1 -DEMSCRIPTEN -Xclang -iwithsysroot/include/fakesdl -Xclang -iwithsysroot/include/compat -g3 -v -pthread -c wasmfs_opefs_rename.c -o /var/folders/d8/08bv2b6s2b50q04__ln3cmbh0000gp/T/emscripten_temp_ckhixeop/wasmfs_opefs_rename_0.o
clang version 21.0.0git (https:/github.com/llvm/llvm-project 4775e6d9099467df9363e1a3cd5950cc3d2fde05)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: /Users/richardgillaspy/GitHubOpen/emsdk/upstream/bin
(in-process)
"/Users/richardgillaspy/GitHubOpen/emsdk/upstream/bin/clang-21" -cc1 -triple wasm32-unknown-emscripten -emit-obj -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name wasmfs_opefs_rename.c -mrelocation-model static -mframe-pointer=none -ffp-contract=on -fno-rounding-math -mconstructor-aliases -target-feature +atomics -target-feature +bulk-memory -target-feature +mutable-globals -target-feature +sign-ext -target-cpu generic -fvisibility=hidden -debug-info-kind=constructor -dwarf-version=4 -debugger-tuning=gdb -fdebug-compilation-dir=/Users/richardgillaspy/GitHubOpen/emsdk/upstream/emscripten/test -v -fcoverage-compilation-dir=/Users/richardgillaspy/GitHubOpen/emsdk/upstream/emscripten/test -resource-dir /Users/richardgillaspy/GitHubOpen/emsdk/upstream/lib/clang/21 -D EMSCRIPTEN_SHARED_MEMORY=1 -D EMSCRIPTEN -isysroot /Users/richardgillaspy/GitHubOpen/emsdk/upstream/emscripten/cache/sysroot -internal-isystem /Users/richardgillaspy/GitHubOpen/emsdk/upstream/lib/clang/21/include -internal-isystem /Users/richardgillaspy/GitHubOpen/emsdk/upstream/emscripten/cache/sysroot/include/wasm32-emscripten -internal-isystem /Users/richardgillaspy/GitHubOpen/emsdk/upstream/emscripten/cache/sysroot/include -ferror-limit 19 -pthread -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fignore-exceptions -fcolor-diagnostics -iwithsysroot/include/fakesdl -iwithsysroot/include/compat -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr -o /var/folders/d8/08bv2b6s2b50q04__ln3cmbh0000gp/T/emscripten_temp_ckhixeop/wasmfs_opefs_rename_0.o -x c wasmfs_opefs_rename.c
clang -cc1 version 21.0.0git based upon LLVM 21.0.0git default target x86_64-apple-darwin23.6.0
ignoring nonexistent directory "/Users/richardgillaspy/GitHubOpen/emsdk/upstream/emscripten/cache/sysroot/include/wasm32-emscripten"
#include "..." search starts here:
#include <...> search starts here:
/Users/richardgillaspy/GitHubOpen/emsdk/upstream/emscripten/cache/sysroot/include/fakesdl
/Users/richardgillaspy/GitHubOpen/emsdk/upstream/emscripten/cache/sysroot/include/compat
/Users/richardgillaspy/GitHubOpen/emsdk/upstream/lib/clang/21/include
/Users/richardgillaspy/GitHubOpen/emsdk/upstream/emscripten/cache/sysroot/include
End of search list.
/Users/richardgillaspy/GitHubOpen/emsdk/upstream/bin/clang --version
/Users/richardgillaspy/GitHubOpen/emsdk/upstream/bin/wasm-ld -o test.wasm /var/folders/d8/08bv2b6s2b50q04__ln3cmbh0000gp/T/emscripten_temp_ckhixeop/wasmfs_opefs_rename_0.o -L/Users/richardgillaspy/GitHubOpen/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten -L/Users/richardgillaspy/GitHubOpen/emsdk/upstream/emscripten/src/lib /Users/richardgillaspy/GitHubOpen/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/crtbegin.o /Users/richardgillaspy/GitHubOpen/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/crt1_proxy_main.o -lGL-mt-getprocaddr -lal -lhtml5 -lstubs-debug -lnoexit -lc-mt-debug -ldlmalloc-mt-debug -lcompiler_rt-mt -lc++-mt-noexcept -lc++abi-debug-mt-noexcept -lsockets-mt -lwasmfs-mt-debug -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr /var/folders/d8/08bv2b6s2b50q04__ln3cmbh0000gp/T/tmpzsmb4fcilibemscripten_js_symbols.so --import-memory --shared-memory --export=malloc --export=free --export=emscripten_stack_get_end --export=emscripten_stack_get_free --export=emscripten_stack_get_base --export=emscripten_stack_get_current --export=emscripten_stack_init --export=wasmfs_flush --export=emscripten_builtin_memalign --export=wasmfs_create_file --export=wasmfs_unmount --export=_wasmfs_mount --export=_wasmfs_read_file --export=_wasmfs_write_file --export=_wasmfs_open --export=_wasmfs_close --export=_wasmfs_write --export=_wasmfs_pwrite --export=_wasmfs_rename --export=_wasmfs_mkdir --export=_wasmfs_unlink --export=_wasmfs_chdir --export=_wasmfs_mknod --export=_wasmfs_rmdir --export=_wasmfs_mmap --export=_wasmfs_munmap --export=_wasmfs_msync --export=_wasmfs_read --export=_wasmfs_pread --export=_wasmfs_symlink --export=_wasmfs_truncate --export=_wasmfs_ftruncate --export=_wasmfs_stat --export=_wasmfs_lstat --export=_wasmfs_chmod --export=_wasmfs_fchmod --export=_wasmfs_lchmod --export=_wasmfs_utime --export=_wasmfs_llseek --export=_wasmfs_identify --export=_wasmfs_readlink --export=_wasmfs_readdir_start --export=_wasmfs_readdir_get --export=_wasmfs_readdir_finish --export=_wasmfs_get_cwd --export=_emscripten_stack_alloc --export=_emscripten_thread_free_data --export=_emscripten_thread_crashed --export=__wasm_call_ctors --export=_emscripten_tls_init --export=_emscripten_thread_init --export=_emscripten_stack_restore --export=emscripten_stack_set_limits --export=_emscripten_thread_exit --export=malloc --export=free --export=wasmfs_create_jsimpl_backend --export=wasmfs_create_memory_backend --export-if-defined=__start_em_asm --export-if-defined=__stop_em_asm --export-if-defined=__start_em_lib_deps --export-if-defined=__stop_em_lib_deps --export-if-defined=__start_em_js --export-if-defined=__stop_em_js --export-if-defined=main --export-if-defined=__main_argc_argv --export-if-defined=fflush --export-table -z stack-size=65536 --no-growable-memory --initial-memory=16777216 --entry=_emscripten_proxy_main --stack-first --table-base=1
/Users/richardgillaspy/GitHubOpen/emsdk/upstream/bin/llvm-objcopy test.wasm test.wasm --remove-section=producers
emcc: warning: main
is defined in the input files, but _main
is not in EXPORTED_FUNCTIONS
. Add it to this list if you want main
to run. [-Wunused-main]
/Users/richardgillaspy/GitHubOpen/emsdk/node/20.18.0_64bit/bin/node /Users/richardgillaspy/GitHubOpen/emsdk/upstream/emscripten/tools/compiler.mjs -
/Users/richardgillaspy/GitHubOpen/emsdk/node/20.18.0_64bit/bin/node /Users/richardgillaspy/GitHubOpen/emsdk/upstream/emscripten/tools/preprocessor.mjs - shell.html
#include <assert.h>
#include <dirent.h>
#include <fcntl.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <errno.h>
#include <emscripten.h>
#include <emscripten/console.h>
#include <emscripten/wasmfs.h>
void cleanup(void) {
unlink("/data/dir1/subdir1/foo.txt");
unlink("/data/newDir1/subdir1/foo.txt");
rmdir("/data/newDir1/subdir1");
rmdir("/data/newDir1");
rmdir("/data/dir1/subdir1");
rmdir("/data/dir1");
rmdir("/data/dir2");
}
int main(int argc, char* argv[]) {
int err, fd, nwritten;
const char* msg = "Hello, OPFS!";
char msg2[100] = {};
emscripten_console_log("starting main");
backend_t opfs = wasmfs_create_opfs_backend();
emscripten_console_log("created OPFS backend");
err = wasmfs_create_directory("/opfs", 0777, opfs);
assert(err == 0);
emscripten_console_log("mounted OPFS root directory");
mkdir("/opfs/data", 0777);
symlink("/opfs/data", "/data");
cleanup();
chdir("/data");
mkdir("/data/dir1", 0777);
mkdir("/data/dir2", 0777);
mkdir("/data/dir1/subdir1", 0777);
fd = open("/data/dir1/subdir1/foo.txt", O_RDWR | O_CREAT | O_EXCL, 0777);
assert(fd > 0);
emscripten_console_log("created OPFS file");
nwritten = write(fd, msg, strlen(msg));
assert(nwritten == strlen(msg));
close(fd);
emscripten_console_logf("wrote message: %s (%d)", msg, nwritten);
if(0 != rename("/data/dir1", "/data/newDir1")) {
emscripten_console_logf("rename failed: %d %s", errno, strerror(errno));
}
assert(stat("/data/newDir1", NULL) == 0);
fd = open("/data/newDir1/subdir1/foo.txt", O_RDWR);
assert(fd > 0);
emscripten_console_logf("opened file: %d", fd);
read(fd, msg2, strlen(msg2));
assert(strcmp(msg2, msg) == 0);
emscripten_console_logf("read message: %s (%d)", msg2, (int) strlen(msg2));
close(fd);
}