[CMAKE] Fix name collisions causing potential infinite recursion
Summary:
D11229 introduced a new internal function named _check_linker_flag, and this caused several issues under some specific circumstances. We had 2 issues here:
- CMake introduced its own check_linker_flag method starting with version 3.18. This means we are overriding the built-in method when a recent version is used.
- CMake defines internal helpers for functions and macros with the same name as the callsite with a leading underscore. So our _check_linker_flags function was conflicting with the internal variant created for our function, and which in turns overrides the built-in one.
As a consequence CMake get confused when using asan and ubsan: when using these specific sanitizers, the check_cxx_source_compiles is called first, which in turn loads and calls the built-in _check_linker_flag thanks to CMP0056 policy, and only after it loads our AddCompilerFlags.cmake module that redefines _check_linker_flag. This causes CMake to enter an infinite recursion loop upon the next check_linker_flag call.
Fortunately the fix is simpler than the issue, and just renaming both the functions with some boring names is enough as the logic was correct in the first place.
Test Plan:
Run ASAN and UBSAN and check CMake succeeds.
Check git grep check_linker_flag returns no occurrence anymore.
Reviewers: #bitcoin_abc, PiRK
Reviewed By: #bitcoin_abc, PiRK
Differential Revision: https://reviews.bitcoinabc.org/D11234