[Lldb-commits] [lldb] r348511 - [build.py] Embed the output file name in generated object file names.

Zachary Turner via lldb-commits lldb-commits at lists.llvm.org
Thu Dec 6 10:39:58 PST 2018


Author: zturner
Date: Thu Dec  6 10:39:58 2018
New Revision: 348511

URL: http://llvm.org/viewvc/llvm-project?rev=348511&view=rev
Log:
[build.py] Embed the output file name in generated object file names.

In compile-and-link mode, the user doesn't specify the name of the
object files to generate, because there could be multiple inputs
on a single command line and this would be hard to specify.  So the
script just tries to be smart and figure out the best object file
names.  However, if two build scripts are running in parallel and
using the same source files as input, they would previously race
to write the same object files, since the computed name only considered
the source file names when computing the object file names.

With this patch, we also consider the final executable name.  In a
way, this "namespaces" the generated object files so that as long
as the final executable file names don't clash, the intermediate
object file names won't clash either.

Modified:
    lldb/trunk/lit/BuildScript/modes.test
    lldb/trunk/lit/BuildScript/toolchain-clang-cl.test
    lldb/trunk/lit/BuildScript/toolchain-msvc.test
    lldb/trunk/lit/helper/build.py

Modified: lldb/trunk/lit/BuildScript/modes.test
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/BuildScript/modes.test?rev=348511&r1=348510&r2=348511&view=diff
==============================================================================
--- lldb/trunk/lit/BuildScript/modes.test (original)
+++ lldb/trunk/lit/BuildScript/modes.test Thu Dec  6 10:39:58 2018
@@ -29,9 +29,9 @@ LINK: linking foobar.obj -> foo.exe
 
 LINK-MULTI: linking foo.obj+bar.obj -> foobar.exe
 
-BOTH: compiling foobar.c -> foobar.obj
-BOTH: linking foobar.obj -> foobar.exe
+BOTH: compiling foobar.c -> foobar.exe-foobar.obj
+BOTH: linking foobar.exe-foobar.obj -> foobar.exe
 
-BOTH-MULTI: compiling foo.c -> foo.obj
-BOTH-MULTI: compiling bar.c -> bar.obj
-BOTH-MULTI: linking foo.obj+bar.obj -> foobar.exe
+BOTH-MULTI: compiling foo.c -> foobar.exe-foo.obj
+BOTH-MULTI: compiling bar.c -> foobar.exe-bar.obj
+BOTH-MULTI: linking foobar.exe-foo.obj+foobar.exe-bar.obj -> foobar.exe

Modified: lldb/trunk/lit/BuildScript/toolchain-clang-cl.test
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/BuildScript/toolchain-clang-cl.test?rev=348511&r1=348510&r2=348511&view=diff
==============================================================================
--- lldb/trunk/lit/BuildScript/toolchain-clang-cl.test (original)
+++ lldb/trunk/lit/BuildScript/toolchain-clang-cl.test Thu Dec  6 10:39:58 2018
@@ -19,12 +19,12 @@ CHECK-32:   Verbose: True
 CHECK-32:   Dryrun: True
 CHECK-32:   Inputs: foobar.c
 CHECK-32: Cleaning {{.*}}toolchain-clang-cl.test.tmp{{.}}foobar.ilk
-CHECK-32: Cleaning {{.*}}toolchain-clang-cl.test.tmp{{.}}foobar.obj
+CHECK-32: Cleaning {{.*}}toolchain-clang-cl.test.tmp{{.}}foo.exe-foobar.obj
 CHECK-32: Cleaning {{.*}}toolchain-clang-cl.test.tmp{{.}}foo.pdb
 CHECK-32: Cleaning {{.*}}toolchain-clang-cl.test.tmp{{.}}foo.exe
-CHECK-32: compiling foobar.c -> foobar.obj
+CHECK-32: compiling foobar.c -> foo.exe-foobar.obj
 CHECK-32: {{.*}}clang-cl{{(.exe)?}} -m32
-CHECK-32: linking foobar.obj -> foo.exe
+CHECK-32: linking foo.exe-foobar.obj -> foo.exe
 CHECK-32: {{.*}}lld-link
 
 CHECK-64: Script Arguments:
@@ -40,10 +40,10 @@ CHECK-64:   Verbose: True
 CHECK-64:   Dryrun: True
 CHECK-64:   Inputs: foobar.c
 CHECK-64: Cleaning {{.*}}toolchain-clang-cl.test.tmp{{.}}foobar.ilk
-CHECK-64: Cleaning {{.*}}toolchain-clang-cl.test.tmp{{.}}foobar.obj
+CHECK-64: Cleaning {{.*}}toolchain-clang-cl.test.tmp{{.}}foo.exe-foobar.obj
 CHECK-64: Cleaning {{.*}}toolchain-clang-cl.test.tmp{{.}}foo.pdb
 CHECK-64: Cleaning {{.*}}toolchain-clang-cl.test.tmp{{.}}foo.exe
-CHECK-64: compiling foobar.c -> foobar.obj
+CHECK-64: compiling foobar.c -> foo.exe-foobar.obj
 CHECK-64: {{.*}}clang-cl{{(.exe)?}} -m64
-CHECK-64: linking foobar.obj -> foo.exe
+CHECK-64: linking foo.exe-foobar.obj -> foo.exe
 CHECK-64: {{.*}}lld-link{{(.exe)?}}

Modified: lldb/trunk/lit/BuildScript/toolchain-msvc.test
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/BuildScript/toolchain-msvc.test?rev=348511&r1=348510&r2=348511&view=diff
==============================================================================
--- lldb/trunk/lit/BuildScript/toolchain-msvc.test (original)
+++ lldb/trunk/lit/BuildScript/toolchain-msvc.test Thu Dec  6 10:39:58 2018
@@ -19,12 +19,12 @@ X86:   Verbose: True
 X86:   Dryrun: True
 X86:   Inputs: foobar.c
 X86: Cleaning {{.*}}toolchain-msvc.test.tmp\foobar.ilk
-X86: Cleaning {{.*}}toolchain-msvc.test.tmp\foobar.obj
+X86: Cleaning {{.*}}toolchain-msvc.test.tmp\foo.exe-foobar.obj
 X86: Cleaning {{.*}}toolchain-msvc.test.tmp\foo.pdb
 X86: Cleaning {{.*}}toolchain-msvc.test.tmp\foo.exe
-X86: compiling foobar.c -> foobar.obj
+X86: compiling foobar.c -> foo.exe-foobar.obj
 X86:   Command Line: {{.*}}\{{[Hh]ost[Xx]64}}\x86\cl.exe
-X86: linking foobar.obj -> foo.exe
+X86: linking foo.exe-foobar.obj -> foo.exe
 X86:   Command Line: {{.*}}\{{[Hh]ost[Xx]64}}\x86\link.exe
 X86:   Env
 X86:     LIB = {{.*}}\ATLMFC\lib\x86
@@ -47,12 +47,12 @@ X64:   Verbose: True
 X64:   Dryrun: True
 X64:   Inputs: foobar.c
 X64: Cleaning {{.*}}toolchain-msvc.test.tmp\foobar.ilk
-X64: Cleaning {{.*}}toolchain-msvc.test.tmp\foobar.obj
+X64: Cleaning {{.*}}toolchain-msvc.test.tmp\foo.exe-foobar.obj
 X64: Cleaning {{.*}}toolchain-msvc.test.tmp\foo.pdb
 X64: Cleaning {{.*}}toolchain-msvc.test.tmp\foo.exe
-X64: compiling foobar.c -> foobar.obj
+X64: compiling foobar.c -> foo.exe-foobar.obj
 X64:   Command Line: {{.*}}\{{[Hh]ost[Xx]64}}\x64\cl.exe
-X64: linking foobar.obj -> foo.exe
+X64: linking foo.exe-foobar.obj -> foo.exe
 X64:   Command Line: {{.*}}\{{[Hh]ost[Xx]64}}\x64\link.exe
 X64:   Env
 X64:     LIB = {{.*}}\ATLMFC\lib\x64

Modified: lldb/trunk/lit/helper/build.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/helper/build.py?rev=348511&r1=348510&r2=348511&view=diff
==============================================================================
--- lldb/trunk/lit/helper/build.py (original)
+++ lldb/trunk/lit/helper/build.py Thu Dec  6 10:39:58 2018
@@ -486,9 +486,12 @@ class MsvcBuilder(Builder):
             linkenv.update(defaultenv)
         return (compileenv, linkenv)
 
-    def _output_name(self, input, extension):
-        basename = os.path.basename(input)
-        basename = os.path.splitext(basename)[0] + extension
+    def _output_name(self, input, extension, with_executable=False):
+        basename = os.path.splitext(os.path.basename(input))[0] + extension
+        if with_executable:
+            exe_basename = os.path.basename(self._exe_file_name())
+            basename = exe_basename + '-' + basename
+
         output = os.path.join(self.outdir, basename)
         return os.path.normpath(output)
 
@@ -502,6 +505,13 @@ class MsvcBuilder(Builder):
         if self.mode == 'link':
             return self.inputs
 
+        if self.mode == 'compile-and-link':
+            # Object file names should factor in both the input file (source)
+            # name and output file (executable) name, to ensure that two tests
+            # which share a common source file don't race to write the same
+            # object file.
+            return [self._output_name(x, '.obj', True) for x in self.inputs]
+
         if self.mode == 'compile' and self.output:
             return [self.output]
 




More information about the lldb-commits mailing list