Skip to content

Commit c740b97

Browse files
Changqing-JINGatc-github
authored andcommitted
[CI] Add windows arm64 spectest to public github (#764)
1 parent bfe61b4 commit c740b97

File tree

3 files changed

+102
-19
lines changed

3 files changed

+102
-19
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Public GitHub
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- develop
8+
- 'release/*'
9+
pull_request:
10+
branches:
11+
- master
12+
- develop
13+
- 'release/*'
14+
workflow_dispatch:
15+
16+
concurrency:
17+
group: "${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}"
18+
cancel-in-progress: true
19+
20+
jobs:
21+
aarch64_windows_cmake_build_test:
22+
runs-on: windows-11-arm
23+
strategy:
24+
fail-fast: false
25+
matrix:
26+
include:
27+
- Compiler_type: aarch64_debug_msvc
28+
cmake_arguments: -DVB_ENABLE_DEV_FEATURE=OFF -DENABLE_MSVC_PARALLEL=0 -DENABLE_WERROR=1 -A ARM64 -DENABLE_SPECTEST=1 -DENABLE_DEMO=1
29+
Build_type: Debug
30+
- Compiler_type: aarch64_relwithdebinfo_msvc
31+
cmake_arguments: -DVB_ENABLE_DEV_FEATURE=OFF -DENABLE_MSVC_PARALLEL=0 -DENABLE_WERROR=1 -A ARM64 -DENABLE_SPECTEST=1 -DENABLE_DEMO=1
32+
Build_type: RelWithDebInfo
33+
steps:
34+
- uses: actions/checkout@v4
35+
with:
36+
submodules: true
37+
# Here x86_64 executable file can be used because windows has instruction emulator.
38+
- name: Install wabt
39+
run: |
40+
aria2c https://github.com/WebAssembly/wabt/releases/download/1.0.36/wabt-1.0.36-windows.tar.gz
41+
tar -xzf wabt-1.0.36-windows.tar.gz
42+
mv wabt-1.0.36 C:\wabt-1.0.36
43+
echo "C:\wabt-1.0.36\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
44+
- name: gen testcase
45+
run: python tests/spectest.py
46+
- name: Build and test
47+
run: |
48+
mkdir build
49+
cd build
50+
cmake .. ${{ matrix.cmake_arguments }}
51+
cmake --build . --config ${{ matrix.Build_type }}
52+
ctest --verbose -C ${{ matrix.Build_type }}

cmake/AutoSelectBackendTarget.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
function(AutoSelectBackendTarget)
22
if(${CMAKE_GENERATOR} MATCHES "Visual Studio")
33
message("Visual Studio Setting")
4-
if(${CMAKE_GENERATOR_PLATFORM} MATCHES "ARM64")
4+
if(${CMAKE_GENERATOR_PLATFORM} MATCHES "[Aa][Rr][Mm]64")
55
set(NOW_TARGET "aarch64")
6-
elseif(${CMAKE_GENERATOR_PLATFORM} MATCHES "ARM")
6+
elseif(${CMAKE_GENERATOR_PLATFORM} MATCHES "[Aa][Rr][Mm]")
77
set(NOW_TARGET "aarch32")
88
elseif(${CMAKE_GENERATOR_PLATFORM} MATCHES "x64")
99
set(NOW_TARGET "x86_64")

src/utils/SignalFunctionWrapper.hpp

Lines changed: 48 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,32 @@ static_assert(false, "OS not supported");
3535
#endif
3636

3737
namespace vb {
38+
39+
///
40+
/// @brief RAII wrapper to set and reset runtime pointer for signal handling
41+
///
42+
/// Sets the thread-local runtime pointer in constructor and resets to nullptr in destructor
43+
///
44+
class ScopedRuntimeGuard final {
45+
public:
46+
///
47+
/// @brief Construct and set the runtime pointer
48+
///
49+
/// @param runtime The runtime to set
50+
///
51+
explicit ScopedRuntimeGuard(Runtime const &runtime) VB_NOEXCEPT;
52+
53+
///
54+
/// @brief Destructor resets runtime pointer to nullptr
55+
///
56+
~ScopedRuntimeGuard() VB_NOEXCEPT;
57+
58+
ScopedRuntimeGuard(ScopedRuntimeGuard const &) = delete;
59+
ScopedRuntimeGuard &operator=(ScopedRuntimeGuard const &) & = delete;
60+
ScopedRuntimeGuard(ScopedRuntimeGuard &&) = delete;
61+
ScopedRuntimeGuard &operator=(ScopedRuntimeGuard &&) & = delete;
62+
};
63+
3864
///
3965
/// @brief A wrapper to run Wasm function inside signal handler
4066
///
@@ -51,7 +77,7 @@ class SignalFunctionWrapper final {
5177
/// @throws std::runtime_error signal handler setup failed
5278
///
5379
static inline void start(Runtime &runtime) {
54-
trySetRuntime(runtime);
80+
ScopedRuntimeGuard const guard{runtime};
5581
SignalFunction::call_raw(start_wrapper, runtime);
5682
}
5783

@@ -77,7 +103,7 @@ class SignalFunctionWrapper final {
77103
template <size_t NumReturnValue, typename... FunctionArguments>
78104
static std::array<WasmValue, NumReturnValue> call(ModuleFunction<NumReturnValue, FunctionArguments...> const &function,
79105
FunctionArguments... args) VB_THROW {
80-
trySetRuntime(function.getRuntime());
106+
ScopedRuntimeGuard const guard{function.getRuntime()};
81107
return SignalFunction::call_raw<NumReturnValue>(function, args...);
82108
}
83109

@@ -91,7 +117,7 @@ class SignalFunctionWrapper final {
91117
/// @throws std::runtime_error signal handler setup failed
92118
///
93119
static void call(RawModuleFunction const &function, uint8_t const *const serializedArgs, uint8_t *const results) {
94-
trySetRuntime(function.getRuntime());
120+
ScopedRuntimeGuard const guard{function.getRuntime()};
95121
return SignalFunction::call_raw(callRawModuleFunction_wrapper, function, serializedArgs, results);
96122
}
97123

@@ -105,7 +131,7 @@ class SignalFunctionWrapper final {
105131
/// @throws std::runtime_error signal handler setup failed
106132
///
107133
static void call(RawModuleFunction const &function, WasmValue const *const serializedArgs, WasmValue *const results) {
108-
trySetRuntime(function.getRuntime());
134+
ScopedRuntimeGuard const guard{function.getRuntime()};
109135
return SignalFunction::call_raw(callRawModuleFunction_wrapper, function, pCast<uint8_t const *const>(serializedArgs),
110136
pCast<uint8_t *const>(results));
111137
}
@@ -131,18 +157,6 @@ class SignalFunctionWrapper final {
131157
#endif
132158

133159
private:
134-
///
135-
/// @brief Set the runtime pointer of current thread
136-
///
137-
/// @param runtime
138-
/// @note If signal handler is not required by current build config, this function will do nothing
139-
static void trySetRuntime(Runtime const &runtime) VB_NOEXCEPT {
140-
#if !LINEAR_MEMORY_BOUNDS_CHECKS || !ACTIVE_STACK_OVERFLOW_CHECK
141-
pRuntime_ = &runtime;
142-
#else
143-
static_cast<void>(runtime);
144-
#endif
145-
}
146160
///
147161
/// @brief wrap the raw module function in a function type
148162
///
@@ -191,8 +205,25 @@ class SignalFunctionWrapper final {
191205
static void probeLinearMemoryOffset() VB_NOEXCEPT;
192206
#endif
193207

194-
friend SignalFunction; ///< Allow OS specific signal function to access private members
208+
friend SignalFunction; ///< Allow OS specific signal function to access private members
209+
friend ScopedRuntimeGuard; ///< Allow RAII guard to access pRuntime_
195210
};
196211

212+
// ScopedRuntimeGuard implementation (after SignalFunctionWrapper is complete)
213+
// coverity[autosar_cpp14_a3_1_5_violation]
214+
inline ScopedRuntimeGuard::ScopedRuntimeGuard(Runtime const &runtime) VB_NOEXCEPT {
215+
static_cast<void>(runtime);
216+
#if !LINEAR_MEMORY_BOUNDS_CHECKS || !ACTIVE_STACK_OVERFLOW_CHECK
217+
SignalFunctionWrapper::pRuntime_ = &runtime;
218+
#endif
219+
}
220+
// coverity[autosar_cpp14_a3_1_5_violation]
221+
// coverity[autosar_cpp14_a12_7_1_violation]
222+
inline ScopedRuntimeGuard::~ScopedRuntimeGuard() VB_NOEXCEPT {
223+
#if !LINEAR_MEMORY_BOUNDS_CHECKS || !ACTIVE_STACK_OVERFLOW_CHECK
224+
SignalFunctionWrapper::pRuntime_ = nullptr;
225+
#endif
226+
}
227+
197228
} // namespace vb
198229
#endif

0 commit comments

Comments
 (0)