[Notes] [Git][BuildStream/buildstream][raoul/775-execution-environment-reqs] 4 commits: Sandbox: use linux32 for x86-32 builds on x86-64 machines



Title: GitLab

Raoul Hidalgo Charman pushed to branch raoul/775-execution-environment-reqs at BuildStream / buildstream

Commits:

4 changed files:

Changes:

  • buildstream/_platform/linux.py
    ... ... @@ -59,6 +59,9 @@ class Linux(Platform):
    59 59
             else:
    
    60 60
                 self._user_ns_available = False
    
    61 61
     
    
    62
    +        # Set linux32 option
    
    63
    +        self._linux32 = False
    
    64
    +
    
    62 65
         def create_sandbox(self, *args, **kwargs):
    
    63 66
             if not self._local_sandbox_available:
    
    64 67
                 return self._create_dummy_sandbox(*args, **kwargs)
    
    ... ... @@ -78,11 +81,20 @@ class Linux(Platform):
    78 81
                 # will match the host UID/GID.
    
    79 82
                 return False
    
    80 83
     
    
    81
    -        # We can't do builds for another host or architecture
    
    82
    -        if config.build_os != self.get_host_os():
    
    84
    +        # We can't do builds for another host or architecture except x86-32 on
    
    85
    +        # x86-64
    
    86
    +        host_os = self.get_host_os()
    
    87
    +        host_arch = self.get_host_arch()
    
    88
    +        if config.build_os != host_os:
    
    83 89
                 raise PlatformError("Configured and host OS don't match.")
    
    84
    -        elif config.build_arch != self.get_host_arch():
    
    85
    -            raise PlatformError("Configured and host architecture don't match.")
    
    90
    +        elif config.build_arch != host_arch:
    
    91
    +            # We can use linux32 for building 32bit on 64bit machines
    
    92
    +            if (host_os == "Linux" and
    
    93
    +                ((config.build_arch == "x86-32" and host_arch == "x86-64") or
    
    94
    +                 (config.build_arch == "AArch32" and host_arch == "AArch64"))):
    
    95
    +                self._linux32 = True
    
    96
    +            else:
    
    97
    +                raise PlatformError("Configured architecture and host architecture don't match.")
    
    86 98
     
    
    87 99
             return True
    
    88 100
     
    
    ... ... @@ -109,6 +121,7 @@ class Linux(Platform):
    109 121
             kwargs['user_ns_available'] = self._user_ns_available
    
    110 122
             kwargs['die_with_parent_available'] = self._die_with_parent_available
    
    111 123
             kwargs['json_status_available'] = self._json_status_available
    
    124
    +        kwargs['linux32'] = self._linux32
    
    112 125
             return SandboxBwrap(*args, **kwargs)
    
    113 126
     
    
    114 127
         def _check_user_ns_available(self):
    

  • buildstream/sandbox/_sandboxbwrap.py
    ... ... @@ -57,6 +57,7 @@ class SandboxBwrap(Sandbox):
    57 57
             self.user_ns_available = kwargs['user_ns_available']
    
    58 58
             self.die_with_parent_available = kwargs['die_with_parent_available']
    
    59 59
             self.json_status_available = kwargs['json_status_available']
    
    60
    +        self.linux32 = kwargs['linux32']
    
    60 61
     
    
    61 62
         def run(self, command, flags, *, cwd=None, env=None):
    
    62 63
             stdout, stderr = self._get_output()
    
    ... ... @@ -84,8 +85,14 @@ class SandboxBwrap(Sandbox):
    84 85
             mount_map = MountMap(self, flags & SandboxFlags.ROOT_READ_ONLY)
    
    85 86
             root_mount_source = mount_map.get_mount_source('/')
    
    86 87
     
    
    88
    +        # start command with linux32 if needed
    
    89
    +        if self.linux32:
    
    90
    +            bwrap_command = [utils.get_host_tool('linux32')]
    
    91
    +        else:
    
    92
    +            bwrap_command = []
    
    93
    +
    
    87 94
             # Grab the full path of the bwrap binary
    
    88
    -        bwrap_command = [utils.get_host_tool('bwrap')]
    
    95
    +        bwrap_command += [utils.get_host_tool('bwrap')]
    
    89 96
     
    
    90 97
             for k, v in env.items():
    
    91 98
                 bwrap_command += ['--setenv', k, v]
    

  • doc/source/format_declaring.rst
    ... ... @@ -294,8 +294,10 @@ can be viewed in detail in the :ref:`builtin public data <public_builtin>` secti
    294 294
     Sandbox
    
    295 295
     ~~~~~~~
    
    296 296
     Configuration for the build sandbox (other than :ref:`environment variables <format_environment>`)
    
    297
    -can be placed in the ``sandbox`` configuration. At present, only the
    
    298
    -UID and GID used by the user in the group can be specified.
    
    297
    +can be placed in the ``sandbox`` configuration. The UID and GID used by the user
    
    298
    +in the group can be specified, as well as the desired OS and machine
    
    299
    +architecture. Possible machine architecture follow the same list as specified in
    
    300
    +the :ref:`architecture option <project_options_arch>`.
    
    299 301
     
    
    300 302
     .. code:: yaml
    
    301 303
     
    
    ... ... @@ -311,6 +313,23 @@ you can supply a different uid or gid for the sandbox. Only
    311 313
     bwrap-style sandboxes support custom user IDs at the moment, and hence
    
    312 314
     this will only work on Linux host platforms.
    
    313 315
     
    
    316
    +.. code:: yaml
    
    317
    +
    
    318
    +   # Specify build OS and architecture
    
    319
    +   sandbox:
    
    320
    +     build-os: AIX
    
    321
    +     build-arch: Power-ISA-BE
    
    322
    +
    
    323
    +When building locally, if these don't match the host machine then generally the
    
    324
    +build will fail. The exception is when the OS is Linux and the architecture
    
    325
    +specifies an ``x86-32`` build on an ``x86-64`` machine, in which case the
    
    326
    +``linux32`` command is prepended to the bubblewrap command.
    
    327
    +
    
    328
    +When building remotely, the OS and architecture are added to the ``Platform``
    
    329
    +field in the ``Command`` uploaded. Whether this actually results in a building
    
    330
    +the element for the desired OS and architecture is dependent on the server
    
    331
    +having implemented these options the same as buildstream.
    
    332
    +
    
    314 333
     .. note::
    
    315 334
     
    
    316 335
        The ``sandbox`` configuration is available since :ref:`format version 6 <project_format_version>`
    

  • doc/source/format_project.rst
    ... ... @@ -538,9 +538,22 @@ exported as a comma separated list of selected value strings.
    538 538
     
    
    539 539
     Architecture
    
    540 540
     ~~~~~~~~~~~~
    
    541
    -The ``arch`` option type is special enumeration option which
    
    542
    -defaults to the result of `uname -m`, and does not support
    
    543
    -assigning any default in the project configuration.
    
    541
    +The ``arch`` option type is a special enumeration option which defaults via
    
    542
    +`uname -m` results to the following list.
    
    543
    +
    
    544
    +* AArch32
    
    545
    +* AArch64
    
    546
    +* AArch64-BE
    
    547
    +* Power-ISA-BE
    
    548
    +* Power-ISA-LE
    
    549
    +* Sparc-V9
    
    550
    +* x86-32
    
    551
    +* x86-64
    
    552
    +
    
    553
    +The reason for this, opposed to using just `uname -m`, is that we want an
    
    554
    +OS-independent list, as well as several results mapping to the same architecture
    
    555
    +(e.g. i386, i486 etc. are all x86-32). It does not support assigning any default
    
    556
    +in the project configuration.
    
    544 557
     
    
    545 558
     .. code:: yaml
    
    546 559
     
    
    ... ... @@ -549,16 +562,40 @@ assigning any default in the project configuration.
    549 562
            type: arch
    
    550 563
            description: The machine architecture
    
    551 564
            values:
    
    552
    -       - arm
    
    553
    -       - aarch64
    
    554
    -       - i386
    
    555
    -       - x86_64
    
    565
    +       - AArch32
    
    566
    +       - AArch64
    
    567
    +       - x86-32
    
    568
    +       - x86-64
    
    556 569
     
    
    557 570
     
    
    558 571
     Architecture options can be tested with the same expressions
    
    559 572
     as other Enumeration options.
    
    560 573
     
    
    561 574
     
    
    575
    +.. _project_options_os:
    
    576
    +
    
    577
    +OS
    
    578
    +~~
    
    579
    +
    
    580
    +The ``os`` option type is a special enumeration option, which defaults to the
    
    581
    +results of `uname -s`. It does not support assigning any default in the project
    
    582
    +configuration.
    
    583
    +
    
    584
    +.. code:: yaml
    
    585
    +
    
    586
    +    options:
    
    587
    +      machine_os:
    
    588
    +        type: os
    
    589
    +        description: The machine OS
    
    590
    +        values:
    
    591
    +        - Linux
    
    592
    +        - SunOS
    
    593
    +        - Darwin
    
    594
    +        - FreeBSD
    
    595
    +
    
    596
    +Os options can be tested with the same expressions as other Enumeration options.
    
    597
    +
    
    598
    +
    
    562 599
     .. _project_options_element_mask:
    
    563 600
     
    
    564 601
     Element mask
    



  • [Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]