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.
This commit is contained in:
Andrew Kelley
2023-12-24 19:20:03 -07:00
parent 8cf2cfc52c
commit 41ab64c3eb
2 changed files with 36 additions and 1 deletions

View File

@@ -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.

View File

@@ -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", .{}),
};
}