5.7.1.11 Libc-variant Option

The -mlibc-variant=variant option specifies whether speed- or size-orientated string functions are linked in with the program. Size-orientated functions are linked in if this option is not used.

Many of the library functions provided by <string.h> are available in two variants. The size-orientated functions require less code to implement. These can be explicitly selected by using a size argument to the option, for example -mlibc-variant=size. The speed-orientated functions might be larger, but they execute quickly, resulting in improved program performance. They can be selected by using a speed argument to the option.

Important: Note that some of the speed-orientated functions might use the device's Floating-Point Unit (FPU) or Digital Signal Processor (DSP) extension, when this is available. In some cases, the usage of the FPU or DSP might require the interrupt context switching code to save and restore more registers, thereby affecting the program's interrupt latency. Take this into consideration when calling these string functions from an interrupt context.
All architectures implement the size-orientated function variants. The table below shows those architectures that additionally support speed-orientated variants. In the table, Single Precision Floating Point (FP), Double Precision Floating Point (DF), and Single Instruction Multiple Data Parallel Processing (SIMD) architecture extensions are listed. For cases where only the size-orientated variant is available, it will always be selected, regardless of the variant specified by this option.
Table 5-5. Availability of speed-orientated over size-orientated variants for String function by device architecture
Arm architecture memset() memcpy() strlen() strcmp() memmove() memchr()
ARMv6-M + speed + speed + speed
ARMv7E-M + speed + speed + speed + speed + speed + speed
ARMv7E-M+DP + speed + speed + speed + speed + speed + speed
ARMv7E-M+FP + speed + speed + speed + speed + speed + speed
ARMv7VE+SIMD + speed + speed + speed + speed + speed
ARMv7-A + speed + speed + speed + speed + speed
ARMv7-A+FP + speed + speed + speed + speed + speed
ARMv7-A+SIMD + speed + speed + speed + speed + speed
ARMv8-M Baseline + speed + speed + speed
ARMv8-M Mainline + speed + speed + speed + speed
ARMv8-M Mainline+FP + speed + speed + speed + speed