SATURDAY, SEPTEMBER 5, 2026
gcc/testsuite
Darwin LTO test now uses -shared option.
Darwin LTO test now includes -shared option for correct linking.
The Darwin LTO test suite previously failed to link due to missing symbols. This commit adds the necessary -shared option to the test case’s linker flags, resolving the issue and ensuring proper symbol resolution during the LTO process on Darwin systems.
In Details
The dg-extra-ld-options directive in GCC's test suite is not cumulative. For Darwin, the LTO test pr64415_0.c requires the -shared flag to avoid a missing _main symbol. This change ensures the flag is correctly applied in the test's environment.
For Context
- LTO
- Link-Time Optimization. A build process optimization where the compiler performs optimizations across multiple source files after they have been compiled to intermediate object files but before the final executable is linked. This allows for more aggressive optimizations than whole-program optimization at compile time.
- Darwin
- The name of Apple's Unix-like operating system, on which macOS, iOS, and other Apple platforms are based. GCC's Darwin support includes specific build and linking behaviors.
- dg-extra-ld-options
- A GCC test suite directive that adds extra options to the linker command line for a specific test case. These options are typically used to configure linking behavior for that particular test.
- _main symbol
- In C and C++,
_main(ormain) is the entry point of the program. Its absence typically indicates a linking error, often occurring when a program intended to be linked as a shared library is linked as an executable.