authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-12-24 19:20:03-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-01-01 17:51:21-07:00
log41ab64c3eb7a104e78ca96cfe861a03f3a150d47
tree357286a9f8e5b282497595d4082e388169256928
parent8cf2cfc52c23fec8de2fa8ca54c2589daed2135b

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.

2 files changed, 36 insertions(+), 1 deletions(-)

src/Compilation/Config.zig+33-1
......@@ -99,7 +99,39 @@ pub const Options = struct {
9999 rdynamic: ?bool = null,
100100};
101101
102pub fn resolve(options: Options) !Config {
102pub const ResolveError = error{
103 WasiExecModelRequiresWasi,
104 SharedMemoryIsWasmOnly,
105 ObjectFilesCannotShareMemory,
106 SharedMemoryRequiresAtomicsAndBulkMemory,
107 ThreadsRequireSharedMemory,
108 UnknownTargetEntryPoint,
109 NonExecutableEntryPoint,
110 EmittingLlvmModuleRequiresLlvmBackend,
111 LlvmLacksTargetSupport,
112 ZigLacksTargetSupport,
113 EmittingBinaryRequiresLlvmLibrary,
114 LldIncompatibleObjectFormat,
115 LtoRequiresLld,
116 SanitizeThreadRequiresLibCpp,
117 LibCppRequiresLibUnwind,
118 OsRequiresLibC,
119 LibCppRequiresLibC,
120 LibUnwindRequiresLibC,
121 TargetCannotDynamicLink,
122 LibCRequiresDynamicLinking,
123 SharedLibrariesRequireDynamicLinking,
124 ExportMemoryAndDynamicIncompatible,
125 DynamicLibraryPrecludesPie,
126 TargetRequiresPie,
127 SanitizeThreadRequiresPie,
128 BackendLacksErrorTracing,
129 LlvmLibraryUnavailable,
130 LldUnavailable,
131 ClangUnavailable,
132};
133
134pub fn resolve(options: Options) ResolveError!Config {
103135 const target = options.resolved_target.result;
104136
105137 // WASI-only. Resolve the optional exec-model option, defaults to command.
src/main.zig+3
......@@ -3867,6 +3867,9 @@ fn createModule(
38673867 error.TargetRequiresPie => fatal("the specified target requires position independent executables", .{}),
38683868 error.SanitizeThreadRequiresPie => fatal("thread sanitization requires position independent executables", .{}),
38693869 error.BackendLacksErrorTracing => fatal("the selected backend has not yet implemented error return tracing", .{}),
3870 error.LlvmLibraryUnavailable => fatal("zig was compiled without LLVM libraries", .{}),
3871 error.LldUnavailable => fatal("zig was compiled without LLD libraries", .{}),
3872 error.ClangUnavailable => fatal("zig was compiled without Clang libraries", .{}),
38703873 };
38713874 }
38723875