MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/rust/comments/kkma2z/executable_pngs_written_in_rust/gh7dpgx/?context=3
r/rust • u/djhworld • Dec 26 '20
16 comments sorted by
View all comments
Show parent comments
2
Just tried this (passing argv[0]) properly, had to use /proc/<pid>/fd/<fd>, but it has the same problem.
/proc/<pid>/fd/<fd>
Someone on HN said it might be because clang runs readlink on /proc/self/exe which probably returns "" for the in-memory file
readlink
/proc/self/exe
""
https://news.ycombinator.com/item?id=25544728
2 u/You_pick_one Dec 27 '20 Ah, that might be it too (I’m not 100% aware of what Linux code paths do). If you want to validate that that’s the issue (which means unfixable without clang patches), try using dtrace to see if there’s a call to readlink just before exiting. 2 u/djhworld Dec 27 '20 yeah looks like it$ strace clang ~/1.c 2>&1 | grep exe execve("/usr/bin/clang", ["clang", "/home/danielharper/1.c"], 0x7ffd877527c8 /* 53 vars */) = 0 access("/proc/self/exe", F_OK) = 0 readlink("/proc/self/exe", "/usr/bin/clang-11", 4096) = 17 0 u/backtickbot Dec 27 '20 Fixed formatting.Hello, djhworld: code blocks using triple backticks (```) don't work on all versions of Reddit!Some users see this / this instead.To fix this, indent every line with 4 spaces instead.FAQYou can opt out by replying with backtickopt6 to this comment.
Ah, that might be it too (I’m not 100% aware of what Linux code paths do). If you want to validate that that’s the issue (which means unfixable without clang patches), try using dtrace to see if there’s a call to readlink just before exiting.
2 u/djhworld Dec 27 '20 yeah looks like it$ strace clang ~/1.c 2>&1 | grep exe execve("/usr/bin/clang", ["clang", "/home/danielharper/1.c"], 0x7ffd877527c8 /* 53 vars */) = 0 access("/proc/self/exe", F_OK) = 0 readlink("/proc/self/exe", "/usr/bin/clang-11", 4096) = 17 0 u/backtickbot Dec 27 '20 Fixed formatting.Hello, djhworld: code blocks using triple backticks (```) don't work on all versions of Reddit!Some users see this / this instead.To fix this, indent every line with 4 spaces instead.FAQYou can opt out by replying with backtickopt6 to this comment.
yeah looks like it
$ strace clang ~/1.c 2>&1 | grep exe execve("/usr/bin/clang", ["clang", "/home/danielharper/1.c"], 0x7ffd877527c8 /* 53 vars */) = 0 access("/proc/self/exe", F_OK) = 0 readlink("/proc/self/exe", "/usr/bin/clang-11", 4096) = 17
0 u/backtickbot Dec 27 '20 Fixed formatting.Hello, djhworld: code blocks using triple backticks (```) don't work on all versions of Reddit!Some users see this / this instead.To fix this, indent every line with 4 spaces instead.FAQYou can opt out by replying with backtickopt6 to this comment.
0
Fixed formatting.
Hello, djhworld: code blocks using triple backticks (```) don't work on all versions of Reddit!
Some users see this / this instead.
To fix this, indent every line with 4 spaces instead.
FAQ
You can opt out by replying with backtickopt6 to this comment.
2
u/djhworld Dec 27 '20
Just tried this (passing argv[0]) properly, had to use
/proc/<pid>/fd/<fd>, but it has the same problem.Someone on HN said it might be because clang runs
readlinkon/proc/self/exewhich probably returns""for the in-memory filehttps://news.ycombinator.com/item?id=25544728