@@ -9,6 +9,7 @@ find_program(MAKE make REQUIRED)
9
9
10
10
option (WASI_SDK_DEBUG_PREFIX_MAP "Pass `-fdebug-prefix-map` for built artifacts" ON )
11
11
option (WASI_SDK_INCLUDE_TESTS "Whether or not to build tests by default" OFF )
12
+ option (WASI_SDK_LTO "Whether or not to build LTO assets" ON )
12
13
13
14
set (wasi_sysroot ${CMAKE_INSTALL_PREFIX} /share/wasi-sysroot)
14
15
@@ -149,10 +150,12 @@ endfunction()
149
150
150
151
function (define_wasi_libc target )
151
152
define_wasi_libc_sub (${target} "" OFF )
152
- define_wasi_libc_sub (${target} "-lto" ON )
153
+ if (WASI_SDK_LTO)
154
+ define_wasi_libc_sub (${target} "-lto" ON )
155
+ endif ()
153
156
154
157
add_custom_target (wasi-libc-${target}
155
- DEPENDS wasi-libc-${target} -build wasi-libc-${target} -lto-build )
158
+ DEPENDS wasi-libc-${target} -build $<$< BOOL : ${WASI_SDK_LTO} >: wasi-libc-${target} -lto-build > )
156
159
endfunction ()
157
160
158
161
foreach (target IN LISTS WASI_SDK_TARGETS)
@@ -249,17 +252,19 @@ endfunction()
249
252
250
253
function (define_libcxx target )
251
254
define_libcxx_sub(${target} "" "" "" )
252
- # Note: clang knows this /llvm-lto/${llvm_version} convention.
253
- # https://github.com/llvm/llvm-project/blob/llvmorg-18.1.8/clang/lib/Driver/ToolChains/WebAssembly.cpp#L204-L210
254
- define_libcxx_sub(${target} "-lto" "-flto=full" "/llvm-lto/${llvm_version} " )
255
+ if (WASI_SDK_LTO)
256
+ # Note: clang knows this /llvm-lto/${llvm_version} convention.
257
+ # https://github.com/llvm/llvm-project/blob/llvmorg-18.1.8/clang/lib/Driver/ToolChains/WebAssembly.cpp#L204-L210
258
+ define_libcxx_sub(${target} "-lto" "-flto=full" "/llvm-lto/${llvm_version} " )
259
+ endif ()
255
260
256
261
# As of this writing, `clang++` will ignore the target-specific include dirs
257
262
# unless this one also exists:
258
263
add_custom_target (libcxx-${target} -extra-dir
259
264
COMMAND ${CMAKE_COMMAND} -E make_directory ${wasi_sysroot} /include /c++/v1
260
265
COMMENT "creating libcxx-specific header file folder" )
261
266
add_custom_target (libcxx-${target}
262
- DEPENDS libcxx-${target} -build libcxx-${target} -lto-build libcxx-${target} -extra-dir)
267
+ DEPENDS libcxx-${target} -build $<$< BOOL : ${WASI_SDK_LTO} >: libcxx-${target} -lto-build > libcxx-${target} -extra-dir)
263
268
endfunction ()
264
269
265
270
foreach (target IN LISTS WASI_SDK_TARGETS)
0 commit comments