-nostdlib
Tells the compiler to not use the Arm® standard C and C++ libraries.
If you use the -nostdlib
option, armclang
does not collude with the Arm standard
library and only emits calls to functions that the C Standard or the AEABI defines.
The output from armclang
works with any ISO C
library that is compliant with AEABI.
The -nostdlib
armclang
option, passes the --no_scanlib
linker option to armlink
. Therefore you must specify the location of the libraries you want
to use as input objects to armlink
, or with the
--userlibpath
armlink
option.
Note
If you want to use your own libraries instead of the Arm standard libraries or if you want to re-implement the standard library functions, then you must use the-nostdlib
armclang
option. Your libraries must be compliant
with the ISO C library and with the AEABI specification.Default
-nostdlib
is disabled by default.
Example
#include "math.h" double foo(double d) { return sqrt(d + 1.0); } int main(int argc, char *argv[]) { return foo(argc); }
Compiling this code with -nostdlib
generates
a call to sqrt
, which is AEABI compliant.
armclang --target=arm-arm-none-eabi -mcpu=Cortex-A9 -O0 -S -o- file.c -mfloat-abi=hard -nostdlib
Compiling this code without -nostdlib
generates a call to __hardfp_sqrt
(from the
Arm
standard library), which the C Standard and the AEABI do not define.
armclang --target=arm-arm-none-eabi -mcpu=Cortex-A9 -O0 -S -o- file.c -mfloat-abi=hard