Skip to content

Commit a53d99f

Browse files
cabelitosfacebook-github-bot
authored andcommitted
feat: add support for compiling open/r on 64-bit arm linux (#95)
Summary: Description: Prior to this patch it was not possible to run open/r on linux running on ARM due to cmake and openssl being harded to download/compile for the x86_64 arch. In order to prevent such problem this patch actively compiles cmake instead of using pre-compiled binaries and also allows the OpenSSLBuilder to provide the correct build args to openssl, thus not trying to compile or run x86_64 software. Pull Request resolved: facebook/openr#95 Test Plan: * built the project by using ./build/build_openr.sh Reviewed By: wez Differential Revision: D28224684 Pulled By: cooperlees fbshipit-source-id: 9de61dc6d7dcf7116ec5c67f3f165cd4a4bb5e5c
1 parent bab4d83 commit a53d99f

5 files changed

Lines changed: 54 additions & 17 deletions

File tree

build/fbcode_builder/getdeps/builder.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,12 @@ def run_tests(
185185
self._run_cmd(cmd, env=env)
186186

187187

188+
class CMakeBootStrapBuilder(MakeBuilder):
189+
def _build(self, install_dirs, reconfigure):
190+
self._run_cmd(["./bootstrap", "--prefix=" + self.inst_dir])
191+
super(CMakeBootStrapBuilder, self)._build(install_dirs, reconfigure)
192+
193+
188194
class AutoconfBuilder(BuilderBase):
189195
def __init__(self, build_opts, ctx, manifest, src_dir, build_dir, inst_dir, args):
190196
super(AutoconfBuilder, self).__init__(
@@ -868,7 +874,9 @@ def _build(self, install_dirs, reconfigure):
868874
args = ["darwin64-x86_64-cc"]
869875
elif self.build_opts.is_linux():
870876
make = "make"
871-
args = ["linux-x86_64"]
877+
args = (
878+
["linux-x86_64"] if not self.build_opts.is_arm() else ["linux-aarch64"]
879+
)
872880
else:
873881
raise Exception("don't know how to build openssl for %r" % self.ctx)
874882

build/fbcode_builder/getdeps/buildopts.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@ def is_darwin(self):
141141
def is_windows(self):
142142
return self.host_type.is_windows()
143143

144+
def is_arm(self):
145+
return self.host_type.is_arm()
146+
144147
def get_vcvars_path(self):
145148
return self.vcvars_path
146149

build/fbcode_builder/getdeps/manifest.py

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
OpenNSABuilder,
2222
OpenSSLBuilder,
2323
SqliteBuilder,
24+
CMakeBootStrapBuilder,
2425
)
2526
from .expr import parse_expr
2627
from .fetcher import (
@@ -437,21 +438,34 @@ def create_builder( # noqa:C901
437438
build_dir = os.path.join(build_dir, subdir)
438439
print("build_dir is %s" % build_dir) # just to quiet lint
439440

440-
if builder == "make":
441+
if builder == "make" or builder == "cmakebootstrap":
441442
build_args = self.get_section_as_args("make.build_args", ctx)
442443
install_args = self.get_section_as_args("make.install_args", ctx)
443444
test_args = self.get_section_as_args("make.test_args", ctx)
444-
return MakeBuilder(
445-
build_options,
446-
ctx,
447-
self,
448-
src_dir,
449-
None,
450-
inst_dir,
451-
build_args,
452-
install_args,
453-
test_args,
454-
)
445+
if builder == "cmakebootstrap":
446+
return CMakeBootStrapBuilder(
447+
build_options,
448+
ctx,
449+
self,
450+
src_dir,
451+
None,
452+
inst_dir,
453+
build_args,
454+
install_args,
455+
test_args,
456+
)
457+
else:
458+
return MakeBuilder(
459+
build_options,
460+
ctx,
461+
self,
462+
src_dir,
463+
None,
464+
inst_dir,
465+
build_args,
466+
install_args,
467+
test_args,
468+
)
455469

456470
if builder == "autoconf":
457471
args = self.get_section_as_args("autoconf.args", ctx)

build/fbcode_builder/getdeps/platform.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
from __future__ import absolute_import, division, print_function, unicode_literals
77

8+
import platform
89
import re
910
import shlex
1011
import sys
@@ -70,10 +71,18 @@ def __init__(self, ostype=None, distro=None, distrovers=None):
7071
self.distro = distro
7172
# The OS/distro version if known
7273
self.distrovers = distrovers
74+
machine = platform.machine().lower()
75+
if "arm" in machine or "aarch" in machine:
76+
self.isarm = True
77+
else:
78+
self.isarm = False
7379

7480
def is_windows(self):
7581
return self.ostype == "windows"
7682

83+
def is_arm(self):
84+
return self.isarm
85+
7786
def is_darwin(self):
7887
return self.ostype == "darwin"
7988

build/fbcode_builder/manifests/cmake

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ url = https://github.com/Kitware/CMake/releases/download/v3.14.0/cmake-3.14.0-Da
2020
sha256 = a02ad0d5b955dfad54c095bd7e937eafbbbfe8a99860107025cc442290a3e903
2121

2222
[download.os=linux]
23-
url = https://github.com/Kitware/CMake/releases/download/v3.14.0/cmake-3.14.0-Linux-x86_64.tar.gz
24-
sha256 = 91dc9af7345e458eb10c853aa875e591efb7079a045641685ddec8d973c2b2bc
23+
url = https://github.com/Kitware/CMake/releases/download/v3.14.0/cmake-3.14.0.tar.gz
24+
sha256 = aa76ba67b3c2af1946701f847073f4652af5cbd9f141f221c97af99127e75502
2525

2626
[build.os=windows]
2727
builder = nop
@@ -36,5 +36,8 @@ CMake.app/Contents/bin = bin
3636
CMake.app/Contents/share = share
3737

3838
[build.os=linux]
39-
builder = nop
40-
subdir = cmake-3.14.0-Linux-x86_64
39+
builder = cmakebootstrap
40+
subdir = cmake-3.14.0
41+
42+
[make.install_args.os=linux]
43+
install

0 commit comments

Comments
 (0)