phoenix-rtos-project
phoenix-rtos-project copied to clipboard
Possible problems when changing compiler version to >= 10
If you plan to change your gcc
compiler version to >= 10
then you may experience the following problems:
-
the compiler, in the case of a simple loop writing a constant value to cells of memory may use
memset()
function, which is not defined. For example, such loops:https://github.com/phoenix-rtos/phoenix-rtos-kernel/blob/1c700bbab4851a4d9010ddc4ff1b14fcada19295/lib/printf.c#L114-L115
while (pad_len-- > 0) *out++ = ' ';
https://github.com/phoenix-rtos/phoenix-rtos-kernel/blob/1c700bbab4851a4d9010ddc4ff1b14fcada19295/hal/armv7a/pmap.c#L546-L549
for (i = 0; i < sizeof(pmap_common.asid_map) / sizeof(pmap_common.asid_map[0]); ++i) { pmap_common.asid_map[i] = NULL; pmap_common.asids[i] = i; }
Solution:
- adding the
-ffreestanding
option to theCFLAGS
inMakefile.common
or in theMakefile
in thekernel
andplo
repository.
- adding the
-
since version
10
gcc
, the default option is-fno-common
(9
has-fcommon
set as default) This causes a problem with linking thelibjffs2
library. This is caused by the definition of theinit_user_ns
variable asglobal
in the header file: https://github.com/phoenix-rtos/phoenix-rtos-filesystems/blob/8af595a6b37129b4a6cb7e0cb93705c4d6b3476b/jffs2/phoenix-rtos.h#L139struct user_namespace init_user_ns;
Solution:
- define the
init_user_ns
variable in one of the source files, and in the header file declare this variable.asextern
. - compile the source files that make up this library with the
-fcommon
option.
- define the
Thanks for bringing it to our attention.
Regarding the (1):
- IMHO plo / kernel should be compiled with
-ffreestanding
as they are being run in C freestanding environment - adding the
-ffreestanding
option is not enough for gcc to avoidmemset
problems (see my comment here: https://github.com/phoenix-rtos/plo/pull/167#issuecomment-1072521885) - it explicitly requiresmem*
functions to be implemented even in freestanding environment
- Fixed as of https://github.com/phoenix-rtos/phoenix-rtos-filesystems/pull/125 and https://github.com/phoenix-rtos/phoenix-rtos-build/pull/181