]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
buildman: Support disabling LTO
authorSimon Glass <sjg@chromium.org>
Tue, 21 Feb 2023 19:40:28 +0000 (12:40 -0700)
committerSimon Glass <sjg@chromium.org>
Wed, 8 Mar 2023 19:38:48 +0000 (11:38 -0800)
This cuts down build performance considerably and is not always needed,
when checking for build errors, etc.

Add a flag to disable it.

Signed-off-by: Simon Glass <sjg@chromium.org>
tools/buildman/builder.py
tools/buildman/builderthread.py
tools/buildman/buildman.rst
tools/buildman/cmdline.py
tools/buildman/control.py
tools/buildman/func_test.py

index c2a69027f885b74a82d19644fbf0b59f07eebef9..107086cc0e5ad1de60f51796526cb4398b834ab5 100644 (file)
@@ -194,6 +194,7 @@ class Builder:
         work_in_output: Use the output directory as the work directory and
             don't write to a separate output directory.
         thread_exceptions: List of exceptions raised by thread jobs
+        no_lto (bool): True to set the NO_LTO flag when building
 
     Private members:
         _base_board_dict: Last-summarised Dict of boards
@@ -253,7 +254,7 @@ class Builder:
                  config_only=False, squash_config_y=False,
                  warnings_as_errors=False, work_in_output=False,
                  test_thread_exceptions=False, adjust_cfg=None,
-                 allow_missing=False):
+                 allow_missing=False, no_lto=False):
         """Create a new Builder object
 
         Args:
@@ -292,6 +293,7 @@ class Builder:
                     C=val to set the value of C (val must have quotes if C is
                         a string Kconfig
             allow_missing: Run build with BINMAN_ALLOW_MISSING=1
+            no_lto (bool): True to set the NO_LTO flag when building
 
         """
         self.toolchains = toolchains
@@ -331,6 +333,7 @@ class Builder:
         self.adjust_cfg = adjust_cfg
         self.allow_missing = allow_missing
         self._ide = False
+        self.no_lto = no_lto
 
         if not self.squash_config_y:
             self.config_filenames += EXTRA_CONFIG_FILENAMES
index 7ba9a856dd58a9e3d1d0fc084c8efd6433277e75..dae3d4ab9ff676159041ff3be72ff40597679c99 100644 (file)
@@ -255,6 +255,8 @@ class BuilderThread(threading.Thread):
                     args.append('KCFLAGS=-Werror')
                 if self.builder.allow_missing:
                     args.append('BINMAN_ALLOW_MISSING=1')
+                if self.builder.no_lto:
+                    args.append('NO_LTO=1')
                 config_args = ['%s_defconfig' % brd.target]
                 config_out = ''
                 args.extend(self.builder.toolchains.GetMakeArguments(brd))
index 11c721417912e8c3b6957abfeef6c36bea89fe54..800b83a89de0675eca0c491131081c809601f0ba 100644 (file)
@@ -1123,6 +1123,20 @@ toolchain. For example:
    buildman -O clang-7 --board sandbox
 
 
+Building without LTO
+--------------------
+
+Link-time optimisation (LTO) is designed to reduce code size by globally
+optimising the U-Boot build. Unfortunately this can dramatically slow down
+builds. This is particularly noticeable when running a lot of builds.
+
+Use the -L (--no-lto) flag to disable LTO.
+
+.. code-block:: bash
+
+   buildman -L --board sandbox
+
+
 Doing a simple build
 --------------------
 
index c485994e9fe53fa864bee8c166733347c4e210fc..409013671be4fe057905e45e41d41e180e75f8a7 100644 (file)
@@ -71,6 +71,8 @@ def ParseArgs():
           default=False, help="Don't convert y to 1 in configs")
     parser.add_option('-l', '--list-error-boards', action='store_true',
           default=False, help='Show a list of boards next to each error/warning')
+    parser.add_option('-L', '--no-lto', action='store_true',
+          default=False, help='Disable Link-time Optimisation (LTO) for builds')
     parser.add_option('--list-tool-chains', action='store_true', default=False,
           help='List available tool chains (use -v to see probing detail)')
     parser.add_option('-m', '--mrproper', action='store_true',
index 87e7d0e20121338bdf96ebe93c3fb58215b56ee5..13a462ae5954020b8953fe81aec0550c74e58eb7 100644 (file)
@@ -351,7 +351,7 @@ def DoBuildman(options, args, toolchains=None, make_func=None, brds=None,
             work_in_output=options.work_in_output,
             test_thread_exceptions=test_thread_exceptions,
             adjust_cfg=adjust_cfg,
-            allow_missing=allow_missing)
+            allow_missing=allow_missing, no_lto=options.no_lto)
     builder.force_config_on_failure = not options.quick
     if make_func:
         builder.do_make = make_func
index 799c609446e5850737b2e529986997b19e5303c2..6d1557293f03740848fb5df3745488d942ea65a2 100644 (file)
@@ -724,15 +724,32 @@ Some images are invalid'''
         self.assertEqual(False,
                          control.get_allow_missing(False, True, 2, True))
 
-    def testCmdFile(self):
-        """Test that the -cmd-out file is produced"""
-        self._RunControl('-o', self._output_dir)
+    def check_command(self, *extra_args):
+        """Run a command with the extra arguments and return the commands used
+
+        Args:
+            extra_args (list of str): List of extra arguments
+
+        Returns:
+            list of str: Lines returned in the out-cmd file
+        """
+        self._RunControl('-o', self._output_dir, *extra_args)
         board0_dir = os.path.join(self._output_dir, 'current', 'board0')
         self.assertTrue(os.path.exists(os.path.join(board0_dir, 'done')))
         cmd_fname = os.path.join(board0_dir, 'out-cmd')
         self.assertTrue(os.path.exists(cmd_fname))
         data = tools.read_file(cmd_fname)
-        lines = data.splitlines()
+        return data.splitlines()
+
+    def testCmdFile(self):
+        """Test that the -cmd-out file is produced"""
+        lines = self.check_command()
         self.assertEqual(2, len(lines))
         self.assertRegex(lines[0], b'make O=/.*board0_defconfig')
         self.assertRegex(lines[0], b'make O=/.*-s.*')
+
+    def testNoLto(self):
+        """Test that the --no-lto flag works"""
+        lines = self.check_command('-L')
+        self.assertIn(b'NO_LTO=1', lines[0])
+