From e12889d8e1744658f1aa02eb75edc9c0aab238e4 Mon Sep 17 00:00:00 2001 From: Hugues Kamba Date: Wed, 29 May 2019 14:42:28 +0100 Subject: [PATCH] microlib support: Fix build with Arm Compiler 6 and MicroLib Building binaries with MicroLib and Arm compiler 6 has been failing because of a bug in Arm compiler 6. The compiler introduces a symbol, `__scanf_mbtowc`, which is not present in MicroLib C library. The present commit adds a weak reference to the symbol to allow a successful linkage. This is a temporary fix until the bug in the compiler is fixed. It should be removed after the compiler bug is fixed. --- .../TOOLCHAIN_ARM_MICRO/mbed_boot_arm_micro.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/rtos/TARGET_CORTEX/TOOLCHAIN_ARM_MICRO/mbed_boot_arm_micro.c b/rtos/TARGET_CORTEX/TOOLCHAIN_ARM_MICRO/mbed_boot_arm_micro.c index c2ce8ddb19..43f24fea6a 100644 --- a/rtos/TARGET_CORTEX/TOOLCHAIN_ARM_MICRO/mbed_boot_arm_micro.c +++ b/rtos/TARGET_CORTEX/TOOLCHAIN_ARM_MICRO/mbed_boot_arm_micro.c @@ -68,3 +68,20 @@ MBED_WEAK void __aeabi_assert(const char *expr, const char *file, int line) { mbed_assert_internal(expr, file, line); } + +// The below resolves the linker error generated by a bug in Arm Compiler 6 +// When building with MicroLib, the compiler inadvertently introduces the +// _scanf_mbtowc symbol to the build. The code below provides a weak reference +// for the missing symbol +#include +typedef int ScanfReadRec; +MBED_WEAK long int _scanf_mbtowc( + int ignored, + FILE *p, + ScanfReadRec *sr, + int *charmap, + int exact +) +{ + return 0; +}