Allow users to overwrite ld with environment variable in linker optimization script (#137331)

This should help in the case of cross compilation.

xref: https://github.com/conda-forge/pytorch-cpu-feedstock/pull/261

Fixes #ISSUE_NUMBER

Pull Request resolved: https://github.com/pytorch/pytorch/pull/137331
Approved by: https://github.com/isuruf, https://github.com/seemethere
This commit is contained in:
Mark Harfouche 2024-11-26 22:54:21 +00:00 committed by PyTorch MergeBot
parent 23793cf93d
commit 43afaa4aac

View File

@ -1,3 +1,4 @@
import os
import subprocess
@ -9,8 +10,8 @@ def gen_linker_script(
prioritized_text = [
line.replace("\n", "") for line in prioritized_text if line != "\n"
]
linker_script_lines = subprocess.check_output(["ld", "-verbose"], text=True).split(
ld = os.environ.get("LD", "ld")
linker_script_lines = subprocess.check_output([ld, "-verbose"], text=True).split(
"\n"
)