Skip to content

Commit

Permalink
Handle cross compile within manylinux (#7150)
Browse files Browse the repository at this point in the history
  • Loading branch information
smoy committed Mar 6, 2024
1 parent e8c8d8a commit 017367d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
14 changes: 13 additions & 1 deletion scripts/mk_unix_dist.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@ def check_build_dir(path):

# Create a build directory using mk_make.py
def mk_build_dir(path):
global LINUX_X64
if not check_build_dir(path) or FORCE_MK:
env = os.environ
opts = [sys.executable, os.path.join('scripts', 'mk_make.py'), "-b", path, "--staticlib"]
if DOTNET_CORE_ENABLED:
opts.append('--dotnet')
Expand All @@ -133,7 +135,17 @@ def mk_build_dir(path):
opts.append('--python')
if mk_util.IS_ARCH_ARM64:
opts.append('--arm64=true')
if subprocess.call(opts) != 0:
if mk_util.IS_ARCH_ARM64 and LINUX_X64:
# we are machine x64 but build against arm64
# so we have to do cross compiling
# the cross compiler is download from ARM GNU
# toolchain
myvar = {
"CC": "aarch64-none-linux-gnu-gcc",
"CXX": "aarch64-none-linux-gnu-g++"
}
env.update(myvar)
if subprocess.call(opts, env=env) != 0:
raise MKException("Failed to generate build directory at '%s'" % path)

# Create build directories
Expand Down
6 changes: 6 additions & 0 deletions scripts/nightly.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,12 @@ stages:
vmImage: "ubuntu-latest"
container: "quay.io/pypa/manylinux2014_x86_64:latest"
steps:
- script: yum install wget
- script: wget -q -O /tmp/arm-toolchain.tar.xz 'https://developer.arm.com/-/media/Files/downloads/gnu/13.2.rel1/binrel/arm-gnu-toolchain-13.2.rel1-x86_64-aarch64-none-linux-gnu.tar.xz?rev=22c39fc25e5541818967b4ff5a09ef3e&hash=E7676169CE35FC2AAECF4C121E426083871CA6E5'
- script: tar xf /tmp/arm-toolchain.tar.xz -C /arm-toolchain/ --strip-components=1
- script: echo '##vso[task.prependpath]/arm-toolchain/bin'
- script: echo $PATH
- script: stat /arm-toolchain/bin/aarch64-none-linux-gnu-gcc
- task: PythonScript@0
displayName: Build
inputs:
Expand Down

0 comments on commit 017367d

Please sign in to comment.