Skip to content

Commit daa730e

Browse files
committed
uaol-wov: Fix build issue related to MWW path, compiler options
Fix the build issues related to - libc.a path update to use from xt-clang xtensa - comment ibuffer_allocater.cc entry as file does not exist - Add zephyr compiler options - Introduce assert_func Signed-off-by: Uday M Bhat <uday.m.bhat@intel.com>
1 parent 6eea19c commit daa730e

3 files changed

Lines changed: 98 additions & 27 deletions

File tree

‎src/audio/microwakeword/CMakeLists.txt‎

Lines changed: 83 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,14 @@ if(NOT EXISTS "${MWW_TOOLCHAIN_LIBC_ARCHIVE}")
5959
endif()
6060
endif()
6161

62+
if(NOT EXISTS "${MWW_TOOLCHAIN_LIBC_ARCHIVE}" AND NOT "$ENV{XTENSA_SYSTEM}" STREQUAL "")
63+
get_filename_component(MWW_XTENSA_CORE_DIR "$ENV{XTENSA_SYSTEM}/.." REALPATH)
64+
set(MWW_XTENSA_LIBC_ARCHIVE "${MWW_XTENSA_CORE_DIR}/xtensa-elf/lib/libc.a")
65+
if(EXISTS "${MWW_XTENSA_LIBC_ARCHIVE}")
66+
set(MWW_TOOLCHAIN_LIBC_ARCHIVE "${MWW_XTENSA_LIBC_ARCHIVE}")
67+
endif()
68+
endif()
69+
6270
set(MWW_TOOLCHAIN_INCLUDE_ROOT "")
6371
if(EXISTS "${MWW_TOOLCHAIN_LIBC_ARCHIVE}")
6472
get_filename_component(MWW_TOOLCHAIN_LIB_DIR "${MWW_TOOLCHAIN_LIBC_ARCHIVE}" DIRECTORY)
@@ -138,7 +146,7 @@ add_library(mww_tflm_lib STATIC
138146
${TFLM_PATH}/tensorflow/lite/micro/micro_resource_variable.cc
139147
${TFLM_PATH}/tensorflow/lite/micro/micro_interpreter_context.cc
140148
${TFLM_PATH}/tensorflow/lite/micro/fake_micro_context.cc
141-
${TFLM_PATH}/tensorflow/lite/micro/arena_allocator/ibuffer_allocator.cc
149+
# ${TFLM_PATH}/tensorflow/lite/micro/arena_allocator/ibuffer_allocator.cc
142150
${TFLM_PATH}/tensorflow/lite/micro/arena_allocator/persistent_arena_buffer_allocator.cc
143151
${TFLM_PATH}/tensorflow/lite/micro/arena_allocator/recording_single_arena_buffer_allocator.cc
144152
${TFLM_PATH}/tensorflow/lite/micro/arena_allocator/non_persistent_arena_buffer_allocator.cc
@@ -223,35 +231,83 @@ if(NOT CONFIG_COMP_MWW STREQUAL "m")
223231
if(NOT EXISTS "${MWW_TOOLCHAIN_LIBC_ARCHIVE}")
224232
message(FATAL_ERROR "Microwakeword libc shim: libc.a not found for ${SOC_TOOLCHAIN_NAME}")
225233
endif()
226-
set(MWW_LIBC_SHIM_MEMBERS
227-
libc_stdlib_abs.c.o
228-
libm_math_s_floor.c.o
229-
libm_math_sf_exp.c.o
230-
libm_math_sf_log.c.o
231-
libm_math_sf_ceil.c.o
232-
libm_math_s_frexp.c.o
233-
libm_common_s_round.c.o
234-
libm_common_sf_fmax.c.o
235-
libm_common_sf_fmin.c.o
236-
libm_common_sf_round.c.o
237-
libm_common_sf_isnan.c.o
238-
libm_common_sf_issignaling.c.o
239-
libm_common_math_errf_uflowf.c.o
240-
libm_common_math_errf_oflowf.c.o
241-
libm_common_math_errf_divzerof.c.o
242-
libm_common_math_errf_invalidf.c.o
243-
)
234+
execute_process(
235+
COMMAND ${CMAKE_AR} t ${MWW_TOOLCHAIN_LIBC_ARCHIVE}
236+
OUTPUT_VARIABLE MWW_LIBC_ARCHIVE_MEMBERS
237+
OUTPUT_STRIP_TRAILING_WHITESPACE
238+
)
239+
set(MWW_TOOLCHAIN_LIBM_ARCHIVE "")
240+
set(MWW_LIBM_SHIM_MEMBERS "")
241+
if(MWW_LIBC_ARCHIVE_MEMBERS MATCHES "(^|\n)lib_a-abs\\.o(\n|$)")
242+
set(MWW_LIBC_SHIM_MEMBERS
243+
lib_a-abs.o
244+
lib_a-errno.o
245+
lib_a-impure.o
246+
lib_a-s_nan.o
247+
lib_a-sf_finite.o
248+
lib_a-sf_fpclassify.o
249+
)
250+
set(MWW_TOOLCHAIN_LIBM_ARCHIVE "${MWW_TOOLCHAIN_LIB_DIR}/libm.a")
251+
set(MWW_LIBM_SHIM_MEMBERS
252+
lib_a-ef_exp.o
253+
lib_a-ef_log.o
254+
lib_a-s_ceil.o
255+
lib_a-s_floor.o
256+
lib_a-s_frexp.o
257+
lib_a-s_lib_ver.o
258+
lib_a-s_matherr.o
259+
lib_a-s_round.o
260+
lib_a-s_signbit.o
261+
lib_a-sf_fmax.o
262+
lib_a-sf_fmin.o
263+
lib_a-sf_isnan.o
264+
lib_a-sf_round.o
265+
lib_a-wf_exp.o
266+
lib_a-wf_log.o
267+
)
268+
else()
269+
set(MWW_LIBC_SHIM_MEMBERS
270+
libc_stdlib_abs.c.o
271+
libm_math_s_floor.c.o
272+
libm_math_sf_exp.c.o
273+
libm_math_sf_log.c.o
274+
libm_math_sf_ceil.c.o
275+
libm_math_s_frexp.c.o
276+
libm_common_s_round.c.o
277+
libm_common_sf_fmax.c.o
278+
libm_common_sf_fmin.c.o
279+
libm_common_sf_round.c.o
280+
libm_common_sf_isnan.c.o
281+
libm_common_sf_issignaling.c.o
282+
libm_common_math_errf_uflowf.c.o
283+
libm_common_math_errf_oflowf.c.o
284+
libm_common_math_errf_divzerof.c.o
285+
libm_common_math_errf_invalidf.c.o
286+
)
287+
endif()
244288
set(MWW_LIBC_SHIM_DIR ${CMAKE_CURRENT_BINARY_DIR}/mww_libc_shim)
245289
set(MWW_LIBC_SHIM_ARCHIVE ${CMAKE_CURRENT_BINARY_DIR}/libmww_libc_shim.a)
246290
file(MAKE_DIRECTORY ${MWW_LIBC_SHIM_DIR})
247-
add_custom_command(
248-
OUTPUT ${MWW_LIBC_SHIM_ARCHIVE}
249-
COMMAND ${CMAKE_AR} x ${MWW_TOOLCHAIN_LIBC_ARCHIVE} ${MWW_LIBC_SHIM_MEMBERS}
250-
COMMAND ${CMAKE_AR} rcs ${MWW_LIBC_SHIM_ARCHIVE} ${MWW_LIBC_SHIM_MEMBERS}
251-
WORKING_DIRECTORY ${MWW_LIBC_SHIM_DIR}
252-
DEPENDS ${MWW_TOOLCHAIN_LIBC_ARCHIVE}
253-
COMMENT "Extracting abs()/libm members TFLM needs from the toolchain libc.a"
254-
)
291+
if(MWW_LIBM_SHIM_MEMBERS)
292+
add_custom_command(
293+
OUTPUT ${MWW_LIBC_SHIM_ARCHIVE}
294+
COMMAND ${CMAKE_AR} x ${MWW_TOOLCHAIN_LIBC_ARCHIVE} ${MWW_LIBC_SHIM_MEMBERS}
295+
COMMAND ${CMAKE_AR} x ${MWW_TOOLCHAIN_LIBM_ARCHIVE} ${MWW_LIBM_SHIM_MEMBERS}
296+
COMMAND ${CMAKE_AR} rcs ${MWW_LIBC_SHIM_ARCHIVE} ${MWW_LIBC_SHIM_MEMBERS} ${MWW_LIBM_SHIM_MEMBERS}
297+
WORKING_DIRECTORY ${MWW_LIBC_SHIM_DIR}
298+
DEPENDS ${MWW_TOOLCHAIN_LIBC_ARCHIVE} ${MWW_TOOLCHAIN_LIBM_ARCHIVE}
299+
COMMENT "Extracting abs()/libm members TFLM needs from the toolchain archives"
300+
)
301+
else()
302+
add_custom_command(
303+
OUTPUT ${MWW_LIBC_SHIM_ARCHIVE}
304+
COMMAND ${CMAKE_AR} x ${MWW_TOOLCHAIN_LIBC_ARCHIVE} ${MWW_LIBC_SHIM_MEMBERS}
305+
COMMAND ${CMAKE_AR} rcs ${MWW_LIBC_SHIM_ARCHIVE} ${MWW_LIBC_SHIM_MEMBERS}
306+
WORKING_DIRECTORY ${MWW_LIBC_SHIM_DIR}
307+
DEPENDS ${MWW_TOOLCHAIN_LIBC_ARCHIVE}
308+
COMMENT "Extracting abs()/libm members TFLM needs from the toolchain libc.a"
309+
)
310+
endif()
255311
add_custom_target(mww_libc_shim_gen DEPENDS ${MWW_LIBC_SHIM_ARCHIVE})
256312
add_library(mww_libc_shim STATIC IMPORTED GLOBAL)
257313
set_target_properties(mww_libc_shim PROPERTIES IMPORTED_LOCATION ${MWW_LIBC_SHIM_ARCHIVE})

‎src/audio/microwakeword/mww.c‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,16 @@ int DebugVsnprintf(char *buffer, size_t buf_size, const char *format,
5757
return vsnprintk(buffer, buf_size, format, vlist);
5858
}
5959

60+
void __assert_func(const char *file, int line, const char *func,
61+
const char *failedexpr)
62+
{
63+
(void)file;
64+
(void)line;
65+
(void)func;
66+
(void)failedexpr;
67+
sof_panic(0);
68+
}
69+
6070
#include <sof/lib/notifier.h>
6171
#include <sof/audio/wov_arbiter.h>
6272

‎zephyr/CMakeLists.txt‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,11 @@ if (NOT CONFIG_COMPILER_INLINE_FUNCTION_OPTION)
674674
target_compile_options(SOF INTERFACE -fno-inline-functions)
675675
endif()
676676

677+
if (ARCH STREQUAL "xtensa")
678+
target_compile_options(SOF INTERFACE -mlongcalls)
679+
zephyr_compile_options(-mtext-section-literals)
680+
endif()
681+
677682
# SOF needs `typeof`, `__VA_ARGS__` and maybe other GNU C99
678683
# extensions. TODO other flags required ?
679684
target_compile_options(SOF INTERFACE $<$<COMPILE_LANGUAGE:C,ASM>: -std=gnu99>)

0 commit comments

Comments
 (0)