[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,25 @@ 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
    +                # check linux32 is available
    
    96
    +                try:
    
    97
    +                    utils.get_host_tool('linux32')
    
    98
    +                    self._linux32 = True
    
    99
    +                except utils.ProgramNotFoundError:
    
    100
    +                    pass
    
    101
    +            else:
    
    102
    +                raise PlatformError("Configured architecture and host architecture don't match.")
    
    86 103
     
    
    87 104
             return True
    
    88 105
     
    
    ... ... @@ -109,6 +126,7 @@ class Linux(Platform):
    109 126
             kwargs['user_ns_available'] = self._user_ns_available
    
    110 127
             kwargs['die_with_parent_available'] = self._die_with_parent_available
    
    111 128
             kwargs['json_status_available'] = self._json_status_available
    
    129
    +        kwargs['linux32'] = self._linux32
    
    112 130
             return SandboxBwrap(*args, **kwargs)
    
    113 131
     
    
    114 132
         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, env):
    
    62 63
             stdout, stderr = self._get_output()
    
    ... ... @@ -74,8 +75,14 @@ class SandboxBwrap(Sandbox):
    74 75
             mount_map = MountMap(self, flags & SandboxFlags.ROOT_READ_ONLY)
    
    75 76
             root_mount_source = mount_map.get_mount_source('/')
    
    76 77
     
    
    78
    +        # start command with linux32 if needed
    
    79
    +        if self.linux32:
    
    80
    +            bwrap_command = [utils.get_host_tool('linux32')]
    
    81
    +        else:
    
    82
    +            bwrap_command = []
    
    83
    +
    
    77 84
             # Grab the full path of the bwrap binary
    
    78
    -        bwrap_command = [utils.get_host_tool('bwrap')]
    
    85
    +        bwrap_command += [utils.get_host_tool('bwrap')]
    
    79 86
     
    
    80 87
             for k, v in env.items():
    
    81 88
                 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
    ... ... @@ -552,9 +552,22 @@ exported as a comma separated list of selected value strings.
    552 552
     
    
    553 553
     Architecture
    
    554 554
     ~~~~~~~~~~~~
    
    555
    -The ``arch`` option type is special enumeration option which
    
    556
    -defaults to the result of `uname -m`, and does not support
    
    557
    -assigning any default in the project configuration.
    
    555
    +The ``arch`` option type is a special enumeration option which defaults via
    
    556
    +`uname -m` results to the following list.
    
    557
    +
    
    558
    +* AArch32
    
    559
    +* AArch64
    
    560
    +* AArch64-BE
    
    561
    +* Power-ISA-BE
    
    562
    +* Power-ISA-LE
    
    563
    +* Sparc-V9
    
    564
    +* x86-32
    
    565
    +* x86-64
    
    566
    +
    
    567
    +The reason for this, opposed to using just `uname -m`, is that we want an
    
    568
    +OS-independent list, as well as several results mapping to the same architecture
    
    569
    +(e.g. i386, i486 etc. are all x86-32). It does not support assigning any default
    
    570
    +in the project configuration.
    
    558 571
     
    
    559 572
     .. code:: yaml
    
    560 573
     
    
    ... ... @@ -563,16 +576,40 @@ assigning any default in the project configuration.
    563 576
            type: arch
    
    564 577
            description: The machine architecture
    
    565 578
            values:
    
    566
    -       - arm
    
    567
    -       - aarch64
    
    568
    -       - i386
    
    569
    -       - x86_64
    
    579
    +       - AArch32
    
    580
    +       - AArch64
    
    581
    +       - x86-32
    
    582
    +       - x86-64
    
    570 583
     
    
    571 584
     
    
    572 585
     Architecture options can be tested with the same expressions
    
    573 586
     as other Enumeration options.
    
    574 587
     
    
    575 588
     
    
    589
    +.. _project_options_os:
    
    590
    +
    
    591
    +OS
    
    592
    +~~
    
    593
    +
    
    594
    +The ``os`` option type is a special enumeration option, which defaults to the
    
    595
    +results of `uname -s`. It does not support assigning any default in the project
    
    596
    +configuration.
    
    597
    +
    
    598
    +.. code:: yaml
    
    599
    +
    
    600
    +    options:
    
    601
    +      machine_os:
    
    602
    +        type: os
    
    603
    +        description: The machine OS
    
    604
    +        values:
    
    605
    +        - Linux
    
    606
    +        - SunOS
    
    607
    +        - Darwin
    
    608
    +        - FreeBSD
    
    609
    +
    
    610
    +Os options can be tested with the same expressions as other Enumeration options.
    
    611
    +
    
    612
    +
    
    576 613
     .. _project_options_element_mask:
    
    577 614
     
    
    578 615
     Element mask
    



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