Skip to content

Commit 363b6f4

Browse files
committed
build(wasi): add -fno-lto for __cxa_init_primary_exception
Addresses: wasm-ld: warning: function signature mismatch: __cxa_init_primary_exception >>> defined as (i32, i32, i32) -> i32 in lto.tmp >>> defined as (i32, i32, i32) -> void in libwasi-itk-extras.a(exceptionShim.cxx.o)
1 parent c658854 commit 363b6f4

File tree

3 files changed

+36
-5
lines changed

3 files changed

+36
-5
lines changed

src/docker/itk-wasm/ITKWebAssemblyInterface.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,10 @@ function(add_executable target)
6464
# WASI
6565
set_property(TARGET ${wasm_target} PROPERTY SUFFIX ".wasi.wasm")
6666
if (NOT TARGET wasi-itk-extras AND DEFINED CMAKE_CXX_COMPILE_OBJECT)
67+
set_source_files_properties(/ITKWebAssemblyInterface/src/exceptionShimInitPrimaryException.cxx PROPERTIES COMPILE_FLAGS "-fno-lto")
6768
add_library(wasi-itk-extras STATIC
6869
/ITKWebAssemblyInterface/src/exceptionShim.cxx
70+
/ITKWebAssemblyInterface/src/exceptionShimInitPrimaryException.cxx
6971
/ITKWebAssemblyInterface/src/cxaThreadAtExitShim.cxx
7072
/ITKWebAssemblyInterface/src/pthreadShim.cxx
7173
/ITKWebAssemblyInterface/src/initialization.cxx)

src/exceptionShim.cxx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,6 @@ void __cxa_throw(void *, void *, void *)
3333
abort();
3434
}
3535

36-
// Only triggered with Debug wasi-threads builds
37-
void __cxa_init_primary_exception(void *, void *, void *)
38-
{
39-
}
40-
4136
}
4237

4338
#endif // __cplusplus
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*=========================================================================
2+
*
3+
* Copyright NumFOCUS
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* https://www.apache.org/licenses/LICENSE-2.0.txt
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*=========================================================================*/
18+
// Workaround for current lack of exception support
19+
// Needs separate flags.
20+
21+
#ifdef __cplusplus
22+
23+
#include <stdlib.h>
24+
25+
extern "C" {
26+
27+
// Only triggered with Debug wasi-threads builds
28+
void __cxa_init_primary_exception(void *, void *, void *)
29+
{
30+
}
31+
32+
}
33+
34+
#endif // __cplusplus

0 commit comments

Comments
 (0)