Zig 0.17.0-dev (Split by item)

Shortcut keys
?
Show these tips
S
Focus search field
Esc
Clear focus & close tips
U
Jump to source code
↑
Move up in search results
↓
Move down in search results
↵
Go to active search result
This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig standard library. Public Struct

Compile

Public Struct
std.Build.Configuration.Step.Compile
pub const Compile = struct

Fields

flags: @This().Flags
flags2: Flags2
flags3: Flags3
flags4: Flags4
root_module: Module.Index
root_name: String
filters: Storage.FlagLengthPrefixedList(.flags, .filters_len, String)
installed_headers: Storage.FlagLengthPrefixedList(.flags, .installed_headers_len, Storage.Extended(InstalledHeader.Flags, InstalledHeader))
force_undefined_symbols: Storage.FlagLengthPrefixedList(.flags, .force_undefined_symbols_len, String)
expect_errors: Storage.FlagUnion(.flags4, .expect_errors, ExpectErrors)
linker_script: Storage.FlagOptional(.flags4, .linker_script, LazyPath.Index)
version_script: Storage.FlagOptional(.flags4, .version_script, LazyPath.Index)
zig_lib_dir: Storage.FlagOptional(.flags3, .zig_lib_dir, LazyPath.Index)
libc_file: Storage.FlagOptional(.flags4, .libc_file, LazyPath.Index)
win32_manifest: Storage.FlagOptional(.flags3, .win32_manifest, LazyPath.Index)
win32_module_definition: Storage.FlagOptional(.flags3, .win32_module_definition, LazyPath.Index)
entitlements: Storage.FlagOptional(.flags4, .entitlements, LazyPath.Index)
version: Storage.FlagOptional(.flags3, .version, String)
entry: Storage.EnumOptional(.flags3, .entry, .symbol_name, String)
install_name: Storage.FlagOptional(.flags4, .install_name, String)
initial_memory: Storage.FlagOptional(.flags3, .initial_memory, u64)
max_memory: Storage.FlagOptional(.flags3, .max_memory, u64)
global_base: Storage.FlagOptional(.flags3, .global_base, u64)
image_base: Storage.FlagOptional(.flags3, .image_base, u64)
link_z_common_page_size: Storage.FlagOptional(.flags4, .link_z_common_page_size, u64)
link_z_max_page_size: Storage.FlagOptional(.flags4, .link_z_max_page_size, u64)
pagezero_size: Storage.FlagOptional(.flags4, .pagezero_size, u64)
stack_size: Storage.FlagOptional(.flags4, .stack_size, u64)
headerpad_size: Storage.FlagOptional(.flags4, .headerpad_size, u32)
error_limit: Storage.FlagOptional(.flags4, .error_limit, u32)
build_id: Storage.EnumOptional(.flags3, .build_id, .hexstring, String)
test_runner: Storage.FlagUnion(.flags3, .test_runner, TestRunner)
emit_directory: Storage.FlagOptional(.flags4, .emit_directory, GeneratedFileIndex)
generated_docs: Storage.FlagOptional(.flags4, .generated_docs, GeneratedFileIndex)
generated_asm: Storage.FlagOptional(.flags4, .generated_asm, GeneratedFileIndex)
generated_bin: Storage.FlagOptional(.flags4, .generated_bin, GeneratedFileIndex)
generated_pdb: Storage.FlagOptional(.flags4, .generated_pdb, GeneratedFileIndex)
generated_implib: Storage.FlagOptional(.flags4, .generated_implib, GeneratedFileIndex)
generated_llvm_bc: Storage.FlagOptional(.flags4, .generated_llvm_bc, GeneratedFileIndex)
generated_llvm_ir: Storage.FlagOptional(.flags4, .generated_llvm_ir, GeneratedFileIndex)
generated_h: Storage.FlagOptional(.flags4, .generated_h, GeneratedFileIndex)

Structs

Types

Functions

pub fn isDynamicLibrary(compile: *const Compile) bool
pub fn isStaticLibrary(compile: *const Compile) bool
pub fn producesImplib(compile: *const Compile, c: *const Configuration) bool
pub fn isDll(compile: *const Compile, c: *const Configuration) bool
pub fn rootModuleTarget(compile: *const Compile, c: *const Configuration) TargetQuery

File

Build/Configuration.zig:707
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
    pub const Compile = struct {
        flags: @This().Flags,
        flags2: Flags2,
        flags3: Flags3,
        flags4: Flags4,

        root_module: Module.Index,
        root_name: String,

        filters: Storage.FlagLengthPrefixedList(.flags, .filters_len, String),
        installed_headers: Storage.FlagLengthPrefixedList(.flags, .installed_headers_len, Storage.Extended(InstalledHeader.Flags, InstalledHeader)),
        force_undefined_symbols: Storage.FlagLengthPrefixedList(.flags, .force_undefined_symbols_len, String),
        expect_errors: Storage.FlagUnion(.flags4, .expect_errors, ExpectErrors),
        linker_script: Storage.FlagOptional(.flags4, .linker_script, LazyPath.Index),
        version_script: Storage.FlagOptional(.flags4, .version_script, LazyPath.Index),
        zig_lib_dir: Storage.FlagOptional(.flags3, .zig_lib_dir, LazyPath.Index),
        libc_file: Storage.FlagOptional(.flags4, .libc_file, LazyPath.Index),
        win32_manifest: Storage.FlagOptional(.flags3, .win32_manifest, LazyPath.Index),
        win32_module_definition: Storage.FlagOptional(.flags3, .win32_module_definition, LazyPath.Index),
        entitlements: Storage.FlagOptional(.flags4, .entitlements, LazyPath.Index),
        version: Storage.FlagOptional(.flags3, .version, String), // semantic version string
        entry: Storage.EnumOptional(.flags3, .entry, .symbol_name, String),
        install_name: Storage.FlagOptional(.flags4, .install_name, String),
        initial_memory: Storage.FlagOptional(.flags3, .initial_memory, u64),
        max_memory: Storage.FlagOptional(.flags3, .max_memory, u64),
        global_base: Storage.FlagOptional(.flags3, .global_base, u64),
        image_base: Storage.FlagOptional(.flags3, .image_base, u64),
        link_z_common_page_size: Storage.FlagOptional(.flags4, .link_z_common_page_size, u64),
        link_z_max_page_size: Storage.FlagOptional(.flags4, .link_z_max_page_size, u64),
        pagezero_size: Storage.FlagOptional(.flags4, .pagezero_size, u64),
        stack_size: Storage.FlagOptional(.flags4, .stack_size, u64),
        headerpad_size: Storage.FlagOptional(.flags4, .headerpad_size, u32),
        error_limit: Storage.FlagOptional(.flags4, .error_limit, u32),
        build_id: Storage.EnumOptional(.flags3, .build_id, .hexstring, String),
        test_runner: Storage.FlagUnion(.flags3, .test_runner, TestRunner),

        emit_directory: Storage.FlagOptional(.flags4, .emit_directory, GeneratedFileIndex),
        generated_docs: Storage.FlagOptional(.flags4, .generated_docs, GeneratedFileIndex),
        generated_asm: Storage.FlagOptional(.flags4, .generated_asm, GeneratedFileIndex),
        generated_bin: Storage.FlagOptional(.flags4, .generated_bin, GeneratedFileIndex),
        generated_pdb: Storage.FlagOptional(.flags4, .generated_pdb, GeneratedFileIndex),
        generated_implib: Storage.FlagOptional(.flags4, .generated_implib, GeneratedFileIndex),
        generated_llvm_bc: Storage.FlagOptional(.flags4, .generated_llvm_bc, GeneratedFileIndex),
        generated_llvm_ir: Storage.FlagOptional(.flags4, .generated_llvm_ir, GeneratedFileIndex),
        generated_h: Storage.FlagOptional(.flags4, .generated_h, GeneratedFileIndex),

        pub const InstalledHeader = union(@This().Tag) {
            file: File,
            directory: Directory,

            pub const Flags = packed struct(u32) {
                tag: InstalledHeader.Tag,
                _: u24 = 0,
            };

            pub const Tag = enum(u8) {
                file,
                directory,
            };

            pub const File = struct {
                flags: @This().Flags = .{},
                source: LazyPath.Index,
                dest_sub_path: String,

                pub const Flags = packed struct(u32) {
                    tag: InstalledHeader.Tag = .file,
                    _: u24 = 0,
                };
            };

            pub const Directory = struct {
                flags: @This().Flags,
                source: LazyPath.Index,
                dest_sub_path: String,
                exclude_extensions: Storage.FlagLengthPrefixedList(.flags, .exclude_extensions, String),
                include_extensions: Storage.FlagLengthPrefixedList(.flags, .include_extensions, String),

                pub const Flags = packed struct(u32) {
                    tag: InstalledHeader.Tag = .directory,
                    exclude_extensions: bool,
                    include_extensions: bool,
                    _: u22 = 0,
                };
            };
        };
        pub const ExpectErrors = union(@This().Tag) {
            pub const Tag = enum(u3) { contains, exact, starts_with, stderr_contains, none };

            contains: String,
            exact: Storage.LengthPrefixedList(String),
            starts_with: String,
            stderr_contains: String,
            none: void,
        };
        pub const TestRunner = union(@This().Tag) {
            pub const Tag = enum(u2) { default, simple, server };

            default: void,
            simple: LazyPath.Index,
            server: LazyPath.Index,
        };
        pub const Entry = enum(u2) { default, disabled, enabled, symbol_name };

        pub const Lto = enum(u2) {
            none,
            full,
            thin,
            default,

            pub fn init(lto: ?std.zig.LtoMode) Lto {
                return switch (lto orelse return .default) {
                    .none => .none,
                    .full => .full,
                    .thin => .thin,
                };
            }
        };

        pub const BuildId = enum(u3) {
            none,
            fast,
            uuid,
            sha1,
            md5,
            hexstring,
            default,

            pub fn init(build_id: ?std.zig.BuildId) BuildId {
                return switch (build_id orelse return .default) {
                    .none => .none,
                    .fast => .fast,
                    .uuid => .uuid,
                    .sha1 => .sha1,
                    .md5 => .md5,
                    .hexstring => .hexstring,
                };
            }

            pub fn unwrap(this: @This(), hexstring: ?String, c: *const Configuration) ?std.zig.BuildId {
                if (hexstring) |h| {
                    assert(this == .hexstring);
                    return .initHexString(h.slice(c));
                }
                return switch (this) {
                    .none => .none,
                    .fast => .fast,
                    .uuid => .uuid,
                    .sha1 => .sha1,
                    .md5 => .md5,
                    .hexstring => unreachable,
                    .default => null,
                };
            }
        };
        pub const WasiExecModel = enum(u2) {
            default,
            command,
            reactor,

            pub fn init(wasi_exec_model: ?std.builtin.WasiExecModel) WasiExecModel {
                return switch (wasi_exec_model orelse return .default) {
                    .command => .command,
                    .reactor => .reactor,
                };
            }
        };
        pub const Linkage = enum(u2) {
            static,
            dynamic,
            default,

            pub fn init(link_mode: ?std.builtin.LinkMode) Linkage {
                return switch (link_mode orelse return .default) {
                    .static => .static,
                    .dynamic => .dynamic,
                };
            }

            pub fn unwrap(this: @This()) ?std.builtin.LinkMode {
                return switch (this) {
                    .static => .static,
                    .dynamic => .dynamic,
                    .default => null,
                };
            }
        };
        pub const Kind = enum(u3) {
            exe,
            lib,
            obj,
            @"test",
            test_obj,

            pub fn isTest(kind: Kind) bool {
                return switch (kind) {
                    .exe, .lib, .obj => false,
                    .@"test", .test_obj => true,
                };
            }

            pub fn toOutputMode(kind: Kind) std.builtin.OutputMode {
                return switch (kind) {
                    .exe, .@"test" => .Exe,
                    .lib => .Lib,
                    .obj, .test_obj => .Obj,
                };
            }
        };
        pub const Subsystem = enum(u4) {
            console,
            windows,
            posix,
            native,
            efi_application,
            efi_boot_service_driver,
            efi_rom,
            efi_runtime_driver,
            default,

            pub fn init(subsystem: ?std.zig.Subsystem) Subsystem {
                return switch (subsystem orelse return .default) {
                    .console => .console,
                    .windows => .windows,
                    .posix => .posix,
                    .native => .native,
                    .efi_application => .efi_application,
                    .efi_boot_service_driver => .efi_boot_service_driver,
                    .efi_rom => .efi_rom,
                    .efi_runtime_driver => .efi_runtime_driver,
                };
            }
        };

        pub const Flags = packed struct(u32) {
            tag: Tag = .compile,

            filters_len: bool,
            installed_headers_len: bool,
            force_undefined_symbols_len: bool,

            verbose_link: bool,
            verbose_cc: bool,
            rdynamic: bool,
            import_memory: bool,
            export_memory: bool,
            import_symbols: bool,
            import_table: bool,
            export_table: bool,
            growable_table: bool,
            shared_memory: bool,
            link_eh_frame_hdr: bool,
            link_emit_relocs: bool,
            link_function_sections: bool,
            link_data_sections: bool,
            linker_dynamicbase: bool,
            link_z_notext: bool,
            link_z_relro: bool,
            link_z_lazy: bool,
            link_z_defs: bool,
            headerpad_max_install_names: bool,
            dead_strip_dylibs: bool,
            force_load_objc: bool,
            discard_local_symbols: bool,
            mingw_unicode_entry_point: bool,
        };

        pub const Flags2 = packed struct(u32) {
            pie: DefaultingBool,
            formatted_panics: DefaultingBool,
            bundle_compiler_rt: DefaultingBool,
            bundle_ubsan_rt: DefaultingBool,
            each_lib_rpath: DefaultingBool,
            link_gc_sections: DefaultingBool,
            linker_allow_shlib_undefined: DefaultingBool,
            linker_allow_undefined_version: DefaultingBool,
            linker_enable_new_dtags: DefaultingBool,
            dll_export_fns: DefaultingBool,
            use_llvm: DefaultingBool,
            use_lld: DefaultingBool,
            use_new_linker: DefaultingBool,
            allow_so_scripts: DefaultingBool,
            sanitize_coverage_trace_pc_guard: DefaultingBool,
            linkage: Linkage,
        };

        pub const Flags3 = packed struct(u32) {
            version: bool,
            initial_memory: bool,
            max_memory: bool,
            kind: Kind,
            compress_debug_sections: std.zig.CompressDebugSections,
            global_base: bool,
            test_runner: TestRunner.Tag,
            wasi_exec_model: WasiExecModel,
            win32_manifest: bool,
            win32_module_definition: bool,
            zig_lib_dir: bool,
            rc_includes: std.zig.RcIncludes,
            image_base: bool,
            build_id: BuildId,
            entry: Entry,
            lto: Lto,
            subsystem: Subsystem,
            _: u2 = 0,
        };

        pub const Flags4 = packed struct(u32) {
            libc_file: bool,
            link_z_common_page_size: bool,
            link_z_max_page_size: bool,
            pagezero_size: bool,
            stack_size: bool,
            headerpad_size: bool,
            error_limit: bool,
            install_name: bool,
            entitlements: bool,
            expect_errors: ExpectErrors.Tag,
            linker_script: bool,
            version_script: bool,
            emit_directory: bool,
            generated_docs: bool,
            generated_asm: bool,
            generated_bin: bool,
            generated_pdb: bool,
            generated_implib: bool,
            generated_llvm_bc: bool,
            generated_llvm_ir: bool,
            generated_h: bool,
            incremental: DefaultingBool,
            _: u7 = 0,
        };

        pub fn isDynamicLibrary(compile: *const Compile) bool {
            return compile.flags3.kind == .lib and compile.flags2.linkage == .dynamic;
        }

        pub fn isStaticLibrary(compile: *const Compile) bool {
            return compile.flags3.kind == .lib and compile.flags2.linkage != .dynamic;
        }

        pub fn producesImplib(compile: *const Compile, c: *const Configuration) bool {
            return isDll(compile, c);
        }

        pub fn isDll(compile: *const Compile, c: *const Configuration) bool {
            return isDynamicLibrary(compile) and rootModuleTarget(compile, c).flags.os_tag == .windows;
        }

        pub fn rootModuleTarget(compile: *const Compile, c: *const Configuration) TargetQuery {
            return compile.root_module.get(c).resolved_target.get(c).?.result.get(c);
        }
    }