Skip to content

Commit

Permalink
HACKs print linker info
Browse files Browse the repository at this point in the history
I think we're running an old buggy linker in GitHub Actions.
Let's print the linker info to help debug this.
  • Loading branch information
indygreg committed Feb 20, 2024
1 parent 2e11c03 commit 39a8d1f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/apple.yml
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,12 @@ jobs:

- name: Build
run: |
# Our LLVM toolchain doesn't provide a linker. And the /usr/bin/ld on macOS
# runners may contain a bug where weak references aren't preserved during LTO.
# So force the use of a modern LLVM linker.
brew install llvm@16
export FORCE_LINKER=$(brew --prefix llvm@16)/bin/lld
if [ "${{ matrix.build.target_triple }}" = "aarch64-apple-darwin" ]; then
export APPLE_SDK_PATH=/Applications/Xcode_15.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk
elif [ "${{ matrix.build.target_triple }}" = "x86_64-apple-darwin" ]; then
Expand Down
9 changes: 9 additions & 0 deletions cpython-unix/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,15 @@ def add_target_env(env, build_platform, target_triple, build_env):
extra_host_cflags.extend(["-isysroot", host_sdk_path])
extra_host_ldflags.extend(["-isysroot", host_sdk_path])

# Our custom LLVM toolchain doesn't include an lld. Our clang driver
# will pick up /usr/bin/ld by default. On some macOS, /usr/bin/ld is
# an older version of LLVM and won't preserve weak references when doing
# LTO.
if "FORCE_LINKER" in os.environ:
flag = "-fuse-ld=%s" % os.environ["FORCE_LINKER"]
extra_host_ldflags.append(flag)
extra_target_ldflags.append(flag)

env["EXTRA_HOST_CFLAGS"] = " ".join(extra_host_cflags)
env["EXTRA_HOST_LDFLAGS"] = " ".join(extra_host_ldflags)
env["EXTRA_TARGET_CFLAGS"] = " ".join(extra_target_cflags)
Expand Down
2 changes: 2 additions & 0 deletions cpython-unix/targets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ aarch64-apple-darwin:
- '-Wno-undef-prefix'
- '-fvisibility=hidden'
target_ldflags:
- '-v'
- '-arch'
- 'arm64'
- '-mmacosx-version-min=11.0'
Expand Down Expand Up @@ -569,6 +570,7 @@ x86_64-apple-darwin:
- '-Wno-undef-prefix'
- '-fvisibility=hidden'
target_ldflags:
- '-v'
- '-arch'
- 'x86_64'
- '-mmacosx-version-min=10.9'
Expand Down

0 comments on commit 39a8d1f

Please sign in to comment.