GNU Compiler Collection (GCC) 10 and Glibc 2.28 incorporate important changes compared with GCC 8 and Glibc 2.32. The changes affect the forward or backward compatibility of GCC 10 and Glibc 2.28. This topic describes the compatibility between the GCC versions and between the Glibc versions. This topic also describes how to mitigate the impacts.
Background information
The compatibility between the GCC or Glibc versions can be classified into Application Binary Interface (ABI) compatibility and API compatibility. The ABI compatibility between the GCC or Glibc versions refers to the compatibility in which binaries can run without the need for code recompilation. The API compatibility between the GCC or Glibc versions refers to the compatibility in which application code can run unchanged without the need for code recompilation.
ABI compatibility between the GCC or Glibc versions
In most cases, the GCC compiler does not involve ABI compatibility. However, operating system distributions, such as Alibaba Cloud Linux and CentOS, include the standard C++ library (libstdc++) in GCC packages. The impacts of GCC on the ABI compatibility with applications refer to the impacts of the libstdc++ library on the ABI compatibility with applications.
Forward compatibility:
libstdc++andGlibcare highly forward-compatible. Most of the components that are compiled onGCC 8andGlibc 2.28on CentOS can run inGCC 10andGlibc 2.32environments, respectively, on Alibaba Cloud Linux 3 without the need for code compilation.Backward compatibility:
libstdc++andGlibcare not backward-compatible. The components that are compiled onGCC 10andGlibc 2.32on Alibaba Cloud Linux 3 cannot run unchanged inGCC 8andGlibc 2.32environments, respectively, on CentOS 8.
API compatibility between the GCC or Glibc versions
GCC and Glibc are core toolchain components of operating systems and are highly backward-compatible and forward-compatible with APIs. However, during version updates, changes that affect API compatibility may be made to GCC and Glibc.
GCC
Example of changes that affect forward API compatibility: The compilation parameters that are used in early
GCCversions are deprecated in later GCC versions. As a result, you cannot compile applications that use the compilation parameters by using laterGCCversions. To use later GCC versions to compile the applications, you must modify the compilation parameters for the applications.Example of changes that affect backward API compatibility: New compilation parameters are introduced in later
GCCversions. As a result, you cannot compile applications that use the new compilation parameters by using earlyGCCversions. To use early GCC versions to compile the applications, you must modify the compilation parameters for the applications.
Glibc
Example of changes that affect forward API compatibility: Functions or header files that are used in early
Glibcversions are deprecated in later Glibc versions. As a result, you cannot compile applications that use the functions or header files by using laterGlibcversions. To use later Glibc versions to compile the applications, you must modify the application code.Example of changes that affect backward API compatibility: New functions and implementations are introduced in later
Glibcversions. As a result, you cannot compile applications that use the new functions by using earlyGlibcversions. To use early Glibc versions to compile the applications, you must modify the application code.
Changes in Glibc 2.32 and impacts of the changes
The following table describes the important changes in Glibc 2.28 compared with Glibc 2.32, the impacts of the changes, and how to mitigate the impacts.
Type | Change | Compatibility type | Impact | How to mitigate the impacts |
| The | API | If the | Use the |
The | API | If the | Use the | |
The | API | The | Use the | |
The | API | The | Use the | |
The | API | If an application runs in | Add the | |
| The | API | The code that references the header file cannot be compiled. | Delete the reference to the |
The | API | The | Access the | |
| The | ABI | Applications that are complied on | The kernel and |
API | An error occurs if you use Glibc 2.32 to compile applications that use the sstk function. | |||
| The | ABI | Binaries that are compiled on Glibc 2.28 remain ABI-compatible with | No solution is required. |
API | When you use Glibc 2.32 to compile applications that use the functions or macro, a | Modify the source code and use the | ||
The | ABI | Binaries that are compiled on Glibc 2.28 remain ABI-compatible with | No solution is required. | |
API | When you use Glibc 2.32 to compile applications that use the functions, a | Modify the source code and use the | ||
| The | ABI | Binaries that are compiled on Glibc 2.28 remain ABI-compatible with | No solution is required. |
API | When you use Glibc 2.32 to compile applications that use the functions, a | Use the | ||
| The simulated implementation of the | API | If the kernel does not support the | If the kernel does not support the |
| The | API | Using weak references to | Use the |
|
| API | Dependencies must be changed for all code that references |
|
Changes in GCC 10 and impacts of the changes
The following table describes the important changes in GCC 10 compared with GCC 8, the impacts of the changes, and how to mitigate the impacts.
Type | Change | Compatibility type | Impact | How to mitigate the impacts |
|
| API | Multiple uninitialized duplicate global variables can be defined in the The variables are merged and stored in the |
|
| If a parameter does not match an argument, | API | A compilation error occurs if parameters do not match arguments. |
|
|
| API | Errors occur while compiling applications. | Add required header files to the applications based on the error messages. |
Enumeration check |
| API | Errors occur while compiling applications. | Use enumerations in the correct manner. |
Large System Extensions (LSE) | The | API | This option is used to detect the support of | Use this option in the correct manner. For information about other |
Changes to the warning options of GCC 10
The following table describes the changes to the warning options of GCC 10 compared with GCC 8.
Compilation warnings do not directly affect API compatibility. If compilation warnings appear when you migrate applications to Alibaba Cloud Linux 3, we recommend that you modify the application code to suppress the warnings.
Option | Compatibility type | Change type | Description |
| API | Addition | Warns that taking the address of a |
| API | Addition | Warns about accesses to elements of zero-length array members that may overlap other members of the same object. This option is enabled by |
| API | Enhancement | Warns about out-of-bounds accesses to member arrays and accesses to elements of zero-length arrays. |
| API | Enhancement | Warns about declarations that use the alias and similar attributes whose target is incompatible with the type of the alias. |
| API | Enhancement | Warns about calls to formatted input/output functions that may overflow the destination buffer. This warning is triggered when certain or likely buffer overflow in calls to formatted output functions is detected. |
| API | Addition | Warns when particular function attributes are missing in the aliases but not in their target. |
| API | Enhancement | |
| API | Enhancement |
|
| API | Enhancement | Warns about instances of return statements returning addresses of automatic variables. |
| API | Enhancement | Warns about overlapping accesses to dynamically allocated objects. |
| API | Enhancement |
|
References
For information about other changes in the GCC and Glibc versions, see the Release notes for Glibc and GCC.