Skip to content

Commit

Permalink
Silence warnings when compiling bytecode using WASM.
Browse files Browse the repository at this point in the history
Summary:
When using `hermesc.js` to compile to bytecode it was displaying some unwanted warnings about `pthread_sigmask`. For example:
```
[[email protected] ~/fbsource] node buck-out/gen/ce9b6f2e/xplat/hermes/tools/hermesc/hermesc.js -emit-binary -out ~/foo.hbc ~/foo.js
pthread_sigmask() is not supported: this is a no-op.
pthread_sigmask() is not supported: this is a no-op.
```
With this diff, `LLVM_ENABLE_THREADS` is set to 0 in the WASM config. This means prevents it from trying to use the function `pthread_sigmask`:

https://www.internalfb.com/intern/diffusion/FBS/browsefile/master/xplat/hermes/external/llvh/lib/Support/Unix/Process.inc?commit=504758d2ae39ed63e7ffdf81a390c796583509ce&lines=236-242%2C251-256

This seems like the most non-intrusive way to silence the warning. Let me know if there is concern this might affect performance and we can find another way to handle this.

Reviewed By: dulinriley

Differential Revision: D26690011

fbshipit-source-id: d092f4f642316c8e338f1ddcd386a769146d018e
  • Loading branch information
MartinSherburn authored and facebook-github-bot committed Mar 3, 2021
1 parent 032e775 commit 7a02fc6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
4 changes: 3 additions & 1 deletion external/llvh/cmake/config-ix.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,9 @@ set(RETSIGTYPE void)

if( LLVM_ENABLE_THREADS )
# Check if threading primitives aren't supported on this platform
if( NOT HAVE_PTHREAD_H AND NOT WIN32 )
# Disable threads on emscripten because it doesn't have a full implementation
# including support for pthread_sigmask
if( (NOT HAVE_PTHREAD_H AND NOT WIN32) OR EMSCRIPTEN )
set(LLVM_ENABLE_THREADS 0)
endif()
endif()
Expand Down
14 changes: 14 additions & 0 deletions external/llvh/patches/emscripten-disable-threads.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
diff --git a/cmake/config-ix.cmake b/cmake/config-ix.cmake
--- a/cmake/config-ix.cmake
+++ b/cmake/config-ix.cmake
@@ -476,7 +476,9 @@

if( LLVM_ENABLE_THREADS )
# Check if threading primitives aren't supported on this platform
- if( NOT HAVE_PTHREAD_H AND NOT WIN32 )
+ # Disable threads on emscripten because it doesn't have a full implementation
+ # including support for pthread_sigmask
+ if( (NOT HAVE_PTHREAD_H AND NOT WIN32) OR EMSCRIPTEN )
set(LLVM_ENABLE_THREADS 0)
endif()
endif()

0 comments on commit 7a02fc6

Please sign in to comment.