| ... | ... | @@ -1769,7 +1769,8 @@ fn buildOutputType( |
| 1769 | 1769 | }) catch |err| { |
| 1770 | 1770 | fatal("unable to create compilation: {}", .{@errorName(err)}); |
| 1771 | 1771 | }; |
| 1772 | | defer comp.destroy(); |
| 1772 | var comp_destroyed = false; |
| 1773 | defer if (!comp_destroyed) comp.destroy(); |
| 1773 | 1774 | |
| 1774 | 1775 | if (show_builtin) { |
| 1775 | 1776 | return std.io.getStdOut().writeAll(try comp.generateBuiltinZigSource(arena)); |
| ... | ... | @@ -1845,9 +1846,10 @@ fn buildOutputType( |
| 1845 | 1846 | if (runtime_args_start) |i| { |
| 1846 | 1847 | try argv.appendSlice(all_args[i..]); |
| 1847 | 1848 | } |
| 1848 | | // We do not execve for tests because if the test fails we want to print the error message and |
| 1849 | | // invocation below. |
| 1849 | // We do not execve for tests because if the test fails we want to print |
| 1850 | // the error message and invocation below. |
| 1850 | 1851 | if (std.process.can_execv and arg_mode == .run and !watch) { |
| 1852 | // execv releases the locks; no need to destroy the Compilation here. |
| 1851 | 1853 | const err = std.process.execv(gpa, argv.items); |
| 1852 | 1854 | const cmd = try argvCmd(arena, argv.items); |
| 1853 | 1855 | fatal("the following command failed to execve with '{s}':\n{s}", .{ @errorName(err), cmd }); |
| ... | ... | @@ -1859,6 +1861,13 @@ fn buildOutputType( |
| 1859 | 1861 | child.stdout_behavior = .Inherit; |
| 1860 | 1862 | child.stderr_behavior = .Inherit; |
| 1861 | 1863 | |
| 1864 | if (!watch) { |
| 1865 | // Here we release all the locks associated with the Compilation so |
| 1866 | // that whatever this child process wants to do won't deadlock. |
| 1867 | comp.destroy(); |
| 1868 | comp_destroyed = true; |
| 1869 | } |
| 1870 | |
| 1862 | 1871 | const term = try child.spawnAndWait(); |
| 1863 | 1872 | switch (arg_mode) { |
| 1864 | 1873 | .run => { |