-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Define SANITIZER_USES_CANONICAL_LINUX_SYSCALLS in compiler-rt #15411
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
4acbd74
to
cce72bf
Compare
77f3ebf
to
1f6d26a
Compare
1f6d26a
to
c4ad261
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you elaborate on the benefits here more? I'm unclear on the purpose of this.
system/lib/fetch/asmfs.cpp
Outdated
@@ -1054,7 +1054,7 @@ static long open(const char* pathname, int flags, int mode) { | |||
return (long)desc; | |||
} | |||
|
|||
long __syscall_open(long path, long flags, ...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes to use at()
variants increase code size slightly. Very little, but still, is it worth the benefits here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, indeed. I think its worth it for the reduced complexity and maintenance.
It also a code size win for programs that call both flavors of these functions and fewer JS imports.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree it reduces complexity somewhat. I also agree it's a code size win for programs that use both. But I worry that maybe the common case is a program that uses just one, and it used to use the simple one, which is the case we'd be regressing. That might be worth measuring at least.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I don't think it will be a regression even for simple such programs, at least no more than the single line which is the call to SYSCALLS.calculateAt
. SYSCALLS.calculateAt
is part of the SYSCALLS
objects which IIRC clusure is not able to remove anyway.. so I think the calculateAt
method gets included in any case. But I can/will measure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that we just landed af4a408 is seems a reasonable extension to land this too.
c2dbfa9
to
fef8f84
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good. Basically lgtm % comments and also assuming you don't measure more than a few bytes of change in size in simple programs using files (and not using files, just to be sure, but there should be 0 change there).
@@ -14,7 +14,7 @@ int dup2(int old, int new) | |||
#else | |||
if (old==new) { | |||
#ifdef __EMSCRIPTEN__ | |||
r = __wasi_fd_is_valid(old) ? 0 : -1; | |||
r = __wasi_fd_is_valid(old) ? 0 : -EBADF; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a separate bugfix from this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes indeed, let me see if I can split that out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually this is bugfix, but it doesn't make sense to land separately really since this is basically in dead code. Prior to this PR SYS_dup2
is defined so this entire block of code is ifdef'd out. By removing SYS_dup2
in this PR we are forced to fix this existing bug.
I guess I could split out the removal of dup2.... that could work.
The musl implemenation of dup2 works fine without this syscall as it can be implemented in terms of dup3. As part of this change I was forced to implement __wasi_fd_fdstat_get for wasmfs since dup2 not depends on this wasi syscall. Split out from #15411
The musl implemenation of dup2 works fine without this syscall as it can be implemented in terms of dup3. As part of this change I was forced to implement __wasi_fd_fdstat_get for wasmfs since dup2 not depends on this wasi syscall. Split out from #15411
The musl implemenation of dup2 works fine without this syscall as it can be implemented in terms of dup3. As part of this change I was forced to implement __wasi_fd_fdstat_get for wasmfs since dup2 not depends on this wasi syscall. Split out from #15411
The musl implemenation of dup2 works fine without this syscall as it can be implemented in terms of dup3. As part of this change I was forced to implement __wasi_fd_fdstat_get for wasmfs since dup2 not depends on this wasi syscall. Split out from #15411
The musl implemenation of dup2 works fine without this syscall as it can be implemented in terms of dup3. As part of this change I was forced to implement __wasi_fd_fdstat_get for wasmfs since dup2 not depends on this wasi syscall. Split out from #15411
fef8f84
to
5fa5a32
Compare
5fa5a32
to
617b4d8
Compare
No change in side for non-file using code (I ran For an example that uses fopen I see 3 bytes increase in wasm size and 18 byte increase in (non-closure) output (out of 65041 bytes!).
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, however, is it possible to delay landing this? The changes to library_syscall.js
here will require updates to the external PThreadFS codebase, which is temporary and not heavily tested. I would prefer to wait on landing this until WasmFS replaces PThreadFS to avoid disruption to our partners.
Sure, no hurry. |
f167bd5
to
4c318cf
Compare
In defining this I noticed that musl will also choose to use these canonical syscalls when the alternative is not defined. This allows us to remove a bunch of duplicate syscalls and their implementation.
4c318cf
to
25c18cb
Compare
This syscall was removed in #15411
This syscall was removed in #15411
…18984) This syscall was removed in emscripten-core#15411
…18984) This syscall was removed in emscripten-core#15411
In defining this I noticed that musl will also choose to use
these canonical syscalls when the alternative is not defined.
This allows us to remove a bunch of duplicate syscalls and
their implementation.