diff options
| author | 陈泽堂 <[email protected]> | 2026-11-02 18:08:11 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-11-02 18:08:11 +0800 |
| commit | 2254560414260f60471f4c0483e21ec9cf0a7758 (patch) | |
| tree | d26f1d9a241db93604c4783eb733b46dce31161e /src/klibc/SConscript | |
| parent | dace1947ddb6a9ecbfcad216e784e8e74df60967 (diff) | |
fix[klibc]: stop gcc from turning the kstring.c byte loops into memset/memcpy calls #11965
Diffstat (limited to 'src/klibc/SConscript')
| -rw-r--r-- | src/klibc/SConscript | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/klibc/SConscript b/src/klibc/SConscript index ce214ad105..7ea41b6aec 100644 --- a/src/klibc/SConscript +++ b/src/klibc/SConscript @@ -1,5 +1,6 @@ from building import * import os +import rtconfig cwd = GetCurrentDir() src = ['kerrno.c', 'kstdio.c', 'kstring.c'] @@ -13,7 +14,18 @@ if not GetDepend(['RT_KLIBC_USING_LIBC_VSNPRINTF']): if not GetDepend(['RT_KLIBC_USING_LIBC_VSSCANF']): src += ['rt_vsscanf.c'] -group = DefineGroup('Libc', src, depend = ['']) +# at -O2/-Os, GCC recognises the byte loops used by rt_memset()/rt_memcpy()/ +# rt_memmove() in kstring.c and turns them into calls to memset()/memcpy()/ +# memmove(). Those symbols do not exist on targets built without a C library, +# so the firmware fails to link (see issue #6128). Keep the loops here. +group_args = {'depend': ['']} +if rtconfig.CROSS_TOOL == 'gcc' and not GetOption('clang-analyzer'): + # Do not pass LOCAL_CFLAGS in --clang-analyzer builds: building.py replaces + # CFLAGS with a list there, and local_group() concatenates it with this + # string, which raises TypeError and stops the static analysis. + group_args['LOCAL_CFLAGS'] = ' -fno-tree-loop-distribute-patterns' + +group = DefineGroup('Libc', src, **group_args) list = os.listdir(cwd) for item in list: |
