summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaoul Hidalgo Charman <raoul.hidalgocharman@codethink.co.uk>2018-11-26 17:10:56 +0000
committerRaoul Hidalgo Charman <raoul.hidalgocharman@codethink.co.uk>2018-12-05 10:44:02 +0000
commitb0603fb014c51660860ca452d4fa84c8ce52cac7 (patch)
tree723da967a125fddd29cab5fb1093ee6359aabec1
parente5d8c7d8a0ddbee8ff14b73960809831b9a9fbb2 (diff)
downloadbuildstream-b0603fb014c51660860ca452d4fa84c8ce52cac7.tar.gz
Sandbox: use linux32 for x86-32 builds on x86-64 machines
o _platform/linux.py: Add linux32 flag to send to sandbox bwrap when the build arch is x86-32 and the machines arch is x86-64 or similarly with aarch32 and aarch64. o sandbox/_sandboxbwrap.py: Use flag passed to start bwrap command with linux32 if set.
-rw-r--r--buildstream/_platform/linux.py26
-rw-r--r--buildstream/sandbox/_sandboxbwrap.py9
2 files changed, 30 insertions, 5 deletions
diff --git a/buildstream/_platform/linux.py b/buildstream/_platform/linux.py
index f9033914c..702059a5d 100644
--- a/buildstream/_platform/linux.py
+++ b/buildstream/_platform/linux.py
@@ -59,6 +59,9 @@ class Linux(Platform):
else:
self._user_ns_available = False
+ # Set linux32 option
+ self._linux32 = False
+
def create_sandbox(self, *args, **kwargs):
if not self._local_sandbox_available:
return self._create_dummy_sandbox(*args, **kwargs)
@@ -78,11 +81,25 @@ class Linux(Platform):
# will match the host UID/GID.
return False
- # We can't do builds for another host or architecture
- if config.build_os != self.get_host_os():
+ # We can't do builds for another host or architecture except x86-32 on
+ # x86-64
+ host_os = self.get_host_os()
+ host_arch = self.get_host_arch()
+ if config.build_os != host_os:
raise PlatformError("Configured and host OS don't match.")
- elif config.build_arch != self.get_host_arch():
- raise PlatformError("Configured and host architecture don't match.")
+ elif config.build_arch != host_arch:
+ # We can use linux32 for building 32bit on 64bit machines
+ if (host_os == "Linux" and
+ ((config.build_arch == "x86-32" and host_arch == "x86-64") or
+ (config.build_arch == "aarch32" and host_arch == "aarch64"))):
+ # check linux32 is available
+ try:
+ utils.get_host_tool('linux32')
+ self._linux32 = True
+ except utils.ProgramNotFoundError:
+ pass
+ else:
+ raise PlatformError("Configured architecture and host architecture don't match.")
return True
@@ -109,6 +126,7 @@ class Linux(Platform):
kwargs['user_ns_available'] = self._user_ns_available
kwargs['die_with_parent_available'] = self._die_with_parent_available
kwargs['json_status_available'] = self._json_status_available
+ kwargs['linux32'] = self._linux32
return SandboxBwrap(*args, **kwargs)
def _check_user_ns_available(self):
diff --git a/buildstream/sandbox/_sandboxbwrap.py b/buildstream/sandbox/_sandboxbwrap.py
index f7b11326a..d2abc33d0 100644
--- a/buildstream/sandbox/_sandboxbwrap.py
+++ b/buildstream/sandbox/_sandboxbwrap.py
@@ -57,6 +57,7 @@ class SandboxBwrap(Sandbox):
self.user_ns_available = kwargs['user_ns_available']
self.die_with_parent_available = kwargs['die_with_parent_available']
self.json_status_available = kwargs['json_status_available']
+ self.linux32 = kwargs['linux32']
def _run(self, command, flags, *, cwd, env):
stdout, stderr = self._get_output()
@@ -74,8 +75,14 @@ class SandboxBwrap(Sandbox):
mount_map = MountMap(self, flags & SandboxFlags.ROOT_READ_ONLY)
root_mount_source = mount_map.get_mount_source('/')
+ # start command with linux32 if needed
+ if self.linux32:
+ bwrap_command = [utils.get_host_tool('linux32')]
+ else:
+ bwrap_command = []
+
# Grab the full path of the bwrap binary
- bwrap_command = [utils.get_host_tool('bwrap')]
+ bwrap_command += [utils.get_host_tool('bwrap')]
for k, v in env.items():
bwrap_command += ['--setenv', k, v]