Commit 41ab64c3eb

Andrew Kelley <andrew@ziglang.org>
2023-12-25 03:20:03
Compilation.Config.resolve: explicit error set
Some logic has comptime-known conditions, causing the inferred error set to be different on different compiler build configurations.
1 parent 8cf2cfc
Changed files (2)
src
Compilation
src/Compilation/Config.zig
@@ -99,7 +99,39 @@ pub const Options = struct {
     rdynamic: ?bool = null,
 };
 
-pub fn resolve(options: Options) !Config {
+pub const ResolveError = error{
+    WasiExecModelRequiresWasi,
+    SharedMemoryIsWasmOnly,
+    ObjectFilesCannotShareMemory,
+    SharedMemoryRequiresAtomicsAndBulkMemory,
+    ThreadsRequireSharedMemory,
+    UnknownTargetEntryPoint,
+    NonExecutableEntryPoint,
+    EmittingLlvmModuleRequiresLlvmBackend,
+    LlvmLacksTargetSupport,
+    ZigLacksTargetSupport,
+    EmittingBinaryRequiresLlvmLibrary,
+    LldIncompatibleObjectFormat,
+    LtoRequiresLld,
+    SanitizeThreadRequiresLibCpp,
+    LibCppRequiresLibUnwind,
+    OsRequiresLibC,
+    LibCppRequiresLibC,
+    LibUnwindRequiresLibC,
+    TargetCannotDynamicLink,
+    LibCRequiresDynamicLinking,
+    SharedLibrariesRequireDynamicLinking,
+    ExportMemoryAndDynamicIncompatible,
+    DynamicLibraryPrecludesPie,
+    TargetRequiresPie,
+    SanitizeThreadRequiresPie,
+    BackendLacksErrorTracing,
+    LlvmLibraryUnavailable,
+    LldUnavailable,
+    ClangUnavailable,
+};
+
+pub fn resolve(options: Options) ResolveError!Config {
     const target = options.resolved_target.result;
 
     // WASI-only. Resolve the optional exec-model option, defaults to command.
src/main.zig
@@ -3867,6 +3867,9 @@ fn createModule(
             error.TargetRequiresPie => fatal("the specified target requires position independent executables", .{}),
             error.SanitizeThreadRequiresPie => fatal("thread sanitization requires position independent executables", .{}),
             error.BackendLacksErrorTracing => fatal("the selected backend has not yet implemented error return tracing", .{}),
+            error.LlvmLibraryUnavailable => fatal("zig was compiled without LLVM libraries", .{}),
+            error.LldUnavailable => fatal("zig was compiled without LLD libraries", .{}),
+            error.ClangUnavailable => fatal("zig was compiled without Clang libraries", .{}),
         };
     }