1e41f4b71Sopenharmony_ci# musl libc 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ci## Overview 4e41f4b71Sopenharmony_ciThe C standard library (libc) provides standard header files and common library implementations (such as input/output processing and string handling) in C language programming. 5e41f4b71Sopenharmony_ci 6e41f4b71Sopenharmony_ciOpenHarmony uses musl as the libc. musl is a lightweight, fast, simple, and free open-source libc. For details, see [musl libc Reference Manual](http://musl.libc.org/manual.html). 7e41f4b71Sopenharmony_ci 8e41f4b71Sopenharmony_ciFor details about the differences between musl and glibc, see [Functional differences from glibc](https://wiki.musl-libc.org/functional-differences-from-glibc.html). 9e41f4b71Sopenharmony_ci 10e41f4b71Sopenharmony_ci## libc Components 11e41f4b71Sopenharmony_ci 12e41f4b71Sopenharmony_ciC11 is implemented by [libc, libm, and libdl](https://en.cppreference.com/w/c/header). 13e41f4b71Sopenharmony_ci 14e41f4b71Sopenharmony_ci- libc: provides thread-related interfaces and a majority of standard interfaces. 15e41f4b71Sopenharmony_ci 16e41f4b71Sopenharmony_ci- libm: provides mathematical library interfaces. Currently, OpenHarmony provides a link to libm, and the interfaces are defined in libc. 17e41f4b71Sopenharmony_ci 18e41f4b71Sopenharmony_ci- libdl: provides dynamic linker interfaces such as dlopen. Currently, OpenHarmony provides a link to libdl, and the interfaces are defined in libc. 19e41f4b71Sopenharmony_ci 20e41f4b71Sopenharmony_ci 21e41f4b71Sopenharmony_ci## musl Version 22e41f4b71Sopenharmony_ci 23e41f4b71Sopenharmony_ci- 1.2.0 24e41f4b71Sopenharmony_ci- 1.2.3 from OpenHarmony 4.0 25e41f4b71Sopenharmony_ci- 1.2.5 from OpenHarmony 5.0 26e41f4b71Sopenharmony_ci 27e41f4b71Sopenharmony_ci## Supported Capabilities 28e41f4b71Sopenharmony_ciOpenHarmony provides header files and library interfaces that are compatible (not fully compatible) with C99, C11, and POSIX, and supports Armv7-A, Arm64, and x86_64 architectures. 29e41f4b71Sopenharmony_ci 30e41f4b71Sopenharmony_ciTo better adapt to the basic features of OpenHarmony devices, such as high performance, low memory, high security, lightweight, and multi-form support, OpenHarmony has optimized the musl library and removed the interfaces that are not applicable to embedded devices. 31e41f4b71Sopenharmony_ci 32e41f4b71Sopenharmony_ci### New Capabilities 33e41f4b71Sopenharmony_ci1. The dynamic loader supports isolation by namespace. The dynamic libraries that can be loaded by **dlopen()** are restricted by the system namespace. For example, the system dynamic libraries cannot be opened. 34e41f4b71Sopenharmony_ci2. **dlclose()** can be used to unload a dynamic library. This capability is not supported by musl. 35e41f4b71Sopenharmony_ci3. The symbol-versioning is supported. 36e41f4b71Sopenharmony_ci4. **dlopen()** can directly load uncompressed files in a .zip package. 37e41f4b71Sopenharmony_ci 38e41f4b71Sopenharmony_ci### Debugging Capabilities 39e41f4b71Sopenharmony_ciThe libc provides dynamic enabling of debug logging (disabled by default). The debug logs help you learn about exceptions of the libc. With this function, you only need to set **param**, which eliminates the need for rebuilding the libc. However, you are advised not to enable debug logging in official versions because it affects the running performance. 40e41f4b71Sopenharmony_ci 41e41f4b71Sopenharmony_ci#### musl.log 42e41f4b71Sopenharmony_ciSet **musl.log.enable** to **true** to enable printing of musl debug logs. You need to enable musl.log before printing other logs. 43e41f4b71Sopenharmony_ci``` 44e41f4b71Sopenharmony_ciparam set musl.log.enable true 45e41f4b71Sopenharmony_ci``` 46e41f4b71Sopenharmony_ci 47e41f4b71Sopenharmony_ci#### Loader Logging 48e41f4b71Sopenharmony_ciThe loader starts applications and invokes **dlopen** and **dlclose** in the libc. To view exceptions during the loading process, you need to enable the loader logging function. The following describes common operations. 49e41f4b71Sopenharmony_ci* Enable the loader logging for all applications. Exercise caution when enabling this function because a large number of logs will be generated. 50e41f4b71Sopenharmony_ci``` 51e41f4b71Sopenharmony_ciparam set musl.log.ld.app true 52e41f4b71Sopenharmony_ci``` 53e41f4b71Sopenharmony_ci* Enable the loader logging for an application specified by {app_name}. 54e41f4b71Sopenharmony_ci``` 55e41f4b71Sopenharmony_ciparam set musl.log.ld.all false 56e41f4b71Sopenharmony_ciparam set musl.log.ld.app.{app_name} true 57e41f4b71Sopenharmony_ci``` 58e41f4b71Sopenharmony_ci* Enable the loader logging for all applications except the specified application. 59e41f4b71Sopenharmony_ci``` 60e41f4b71Sopenharmony_ciparam set musl.log.ld.all true 61e41f4b71Sopenharmony_ciparam set musl.log.ld.app.{app_name} false 62e41f4b71Sopenharmony_ci``` 63e41f4b71Sopenharmony_ci 64e41f4b71Sopenharmony_ci## Character Encoding Formats Supported by iconv 65e41f4b71Sopenharmony_ci 66e41f4b71Sopenharmony_ciThe following lists the character encoding formats and aliases supported by musl. 67e41f4b71Sopenharmony_ci> **NOTE** 68e41f4b71Sopenharmony_ci> 69e41f4b71Sopenharmony_ci> The character conversion can be successful only when the source character encoding format is correct and the target character encoding format is supported. 70e41f4b71Sopenharmony_ci> musl does not support the following target encoding formats: gb18030, gbk, gb2312, big5, and euckr. 71e41f4b71Sopenharmony_ci 72e41f4b71Sopenharmony_ci| Encoding Format | Alias | Supported by musl| 73e41f4b71Sopenharmony_ci|:-- | :-- | :--: | 74e41f4b71Sopenharmony_ci|utf8 | | Yes | 75e41f4b71Sopenharmony_ci|wchart | | Yes | 76e41f4b71Sopenharmony_ci|ucs2be | | Yes | 77e41f4b71Sopenharmony_ci|ucs2le | | Yes | 78e41f4b71Sopenharmony_ci|utf16be | | Yes | 79e41f4b71Sopenharmony_ci|utf16le | | Yes | 80e41f4b71Sopenharmony_ci|ucs4be |utf32be | Yes | 81e41f4b71Sopenharmony_ci|ucs4le |utf32le | Yes | 82e41f4b71Sopenharmony_ci|ascii |usascii, iso646, iso646us | Yes | 83e41f4b71Sopenharmony_ci|utf16 | | Yes | 84e41f4b71Sopenharmony_ci|ucs4 |utf32 | Yes | 85e41f4b71Sopenharmony_ci|ucs2 | | Yes | 86e41f4b71Sopenharmony_ci|eucjp | | Yes | 87e41f4b71Sopenharmony_ci|shiftjis |sjis, cp932 | Yes | 88e41f4b71Sopenharmony_ci|iso2022jp| | Yes | 89e41f4b71Sopenharmony_ci|gb18030 | | Yes | 90e41f4b71Sopenharmony_ci|gbk | | Yes | 91e41f4b71Sopenharmony_ci|gb2312 | | Yes | 92e41f4b71Sopenharmony_ci|big5 |bigfive, cp950, big5hkscs | Yes | 93e41f4b71Sopenharmony_ci|euckr |ksc5601, ksx1001, cp949 | Yes | 94e41f4b71Sopenharmony_ci|iso88591 |latin1 | Yes | 95e41f4b71Sopenharmony_ci|iso88592 | | Yes | 96e41f4b71Sopenharmony_ci|iso88593 | | Yes | 97e41f4b71Sopenharmony_ci|iso88594 | | Yes | 98e41f4b71Sopenharmony_ci|iso88595 | | Yes | 99e41f4b71Sopenharmony_ci|iso88596 | | Yes | 100e41f4b71Sopenharmony_ci|iso88597 | | Yes | 101e41f4b71Sopenharmony_ci|iso88598 | | Yes | 102e41f4b71Sopenharmony_ci|iso88599 | | Yes | 103e41f4b71Sopenharmony_ci|iso885910| | Yes | 104e41f4b71Sopenharmony_ci|iso885911|tis620 | Yes | 105e41f4b71Sopenharmony_ci|iso885913| | Yes | 106e41f4b71Sopenharmony_ci|iso885914| | Yes | 107e41f4b71Sopenharmony_ci|iso885915|latin9 | Yes | 108e41f4b71Sopenharmony_ci|iso885916| | Yes | 109e41f4b71Sopenharmony_ci|cp1250 |windows1250 | Yes | 110e41f4b71Sopenharmony_ci|cp1251 |windows1251 | Yes | 111e41f4b71Sopenharmony_ci|cp1252 |windows1252 | Yes | 112e41f4b71Sopenharmony_ci|cp1253 |windows1253 | Yes | 113e41f4b71Sopenharmony_ci|cp1254 |windows1254 | Yes | 114e41f4b71Sopenharmony_ci|cp1255 |windows1255 | Yes | 115e41f4b71Sopenharmony_ci|cp1256 |windows1256 | Yes | 116e41f4b71Sopenharmony_ci|cp1257 |windows1257 | Yes | 117e41f4b71Sopenharmony_ci|cp1258 |windows1258 | Yes | 118e41f4b71Sopenharmony_ci|koi8r | | Yes | 119e41f4b71Sopenharmony_ci|koi8u | | Yes | 120e41f4b71Sopenharmony_ci|cp437 | | Yes | 121e41f4b71Sopenharmony_ci|cp850 | | Yes | 122e41f4b71Sopenharmony_ci|cp866 | | Yes | 123e41f4b71Sopenharmony_ci|cp1047 |ibm1047 | Yes | 124e41f4b71Sopenharmony_ci 125e41f4b71Sopenharmony_ci## musl APIs Not Supported 126e41f4b71Sopenharmony_ci 127e41f4b71Sopenharmony_ci[Native API Symbols Not Exported](musl-peculiar-symbol.md) 128e41f4b71Sopenharmony_ci 129e41f4b71Sopenharmony_ci[Restricted musl libc APIs](guidance-on-ndk-libc-interfaces-affected-by-permissions.md) 130e41f4b71Sopenharmony_ci 131e41f4b71Sopenharmony_ci 132e41f4b71Sopenharmony_ci<!--no_check--> 133