Modify CFLAGS compilation options in CMakeLists.txt and Makefile files to migrate builds from x86 to YiTian ECS instances.
Add the -mabi=lp64 option in C and C++
The x86 option -m64 compiles code as 64-bit but is not supported on YiTian instances. Replace -m64 with -mabi=lp64.
Use C and C++ to forcefully add the-fsigned-char compilation option
On x86, the default char type is signed char. On YiTian instances, the default is unsigned char. Add -fsigned-char to enforce signed char during migration.
Use C and C++ to specify processor architecture options
Replace the x86 march mtune mcpu options with -march=armv8-a+sve2 -mcpu=neoverse-n1 to generate optimized binaries for the YiTian instruction set.
Example
CFLAGS before and after migration from x86 to YiTian:
Code before modification:
CFLAGS=-g3 -O2 -DNDEBUG -m64 -Wall -march=corei7
Code after modification:
# GNU Compiler Collection (GCC) 10 (suitable for Neoverse N1)
CFLAGS=-g3 -O2 -DNDEBUG -mabi=lp64 -Wall -march=armv8-a+crc+sve2 -mcpu=neoverse-n1 -fsigned-char
# GCC 11 (suitable for Neoverse N2)
CFLAGS=-g3 -O2 -DNDEBUG -mabi=lp64 -Wall -march=armv8-a+crc+sve2 -mcpu=neoverse-n2 -fsigned-char