-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Open
Labels
backend-llvmThe LLVM backend outputs an LLVM IR Module.The LLVM backend outputs an LLVM IR Module.bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behavior
Milestone
Description
realpath is problematic for several reasons:
- it is not available for many targets, including WASI and BSDs
- it just straight up doesn't work for long file paths, if you have
/long1/long2/foofor example where long1 and long2 together exceed MAX_PATH, then the OS will give an error for that path when asked for the realpath. - it fails to respect the lazy nature of symlinks
- race conditions with moving files around
Robust software avoids realpath.
/home/andy/dev/zig/lib/std/os.zig:5079:15: error: realpath is forbidden
if (true) @compileError("realpath is forbidden");
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
referenced by:
init: /home/andy/dev/zig/src/codegen/llvm.zig:802:38
create: /home/andy/dev/zig/src/codegen/llvm.zig:754:27
createEmpty: /home/andy/dev/zig/src/link/NvPtx.zig:41:39
openPath: /home/andy/dev/zig/src/link/NvPtx.zig:63:12
openPath: /home/andy/dev/zig/src/link.zig:363:41
update: /home/andy/dev/zig/src/Compilation.zig:2003:38
updateModule: /home/andy/dev/zig/src/main.zig:3864:17
cmdBuild: /home/andy/dev/zig/src/main.zig:4510:9
mainArgs: /home/andy/dev/zig/src/main.zig:285:16
main: /home/andy/dev/zig/src/main.zig:213:12
Looks like this regressed in #13843.
Maybe we can even add a std lib option to disallow realpath on a per-application basis and then opt into that restriction in the compiler.
Related:
ianprime0509, Inve1951 and matu3ba
Metadata
Metadata
Assignees
Labels
backend-llvmThe LLVM backend outputs an LLVM IR Module.The LLVM backend outputs an LLVM IR Module.bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behavior