Progmasoft Git

tazel

A build system for C, C++, Objective-C, Objective-C++ and Zig, with C# project files.

Clonegit clone https://git.progmasoft.com/tazel

Name zig's target on every host, unpack LLVM with Windows' tar, drop the clang tools

- zig always gets -target for the platform of the build, so its output is the same
  whichever machine builds it, and the snapshot of PlannerTests is the same on every host.
- The fake archiver of PlannerTests is llvm-ar, as the rule for Apple's ar depends on the
  host.
- The Windows job unpacks LLVM with Windows' own tar.exe and checks it with Get-FileHash;
  Git's tar took D: for a remote host.
- CCTools has no ClangTidy or ClangFormat: Tazel neither formats nor lints.
Commit
64f52cb21c762c0c5b8bf16ac97b6b771fd86def
Author
Leitwolf11 ·
Parents
9c03e6c6c701

Files · Download .tar.gz

Changes

 .github/workflows/ci.yml                                  | 15 ++++++++++-----
 .../Build/Toolchain/Prelude/Toolchains.cs                 |  6 ------
 src/Progmasoft.Tazel/Driver/ZigPlanner.cs                 |  8 +++-----
 tests/Progmasoft.Tazel.Tests/PlannerTests.cs              |  6 +++---
 .../__snapshots__/PlannerTests.TheCommandsOfABuild.snap   |  4 ++++
 5 files changed, 20 insertions(+), 19 deletions(-)

diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index c71a76f..2ffa833 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -74,14 +74,19 @@ jobs:
           path: ${{ runner.temp }}/llvm
           key: llvm-23.1.5-x86_64-pc-windows-msvc
 
+      # Windows' own tar (libarchive) unpacks zstd and takes D:\ as a drive, not as a remote host.
       - name: Install LLVM
         if: runner.os == 'Windows' && steps.llvm.outputs.cache-hit != 'true'
-        shell: bash
+        shell: pwsh
         run: |
-          curl -fsSL -o "$RUNNER_TEMP/llvm.tar.zst" "https://github.com/llvm/llvm-project/releases/download/llvmorg-23.1.5/clang%2Bllvm-23.1.5-x86_64-pc-windows-msvc.tar.zst"
-          echo "b2be33385ddc86e83511417a060de927ae8b09d1f3017cc3cdce5c73cd5029d7  $RUNNER_TEMP/llvm.tar.zst" | sha256sum -c -
-          mkdir -p "$RUNNER_TEMP/llvm"
-          tar --zstd -xf "$RUNNER_TEMP/llvm.tar.zst" -C "$RUNNER_TEMP/llvm" --strip-components=1
+          $archive = Join-Path $env:RUNNER_TEMP "llvm.tar.zst"
+          Invoke-WebRequest -Uri "https://github.com/llvm/llvm-project/releases/download/llvmorg-23.1.5/clang%2Bllvm-23.1.5-x86_64-pc-windows-msvc.tar.zst" -OutFile $archive
+          $sha = (Get-FileHash -Algorithm SHA256 $archive).Hash.ToLowerInvariant()
+          if ($sha -ne "b2be33385ddc86e83511417a060de927ae8b09d1f3017cc3cdce5c73cd5029d7") { throw "LLVM has the SHA-256 $sha" }
+          $llvm = Join-Path $env:RUNNER_TEMP "llvm"
+          New-Item -ItemType Directory -Force $llvm | Out-Null
+          & "$env:SystemRoot\System32\tar.exe" -xf $archive -C $llvm --strip-components 1
+          if ($LASTEXITCODE -ne 0) { throw "tar failed with $LASTEXITCODE" }
 
       - name: Put LLVM first on PATH
         if: runner.os == 'Windows'
diff --git a/src/Progmasoft.Tazel.Dsl/Build/Toolchain/Prelude/Toolchains.cs b/src/Progmasoft.Tazel.Dsl/Build/Toolchain/Prelude/Toolchains.cs
index 40d6cba..6f0f777 100644
--- a/src/Progmasoft.Tazel.Dsl/Build/Toolchain/Prelude/Toolchains.cs
+++ b/src/Progmasoft.Tazel.Dsl/Build/Toolchain/Prelude/Toolchains.cs
@@ -85,12 +85,6 @@ public sealed class CCTools
 
     /// <summary>The archiver of static libraries.</summary>
     public string? Archiver { get; init; }
-
-    /// <summary>clang-tidy, for <c>tazel lint</c>.</summary>
-    public string? ClangTidy { get; init; }
-
-    /// <summary>clang-format, for <c>tazel format</c>.</summary>
-    public string? ClangFormat { get; init; }
 }
 
 /// <summary>A C-family toolchain: the platform it runs on, the one it builds for, its tools and features.</summary>
diff --git a/src/Progmasoft.Tazel/Driver/ZigPlanner.cs b/src/Progmasoft.Tazel/Driver/ZigPlanner.cs
index 036346c..d5824a0 100644
--- a/src/Progmasoft.Tazel/Driver/ZigPlanner.cs
+++ b/src/Progmasoft.Tazel/Driver/ZigPlanner.cs
@@ -224,11 +224,9 @@ internal sealed partial class Planner
         ProjectTarget target, ZigModuleSettings settings, ZigOptimization optimization, List<string> inputs,
         IReadOnlyList<string> includeDirectories)
     {
-        var options = new List<string> { "-O", OptimizationName(optimization) };
-        if (Options.Platform != Host.Platform)
-        {
-            options.AddRange(["-target", ZigTriple(Options.Platform)]);
-        }
+        // The target is always named, so the output is the same on every machine that builds it: zig's baseline CPU
+        // of the platform, never the features of the processor that runs the build.
+        var options = new List<string> { "-O", OptimizationName(optimization), "-target", ZigTriple(Options.Platform) };
 
         if (settings is ZigCompiledSettings { PositionIndependentCode: true })
         {
diff --git a/tests/Progmasoft.Tazel.Tests/PlannerTests.cs b/tests/Progmasoft.Tazel.Tests/PlannerTests.cs
index acdfb29..45bb2ac 100644
--- a/tests/Progmasoft.Tazel.Tests/PlannerTests.cs
+++ b/tests/Progmasoft.Tazel.Tests/PlannerTests.cs
@@ -42,7 +42,7 @@ public sealed class PlannerTests
             {
                 CCompiler = @"{{Path.Combine(root, "tools", "cc")}}",
                 CppCompiler = @"{{Path.Combine(root, "tools", "c++")}}",
-                Archiver = @"{{Path.Combine(root, "tools", "ar")}}",
+                Archiver = @"{{Path.Combine(root, "tools", "llvm-ar")}}",
             },
             Features = [warnings, lto],
         });
@@ -104,7 +104,7 @@ public sealed class PlannerTests
             .Write("BUILD.csx", Build)
             .Write("src/a.cpp", "").Write("src/b.cpp", "").Write("src/shared.c", "").Write("src/main.cc", "")
             .Write("include/math.hpp", "").Write("zig/core.zig", "").Write("zig/main.zig", "").Write("zig/shim.c", "")
-            .Write("tools/cc", "").Write("tools/c++", "").Write("tools/ar", "").Write("tools/zig", "");
+            .Write("tools/cc", "").Write("tools/c++", "").Write("tools/llvm-ar", "").Write("tools/zig", "");
         var workspace = await Workspace.LoadAsync(module.Root, new BuildContext(BuildMode.Debug, Platform.LinuxAmd64),
             new Version(0, 1, 0));
         var options = new BuildOptions
@@ -139,7 +139,7 @@ public sealed class PlannerTests
         module.Write("MODULE.csx", ModuleWithToolchain(module.Root))
             .Write("toolchains/BUILD.csx", Toolchain(module.Root))
             .Write("BUILD.csx", "using Progmasoft.Tazel.Dsl.Build.Prelude;\nCC.StaticLibrary(\"x\", new() { Features = [CC.Enable(\"asan\")] });")
-            .Write("tools/cc", "").Write("tools/c++", "").Write("tools/ar", "").Write("tools/zig", "");
+            .Write("tools/cc", "").Write("tools/c++", "").Write("tools/llvm-ar", "").Write("tools/zig", "");
         var workspace = await Workspace.LoadAsync(module.Root, new BuildContext(BuildMode.Debug, Platform.LinuxAmd64),
             new Version(0, 1, 0));
         var planner = new Planner(workspace, new BuildOptions { Platform = Platform.LinuxAmd64 },
diff --git a/tests/Progmasoft.Tazel.Tests/__snapshots__/PlannerTests.TheCommandsOfABuild.snap b/tests/Progmasoft.Tazel.Tests/__snapshots__/PlannerTests.TheCommandsOfABuild.snap
index d9d5ef3..e6ad857 100644
--- a/tests/Progmasoft.Tazel.Tests/__snapshots__/PlannerTests.TheCommandsOfABuild.snap
+++ b/tests/Progmasoft.Tazel.Tests/__snapshots__/PlannerTests.TheCommandsOfABuild.snap
@@ -183,6 +183,8 @@
       "-Wl,--as-needed",
       "-O",
       "Debug",
+      "-target",
+      "x86_64-linux",
       "-I.",
       "-Iinclude",
       "-cflags",
@@ -196,6 +198,8 @@
       "-Mroot=zig/main.zig",
       "-O",
       "Debug",
+      "-target",
+      "x86_64-linux",
       "-Mcore=zig/core.zig"
     ],
     "Inputs": [