Merge pull request #66246 from apple/maxd/5.8-cmake-dispatch-fix
[5.8] CMake: fix missing `SWIFT_CONCURRENCY_GLOBAL_EXECUTOR`
Explanation: Resolves issues with static linking on Linux
Risk: Medium, affects Linux builds and top-level CMake declarations.
Original PRs: https://github.com/apple/swift/pull/65795 and https://github.com/apple/swift/pull/64312 for `main`, https://github.com/apple/swift/pull/65824 and https://github.com/apple/swift/pull/64633 for `release/5.9`
Reviewed by: @al45tair @drexin @etcwilde
Resolves: some of the issues reported in https://github.com/apple/swift/issues/65097, also resolves https://github.com/apple/swift/issues/58380
Tests: Added in https://github.com/apple/swift-integration-tests/pull/118
`SWIFT_CONCURRENCY_GLOBAL_EXECUTOR` is defined in `stdlib/cmake/modules/StdlibOptions.cmake`, which is not included during the first pass of evaluation of the root `CMakeLists.txt`. It is available on subsequent evaluations after the value is stored in CMake cache. This led to subtle bugs, where `usr/lib/swift_static/linux/static-stdlib-args.lnk` didn't contain certain flags on clean toolchain builds, but did contain them in incremental builds.
Not having these autolinking flags in toolchain builds leads to errors when statically linking executables on Linux.
Additionally, since our trivial lit tests previously didn't link Dispatch statically, they didn't expose a bug where `%import-static-libdispatch` substitution had a missing value. To fix that I had to update `lit.cfg` and clean up some of the related path computations to infer a correct substitution value.