Use Make and CMake to build files for migration to a YiTian ECS instance

Updated at: 2025-03-19 11:55

Make and CMake are used to build CMakeLists.txt and Makefile files. In most cases, the migration content in the CMakeLists.txt and Makefile files is used to specify compilation options, such as data types, processor architectures, and code generation options. This topic describes how to modify CMakeLists.txt and Makefile files when you migrate these files from x86 platforms to YiTian Elastic Compute Service (ECS) instances.

Use C and C++ to add the -mabi=lp64 compilation option

-m64 is a compilation option for x86 platform applications and tells the compiler to compile code as 64-bit. This option is not supported on YiTian instances. You must change -m64 to -mabi=lp64.

Use C and C++ to forcefully add the-fsigned-char compilation option

The default char type is different in the x86 architecture and the ARM architecture. The default char type is signed char in the x86 architecture. The default char type is unsigned char in YiTian instances. When you migrate code from x86 platforms to YiTian instances, you must specify signed char as the char type.

Use C and C++ to specify processor architecture options

When you compile code on YiTian instances, you must change the march mtune mcpu option of the processor architecture to -march=armv8-a+sve2 -mcpu=neoverse-n1. This way, the compiler can generate executable programs based on the micro-architecture and instruction set of YiTian instances to improve performance.

Example

Here is an example on how to modify code when you migrate Make and CMake build files from an x86 platform to a YiTian instance:

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
  • On this page (1)
  • Use C and C++ to add the -mabi=lp64 compilation option
  • Use C and C++ to forcefully add the-fsigned-char compilation option
  • Use C and C++ to specify processor architecture options
  • Example
Feedback
phone Contact Us

Chat now with Alibaba Cloud Customer Service to assist you in finding the right products and services to meet your needs.

alicare alicarealicarealicare