From 85af8a6adfedcf0fd581c44f7aee0acb20216170 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Tue, 13 Feb 2024 09:20:18 -0700 Subject: [PATCH 1/2] provide a `realpath` stub In https://github.com/WebAssembly/wasi-libc/pull/463, I added stubs for `statvfs`, `chmod`, etc. but forgot to add one for `realpath`, which is also required by `libc++`'s `` implementation. Signed-off-by: Joel Dice --- expected/wasm32-wasi-preview2/defined-symbols.txt | 1 + expected/wasm32-wasi-threads/defined-symbols.txt | 1 + expected/wasm32-wasi/defined-symbols.txt | 1 + libc-bottom-half/sources/posix.c | 7 +++++++ 4 files changed, 10 insertions(+) diff --git a/expected/wasm32-wasi-preview2/defined-symbols.txt b/expected/wasm32-wasi-preview2/defined-symbols.txt index dea0473c3..5679de4cc 100644 --- a/expected/wasm32-wasi-preview2/defined-symbols.txt +++ b/expected/wasm32-wasi-preview2/defined-symbols.txt @@ -1050,6 +1050,7 @@ readlinkat readv realloc reallocarray +realpath recv regcomp regerror diff --git a/expected/wasm32-wasi-threads/defined-symbols.txt b/expected/wasm32-wasi-threads/defined-symbols.txt index c434bf8a3..22d6fec60 100644 --- a/expected/wasm32-wasi-threads/defined-symbols.txt +++ b/expected/wasm32-wasi-threads/defined-symbols.txt @@ -1084,6 +1084,7 @@ readlinkat readv realloc reallocarray +realpath recv regcomp regerror diff --git a/expected/wasm32-wasi/defined-symbols.txt b/expected/wasm32-wasi/defined-symbols.txt index 8342dd5ee..13c10d7b5 100644 --- a/expected/wasm32-wasi/defined-symbols.txt +++ b/expected/wasm32-wasi/defined-symbols.txt @@ -941,6 +941,7 @@ readlinkat readv realloc reallocarray +realpath recv regcomp regerror diff --git a/libc-bottom-half/sources/posix.c b/libc-bottom-half/sources/posix.c index 7da6a3df6..710f8be2d 100644 --- a/libc-bottom-half/sources/posix.c +++ b/libc-bottom-half/sources/posix.c @@ -351,6 +351,13 @@ int fstatvfs(int fd, struct statvfs *buf) { return -1; } +char *realpath (const char *__restrict file_name, char *__restrict resolved_name) { + // TODO: We plan to support this eventually in WASI, but not yet. + // Meanwhile, we provide a stub so that libc++'s `` + // implementation will build unmodified. + return NULL; +} + // Like `access`, but with `faccessat`'s flags argument. int __wasilibc_access(const char *path, int mode, int flags) From cd12ce86edc6961133d869563fcdf4626783888c Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Tue, 13 Feb 2024 10:08:08 -0700 Subject: [PATCH 2/2] remove `realpath` stub and use musl's version instead Signed-off-by: Joel Dice --- Makefile | 1 + libc-bottom-half/sources/posix.c | 7 ------- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/Makefile b/Makefile index b96ba3358..106dade31 100644 --- a/Makefile +++ b/Makefile @@ -127,6 +127,7 @@ LIBC_TOP_HALF_MUSL_SOURCES = \ misc/getopt.c \ misc/getopt_long.c \ misc/getsubopt.c \ + misc/realpath.c \ misc/uname.c \ misc/nftw.c \ errno/strerror.c \ diff --git a/libc-bottom-half/sources/posix.c b/libc-bottom-half/sources/posix.c index 710f8be2d..7da6a3df6 100644 --- a/libc-bottom-half/sources/posix.c +++ b/libc-bottom-half/sources/posix.c @@ -351,13 +351,6 @@ int fstatvfs(int fd, struct statvfs *buf) { return -1; } -char *realpath (const char *__restrict file_name, char *__restrict resolved_name) { - // TODO: We plan to support this eventually in WASI, but not yet. - // Meanwhile, we provide a stub so that libc++'s `` - // implementation will build unmodified. - return NULL; -} - // Like `access`, but with `faccessat`'s flags argument. int __wasilibc_access(const char *path, int mode, int flags)