Page MenuHomePhabricator

[CMAKE] Prevent linker segfault with recent MinGw version
ClosedPublic

Authored by Fabien on Mar 18 2022, 17:38.

Details

Reviewers
PiRK
Group Reviewers
Restricted Project
Commits
rABC637de1883ade: [CMAKE] Prevent linker segfault with recent MinGw version
Summary

This is a follow-up to D11227. When testing for the linker flags, cmake builds an .exe with dummy content and check it succeeds. This is causing an issue due to the bug https://sourceware.org/bugzilla/show_bug.cgi?id=26588: the test fails because the linker segfaults. Disabling the the section relocation fixes the issue, however the option must only be set for versions on MinGw that support it (otherwise that dumb linker will error out rather than ignoring the unknown option like any other linker would).
This diff tests for the section relocation option support first, then disables it explicitely for each flag under test. This disable has no impact on the final executable and only applies to the dummy code snippet that is used to test for flag support.

This allows also for explicitely setting the --enable-reloc-section if supported, rather than relying on the linker defaults which tend to change over time. Note that this is supposed to be redundant because --dynamicbase implies --enable-reloc-section.

Depends on D11227 for the test plan (otherwise bitcoin-cli won't build at all).

Test Plan

On Debian 10 (old MinGw) and 11 (recent MinGw):

cmake -GNinja .. \
  -DCMAKE_TOOLCHAIN_FILE=../cmake/platforms/Win64.cmake \
  -DBUILD_BITCOIN_SEEDER=OFF
ninja security-check-bitcoin-cli

Run the gitian windows build.

Diff Detail