emscripten-core / emscripten-core/emscripten
realpath is not portable to windows for NODERAWFS
- Lingua principale
- C++
- Stelle
- 27.6k
- Fork
- 3.6k
- Merge medio
- 1g 14h
- PR unite (30g)
- 125
Descrizione
**Version of emscripten/emsdk:**
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.19 (a5f7b1c9a1c74a830bebedc122d204800ce8dff9)
clang version 16.0.0 (https://github.com/llvm/llvm-project 30171e76f0e5ea8037bc4d1450dd3e12af4d9938)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: /home/rich/source/emsdk/upstream/bin
Building this c program:
```c
#include
#include
#include
#include
#include
int main(int argc, char *argv[])
{
struct dirent *pDirent;
DIR *pDir;
// Ensure correct argument count.
if (argc != 2)
{
printf("Usage: main \n");
return 1;
}
// Get the realpath
char cresolved_path[PATH_MAX];
char * res = realpath(argv[1], cresolved_path);
if (res == NULL) {
char error_buf[300] = {0};
strcpy(error_buf, strerror(errno));
printf("Cannot real path the directory '%s' with '%s'\n", argv[1], error_buf);
return -1;
}
return 0;
}
```
With `-s NODERAWFS` should generate a portable js/wasm combination.
It works fine on linux.
When I run this outputted wasm using node on windows, I get this:
```
PS C:\Users\aku91\source\repos\debugpyweb> node ..\realpath_c\main.js C:\Users\aku91\source\repos
Cannot real path the directory 'C:\Users\aku91\source\repos' with 'No such file or directory'
```
I _think_ the problem lies in the [realpath implementation](https://github.com/emscripten-core/emscripten/blob/main/system/lib/libc/musl/src/misc/realpath.c). It doesn't look like it would work on windows.
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia da system/lib/libc/musl/src/misc/realpath.c e riproduci il problema usando il programma C fornito, compilato con -s NODERAWFS. Esegui il main.js generato con Node su Windows usando un percorso Windows, quindi confronta il risultato con Linux. Il lavoro è completato quando realpath risolve correttamente il percorso Windows nell'output di NODERAWFS.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- c, node.js, wasm
- Ambito
- operating-systems
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 42/100