motiejus/zig

fork of https://codeberg.org/ziglang/zig
git clone https://git.jakstys.lt/motiejus/zig.git
Log | Tree | Refs | README | LICENSE

commit 41ab64c3eb7a104e78ca96cfe861a03f3a150d47 (tree)
parent 8cf2cfc52c23fec8de2fa8ca54c2589daed2135b
Author: Andrew Kelley <andrew@ziglang.org>
Date:   Sun, 24 Dec 2023 19:20:03 -0700

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.

Diffstat:
Msrc/Compilation/Config.zig | 34+++++++++++++++++++++++++++++++++-
Msrc/main.zig | 3+++
2 files changed, 36 insertions(+), 1 deletion(-)

diff --git a/src/Compilation/Config.zig b/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. diff --git a/src/main.zig b/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", .{}), }; }