Skip to content

Commit

Permalink
[SH]tools/sh-demo: conveniently experiment with native compilation
Browse files Browse the repository at this point in the history
sh-demo includes compilation of a .c file produced by `shermes` in the
regular CMake build, making it easy to experiment and test things.
  • Loading branch information
tmikov committed Dec 30, 2024
1 parent fb9e787 commit 4baaa43
Show file tree
Hide file tree
Showing 6 changed files with 1,061 additions and 1 deletion.
1 change: 1 addition & 0 deletions tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ add_subdirectory(node-hermes)
add_subdirectory(shermes)
add_subdirectory(synth)
add_subdirectory(hcdp)
add_subdirectory(sh-demo)

if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/facebook)
add_subdirectory(facebook)
Expand Down
10 changes: 10 additions & 0 deletions tools/sh-demo/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

link_libraries(shermes_console_a hermesvmlean_a jsi)
link_libraries(setjmp)
link_libraries(wasi-emulated-mman)

add_executable(sh-demo demo.c cxa.cpp)
18 changes: 18 additions & 0 deletions tools/sh-demo/cxa.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

#include "llvh/Support/ErrorHandling.h"

extern "C" void __cxa_throw(void* thrown_exception,
std::type_info* tinfo,
void (*dest)(void*)) {
llvh::report_fatal_error("C++ exceptions not supported on Wasi");
}

extern "C" void* __cxa_allocate_exception(size_t) {
llvh::report_fatal_error("C++ exceptions not supported on Wasi");
}
Loading

0 comments on commit 4baaa43

Please sign in to comment.