2017-12-11 23:34:59 -05:00
const std = @import ( " std " ) ;
2021-04-12 16:44:51 -07:00
const builtin = std . builtin ;
2017-04-19 01:13:15 -04:00
const tests = @import ( " test/tests.zig " ) ;
2017-12-11 23:34:59 -05:00
const BufMap = std . BufMap ;
const mem = std . mem ;
const io = std . io ;
2019-05-26 13:17:34 -04:00
const fs = std . fs ;
2023-01-31 00:19:51 -07:00
const InstallDirectoryOptions = std . Build . InstallDirectoryOptions ;
2020-09-03 20:23:00 -07:00
const assert = std . debug . assert ;
2024-07-19 01:04:59 -04:00
const DevEnv = @import ( " src/dev.zig " ) . Env ;
2025-01-16 10:09:41 +00:00
const ValueInterpretMode = enum { direct , by_name } ;
2017-04-19 01:13:15 -04:00
2025-08-18 21:33:09 -07:00
const zig_version : std . SemanticVersion = . { . major = 0 , . minor = 16 , . patch = 0 } ;
2025-01-10 05:35:03 +00:00
const stack_size = 46 * 1024 * 1024 ;
2020-08-15 14:17:40 -07:00
2023-01-31 00:19:51 -07:00
pub fn build ( b : * std . Build ) ! void {
2022-12-01 16:34:15 -07:00
const only_c = b . option ( bool , " only-c " , " Translate the Zig compiler to C code, with only the C backend enabled " ) orelse false ;
2025-01-24 08:11:16 +01:00
const target = b . standardTargetOptions ( . {
. default_target = . {
. ofmt = if ( only_c ) . c else null ,
} ,
} ) ;
2023-04-07 22:17:23 +03:00
const optimize = b . standardOptimizeOption ( . { } ) ;
2022-11-04 18:35:04 -07:00
2023-07-21 20:29:42 -07:00
const flat = b . option ( bool , " flat " , " Put files into the installation prefix in a manner suited for upstream distribution rather than a posix file system hierarchy standard " ) orelse false ;
2022-01-28 17:16:51 -07:00
const single_threaded = b . option ( bool , " single-threaded " , " Build artifacts that run in single threaded mode " ) ;
2021-09-16 13:09:32 -07:00
const use_zig_libcxx = b . option ( bool , " use-zig-libcxx " , " If libc++ is needed, use zig's bundled version, don't try to integrate with the system " ) orelse false ;
2017-10-21 17:31:06 -04:00
2022-11-04 18:35:04 -07:00
const test_step = b . step ( " test " , " Run all the tests " ) ;
2023-05-14 22:59:30 +06:00
const skip_install_lib_files = b . option ( bool , " no-lib " , " skip copying of lib/ files and langref to installation prefix. Useful for development " ) orelse false ;
2023-04-11 21:05:53 +02:00
const skip_install_langref = b . option ( bool , " no-langref " , " skip copying of langref to the installation prefix " ) orelse skip_install_lib_files ;
2024-03-06 22:35:48 -07:00
const std_docs = b . option ( bool , " std-docs " , " include standard library autodocs " ) orelse false ;
2023-06-12 22:02:59 +01:00
const no_bin = b . option ( bool , " no-bin " , " skip emitting compiler binary " ) orelse false ;
2024-10-12 06:27:30 +02:00
const enable_superhtml = b . option ( bool , " enable-superhtml " , " Check langref output HTML validity " ) orelse false ;
2022-11-04 18:35:04 -07:00
2024-04-24 17:41:47 -07:00
const langref_file = generateLangRef ( b ) ;
2023-03-10 14:22:54 -07:00
const install_langref = b . addInstallFileWithDir ( langref_file , . prefix , " doc/langref.html " ) ;
2024-10-12 06:27:30 +02:00
const check_langref = superHtmlCheck ( b , langref_file ) ;
if ( enable_superhtml ) install_langref . step . dependOn ( check_langref ) ;
const check_autodocs = superHtmlCheck ( b , b . path ( " lib/docs/index.html " ) ) ;
if ( enable_superhtml ) {
2024-06-16 20:03:14 -07:00
test_step . dependOn ( check_langref ) ;
2024-10-12 06:27:30 +02:00
test_step . dependOn ( check_autodocs ) ;
2024-06-16 20:03:14 -07:00
}
2023-04-11 21:05:53 +02:00
if ( ! skip_install_langref ) {
2023-03-09 22:12:36 -07:00
b . getInstallStep ( ) . dependOn ( & install_langref . step ) ;
}
2017-11-07 03:22:27 -05:00
2024-03-06 22:51:38 -07:00
const autodoc_test = b . addObject ( . {
. name = " std " ,
2024-04-11 14:02:47 -07:00
. zig_lib_dir = b . path ( " lib " ) ,
2024-12-15 18:09:38 +00:00
. root_module = b . createModule ( . {
. root_source_file = b . path ( " lib/std/std.zig " ) ,
. target = target ,
. optimize = . Debug ,
} ) ,
2023-07-21 20:29:42 -07:00
} ) ;
const install_std_docs = b . addInstallDirectory ( . {
2023-07-23 21:13:58 -07:00
. source_dir = autodoc_test . getEmittedDocs ( ) ,
2023-07-21 20:29:42 -07:00
. install_dir = . prefix ,
. install_subdir = " doc/std " ,
} ) ;
2024-06-17 00:09:40 -07:00
//if (enable_tidy) install_std_docs.step.dependOn(check_autodocs);
2024-03-06 22:35:48 -07:00
if ( std_docs ) {
2023-07-21 20:29:42 -07:00
b . getInstallStep ( ) . dependOn ( & install_std_docs . step ) ;
}
if ( flat ) {
b . installFile ( " LICENSE " , " LICENSE " ) ;
2023-07-23 15:51:13 -07:00
b . installFile ( " README.md " , " README.md " ) ;
2023-07-21 20:29:42 -07:00
}
const langref_step = b . step ( " langref " , " Build and install the language reference " ) ;
langref_step . dependOn ( & install_langref . step ) ;
const std_docs_step = b . step ( " std-docs " , " Build and install the standard library documentation " ) ;
std_docs_step . dependOn ( & install_std_docs . step ) ;
const docs_step = b . step ( " docs " , " Build and install documentation " ) ;
docs_step . dependOn ( langref_step ) ;
docs_step . dependOn ( std_docs_step ) ;
2017-11-07 03:22:27 -05:00
2025-10-09 09:59:55 -07:00
const no_matrix = b . option ( bool , " no-matrix " , " Limit test matrix to exactly one target configuration " ) orelse false ;
2021-04-24 16:39:26 -04:00
const skip_debug = b . option ( bool , " skip-debug " , " Main test suite skips debug builds " ) orelse false ;
2025-10-09 09:59:55 -07:00
const skip_release = b . option ( bool , " skip-release " , " Main test suite skips release builds " ) orelse no_matrix ;
2018-09-12 14:50:26 -04:00
const skip_release_small = b . option ( bool , " skip-release-small " , " Main test suite skips release-small builds " ) orelse skip_release ;
const skip_release_fast = b . option ( bool , " skip-release-fast " , " Main test suite skips release-fast builds " ) orelse skip_release ;
const skip_release_safe = b . option ( bool , " skip-release-safe " , " Main test suite skips release-safe builds " ) orelse skip_release ;
2025-10-09 09:59:55 -07:00
const skip_non_native = b . option ( bool , " skip-non-native " , " Main test suite skips non-native builds " ) orelse no_matrix ;
2019-09-21 23:55:56 -04:00
const skip_libc = b . option ( bool , " skip-libc " , " Main test suite skips tests that link libc " ) orelse false ;
2022-06-01 14:05:58 -07:00
const skip_single_threaded = b . option ( bool , " skip-single-threaded " , " Main test suite skips tests that are single-threaded " ) orelse false ;
2025-07-23 00:23:31 +02:00
const skip_compile_errors = b . option ( bool , " skip-compile-errors " , " Main test suite skips compile error tests " ) orelse false ;
2025-06-06 12:50:14 -07:00
const skip_freebsd = b . option ( bool , " skip-freebsd " , " Main test suite skips targets with freebsd OS " ) orelse false ;
const skip_netbsd = b . option ( bool , " skip-netbsd " , " Main test suite skips targets with netbsd OS " ) orelse false ;
const skip_windows = b . option ( bool , " skip-windows " , " Main test suite skips targets with windows OS " ) orelse false ;
2025-11-14 22:39:12 +01:00
const skip_darwin = b . option ( bool , " skip-darwin " , " Main test suite skips targets with darwin OSs " ) orelse false ;
2025-06-06 12:50:14 -07:00
const skip_linux = b . option ( bool , " skip-linux " , " Main test suite skips targets with linux OS " ) orelse false ;
2025-06-06 23:34:52 -07:00
const skip_llvm = b . option ( bool , " skip-llvm " , " Main test suite skips targets that use LLVM backend " ) orelse false ;
2025-11-22 08:06:26 -08:00
const skip_test_incremental = b . option ( bool , " skip-test-incremental " , " Main test step omits dependency on test-incremental step " ) orelse false ;
2017-10-21 17:31:06 -04:00
2019-07-14 03:06:20 -04:00
const only_install_lib_files = b . option ( bool , " lib-files-only " , " Only install library files " ) orelse false ;
2022-02-16 13:50:47 -07:00
2020-12-07 17:23:17 -07:00
const static_llvm = b . option ( bool , " static-llvm " , " Disable integration with system-installed LLVM, Clang, LLD, and libc++ " ) orelse false ;
2022-10-31 20:29:55 -07:00
const enable_llvm = b . option ( bool , " enable-llvm " , " Build self-hosted compiler with LLVM backend enabled " ) orelse static_llvm ;
2021-08-31 22:50:10 -07:00
const llvm_has_m68k = b . option (
bool ,
" llvm-has-m68k " ,
" Whether LLVM has the experimental target m68k enabled " ,
) orelse false ;
const llvm_has_csky = b . option (
bool ,
" llvm-has-csky " ,
" Whether LLVM has the experimental target csky enabled " ,
) orelse false ;
const llvm_has_arc = b . option (
bool ,
" llvm-has-arc " ,
" Whether LLVM has the experimental target arc enabled " ,
) orelse false ;
2023-01-26 16:33:40 -07:00
const llvm_has_xtensa = b . option (
bool ,
" llvm-has-xtensa " ,
" Whether LLVM has the experimental target xtensa enabled " ,
) orelse false ;
2023-08-18 11:57:12 +02:00
const enable_ios_sdk = b . option ( bool , " enable-ios-sdk " , " Run tests requiring presence of iOS SDK and frameworks " ) orelse false ;
2023-08-18 12:05:13 +02:00
const enable_macos_sdk = b . option ( bool , " enable-macos-sdk " , " Run tests requiring presence of macOS SDK and frameworks " ) orelse enable_ios_sdk ;
2022-11-28 22:04:42 +01:00
const enable_symlinks_windows = b . option ( bool , " enable-symlinks-windows " , " Run tests requiring presence of symlinks on Windows " ) orelse false ;
2020-07-03 18:15:01 -07:00
const config_h_path_option = b . option ( [ ] const u8 , " config_h " , " Path to the generated config.h " ) ;
2020-04-06 13:07:19 -04:00
2021-04-16 18:58:27 -07:00
if ( ! skip_install_lib_files ) {
2023-07-21 20:29:42 -07:00
b . installDirectory ( . {
2024-04-11 14:02:47 -07:00
. source_dir = b . path ( " lib " ) ,
2023-07-21 20:29:42 -07:00
. install_dir = if ( flat ) . prefix else . lib ,
. install_subdir = if ( flat ) " lib " else " zig " ,
2021-04-16 18:58:27 -07:00
. exclude_extensions = & [ _ ] [ ] const u8 {
2022-12-18 16:28:30 -07:00
// exclude files from lib/std/compress/testdata
2022-01-09 02:12:00 +01:00
" .gz " ,
2021-04-16 18:58:27 -07:00
" .z.0 " ,
" .z.9 " ,
2024-02-28 22:37:11 -07:00
" .zst.3 " ,
" .zst.19 " ,
2021-04-16 18:58:27 -07:00
" rfc1951.txt " ,
2022-01-09 02:12:00 +01:00
" rfc1952.txt " ,
2023-01-21 19:10:47 +11:00
" rfc8478.txt " ,
2024-02-14 22:34:13 +01:00
// exclude files from lib/std/compress/flate/testdata
2022-01-09 02:12:00 +01:00
" .expect " ,
" .expect-noinput " ,
" .golden " ,
" .input " ,
" compress-e.txt " ,
" compress-gettysburg.txt " ,
" compress-pi.txt " ,
" rfc1951.txt " ,
2023-02-02 11:59:56 -08:00
// exclude files from lib/std/compress/lzma/testdata
" .lzma " ,
2023-01-23 11:46:40 -08:00
// exclude files from lib/std/compress/xz/testdata
" .xz " ,
2022-01-09 02:12:00 +01:00
// exclude files from lib/std/tz/
2021-12-31 17:17:49 +00:00
" .tzif " ,
2024-01-12 17:51:44 -07:00
// exclude files from lib/std/tar/testdata
" .tar " ,
2022-01-09 02:12:00 +01:00
// others
" README.md " ,
2021-04-16 18:58:27 -07:00
} ,
2021-05-18 17:18:42 -07:00
. blank_extensions = & [ _ ] [ ] const u8 {
" test.zig " ,
} ,
2021-04-16 18:58:27 -07:00
} ) ;
}
2017-10-21 17:31:06 -04:00
2020-09-08 11:15:32 -07:00
if ( only_install_lib_files )
return ;
2023-03-16 20:41:46 +01:00
const entitlements = b . option ( [ ] const u8 , " entitlements " , " Path to entitlements file for hot-code swapping without sudo on macOS " ) ;
2020-09-16 17:17:37 -07:00
const tracy = b . option ( [ ] const u8 , " tracy " , " Enable Tracy integration. Supply path to Tracy source " ) ;
2022-10-26 18:17:49 -07:00
const tracy_callstack = b . option ( bool , " tracy-callstack " , " Include callstack information with Tracy data. Does nothing if -Dtracy is not provided " ) orelse ( tracy != null ) ;
const tracy_allocation = b . option ( bool , " tracy-allocation " , " Include allocation information with Tracy data. Does nothing if -Dtracy is not provided " ) orelse ( tracy != null ) ;
2024-11-29 13:13:06 -07:00
const tracy_callstack_depth : u32 = b . option ( u32 , " tracy-callstack-depth " , " Declare callstack depth for Tracy data. Does nothing if -Dtracy_callstack is not provided " ) orelse 10 ;
2025-02-06 17:41:50 -08:00
const debug_gpa = b . option ( bool , " debug-allocator " , " Force the compiler to use DebugAllocator " ) orelse false ;
2022-12-01 16:34:15 -07:00
const link_libc = b . option ( bool , " force-link-libc " , " Force self-hosted compiler to link libc " ) orelse ( enable_llvm or only_c ) ;
2022-10-05 03:22:10 -07:00
const sanitize_thread = b . option ( bool , " sanitize-thread " , " Enable thread-sanitization " ) orelse false ;
2022-11-04 18:35:04 -07:00
const strip = b . option ( bool , " strip " , " Omit debug information " ) ;
2024-07-16 17:26:41 -07:00
const valgrind = b . option ( bool , " valgrind " , " Enable valgrind integration " ) ;
2023-03-08 14:21:33 +01:00
const pie = b . option ( bool , " pie " , " Produce a Position Independent Executable " ) ;
2025-01-16 10:09:41 +00:00
const value_interpret_mode = b . option ( ValueInterpretMode , " value-interpret-mode " , " How the compiler translates between 'std.builtin' types and its internal datastructures " ) orelse . direct ;
2022-06-09 15:33:04 -07:00
const value_tracing = b . option ( bool , " value-tracing " , " Enable extra state tracking to help troubleshoot bugs in the compiler (using the std.debug.Trace API) " ) orelse false ;
2020-09-16 17:17:37 -07:00
2021-05-03 20:42:36 -07:00
const mem_leak_frames : u32 = b . option ( u32 , " mem-leak-frames " , " How many stack frames to print when a memory leak occurs. Tests get 2x this amount. " ) orelse blk : {
2022-11-04 18:35:04 -07:00
if ( strip == true ) break : blk @as ( u32 , 0 ) ;
2023-01-30 21:39:43 -07:00
if ( optimize != . Debug ) break : blk 0 ;
2021-05-03 20:42:36 -07:00
break : blk 4 ;
} ;
zig build system: change target, compilation, and module APIs
Introduce the concept of "target query" and "resolved target". A target
query is what the user specifies, with some things left to default. A
resolved target has the default things discovered and populated.
In the future, std.zig.CrossTarget will be rename to std.Target.Query.
Introduces `std.Build.resolveTargetQuery` to get from one to the other.
The concept of `main_mod_path` is gone, no longer supported. You have to
put the root source file at the module root now.
* remove deprecated API
* update build.zig for the breaking API changes in this branch
* move std.Build.Step.Compile.BuildId to std.zig.BuildId
* add more options to std.Build.ExecutableOptions, std.Build.ObjectOptions,
std.Build.SharedLibraryOptions, std.Build.StaticLibraryOptions, and
std.Build.TestOptions.
* remove `std.Build.constructCMacro`. There is no use for this API.
* deprecate `std.Build.Step.Compile.defineCMacro`. Instead,
`std.Build.Module.addCMacro` is provided.
- remove `std.Build.Step.Compile.defineCMacroRaw`.
* deprecate `std.Build.Step.Compile.linkFrameworkNeeded`
- use `std.Build.Module.linkFramework`
* deprecate `std.Build.Step.Compile.linkFrameworkWeak`
- use `std.Build.Module.linkFramework`
* move more logic into `std.Build.Module`
* allow `target` and `optimize` to be `null` when creating a Module.
Along with other fields, those unspecified options will be inherited
from parent `Module` when inserted into an import table.
* the `target` field of `addExecutable` is now required. pass `b.host`
to get the host target.
2023-12-02 21:51:34 -07:00
const exe = addCompilerStep ( b , . {
. optimize = optimize ,
. target = target ,
. strip = strip ,
2024-07-16 17:26:41 -07:00
. valgrind = valgrind ,
zig build system: change target, compilation, and module APIs
Introduce the concept of "target query" and "resolved target". A target
query is what the user specifies, with some things left to default. A
resolved target has the default things discovered and populated.
In the future, std.zig.CrossTarget will be rename to std.Target.Query.
Introduces `std.Build.resolveTargetQuery` to get from one to the other.
The concept of `main_mod_path` is gone, no longer supported. You have to
put the root source file at the module root now.
* remove deprecated API
* update build.zig for the breaking API changes in this branch
* move std.Build.Step.Compile.BuildId to std.zig.BuildId
* add more options to std.Build.ExecutableOptions, std.Build.ObjectOptions,
std.Build.SharedLibraryOptions, std.Build.StaticLibraryOptions, and
std.Build.TestOptions.
* remove `std.Build.constructCMacro`. There is no use for this API.
* deprecate `std.Build.Step.Compile.defineCMacro`. Instead,
`std.Build.Module.addCMacro` is provided.
- remove `std.Build.Step.Compile.defineCMacroRaw`.
* deprecate `std.Build.Step.Compile.linkFrameworkNeeded`
- use `std.Build.Module.linkFramework`
* deprecate `std.Build.Step.Compile.linkFrameworkWeak`
- use `std.Build.Module.linkFramework`
* move more logic into `std.Build.Module`
* allow `target` and `optimize` to be `null` when creating a Module.
Along with other fields, those unspecified options will be inherited
from parent `Module` when inserted into an import table.
* the `target` field of `addExecutable` is now required. pass `b.host`
to get the host target.
2023-12-02 21:51:34 -07:00
. sanitize_thread = sanitize_thread ,
. single_threaded = single_threaded ,
} ) ;
2023-03-08 14:21:33 +01:00
exe . pie = pie ;
2023-03-16 20:41:46 +01:00
exe . entitlements = entitlements ;
2025-08-30 12:08:18 -04:00
exe . use_new_linker = b . option ( bool , " new-linker " , " Use the new linker " ) ;
2023-04-25 16:57:43 +03:00
2025-06-13 12:01:59 -04:00
const use_llvm = b . option ( bool , " use-llvm " , " Use the llvm backend " ) ;
exe . use_llvm = use_llvm ;
exe . use_lld = use_llvm ;
2023-09-14 22:49:30 +01:00
if ( no_bin ) {
b . getInstallStep ( ) . dependOn ( & exe . step ) ;
} else {
2023-08-02 15:19:26 -07:00
const install_exe = b . addInstallArtifact ( exe , . {
. dest_dir = if ( flat ) . { . override = . prefix } else . default ,
} ) ;
2023-07-21 20:29:42 -07:00
b . getInstallStep ( ) . dependOn ( & install_exe . step ) ;
}
2022-12-01 16:34:15 -07:00
2023-04-13 16:44:45 -07:00
test_step . dependOn ( & exe . step ) ;
2022-02-16 13:50:47 -07:00
2021-08-27 00:53:23 +01:00
const exe_options = b . addOptions ( ) ;
zig build system: change target, compilation, and module APIs
Introduce the concept of "target query" and "resolved target". A target
query is what the user specifies, with some things left to default. A
resolved target has the default things discovered and populated.
In the future, std.zig.CrossTarget will be rename to std.Target.Query.
Introduces `std.Build.resolveTargetQuery` to get from one to the other.
The concept of `main_mod_path` is gone, no longer supported. You have to
put the root source file at the module root now.
* remove deprecated API
* update build.zig for the breaking API changes in this branch
* move std.Build.Step.Compile.BuildId to std.zig.BuildId
* add more options to std.Build.ExecutableOptions, std.Build.ObjectOptions,
std.Build.SharedLibraryOptions, std.Build.StaticLibraryOptions, and
std.Build.TestOptions.
* remove `std.Build.constructCMacro`. There is no use for this API.
* deprecate `std.Build.Step.Compile.defineCMacro`. Instead,
`std.Build.Module.addCMacro` is provided.
- remove `std.Build.Step.Compile.defineCMacroRaw`.
* deprecate `std.Build.Step.Compile.linkFrameworkNeeded`
- use `std.Build.Module.linkFramework`
* deprecate `std.Build.Step.Compile.linkFrameworkWeak`
- use `std.Build.Module.linkFramework`
* move more logic into `std.Build.Module`
* allow `target` and `optimize` to be `null` when creating a Module.
Along with other fields, those unspecified options will be inherited
from parent `Module` when inserted into an import table.
* the `target` field of `addExecutable` is now required. pass `b.host`
to get the host target.
2023-12-02 21:51:34 -07:00
exe . root_module . addOptions ( " build_options " , exe_options ) ;
2021-08-27 00:53:23 +01:00
exe_options . addOption ( u32 , " mem_leak_frames " , mem_leak_frames ) ;
exe_options . addOption ( bool , " skip_non_native " , skip_non_native ) ;
exe_options . addOption ( bool , " have_llvm " , enable_llvm ) ;
2021-08-31 22:50:10 -07:00
exe_options . addOption ( bool , " llvm_has_m68k " , llvm_has_m68k ) ;
exe_options . addOption ( bool , " llvm_has_csky " , llvm_has_csky ) ;
exe_options . addOption ( bool , " llvm_has_arc " , llvm_has_arc ) ;
2023-01-26 16:33:40 -07:00
exe_options . addOption ( bool , " llvm_has_xtensa " , llvm_has_xtensa ) ;
2025-02-06 17:41:50 -08:00
exe_options . addOption ( bool , " debug_gpa " , debug_gpa ) ;
2024-07-19 01:04:59 -04:00
exe_options . addOption ( DevEnv , " dev " , b . option ( DevEnv , " dev " , " Build a compiler with a reduced feature set for development of specific features " ) orelse if ( only_c ) . bootstrap else . full ) ;
2025-01-16 10:09:41 +00:00
exe_options . addOption ( ValueInterpretMode , " value_interpret_mode " , value_interpret_mode ) ;
2021-08-27 00:53:23 +01:00
2020-09-08 11:15:32 -07:00
if ( link_libc ) {
2024-12-15 18:09:38 +00:00
exe . root_module . link_libc = true ;
2020-09-08 11:15:32 -07:00
}
2023-01-30 21:39:43 -07:00
const is_debug = optimize == . Debug ;
2024-03-01 16:46:48 +01:00
const enable_debug_extensions = b . option ( bool , " debug-extensions " , " Enable commands and options useful for debugging the compiler " ) orelse is_debug ;
2022-01-31 21:11:41 -07:00
const enable_logging = b . option ( bool , " log " , " Enable debug logging with --debug-log " ) orelse is_debug ;
2021-10-14 13:50:10 +02:00
const enable_link_snapshots = b . option ( bool , " link-snapshot " , " Whether to enable linker state snapshots " ) orelse false ;
2020-09-08 11:15:32 -07:00
const opt_version_string = b . option ( [ ] const u8 , " version-string " , " Override Zig version string. Default is to find out with git. " ) ;
2022-12-01 16:34:15 -07:00
const version_slice = if ( opt_version_string ) | version | version else v : {
2022-02-03 15:27:01 -07:00
if ( ! std . process . can_spawn ) {
std . debug . print ( " error: version info cannot be retrieved from git. Zig version must be provided using -Dversion-string \n " , . { } ) ;
std . process . exit ( 1 ) ;
}
2022-02-16 13:50:47 -07:00
const version_string = b . fmt ( " {d}.{d}.{d} " , . { zig_version . major , zig_version . minor , zig_version . patch } ) ;
2020-09-08 11:15:32 -07:00
var code : u8 = undefined ;
2023-10-19 22:36:11 +02:00
const git_describe_untrimmed = b . runAllowFail ( & [ _ ] [ ] const u8 {
2023-12-18 14:43:07 -07:00
" git " ,
2025-03-08 12:27:43 -08:00
" -C " , b . build_root . path orelse " . " , // affects the --git-dir argument
" --git-dir " , " .git " , // affected by the -C argument
" describe " , " --match " , " *.*.* " , //
" --tags " , " --abbrev=9 " ,
2020-09-08 11:15:32 -07:00
} , & code , . Ignore ) catch {
break : v version_string ;
} ;
2021-01-01 21:01:51 -07:00
const git_describe = mem . trim ( u8 , git_describe_untrimmed , " \n \r " ) ;
2025-10-03 14:22:11 -07:00
switch ( mem . countScalar ( u8 , git_describe , '-' ) ) {
2021-01-01 21:01:51 -07:00
0 = > {
2022-10-31 10:24:38 -07:00
// Tagged release version (e.g. 0.10.0).
2021-01-01 21:01:51 -07:00
if ( ! mem . eql ( u8 , git_describe , version_string ) ) {
2020-11-26 13:28:38 +01:00
std . debug . print ( " Zig version '{s}' does not match Git tag '{s}' \n " , . { version_string , git_describe } ) ;
2021-01-01 21:01:51 -07:00
std . process . exit ( 1 ) ;
}
break : v version_string ;
} ,
2 = > {
2022-10-31 10:24:38 -07:00
// Untagged development build (e.g. 0.10.0-dev.2025+ecf0050a9).
2023-05-04 18:15:50 -07:00
var it = mem . splitScalar ( u8 , git_describe , '-' ) ;
2022-07-25 21:04:30 +02:00
const tagged_ancestor = it . first ( ) ;
const commit_height = it . next ( ) .? ;
const commit_id = it . next ( ) .? ;
2021-01-01 21:01:51 -07:00
2023-02-21 18:39:22 +01:00
const ancestor_ver = try std . SemanticVersion . parse ( tagged_ancestor ) ;
2021-01-01 21:01:51 -07:00
if ( zig_version . order ( ancestor_ver ) != . gt ) {
2025-06-27 20:05:22 -07:00
std . debug . print ( " Zig version '{f}' must be greater than tagged ancestor '{f}' \n " , . { zig_version , ancestor_ver } ) ;
2021-01-01 21:01:51 -07:00
std . process . exit ( 1 ) ;
}
// Check that the commit hash is prefixed with a 'g' (a Git convention).
if ( commit_id . len < 1 or commit_id [ 0 ] != 'g' ) {
2020-11-26 13:28:38 +01:00
std . debug . print ( " Unexpected `git describe` output: {s} \n " , . { git_describe } ) ;
2021-01-01 21:01:51 -07:00
break : v version_string ;
}
// The version is reformatted in accordance with the https://semver.org specification.
2020-11-26 13:28:38 +01:00
break : v b . fmt ( " {s}-dev.{s}+{s} " , . { version_string , commit_height , commit_id [ 1 .. ] } ) ;
2021-01-01 21:01:51 -07:00
} ,
else = > {
2020-11-26 13:28:38 +01:00
std . debug . print ( " Unexpected `git describe` output: {s} \n " , . { git_describe } ) ;
2021-01-01 21:01:51 -07:00
break : v version_string ;
} ,
2020-09-08 11:15:32 -07:00
}
} ;
2022-12-01 16:34:15 -07:00
const version = try b . allocator . dupeZ ( u8 , version_slice ) ;
exe_options . addOption ( [ : 0 ] const u8 , " version " , version ) ;
ability to build stage1 using only a zig tarball
The main idea here is that there are now 2 ways to get a stage1 zig
binary:
* The cmake path. Requirements: cmake, system C++ compiler, system
LLVM, LLD, Clang libraries, compiled by the system C++ compiler.
* The zig path. Requirements: a zig installation, system LLVM, LLD,
Clang libraries, compiled by the zig installation.
Note that the former can be used to now take the latter path.
Removed config.h.in and config.zig.in. The build.zig script no longer is
coupled to the cmake script.
cmake no longer tries to determine the zig version. A build with cmake
will yield a stage1 zig binary that reports 0.0.0+zig0. This is going to
get reverted.
`zig build` now accepts `-Dstage1` which will build the stage1 compiler,
and put the stage2 backend behind a feature flag.
build.zig is simplified to only support the use case of enabling LLVM
support when the LLVM, LLD, and Clang libraries were built by zig. This
part is probably sadly going to have to get reverted to make package
maintainers happy.
Zig build system addBuildOption supports a couple new types.
The biggest reason to make this change is that the zig path is an
attractive option for doing compiler development work on Windows. It
allows people to work on the compiler without having MSVC installed,
using only a .zip file that contains Zig + LLVM/LLD/Clang libraries.
2020-12-04 21:33:29 -07:00
2022-02-16 13:50:47 -07:00
if ( enable_llvm ) {
2022-07-15 17:25:38 -07:00
const cmake_cfg = if ( static_llvm ) null else blk : {
if ( findConfigH ( b , config_h_path_option ) ) | config_h_path | {
2025-08-29 20:34:20 -07:00
const file_contents = fs . cwd ( ) . readFileAlloc ( config_h_path , b . allocator , . limited ( max_config_h_bytes ) ) catch unreachable ;
2022-07-15 17:25:38 -07:00
break : blk parseConfigH ( b , file_contents ) ;
} else {
std . log . warn ( " config.h could not be located automatically. Consider providing it explicitly via \" -Dconfig_h \" " , . { } ) ;
break : blk null ;
}
} ;
2022-02-16 13:50:47 -07:00
if ( cmake_cfg ) | cfg | {
// Inside this code path, we have to coordinate with system packaged LLVM, Clang, and LLD.
// That means we also have to rely on stage1 compiled c++ files. We parse config.h to find
// the information passed on to us from cmake.
if ( cfg . cmake_prefix_path . len > 0 ) {
2023-05-04 18:05:40 -07:00
var it = mem . tokenizeScalar ( u8 , cfg . cmake_prefix_path , ';' ) ;
2022-10-11 08:16:27 -07:00
while ( it . next ( ) ) | path | {
b . addSearchPrefix ( path ) ;
}
2022-02-16 13:50:47 -07:00
}
try addCmakeCfgOptionsToExe ( b , cfg , exe , use_zig_libcxx ) ;
} else {
// Here we are -Denable-llvm but no cmake integration.
2025-03-26 23:19:35 +01:00
try addStaticLlvmOptionsToModule ( exe . root_module , . {
. llvm_has_m68k = llvm_has_m68k ,
. llvm_has_csky = llvm_has_csky ,
. llvm_has_arc = llvm_has_arc ,
. llvm_has_xtensa = llvm_has_xtensa ,
} ) ;
2022-02-16 13:50:47 -07:00
}
2023-12-05 16:09:07 -07:00
if ( target . result . os . tag == . windows ) {
compiler: rework type resolution, fully resolve all types
I'm so sorry.
This commit was just meant to be making all types fully resolve by
queueing resolution at the moment of their creation. Unfortunately, a
lot of dominoes ended up falling. Here's what happened:
* I added a work queue job to fully resolve a type.
* I realised that from here we could eliminate `Sema.types_to_resolve`
if we made function codegen a separate job. This is desirable for
simplicity of both spec and implementation.
* This led to a new AIR traversal to detect whether any required type is
unresolved. If a type in the AIR failed to resolve, then we can't run
codegen.
* Because full type resolution now occurs by the work queue job, a bug
was exposed whereby error messages for type resolution were associated
with the wrong `Decl`, resulting in duplicate error messages when the
type was also resolved "by" its owner `Decl` (which really *all*
resolution should be done on).
* A correct fix for this requires using a different `Sema` when
performing type resolution: we need a `Sema` owned by the type. Also
note that this fix is necessary for incremental compilation.
* This means a whole bunch of functions no longer need to take `Sema`s.
* First-order effects: `resolveTypeFields`, `resolveTypeLayout`, etc
* Second-order effects: `Type.abiAlignmentAdvanced`, `Value.orderAgainstZeroAdvanced`, etc
The end result of this is, in short, a more correct compiler and a
simpler language specification. This regressed a few error notes in the
test cases, but nothing that seems worth blocking this change.
Oh, also, I ripped out the old code in `test/src/Cases.zig` which
introduced a dependency on `Compilation`. This dependency was
problematic at best, and this code has been unused for a while. When we
re-enable incremental test cases, we must rewrite their executor to use
the compiler server protocol.
2024-07-04 05:00:32 +01:00
// LLVM depends on networking as of version 18.
2024-12-15 18:09:38 +00:00
exe . root_module . linkSystemLibrary ( " ws2_32 " , . { } ) ;
2024-04-29 16:57:40 -07:00
2024-12-15 18:09:38 +00:00
exe . root_module . linkSystemLibrary ( " version " , . { } ) ;
exe . root_module . linkSystemLibrary ( " uuid " , . { } ) ;
exe . root_module . linkSystemLibrary ( " ole32 " , . { } ) ;
2022-12-07 01:50:49 -08:00
}
2022-02-16 13:50:47 -07:00
}
ability to build stage1 using only a zig tarball
The main idea here is that there are now 2 ways to get a stage1 zig
binary:
* The cmake path. Requirements: cmake, system C++ compiler, system
LLVM, LLD, Clang libraries, compiled by the system C++ compiler.
* The zig path. Requirements: a zig installation, system LLVM, LLD,
Clang libraries, compiled by the zig installation.
Note that the former can be used to now take the latter path.
Removed config.h.in and config.zig.in. The build.zig script no longer is
coupled to the cmake script.
cmake no longer tries to determine the zig version. A build with cmake
will yield a stage1 zig binary that reports 0.0.0+zig0. This is going to
get reverted.
`zig build` now accepts `-Dstage1` which will build the stage1 compiler,
and put the stage2 backend behind a feature flag.
build.zig is simplified to only support the use case of enabling LLVM
support when the LLVM, LLD, and Clang libraries were built by zig. This
part is probably sadly going to have to get reverted to make package
maintainers happy.
Zig build system addBuildOption supports a couple new types.
The biggest reason to make this change is that the zig path is an
attractive option for doing compiler development work on Windows. It
allows people to work on the compiler without having MSVC installed,
using only a .zip file that contains Zig + LLVM/LLD/Clang libraries.
2020-12-04 21:33:29 -07:00
const semver = try std . SemanticVersion . parse ( version ) ;
2021-08-27 00:53:23 +01:00
exe_options . addOption ( std . SemanticVersion , " semver " , semver ) ;
2020-09-08 11:15:32 -07:00
2024-03-01 16:46:48 +01:00
exe_options . addOption ( bool , " enable_debug_extensions " , enable_debug_extensions ) ;
2021-08-27 00:53:23 +01:00
exe_options . addOption ( bool , " enable_logging " , enable_logging ) ;
2021-10-14 13:50:10 +02:00
exe_options . addOption ( bool , " enable_link_snapshots " , enable_link_snapshots ) ;
2021-08-27 00:53:23 +01:00
exe_options . addOption ( bool , " enable_tracy " , tracy != null ) ;
2021-10-31 14:12:36 +00:00
exe_options . addOption ( bool , " enable_tracy_callstack " , tracy_callstack ) ;
2021-10-31 14:16:59 +00:00
exe_options . addOption ( bool , " enable_tracy_allocation " , tracy_allocation ) ;
2024-11-29 13:13:06 -07:00
exe_options . addOption ( u32 , " tracy_callstack_depth " , tracy_callstack_depth ) ;
2022-06-09 15:33:04 -07:00
exe_options . addOption ( bool , " value_tracing " , value_tracing ) ;
2020-09-08 11:15:32 -07:00
if ( tracy ) | tracy_path | {
2023-07-19 10:49:34 +02:00
const client_cpp = b . pathJoin (
2022-10-26 18:17:49 -07:00
& [ _ ] [ ] const u8 { tracy_path , " public " , " TracyClient.cpp " } ,
2023-07-19 10:49:34 +02:00
) ;
2021-09-16 16:51:29 -05:00
2025-03-26 22:47:59 +01:00
const tracy_c_flags : [ ] const [ ] const u8 = & . { " -DTRACY_ENABLE=1 " , " -fno-sanitize=undefined " } ;
2021-09-16 16:51:29 -05:00
2024-12-15 18:09:38 +00:00
exe . root_module . addIncludePath ( . { . cwd_relative = tracy_path } ) ;
exe . root_module . addCSourceFile ( . { . file = . { . cwd_relative = client_cpp } , . flags = tracy_c_flags } ) ;
2020-09-16 17:17:37 -07:00
if ( ! enable_llvm ) {
zig build system: change target, compilation, and module APIs
Introduce the concept of "target query" and "resolved target". A target
query is what the user specifies, with some things left to default. A
resolved target has the default things discovered and populated.
In the future, std.zig.CrossTarget will be rename to std.Target.Query.
Introduces `std.Build.resolveTargetQuery` to get from one to the other.
The concept of `main_mod_path` is gone, no longer supported. You have to
put the root source file at the module root now.
* remove deprecated API
* update build.zig for the breaking API changes in this branch
* move std.Build.Step.Compile.BuildId to std.zig.BuildId
* add more options to std.Build.ExecutableOptions, std.Build.ObjectOptions,
std.Build.SharedLibraryOptions, std.Build.StaticLibraryOptions, and
std.Build.TestOptions.
* remove `std.Build.constructCMacro`. There is no use for this API.
* deprecate `std.Build.Step.Compile.defineCMacro`. Instead,
`std.Build.Module.addCMacro` is provided.
- remove `std.Build.Step.Compile.defineCMacroRaw`.
* deprecate `std.Build.Step.Compile.linkFrameworkNeeded`
- use `std.Build.Module.linkFramework`
* deprecate `std.Build.Step.Compile.linkFrameworkWeak`
- use `std.Build.Module.linkFramework`
* move more logic into `std.Build.Module`
* allow `target` and `optimize` to be `null` when creating a Module.
Along with other fields, those unspecified options will be inherited
from parent `Module` when inserted into an import table.
* the `target` field of `addExecutable` is now required. pass `b.host`
to get the host target.
2023-12-02 21:51:34 -07:00
exe . root_module . linkSystemLibrary ( " c++ " , . { . use_pkg_config = . no } ) ;
2020-09-16 17:17:37 -07:00
}
2024-12-15 18:09:38 +00:00
exe . root_module . link_libc = true ;
2021-09-16 16:51:29 -05:00
2023-12-05 16:09:07 -07:00
if ( target . result . os . tag == . windows ) {
2024-12-15 18:09:38 +00:00
exe . root_module . linkSystemLibrary ( " dbghelp " , . { } ) ;
exe . root_module . linkSystemLibrary ( " ws2_32 " , . { } ) ;
2021-09-16 16:51:29 -05:00
}
2020-09-08 11:15:32 -07:00
}
2024-02-25 14:04:06 +01:00
const test_filters = b . option ( [ ] const [ ] const u8 , " test-filter " , " Skip tests that do not match any filter " ) orelse & [ 0 ] [ ] const u8 { } ;
2024-08-13 23:59:50 +02:00
const test_target_filters = b . option ( [ ] const [ ] const u8 , " test-target-filter " , " Skip tests whose target triple do not match any filter " ) orelse & [ 0 ] [ ] const u8 { } ;
2025-03-21 23:00:14 +01:00
const test_extra_targets = b . option ( bool , " test-extra-targets " , " Enable running module tests for additional targets " ) orelse false ;
2017-04-19 01:13:15 -04:00
2023-08-09 13:39:34 -05:00
var chosen_opt_modes_buf : [ 4 ] builtin . OptimizeMode = undefined ;
2018-09-12 14:50:26 -04:00
var chosen_mode_index : usize = 0 ;
2021-04-24 16:39:26 -04:00
if ( ! skip_debug ) {
2023-08-09 13:39:34 -05:00
chosen_opt_modes_buf [ chosen_mode_index ] = builtin . OptimizeMode . Debug ;
2021-04-24 16:39:26 -04:00
chosen_mode_index += 1 ;
}
2018-09-12 14:50:26 -04:00
if ( ! skip_release_safe ) {
2023-08-09 13:39:34 -05:00
chosen_opt_modes_buf [ chosen_mode_index ] = builtin . OptimizeMode . ReleaseSafe ;
2018-09-12 14:50:26 -04:00
chosen_mode_index += 1 ;
}
if ( ! skip_release_fast ) {
2023-08-09 13:39:34 -05:00
chosen_opt_modes_buf [ chosen_mode_index ] = builtin . OptimizeMode . ReleaseFast ;
2018-09-12 14:50:26 -04:00
chosen_mode_index += 1 ;
}
if ( ! skip_release_small ) {
2023-08-09 13:39:34 -05:00
chosen_opt_modes_buf [ chosen_mode_index ] = builtin . OptimizeMode . ReleaseSmall ;
2018-09-12 14:50:26 -04:00
chosen_mode_index += 1 ;
}
2023-01-30 21:39:43 -07:00
const optimization_modes = chosen_opt_modes_buf [ 0 .. chosen_mode_index ] ;
2017-11-07 03:22:27 -05:00
2024-06-16 19:31:59 -07:00
const fmt_include_paths = & . { " lib " , " src " , " test " , " tools " , " build.zig " , " build.zig.zon " } ;
2024-11-04 14:03:36 -08:00
const fmt_exclude_paths = & . { " test/cases " , " test/behavior/zon " } ;
zig build: many enhancements related to parallel building
Rework std.Build.Step to have an `owner: *Build` field. This
simplified the implementation of installation steps, as well as provided
some much-needed common API for the new parallelized build system.
--verbose is now defined very concretely: it prints to stderr just
before spawning a child process.
Child process execution is updated to conform to the new
parallel-friendly make() function semantics.
DRY up the failWithCacheError handling code. It now integrates properly
with the step graph instead of incorrectly dumping to stderr and calling
process exit.
In the main CLI, fix `zig fmt` crash when there are no errors and stdin
is used.
Deleted steps:
* EmulatableRunStep - this entire thing can be removed in favor of a
flag added to std.Build.RunStep called `skip_foreign_checks`.
* LogStep - this doesn't really fit with a multi-threaded build runner
and is effectively superseded by the new build summary output.
build runner:
* add -fsummary and -fno-summary to override the default behavior,
which is to print a summary if any of the build steps fail.
* print the dep prefix when emitting error messages for steps.
std.Build.FmtStep:
* This step now supports exclude paths as well as a check flag.
* The check flag decides between two modes, modify mode, and check
mode. These can be used to update source files in place, or to fail
the build, respectively.
Zig's own build.zig:
* The `test-fmt` step will do all the `zig fmt` checking that we expect
to be done. Since the `test` step depends on this one, we can simply
remove the explicit call to `zig fmt` in the CI.
* The new `fmt` step will actually perform `zig fmt` and update source
files in place.
std.Build.RunStep:
* expose max_stdio_size is a field (previously an unchangeable
hard-coded value).
* rework the API. Instead of configuring each stream independently,
there is a `stdio` field where you can choose between
`infer_from_args`, `inherit`, or `check`. These determine whether the
RunStep is considered to have side-effects or not. The previous
field, `condition` is gone.
* when stdio mode is set to `check` there is a slice of any number of
checks to make, which include things like exit code, stderr matching,
or stdout matching.
* remove the ill-defined `print` field.
* when adding an output arg, it takes the opportunity to give itself a
better name.
* The flag `skip_foreign_checks` is added. If this is true, a RunStep
which is configured to check the output of the executed binary will
not fail the build if the binary cannot be executed due to being for
a foreign binary to the host system which is running the build graph.
Command-line arguments such as -fqemu and -fwasmtime may affect
whether a binary is detected as foreign, as well as system
configuration such as Rosetta (macOS) and binfmt_misc (Linux).
- This makes EmulatableRunStep no longer needed.
* Fix the child process handling to properly integrate with the new
bulid API and to avoid deadlocks in stdout/stderr streams by polling
if necessary.
std.Build.RemoveDirStep now uses the open build_root directory handle
instead of an absolute path.
2023-03-01 22:56:37 -07:00
const do_fmt = b . addFmt ( . {
. paths = fmt_include_paths ,
. exclude_paths = fmt_exclude_paths ,
} ) ;
2024-06-16 19:31:59 -07:00
b . step ( " fmt " , " Modify source files in place to have conforming formatting " ) . dependOn ( & do_fmt . step ) ;
2021-05-13 11:03:44 +02:00
2024-06-16 19:31:59 -07:00
const check_fmt = b . step ( " test-fmt " , " Check source files having conforming formatting " ) ;
check_fmt . dependOn ( & b . addFmt ( . {
re-enable test-cases and get them all passing
Instead of using `zig test` to build a special version of the compiler
that runs all the test-cases, the zig build system is now used as much
as possible - all with the basic steps found in the standard library.
For incremental compilation tests (the ones that look like foo.0.zig,
foo.1.zig, foo.2.zig, etc.), a special version of the compiler is
compiled into a utility executable called "check-case" which checks
exactly one sequence of incremental updates in an independent
subprocess. Previously, all incremental and non-incremental test cases
were done in the same test runner process.
The compile error checking code is now simpler, but also a bit
rudimentary, and so it additionally makes sure that the actual compile
errors do not include *extra* messages, and it makes sure that the
actual compile errors output in the same order as expected. It is also
based on the "ends-with" property of each line rather than the previous
logic, which frankly I didn't want to touch with a ten-meter pole. The
compile error test cases have been updated to pass in light of these
differences.
Previously, 'error' mode with 0 compile errors was used to shoehorn in a
different kind of test-case - one that only checks if a piece of code
compiles without errors. Now there is a 'compile' mode of test-cases,
and 'error' must be only used when there are greater than 0 errors.
link test cases are updated to omit the target object format argument
when calling checkObject since that is no longer needed.
The test/stage2 directory is removed; the 2 files within are moved to be
directly in the test/ directory.
2023-03-09 18:22:51 -07:00
. paths = fmt_include_paths ,
. exclude_paths = fmt_exclude_paths ,
. check = true ,
} ) . step ) ;
2024-06-16 19:31:59 -07:00
test_step . dependOn ( check_fmt ) ;
2021-05-13 11:03:44 +02:00
re-enable test-cases and get them all passing
Instead of using `zig test` to build a special version of the compiler
that runs all the test-cases, the zig build system is now used as much
as possible - all with the basic steps found in the standard library.
For incremental compilation tests (the ones that look like foo.0.zig,
foo.1.zig, foo.2.zig, etc.), a special version of the compiler is
compiled into a utility executable called "check-case" which checks
exactly one sequence of incremental updates in an independent
subprocess. Previously, all incremental and non-incremental test cases
were done in the same test runner process.
The compile error checking code is now simpler, but also a bit
rudimentary, and so it additionally makes sure that the actual compile
errors do not include *extra* messages, and it makes sure that the
actual compile errors output in the same order as expected. It is also
based on the "ends-with" property of each line rather than the previous
logic, which frankly I didn't want to touch with a ten-meter pole. The
compile error test cases have been updated to pass in light of these
differences.
Previously, 'error' mode with 0 compile errors was used to shoehorn in a
different kind of test-case - one that only checks if a piece of code
compiles without errors. Now there is a 'compile' mode of test-cases,
and 'error' must be only used when there are greater than 0 errors.
link test cases are updated to omit the target object format argument
when calling checkObject since that is no longer needed.
The test/stage2 directory is removed; the 2 files within are moved to be
directly in the test/ directory.
2023-03-09 18:22:51 -07:00
const test_cases_step = b . step ( " test-cases " , " Run the main compiler test cases " ) ;
2025-07-17 23:18:06 -07:00
try tests . addCases ( b , test_cases_step , . {
2025-07-03 17:21:05 +02:00
. test_filters = test_filters ,
. test_target_filters = test_target_filters ,
2025-07-23 00:23:31 +02:00
. skip_compile_errors = skip_compile_errors ,
2025-07-03 17:21:05 +02:00
. skip_non_native = skip_non_native ,
. skip_freebsd = skip_freebsd ,
. skip_netbsd = skip_netbsd ,
. skip_windows = skip_windows ,
2025-11-14 22:39:12 +01:00
. skip_darwin = skip_darwin ,
2025-07-03 17:21:05 +02:00
. skip_linux = skip_linux ,
. skip_llvm = skip_llvm ,
. skip_libc = skip_libc ,
2024-03-04 17:26:41 -08:00
} , . {
2023-07-31 09:43:29 -04:00
. enable_llvm = enable_llvm ,
. llvm_has_m68k = llvm_has_m68k ,
. llvm_has_csky = llvm_has_csky ,
. llvm_has_arc = llvm_has_arc ,
. llvm_has_xtensa = llvm_has_xtensa ,
} ) ;
2023-04-13 16:44:45 -07:00
test_step . dependOn ( test_cases_step ) ;
zig build: many enhancements related to parallel building
Rework std.Build.Step to have an `owner: *Build` field. This
simplified the implementation of installation steps, as well as provided
some much-needed common API for the new parallelized build system.
--verbose is now defined very concretely: it prints to stderr just
before spawning a child process.
Child process execution is updated to conform to the new
parallel-friendly make() function semantics.
DRY up the failWithCacheError handling code. It now integrates properly
with the step graph instead of incorrectly dumping to stderr and calling
process exit.
In the main CLI, fix `zig fmt` crash when there are no errors and stdin
is used.
Deleted steps:
* EmulatableRunStep - this entire thing can be removed in favor of a
flag added to std.Build.RunStep called `skip_foreign_checks`.
* LogStep - this doesn't really fit with a multi-threaded build runner
and is effectively superseded by the new build summary output.
build runner:
* add -fsummary and -fno-summary to override the default behavior,
which is to print a summary if any of the build steps fail.
* print the dep prefix when emitting error messages for steps.
std.Build.FmtStep:
* This step now supports exclude paths as well as a check flag.
* The check flag decides between two modes, modify mode, and check
mode. These can be used to update source files in place, or to fail
the build, respectively.
Zig's own build.zig:
* The `test-fmt` step will do all the `zig fmt` checking that we expect
to be done. Since the `test` step depends on this one, we can simply
remove the explicit call to `zig fmt` in the CI.
* The new `fmt` step will actually perform `zig fmt` and update source
files in place.
std.Build.RunStep:
* expose max_stdio_size is a field (previously an unchangeable
hard-coded value).
* rework the API. Instead of configuring each stream independently,
there is a `stdio` field where you can choose between
`infer_from_args`, `inherit`, or `check`. These determine whether the
RunStep is considered to have side-effects or not. The previous
field, `condition` is gone.
* when stdio mode is set to `check` there is a slice of any number of
checks to make, which include things like exit code, stderr matching,
or stdout matching.
* remove the ill-defined `print` field.
* when adding an output arg, it takes the opportunity to give itself a
better name.
* The flag `skip_foreign_checks` is added. If this is true, a RunStep
which is configured to check the output of the executed binary will
not fail the build if the binary cannot be executed due to being for
a foreign binary to the host system which is running the build graph.
Command-line arguments such as -fqemu and -fwasmtime may affect
whether a binary is detected as foreign, as well as system
configuration such as Rosetta (macOS) and binfmt_misc (Linux).
- This makes EmulatableRunStep no longer needed.
* Fix the child process handling to properly integrate with the new
bulid API and to avoid deadlocks in stdout/stderr streams by polling
if necessary.
std.Build.RemoveDirStep now uses the open build_root directory handle
instead of an absolute path.
2023-03-01 22:56:37 -07:00
2024-08-14 00:22:58 +02:00
const test_modules_step = b . step ( " test-modules " , " Run the per-target module tests " ) ;
2025-01-09 21:49:32 -08:00
test_step . dependOn ( test_modules_step ) ;
2024-08-14 00:22:58 +02:00
test_modules_step . dependOn ( tests . addModuleTests ( b , . {
2024-02-25 14:04:06 +01:00
. test_filters = test_filters ,
2024-08-13 23:59:50 +02:00
. test_target_filters = test_target_filters ,
2025-03-21 23:00:14 +01:00
. test_extra_targets = test_extra_targets ,
2023-03-06 00:27:46 -07:00
. root_src = " test/behavior.zig " ,
. name = " behavior " ,
. desc = " Run the behavior tests " ,
. optimize_modes = optimization_modes ,
2024-02-20 10:15:10 +01:00
. include_paths = & . { } ,
2023-03-06 00:27:46 -07:00
. skip_single_threaded = skip_single_threaded ,
. skip_non_native = skip_non_native ,
2025-10-09 09:59:55 -07:00
. test_default_only = no_matrix ,
2025-06-06 12:50:14 -07:00
. skip_freebsd = skip_freebsd ,
. skip_netbsd = skip_netbsd ,
. skip_windows = skip_windows ,
2025-11-14 22:39:12 +01:00
. skip_darwin = skip_darwin ,
2025-06-06 12:50:14 -07:00
. skip_linux = skip_linux ,
2025-06-06 23:34:52 -07:00
. skip_llvm = skip_llvm ,
2023-03-06 00:27:46 -07:00
. skip_libc = skip_libc ,
2025-07-07 11:36:03 -07:00
// 3888779264 was observed on an x86_64-linux-gnu host.
. max_rss = 4000000000 ,
2023-03-06 00:27:46 -07:00
} ) ) ;
2024-08-14 00:22:58 +02:00
test_modules_step . dependOn ( tests . addModuleTests ( b , . {
2024-02-25 14:04:06 +01:00
. test_filters = test_filters ,
2024-08-13 23:59:50 +02:00
. test_target_filters = test_target_filters ,
2025-03-21 23:00:14 +01:00
. test_extra_targets = test_extra_targets ,
2023-03-06 00:27:46 -07:00
. root_src = " lib/compiler_rt.zig " ,
. name = " compiler-rt " ,
. desc = " Run the compiler_rt tests " ,
. optimize_modes = optimization_modes ,
2024-02-20 10:15:10 +01:00
. include_paths = & . { } ,
2023-03-06 00:27:46 -07:00
. skip_single_threaded = true ,
. skip_non_native = skip_non_native ,
2025-10-09 09:59:55 -07:00
. test_default_only = no_matrix ,
2025-06-06 12:50:14 -07:00
. skip_freebsd = skip_freebsd ,
. skip_netbsd = skip_netbsd ,
. skip_windows = skip_windows ,
2025-11-14 22:39:12 +01:00
. skip_darwin = skip_darwin ,
2025-06-06 12:50:14 -07:00
. skip_linux = skip_linux ,
2025-06-06 23:34:52 -07:00
. skip_llvm = skip_llvm ,
2023-03-06 00:27:46 -07:00
. skip_libc = true ,
2024-06-02 10:10:35 +03:00
. no_builtin = true ,
2023-03-06 00:27:46 -07:00
} ) ) ;
2024-08-14 00:22:58 +02:00
test_modules_step . dependOn ( tests . addModuleTests ( b , . {
2024-02-25 14:04:06 +01:00
. test_filters = test_filters ,
2024-08-13 23:59:50 +02:00
. test_target_filters = test_target_filters ,
2025-03-21 23:00:14 +01:00
. test_extra_targets = test_extra_targets ,
2023-03-06 00:27:46 -07:00
. root_src = " lib/c.zig " ,
2025-04-10 19:17:29 +02:00
. name = " zigc " ,
. desc = " Run the zigc tests " ,
2023-03-06 00:27:46 -07:00
. optimize_modes = optimization_modes ,
2024-02-20 10:15:10 +01:00
. include_paths = & . { } ,
2023-03-06 00:27:46 -07:00
. skip_single_threaded = true ,
. skip_non_native = skip_non_native ,
2025-10-09 09:59:55 -07:00
. test_default_only = no_matrix ,
2025-06-06 12:50:14 -07:00
. skip_freebsd = skip_freebsd ,
. skip_netbsd = skip_netbsd ,
. skip_windows = skip_windows ,
2025-11-14 22:39:12 +01:00
. skip_darwin = skip_darwin ,
2025-06-06 12:50:14 -07:00
. skip_linux = skip_linux ,
2025-06-06 23:34:52 -07:00
. skip_llvm = skip_llvm ,
2023-03-06 00:27:46 -07:00
. skip_libc = true ,
2024-06-02 10:10:35 +03:00
. no_builtin = true ,
2023-03-06 00:27:46 -07:00
} ) ) ;
2021-04-30 23:41:28 +02:00
2024-08-14 00:22:58 +02:00
test_modules_step . dependOn ( tests . addModuleTests ( b , . {
2024-02-25 14:04:06 +01:00
. test_filters = test_filters ,
2024-08-13 23:59:50 +02:00
. test_target_filters = test_target_filters ,
2025-03-21 23:00:14 +01:00
. test_extra_targets = test_extra_targets ,
2023-03-06 00:27:46 -07:00
. root_src = " lib/std/std.zig " ,
. name = " std " ,
. desc = " Run the standard library tests " ,
. optimize_modes = optimization_modes ,
2024-02-20 10:15:10 +01:00
. include_paths = & . { } ,
2023-03-06 00:27:46 -07:00
. skip_single_threaded = skip_single_threaded ,
. skip_non_native = skip_non_native ,
2025-10-09 09:59:55 -07:00
. test_default_only = no_matrix ,
2025-06-06 12:50:14 -07:00
. skip_freebsd = skip_freebsd ,
. skip_netbsd = skip_netbsd ,
. skip_windows = skip_windows ,
2025-11-14 22:39:12 +01:00
. skip_darwin = skip_darwin ,
2025-06-06 12:50:14 -07:00
. skip_linux = skip_linux ,
2025-06-06 23:34:52 -07:00
. skip_llvm = skip_llvm ,
2023-03-06 00:27:46 -07:00
. skip_libc = skip_libc ,
2025-03-27 05:36:27 +01:00
// I observed a value of 5605064704 on the M2 CI.
. max_rss = 6165571174 ,
2023-03-06 00:27:46 -07:00
} ) ) ;
2022-12-01 16:34:15 -07:00
2025-01-09 21:49:32 -08:00
const unit_tests_step = b . step ( " test-unit " , " Run the compiler source unit tests " ) ;
test_step . dependOn ( unit_tests_step ) ;
2024-11-06 22:30:46 +01:00
2025-01-09 21:49:32 -08:00
const unit_tests = b . addTest ( . {
2025-05-10 11:34:19 +01:00
. root_module = addCompilerMod ( b , . {
2025-01-09 21:49:32 -08:00
. optimize = optimize ,
. target = target ,
. single_threaded = single_threaded ,
} ) ,
. filters = test_filters ,
. use_llvm = use_llvm ,
. use_lld = use_llvm ,
. zig_lib_dir = b . path ( " lib " ) ,
} ) ;
2025-05-10 11:34:19 +01:00
if ( link_libc ) {
unit_tests . root_module . link_libc = true ;
}
2025-01-09 21:49:32 -08:00
unit_tests . root_module . addOptions ( " build_options " , exe_options ) ;
unit_tests_step . dependOn ( & b . addRunArtifact ( unit_tests ) . step ) ;
2024-08-14 00:22:58 +02:00
test_step . dependOn ( tests . addStandaloneTests (
b ,
optimization_modes ,
enable_macos_sdk ,
enable_ios_sdk ,
enable_symlinks_windows ,
) ) ;
2024-11-23 15:45:15 +01:00
test_step . dependOn ( tests . addCAbiTests ( b , . {
. test_target_filters = test_target_filters ,
. skip_non_native = skip_non_native ,
2025-06-06 12:50:14 -07:00
. skip_freebsd = skip_freebsd ,
. skip_netbsd = skip_netbsd ,
. skip_windows = skip_windows ,
2025-11-14 22:39:12 +01:00
. skip_darwin = skip_darwin ,
2025-06-06 12:50:14 -07:00
. skip_linux = skip_linux ,
2025-06-06 23:34:52 -07:00
. skip_llvm = skip_llvm ,
2024-11-23 15:45:15 +01:00
. skip_release = skip_release ,
} ) ) ;
2024-08-14 00:22:58 +02:00
test_step . dependOn ( tests . addLinkTests ( b , enable_macos_sdk , enable_ios_sdk , enable_symlinks_windows ) ) ;
tests: split up and enhance stack trace tests
Previously, the `test-stack-traces` step was essentially just testing
error traces, and even there we didn't have much coverage. This commit
solves that by splitting the "stack trace" tests into two separate
harnesses: the "stack trace" tests are for actual stack traces (i.e.
involving stack unwinding), while the "error trace" tests are
specifically for error return traces.
The "stack trace" tests will test different configurations of:
* `-lc`
* `-fPIE`
* `-fomit-frame-pointer`
* `-fllvm`
* unwind tables (currently disabled)
* strip debug info (currently disabled)
The main goal there is to test *stack unwinding* under different
conditions. Meanwhile, the "error trace" tests will test different
configurations of `-O` and `-fllvm`; the main goal here, aside from
checking that error traces themselves do not miscompile, is to check
whether debug info is still working even in optimized builds. Of course,
aggressive optimizations *can* thwart debug info no matter what, so as
before, there is a way to disable cases for specific targets / optimize
modes.
The program which converts stack traces into a more validatable format
by removing things like addresses (previously `check-stack-trace.zig`,
now `convert-stack-trace.zig`) has been rewritten and simplified. Also,
thanks to various fixes in this branch, several workarounds have become
unnecessary: for instance, we don't need to ignore the function name
printed in stack traces in release modes, because `std.debug.Dwarf` now
uses the correct DIE for inlined functions!
Neither `test-stack-traces` nor `test-error-traces` does general foreign
architecture testing, because it seems that (at least for now) external
executors often aren't particularly good at handling stack tracing
correctly (looking at you, Wine). Generally, they just test the native
target (this matches the old behavior of `test-stack-traces`). However,
there is one exception: when on an x86_64 or aarch64 host, we will also
test the 32-bit version (x86 or arm) if the OS supports it, because such
executables can be trivially tested without an external executor.
Oh, also, I wrote a bunch of stack trace tests. Previously there was,
erm, *one* test in `test-stack-traces` which wasn't for error traces.
Now there are a good few!
2025-09-09 22:45:39 +01:00
test_step . dependOn ( tests . addStackTraceTests ( b , test_filters , skip_non_native ) ) ;
test_step . dependOn ( tests . addErrorTraceTests ( b , test_filters , optimization_modes , skip_non_native ) ) ;
2024-08-14 00:22:58 +02:00
test_step . dependOn ( tests . addCliTests ( b ) ) ;
2024-08-06 11:22:37 -04:00
if ( tests . addDebuggerTests ( b , . {
. test_filters = test_filters ,
2024-11-23 18:06:27 +01:00
. test_target_filters = test_target_filters ,
2024-08-06 11:22:37 -04:00
. gdb = b . option ( [ ] const u8 , " gdb " , " path to gdb binary " ) ,
. lldb = b . option ( [ ] const u8 , " lldb " , " path to lldb binary " ) ,
. optimize_modes = optimization_modes ,
. skip_single_threaded = skip_single_threaded ,
. skip_libc = skip_libc ,
} ) ) | test_debugger_step | test_step . dependOn ( test_debugger_step ) ;
2024-11-28 16:17:02 +01:00
if ( tests . addLlvmIrTests ( b , . {
. enable_llvm = enable_llvm ,
. test_filters = test_filters ,
. test_target_filters = test_target_filters ,
} ) ) | test_llvm_ir_step | test_step . dependOn ( test_llvm_ir_step ) ;
2024-08-14 00:22:58 +02:00
2022-12-01 16:34:15 -07:00
try addWasiUpdateStep ( b , version ) ;
re-enable test-cases and get them all passing
Instead of using `zig test` to build a special version of the compiler
that runs all the test-cases, the zig build system is now used as much
as possible - all with the basic steps found in the standard library.
For incremental compilation tests (the ones that look like foo.0.zig,
foo.1.zig, foo.2.zig, etc.), a special version of the compiler is
compiled into a utility executable called "check-case" which checks
exactly one sequence of incremental updates in an independent
subprocess. Previously, all incremental and non-incremental test cases
were done in the same test runner process.
The compile error checking code is now simpler, but also a bit
rudimentary, and so it additionally makes sure that the actual compile
errors do not include *extra* messages, and it makes sure that the
actual compile errors output in the same order as expected. It is also
based on the "ends-with" property of each line rather than the previous
logic, which frankly I didn't want to touch with a ten-meter pole. The
compile error test cases have been updated to pass in light of these
differences.
Previously, 'error' mode with 0 compile errors was used to shoehorn in a
different kind of test-case - one that only checks if a piece of code
compiles without errors. Now there is a 'compile' mode of test-cases,
and 'error' must be only used when there are greater than 0 errors.
link test cases are updated to omit the target object format argument
when calling checkObject since that is no longer needed.
The test/stage2 directory is removed; the 2 files within are moved to be
directly in the test/ directory.
2023-03-09 18:22:51 -07:00
2024-01-07 18:41:26 -07:00
const update_mingw_step = b . step ( " update-mingw " , " Update zig's bundled mingw " ) ;
const opt_mingw_src_path = b . option ( [ ] const u8 , " mingw-src " , " path to mingw-w64 source directory " ) ;
if ( opt_mingw_src_path ) | mingw_src_path | {
2024-08-13 23:38:02 +02:00
const update_mingw_exe = b . addExecutable ( . {
. name = " update_mingw " ,
2024-12-15 18:09:38 +00:00
. root_module = b . createModule ( . {
. target = b . graph . host ,
. root_source_file = b . path ( " tools/update_mingw.zig " ) ,
} ) ,
2024-08-13 23:38:02 +02:00
} ) ;
const update_mingw_run = b . addRunArtifact ( update_mingw_exe ) ;
update_mingw_run . addDirectoryArg ( b . path ( " lib " ) ) ;
2024-01-07 18:41:26 -07:00
update_mingw_run . addDirectoryArg ( . { . cwd_relative = mingw_src_path } ) ;
2024-08-13 23:38:02 +02:00
update_mingw_step . dependOn ( & update_mingw_run . step ) ;
2024-01-07 18:41:26 -07:00
} else {
2024-08-13 23:38:02 +02:00
update_mingw_step . dependOn ( & b . addFail ( " The -Dmingw-src=... option is required for this step " ) . step ) ;
2024-01-07 18:41:26 -07:00
}
2024-08-20 18:09:23 +01:00
const test_incremental_step = b . step ( " test-incremental " , " Run the incremental compilation test cases " ) ;
try tests . addIncrementalTests ( b , test_incremental_step ) ;
2025-11-22 08:06:26 -08:00
if ( ! skip_test_incremental ) test_step . dependOn ( test_incremental_step ) ;
2025-08-26 21:47:59 +02:00
if ( tests . addLibcTests ( b , . {
. optimize_modes = optimization_modes ,
. test_filters = test_filters ,
. test_target_filters = test_target_filters ,
2025-10-30 17:52:05 +01:00
// Highest RSS observed in any test case was exactly 1802878976 on x86_64-linux.
. max_rss = 2253598720 ,
2025-08-26 21:47:59 +02:00
} ) ) | test_libc_step | test_step . dependOn ( test_libc_step ) ;
2022-12-01 16:34:15 -07:00
}
2023-01-31 00:19:51 -07:00
fn addWasiUpdateStep ( b : * std . Build , version : [ : 0 ] const u8 ) ! void {
2022-12-01 16:34:15 -07:00
const semver = try std . SemanticVersion . parse ( version ) ;
zig build system: change target, compilation, and module APIs
Introduce the concept of "target query" and "resolved target". A target
query is what the user specifies, with some things left to default. A
resolved target has the default things discovered and populated.
In the future, std.zig.CrossTarget will be rename to std.Target.Query.
Introduces `std.Build.resolveTargetQuery` to get from one to the other.
The concept of `main_mod_path` is gone, no longer supported. You have to
put the root source file at the module root now.
* remove deprecated API
* update build.zig for the breaking API changes in this branch
* move std.Build.Step.Compile.BuildId to std.zig.BuildId
* add more options to std.Build.ExecutableOptions, std.Build.ObjectOptions,
std.Build.SharedLibraryOptions, std.Build.StaticLibraryOptions, and
std.Build.TestOptions.
* remove `std.Build.constructCMacro`. There is no use for this API.
* deprecate `std.Build.Step.Compile.defineCMacro`. Instead,
`std.Build.Module.addCMacro` is provided.
- remove `std.Build.Step.Compile.defineCMacroRaw`.
* deprecate `std.Build.Step.Compile.linkFrameworkNeeded`
- use `std.Build.Module.linkFramework`
* deprecate `std.Build.Step.Compile.linkFrameworkWeak`
- use `std.Build.Module.linkFramework`
* move more logic into `std.Build.Module`
* allow `target` and `optimize` to be `null` when creating a Module.
Along with other fields, those unspecified options will be inherited
from parent `Module` when inserted into an import table.
* the `target` field of `addExecutable` is now required. pass `b.host`
to get the host target.
2023-12-02 21:51:34 -07:00
const exe = addCompilerStep ( b , . {
. optimize = . ReleaseSmall ,
2024-11-29 01:31:49 +01:00
. target = b . resolveTargetQuery ( std . Target . Query . parse ( . {
. arch_os_abi = " wasm32-wasi " ,
2025-01-22 02:56:53 +01:00
// * `extended_const` is not supported by the `wasm-opt` version in CI.
// * `nontrapping_bulk_memory_len0` is supported by `wasm2c`.
2025-01-22 03:44:24 +01:00
. cpu_features = " baseline-extended_const+nontrapping_bulk_memory_len0 " ,
2024-11-29 01:31:49 +01:00
} ) catch unreachable ) ,
zig build system: change target, compilation, and module APIs
Introduce the concept of "target query" and "resolved target". A target
query is what the user specifies, with some things left to default. A
resolved target has the default things discovered and populated.
In the future, std.zig.CrossTarget will be rename to std.Target.Query.
Introduces `std.Build.resolveTargetQuery` to get from one to the other.
The concept of `main_mod_path` is gone, no longer supported. You have to
put the root source file at the module root now.
* remove deprecated API
* update build.zig for the breaking API changes in this branch
* move std.Build.Step.Compile.BuildId to std.zig.BuildId
* add more options to std.Build.ExecutableOptions, std.Build.ObjectOptions,
std.Build.SharedLibraryOptions, std.Build.StaticLibraryOptions, and
std.Build.TestOptions.
* remove `std.Build.constructCMacro`. There is no use for this API.
* deprecate `std.Build.Step.Compile.defineCMacro`. Instead,
`std.Build.Module.addCMacro` is provided.
- remove `std.Build.Step.Compile.defineCMacroRaw`.
* deprecate `std.Build.Step.Compile.linkFrameworkNeeded`
- use `std.Build.Module.linkFramework`
* deprecate `std.Build.Step.Compile.linkFrameworkWeak`
- use `std.Build.Module.linkFramework`
* move more logic into `std.Build.Module`
* allow `target` and `optimize` to be `null` when creating a Module.
Along with other fields, those unspecified options will be inherited
from parent `Module` when inserted into an import table.
* the `target` field of `addExecutable` is now required. pass `b.host`
to get the host target.
2023-12-02 21:51:34 -07:00
} ) ;
2022-12-01 16:34:15 -07:00
const exe_options = b . addOptions ( ) ;
zig build system: change target, compilation, and module APIs
Introduce the concept of "target query" and "resolved target". A target
query is what the user specifies, with some things left to default. A
resolved target has the default things discovered and populated.
In the future, std.zig.CrossTarget will be rename to std.Target.Query.
Introduces `std.Build.resolveTargetQuery` to get from one to the other.
The concept of `main_mod_path` is gone, no longer supported. You have to
put the root source file at the module root now.
* remove deprecated API
* update build.zig for the breaking API changes in this branch
* move std.Build.Step.Compile.BuildId to std.zig.BuildId
* add more options to std.Build.ExecutableOptions, std.Build.ObjectOptions,
std.Build.SharedLibraryOptions, std.Build.StaticLibraryOptions, and
std.Build.TestOptions.
* remove `std.Build.constructCMacro`. There is no use for this API.
* deprecate `std.Build.Step.Compile.defineCMacro`. Instead,
`std.Build.Module.addCMacro` is provided.
- remove `std.Build.Step.Compile.defineCMacroRaw`.
* deprecate `std.Build.Step.Compile.linkFrameworkNeeded`
- use `std.Build.Module.linkFramework`
* deprecate `std.Build.Step.Compile.linkFrameworkWeak`
- use `std.Build.Module.linkFramework`
* move more logic into `std.Build.Module`
* allow `target` and `optimize` to be `null` when creating a Module.
Along with other fields, those unspecified options will be inherited
from parent `Module` when inserted into an import table.
* the `target` field of `addExecutable` is now required. pass `b.host`
to get the host target.
2023-12-02 21:51:34 -07:00
exe . root_module . addOptions ( " build_options " , exe_options ) ;
2022-12-01 16:34:15 -07:00
exe_options . addOption ( u32 , " mem_leak_frames " , 0 ) ;
exe_options . addOption ( bool , " have_llvm " , false ) ;
2025-02-06 17:41:50 -08:00
exe_options . addOption ( bool , " debug_gpa " , false ) ;
2022-12-01 16:34:15 -07:00
exe_options . addOption ( [ : 0 ] const u8 , " version " , version ) ;
exe_options . addOption ( std . SemanticVersion , " semver " , semver ) ;
2024-03-01 16:46:48 +01:00
exe_options . addOption ( bool , " enable_debug_extensions " , false ) ;
2022-12-01 16:34:15 -07:00
exe_options . addOption ( bool , " enable_logging " , false ) ;
exe_options . addOption ( bool , " enable_link_snapshots " , false ) ;
exe_options . addOption ( bool , " enable_tracy " , false ) ;
exe_options . addOption ( bool , " enable_tracy_callstack " , false ) ;
exe_options . addOption ( bool , " enable_tracy_allocation " , false ) ;
2024-11-29 13:13:06 -07:00
exe_options . addOption ( u32 , " tracy_callstack_depth " , 0 ) ;
2022-12-01 16:34:15 -07:00
exe_options . addOption ( bool , " value_tracing " , false ) ;
2024-07-19 01:04:59 -04:00
exe_options . addOption ( DevEnv , " dev " , . bootstrap ) ;
2022-12-01 16:34:15 -07:00
2025-01-16 10:09:41 +00:00
// zig1 chooses to interpret values by name. The tradeoff is as follows:
//
// * We lose a small amount of performance. This is essentially irrelevant for zig1.
//
// * We lose the ability to perform trivial renames on certain `std.builtin` types without
// zig1.wasm updates. For instance, we cannot rename an enum from PascalCase fields to
// snake_case fields without an update.
//
// * We gain the ability to add and remove fields to and from `std.builtin` types without
// zig1.wasm updates. For instance, we can add a new tag to `CallingConvention` without
// an update.
//
// Because field renames only happen when we apply a breaking change to the language (which
// is becoming progressively rarer), but tags may be added to or removed from target-dependent
// types over time in response to new targets coming into use, we gain more than we lose here.
exe_options . addOption ( ValueInterpretMode , " value_interpret_mode " , . by_name ) ;
2023-03-17 00:52:35 -07:00
const run_opt = b . addSystemCommand ( & . {
" wasm-opt " ,
" -Oz " ,
" --enable-bulk-memory " ,
2024-11-29 01:31:49 +01:00
" --enable-mutable-globals " ,
2025-01-22 03:44:24 +01:00
" --enable-nontrapping-float-to-int " ,
2023-03-17 00:52:35 -07:00
" --enable-sign-ext " ,
} ) ;
2022-12-01 16:34:15 -07:00
run_opt . addArtifactArg ( exe ) ;
run_opt . addArg ( " -o " ) ;
2025-11-15 09:45:22 +00:00
const optimized_wasm = run_opt . addOutputFileArg ( " zig1.wasm " ) ;
2022-12-01 16:34:15 -07:00
2025-11-15 09:45:22 +00:00
const update_zig1 = b . addUpdateSourceFiles ( ) ;
update_zig1 . addCopyFileToSource ( optimized_wasm , " stage1/zig1.wasm " ) ;
update_zig1 . addCopyFileToSource ( b . path ( " lib/zig.h " ) , " stage1/zig.h " ) ;
2023-02-20 20:52:26 -05:00
2022-12-09 16:33:32 -07:00
const update_zig1_step = b . step ( " update-zig1 " , " Update stage1/zig1.wasm " ) ;
2025-11-15 09:45:22 +00:00
update_zig1_step . dependOn ( & update_zig1 . step ) ;
2022-12-01 16:34:15 -07:00
}
2025-05-10 11:34:19 +01:00
const AddCompilerModOptions = struct {
2023-01-30 21:39:43 -07:00
optimize : std . builtin . OptimizeMode ,
zig build system: change target, compilation, and module APIs
Introduce the concept of "target query" and "resolved target". A target
query is what the user specifies, with some things left to default. A
resolved target has the default things discovered and populated.
In the future, std.zig.CrossTarget will be rename to std.Target.Query.
Introduces `std.Build.resolveTargetQuery` to get from one to the other.
The concept of `main_mod_path` is gone, no longer supported. You have to
put the root source file at the module root now.
* remove deprecated API
* update build.zig for the breaking API changes in this branch
* move std.Build.Step.Compile.BuildId to std.zig.BuildId
* add more options to std.Build.ExecutableOptions, std.Build.ObjectOptions,
std.Build.SharedLibraryOptions, std.Build.StaticLibraryOptions, and
std.Build.TestOptions.
* remove `std.Build.constructCMacro`. There is no use for this API.
* deprecate `std.Build.Step.Compile.defineCMacro`. Instead,
`std.Build.Module.addCMacro` is provided.
- remove `std.Build.Step.Compile.defineCMacroRaw`.
* deprecate `std.Build.Step.Compile.linkFrameworkNeeded`
- use `std.Build.Module.linkFramework`
* deprecate `std.Build.Step.Compile.linkFrameworkWeak`
- use `std.Build.Module.linkFramework`
* move more logic into `std.Build.Module`
* allow `target` and `optimize` to be `null` when creating a Module.
Along with other fields, those unspecified options will be inherited
from parent `Module` when inserted into an import table.
* the `target` field of `addExecutable` is now required. pass `b.host`
to get the host target.
2023-12-02 21:51:34 -07:00
target : std . Build . ResolvedTarget ,
strip : ? bool = null ,
2024-07-16 17:26:41 -07:00
valgrind : ? bool = null ,
zig build system: change target, compilation, and module APIs
Introduce the concept of "target query" and "resolved target". A target
query is what the user specifies, with some things left to default. A
resolved target has the default things discovered and populated.
In the future, std.zig.CrossTarget will be rename to std.Target.Query.
Introduces `std.Build.resolveTargetQuery` to get from one to the other.
The concept of `main_mod_path` is gone, no longer supported. You have to
put the root source file at the module root now.
* remove deprecated API
* update build.zig for the breaking API changes in this branch
* move std.Build.Step.Compile.BuildId to std.zig.BuildId
* add more options to std.Build.ExecutableOptions, std.Build.ObjectOptions,
std.Build.SharedLibraryOptions, std.Build.StaticLibraryOptions, and
std.Build.TestOptions.
* remove `std.Build.constructCMacro`. There is no use for this API.
* deprecate `std.Build.Step.Compile.defineCMacro`. Instead,
`std.Build.Module.addCMacro` is provided.
- remove `std.Build.Step.Compile.defineCMacroRaw`.
* deprecate `std.Build.Step.Compile.linkFrameworkNeeded`
- use `std.Build.Module.linkFramework`
* deprecate `std.Build.Step.Compile.linkFrameworkWeak`
- use `std.Build.Module.linkFramework`
* move more logic into `std.Build.Module`
* allow `target` and `optimize` to be `null` when creating a Module.
Along with other fields, those unspecified options will be inherited
from parent `Module` when inserted into an import table.
* the `target` field of `addExecutable` is now required. pass `b.host`
to get the host target.
2023-12-02 21:51:34 -07:00
sanitize_thread : ? bool = null ,
single_threaded : ? bool = null ,
} ;
2025-05-10 11:34:19 +01:00
fn addCompilerMod ( b : * std . Build , options : AddCompilerModOptions ) * std . Build . Module {
2024-12-15 18:09:38 +00:00
const compiler_mod = b . createModule ( . {
2024-04-11 14:02:47 -07:00
. root_source_file = b . path ( " src/main.zig " ) ,
zig build system: change target, compilation, and module APIs
Introduce the concept of "target query" and "resolved target". A target
query is what the user specifies, with some things left to default. A
resolved target has the default things discovered and populated.
In the future, std.zig.CrossTarget will be rename to std.Target.Query.
Introduces `std.Build.resolveTargetQuery` to get from one to the other.
The concept of `main_mod_path` is gone, no longer supported. You have to
put the root source file at the module root now.
* remove deprecated API
* update build.zig for the breaking API changes in this branch
* move std.Build.Step.Compile.BuildId to std.zig.BuildId
* add more options to std.Build.ExecutableOptions, std.Build.ObjectOptions,
std.Build.SharedLibraryOptions, std.Build.StaticLibraryOptions, and
std.Build.TestOptions.
* remove `std.Build.constructCMacro`. There is no use for this API.
* deprecate `std.Build.Step.Compile.defineCMacro`. Instead,
`std.Build.Module.addCMacro` is provided.
- remove `std.Build.Step.Compile.defineCMacroRaw`.
* deprecate `std.Build.Step.Compile.linkFrameworkNeeded`
- use `std.Build.Module.linkFramework`
* deprecate `std.Build.Step.Compile.linkFrameworkWeak`
- use `std.Build.Module.linkFramework`
* move more logic into `std.Build.Module`
* allow `target` and `optimize` to be `null` when creating a Module.
Along with other fields, those unspecified options will be inherited
from parent `Module` when inserted into an import table.
* the `target` field of `addExecutable` is now required. pass `b.host`
to get the host target.
2023-12-02 21:51:34 -07:00
. target = options . target ,
. optimize = options . optimize ,
. strip = options . strip ,
. sanitize_thread = options . sanitize_thread ,
. single_threaded = options . single_threaded ,
2024-12-15 18:09:38 +00:00
. valgrind = options . valgrind ,
2023-01-30 21:39:43 -07:00
} ) ;
2023-11-15 11:30:26 +02:00
2024-12-15 18:09:38 +00:00
const aro_mod = b . createModule ( . {
2024-04-11 14:02:47 -07:00
. root_source_file = b . path ( " lib/compiler/aro/aro.zig " ) ,
2024-02-27 22:06:11 -07:00
} ) ;
2024-12-15 18:09:38 +00:00
compiler_mod . addImport ( " aro " , aro_mod ) ;
2025-05-10 11:34:19 +01:00
return compiler_mod ;
}
fn addCompilerStep ( b : * std . Build , options : AddCompilerModOptions ) * std . Build . Step . Compile {
2024-12-15 18:09:38 +00:00
const exe = b . addExecutable ( . {
. name = " zig " ,
. max_rss = 7_800_000_000 ,
2025-05-10 11:34:19 +01:00
. root_module = addCompilerMod ( b , options ) ,
2024-12-15 18:09:38 +00:00
} ) ;
exe . stack_size = stack_size ;
2022-12-01 16:34:15 -07:00
return exe ;
2017-04-19 01:13:15 -04:00
}
2017-12-11 23:34:59 -05:00
2021-01-03 16:48:52 +01:00
const exe_cflags = [ _ ] [ ] const u8 {
2023-01-29 12:57:24 -07:00
" -std=c++17 " ,
2021-01-03 16:48:52 +01:00
" -D__STDC_CONSTANT_MACROS " ,
" -D__STDC_FORMAT_MACROS " ,
" -D__STDC_LIMIT_MACROS " ,
" -D_GNU_SOURCE " ,
" -fno-exceptions " ,
" -fno-rtti " ,
2024-05-14 19:48:19 +05:00
" -fno-stack-protector " ,
" -fvisibility-inlines-hidden " ,
2024-04-28 21:20:57 -07:00
" -Wno-type-limits " ,
2021-01-03 16:48:52 +01:00
" -Wno-missing-braces " ,
" -Wno-comment " ,
2025-04-08 23:11:32 +02:00
// `exe_cflags` is only used for static linking.
" -DLLVM_BUILD_STATIC " ,
" -DCLANG_BUILD_STATIC " ,
2021-01-03 16:48:52 +01:00
} ;
fn addCmakeCfgOptionsToExe (
2023-01-31 00:19:51 -07:00
b : * std . Build ,
2021-01-03 16:48:52 +01:00
cfg : CMakeConfig ,
2023-05-03 11:49:55 +03:00
exe : * std . Build . Step . Compile ,
2021-09-16 13:09:32 -07:00
use_zig_libcxx : bool ,
2021-01-03 16:48:52 +01:00
) ! void {
2024-12-15 18:09:38 +00:00
const mod = exe . root_module ;
2025-06-13 04:46:30 -04:00
const target = & mod . resolved_target .? . result ;
2024-12-15 18:09:38 +00:00
2025-01-24 03:45:38 +01:00
if ( target . os . tag . isDarwin ( ) ) {
2023-01-01 22:43:09 -05:00
// useful for package maintainers
exe . headerpad_max_install_names = true ;
}
2024-12-15 18:09:38 +00:00
mod . addObjectFile ( . { . cwd_relative = b . pathJoin ( & . {
2021-01-03 16:48:52 +01:00
cfg . cmake_binary_dir ,
" zigcpp " ,
2022-12-07 01:44:15 -07:00
b . fmt ( " {s}{s}{s} " , . {
cfg . cmake_static_library_prefix ,
" zigcpp " ,
cfg . cmake_static_library_suffix ,
} ) ,
2023-07-19 10:49:34 +02:00
} ) } ) ;
2021-01-03 16:48:52 +01:00
assert ( cfg . lld_include_dir . len != 0 ) ;
2024-12-15 18:09:38 +00:00
mod . addIncludePath ( . { . cwd_relative = cfg . lld_include_dir } ) ;
mod . addIncludePath ( . { . cwd_relative = cfg . llvm_include_dir } ) ;
mod . addLibraryPath ( . { . cwd_relative = cfg . llvm_lib_dir } ) ;
addCMakeLibraryList ( mod , cfg . clang_libraries ) ;
addCMakeLibraryList ( mod , cfg . lld_libraries ) ;
addCMakeLibraryList ( mod , cfg . llvm_libraries ) ;
2021-01-03 16:48:52 +01:00
2021-09-16 13:09:32 -07:00
if ( use_zig_libcxx ) {
2024-12-15 18:09:38 +00:00
mod . link_libcpp = true ;
2021-09-16 13:09:32 -07:00
} else {
// System -lc++ must be used because in this code path we are attempting to link
// against system-provided LLVM, Clang, LLD.
2023-01-06 00:57:08 -05:00
const need_cpp_includes = true ;
const static = cfg . llvm_linkage == . static ;
2024-12-15 18:09:38 +00:00
const lib_suffix = if ( static ) target . staticLibSuffix ( ) [ 1 .. ] else target . dynamicLibSuffix ( ) [ 1 .. ] ;
switch ( target . os . tag ) {
2023-01-02 19:18:33 -05:00
. linux = > {
2023-09-01 10:04:26 -04:00
// First we try to link against the detected libcxx name. If that doesn't work, we fall
// back to -lc++ and cross our fingers.
addCxxKnownPath ( b , cfg , exe , b . fmt ( " lib{s}.{s} " , . { cfg . system_libcxx , lib_suffix } ) , " " , need_cpp_includes ) catch | err | switch ( err ) {
error . RequiredLibraryNotFound = > {
2024-12-15 18:09:38 +00:00
mod . link_libcpp = true ;
2023-09-01 10:04:26 -04:00
} ,
else = > | e | return e ,
} ;
2024-12-15 18:09:38 +00:00
mod . linkSystemLibrary ( " unwind " , . { } ) ;
2023-01-02 19:18:33 -05:00
} ,
2024-05-09 15:04:13 +02:00
. ios , . macos , . watchos , . tvos , . visionos = > {
2024-12-15 18:09:38 +00:00
mod . link_libcpp = true ;
2023-01-02 19:18:33 -05:00
} ,
2023-01-15 13:10:19 -05:00
. windows = > {
2024-12-15 18:09:38 +00:00
if ( target . abi != . msvc ) mod . link_libcpp = true ;
2023-01-15 13:10:19 -05:00
} ,
2023-01-02 19:18:33 -05:00
. freebsd = > {
2025-02-01 12:14:37 -05:00
try addCxxKnownPath ( b , cfg , exe , b . fmt ( " libc++.{s} " , . { lib_suffix } ) , null , need_cpp_includes ) ;
if ( static ) try addCxxKnownPath ( b , cfg , exe , b . fmt ( " libgcc_eh.{s} " , . { lib_suffix } ) , null , need_cpp_includes ) ;
2023-01-02 19:18:33 -05:00
} ,
. openbsd = > {
2025-02-01 12:14:37 -05:00
// - llvm requires libexecinfo which has conflicting symbols with libc++abi
// - only an issue with .a linking
// - workaround is to link c++abi dynamically
try addCxxKnownPath ( b , cfg , exe , b . fmt ( " libc++.{s} " , . { target . dynamicLibSuffix ( ) [ 1 .. ] } ) , null , need_cpp_includes ) ;
try addCxxKnownPath ( b , cfg , exe , b . fmt ( " libc++abi.{s} " , . { target . dynamicLibSuffix ( ) [ 1 .. ] } ) , null , need_cpp_includes ) ;
2023-01-02 19:18:33 -05:00
} ,
2023-01-06 00:57:08 -05:00
. netbsd , . dragonfly = > {
2025-02-01 12:14:37 -05:00
try addCxxKnownPath ( b , cfg , exe , b . fmt ( " libstdc++.{s} " , . { lib_suffix } ) , null , need_cpp_includes ) ;
if ( static ) try addCxxKnownPath ( b , cfg , exe , b . fmt ( " libgcc_eh.{s} " , . { lib_suffix } ) , null , need_cpp_includes ) ;
2023-01-02 19:18:33 -05:00
} ,
remove all Oracle Solaris support
There is no straightforward way for the Zig team to access the Solaris system
headers; to do this, one has to create an Oracle account, accept their EULA to
download the installer ISO, and finally install it on a machine or VM. We do not
have to jump through hoops like this for any other OS that we support, and no
one on the team has expressed willingness to do it.
As a result, we cannot audit any Solaris contributions to std.c or other
similarly sensitive parts of the standard library. The best we would be able to
do is assume that Solaris and illumos are 100% compatible with no way to verify
that assumption. But at that point, the solaris and illumos OS tags would be
functionally identical anyway.
For Solaris especially, any contributions that involve APIs introduced after the
OS was made closed-source would also be inherently more risky than equivalent
contributions for other proprietary OSs due to the case of Google LLC v. Oracle
America, Inc., wherein Oracle clearly demonstrated its willingness to pursue
legal action against entities that merely copy API declarations.
Finally, Oracle laid off most of the Solaris team in 2017; the OS has been in
maintenance mode since, presumably to be retired completely sometime in the 2030s.
For these reasons, this commit removes all Oracle Solaris support.
Anyone who still wishes to use Zig on Solaris can try their luck by simply using
illumos instead of solaris in target triples - chances are it'll work. But there
will be no effort from the Zig team to support this use case; we recommend that
people move to illumos instead.
2025-10-26 05:45:38 +01:00
. illumos = > {
2023-10-01 23:09:14 +11:00
try addCxxKnownPath ( b , cfg , exe , b . fmt ( " libstdc++.{s} " , . { lib_suffix } ) , null , need_cpp_includes ) ;
try addCxxKnownPath ( b , cfg , exe , b . fmt ( " libgcc_eh.{s} " , . { lib_suffix } ) , null , need_cpp_includes ) ;
2023-09-26 15:59:24 -06:00
} ,
2024-04-07 21:19:12 -04:00
. haiku = > {
try addCxxKnownPath ( b , cfg , exe , b . fmt ( " libstdc++.{s} " , . { lib_suffix } ) , null , need_cpp_includes ) ;
} ,
2023-01-02 19:18:33 -05:00
else = > { } ,
2021-09-16 13:09:32 -07:00
}
2021-01-03 16:48:52 +01:00
}
if ( cfg . dia_guids_lib . len != 0 ) {
2024-12-15 18:09:38 +00:00
mod . addObjectFile ( . { . cwd_relative = cfg . dia_guids_lib } ) ;
2021-01-03 16:48:52 +01:00
}
}
2025-03-26 23:19:35 +01:00
fn addStaticLlvmOptionsToModule ( mod : * std . Build . Module , options : struct {
llvm_has_m68k : bool ,
llvm_has_csky : bool ,
llvm_has_arc : bool ,
llvm_has_xtensa : bool ,
} ) ! void {
2021-01-03 16:48:52 +01:00
// Adds the Zig C++ sources which both stage1 and stage2 need.
//
// We need this because otherwise zig_clang_cc1_main.cpp ends up pulling
// in a dependency on llvm::cfg::Update<llvm::BasicBlock*>::dump() which is
// unavailable when LLVM is compiled in Release mode.
const zig_cpp_cflags = exe_cflags ++ [ _ ] [ ] const u8 { " -DNDEBUG=1 " } ;
2024-12-15 18:09:38 +00:00
mod . addCSourceFiles ( . {
2023-10-10 20:29:26 +02:00
. files = & zig_cpp_sources ,
. flags = & zig_cpp_cflags ,
} ) ;
2021-01-03 16:48:52 +01:00
for ( clang_libs ) | lib_name | {
2024-12-15 18:09:38 +00:00
mod . linkSystemLibrary ( lib_name , . { } ) ;
2021-01-03 16:48:52 +01:00
}
for ( lld_libs ) | lib_name | {
2024-12-15 18:09:38 +00:00
mod . linkSystemLibrary ( lib_name , . { } ) ;
2021-01-03 16:48:52 +01:00
}
for ( llvm_libs ) | lib_name | {
2024-12-15 18:09:38 +00:00
mod . linkSystemLibrary ( lib_name , . { } ) ;
2021-01-03 16:48:52 +01:00
}
2025-03-26 23:19:35 +01:00
if ( options . llvm_has_m68k ) for ( llvm_libs_m68k ) | lib_name | {
mod . linkSystemLibrary ( lib_name , . { } ) ;
} ;
if ( options . llvm_has_csky ) for ( llvm_libs_csky ) | lib_name | {
mod . linkSystemLibrary ( lib_name , . { } ) ;
} ;
if ( options . llvm_has_arc ) for ( llvm_libs_arc ) | lib_name | {
mod . linkSystemLibrary ( lib_name , . { } ) ;
} ;
if ( options . llvm_has_xtensa ) for ( llvm_libs_xtensa ) | lib_name | {
mod . linkSystemLibrary ( lib_name , . { } ) ;
} ;
2024-12-15 18:09:38 +00:00
mod . linkSystemLibrary ( " z " , . { } ) ;
mod . linkSystemLibrary ( " zstd " , . { } ) ;
2022-11-08 02:14:39 -05:00
2024-12-15 18:09:38 +00:00
if ( mod . resolved_target .? . result . os . tag != . windows or mod . resolved_target .? . result . abi != . msvc ) {
2022-11-08 02:14:39 -05:00
// This means we rely on clang-or-zig-built LLVM, Clang, LLD libraries.
2024-12-15 18:09:38 +00:00
mod . linkSystemLibrary ( " c++ " , . { } ) ;
2022-11-08 02:14:39 -05:00
}
2024-12-15 18:09:38 +00:00
if ( mod . resolved_target .? . result . os . tag == . windows ) {
mod . linkSystemLibrary ( " version " , . { } ) ;
mod . linkSystemLibrary ( " uuid " , . { } ) ;
mod . linkSystemLibrary ( " ole32 " , . { } ) ;
2022-11-08 02:14:39 -05:00
}
2021-01-03 16:48:52 +01:00
}
2020-12-07 17:23:17 -07:00
fn addCxxKnownPath (
2023-01-31 00:19:51 -07:00
b : * std . Build ,
2020-12-07 17:23:17 -07:00
ctx : CMakeConfig ,
2023-05-03 11:49:55 +03:00
exe : * std . Build . Step . Compile ,
2020-12-07 17:23:17 -07:00
objname : [ ] const u8 ,
errtxt : ? [ ] const u8 ,
need_cpp_includes : bool ,
) ! void {
2022-02-03 15:27:01 -07:00
if ( ! std . process . can_spawn )
return error . RequiredLibraryNotFound ;
2023-10-16 22:49:27 +02:00
2024-02-16 06:01:46 +01:00
const path_padded = run : {
2025-07-31 21:54:07 -07:00
var args = std . array_list . Managed ( [ ] const u8 ) . init ( b . allocator ) ;
2024-02-16 06:01:46 +01:00
try args . append ( ctx . cxx_compiler ) ;
var it = std . mem . tokenizeAny ( u8 , ctx . cxx_compiler_arg1 , & std . ascii . whitespace ) ;
while ( it . next ( ) ) | arg | try args . append ( arg ) ;
try args . append ( b . fmt ( " -print-file-name={s} " , . { objname } ) ) ;
break : run b . run ( args . items ) ;
} ;
2023-05-04 18:05:40 -07:00
var tokenizer = mem . tokenizeAny ( u8 , path_padded , " \r \n " ) ;
2022-03-27 21:05:42 +03:00
const path_unpadded = tokenizer . next ( ) .? ;
2020-12-07 17:23:17 -07:00
if ( mem . eql ( u8 , path_unpadded , objname ) ) {
if ( errtxt ) | msg | {
2021-11-30 00:13:07 -07:00
std . debug . print ( " {s} " , . { msg } ) ;
2020-12-07 17:23:17 -07:00
} else {
2021-11-30 00:13:07 -07:00
std . debug . print ( " Unable to determine path to {s} \n " , . { objname } ) ;
2020-12-07 17:23:17 -07:00
}
return error . RequiredLibraryNotFound ;
}
2024-11-17 00:55:09 -05:00
// By default, explicit library paths are not checked for being linker scripts,
// but libc++ may very well be one, so force all inputs to be checked when passing
// an explicit path to libc++.
exe . allow_so_scripts = true ;
2024-12-15 18:09:38 +00:00
exe . root_module . addObjectFile ( . { . cwd_relative = path_unpadded } ) ;
2020-12-07 17:23:17 -07:00
// TODO a way to integrate with system c++ include files here
2022-10-26 18:17:49 -07:00
// c++ -E -Wp,-v -xc++ /dev/null
2020-12-07 17:23:17 -07:00
if ( need_cpp_includes ) {
// I used these temporarily for testing something but we obviously need a
// more general purpose solution here.
2024-12-15 18:09:38 +00:00
//exe.root_module.addIncludePath("/nix/store/2lr0fc0ak8rwj0k8n3shcyz1hz63wzma-gcc-11.3.0/include/c++/11.3.0");
//exe.root_module.addIncludePath("/nix/store/2lr0fc0ak8rwj0k8n3shcyz1hz63wzma-gcc-11.3.0/include/c++/11.3.0/x86_64-unknown-linux-gnu");
2020-12-07 17:23:17 -07:00
}
}
2024-12-15 18:09:38 +00:00
fn addCMakeLibraryList ( mod : * std . Build . Module , list : [ ] const u8 ) void {
2023-05-04 18:05:40 -07:00
var it = mem . tokenizeScalar ( u8 , list , ';' ) ;
2020-12-07 17:23:17 -07:00
while ( it . next ( ) ) | lib | {
if ( mem . startsWith ( u8 , lib , " -l " ) ) {
2024-12-15 18:09:38 +00:00
mod . linkSystemLibrary ( lib [ " -l " . len .. ] , . { } ) ;
} else if ( mod . resolved_target .? . result . os . tag == . windows and
zig build system: change target, compilation, and module APIs
Introduce the concept of "target query" and "resolved target". A target
query is what the user specifies, with some things left to default. A
resolved target has the default things discovered and populated.
In the future, std.zig.CrossTarget will be rename to std.Target.Query.
Introduces `std.Build.resolveTargetQuery` to get from one to the other.
The concept of `main_mod_path` is gone, no longer supported. You have to
put the root source file at the module root now.
* remove deprecated API
* update build.zig for the breaking API changes in this branch
* move std.Build.Step.Compile.BuildId to std.zig.BuildId
* add more options to std.Build.ExecutableOptions, std.Build.ObjectOptions,
std.Build.SharedLibraryOptions, std.Build.StaticLibraryOptions, and
std.Build.TestOptions.
* remove `std.Build.constructCMacro`. There is no use for this API.
* deprecate `std.Build.Step.Compile.defineCMacro`. Instead,
`std.Build.Module.addCMacro` is provided.
- remove `std.Build.Step.Compile.defineCMacroRaw`.
* deprecate `std.Build.Step.Compile.linkFrameworkNeeded`
- use `std.Build.Module.linkFramework`
* deprecate `std.Build.Step.Compile.linkFrameworkWeak`
- use `std.Build.Module.linkFramework`
* move more logic into `std.Build.Module`
* allow `target` and `optimize` to be `null` when creating a Module.
Along with other fields, those unspecified options will be inherited
from parent `Module` when inserted into an import table.
* the `target` field of `addExecutable` is now required. pass `b.host`
to get the host target.
2023-12-02 21:51:34 -07:00
mem . endsWith ( u8 , lib , " .lib " ) and ! fs . path . isAbsolute ( lib ) )
{
2024-12-15 18:09:38 +00:00
mod . linkSystemLibrary ( lib [ 0 .. lib . len - " .lib " . len ] , . { } ) ;
2020-12-07 17:23:17 -07:00
} else {
2024-12-15 18:09:38 +00:00
mod . addObjectFile ( . { . cwd_relative = lib } ) ;
2020-12-07 17:23:17 -07:00
}
}
}
const CMakeConfig = struct {
2024-02-18 20:34:32 -08:00
llvm_linkage : std . builtin . LinkMode ,
2020-12-07 17:23:17 -07:00
cmake_binary_dir : [ ] const u8 ,
cmake_prefix_path : [ ] const u8 ,
2022-12-07 01:44:15 -07:00
cmake_static_library_prefix : [ ] const u8 ,
cmake_static_library_suffix : [ ] const u8 ,
2020-12-07 17:23:17 -07:00
cxx_compiler : [ ] const u8 ,
2023-10-16 22:49:27 +02:00
cxx_compiler_arg1 : [ ] const u8 ,
2020-12-07 17:23:17 -07:00
lld_include_dir : [ ] const u8 ,
lld_libraries : [ ] const u8 ,
clang_libraries : [ ] const u8 ,
2022-10-12 18:11:46 -04:00
llvm_lib_dir : [ ] const u8 ,
llvm_include_dir : [ ] const u8 ,
2020-12-07 17:23:17 -07:00
llvm_libraries : [ ] const u8 ,
dia_guids_lib : [ ] const u8 ,
2023-09-01 10:04:26 -04:00
system_libcxx : [ ] const u8 ,
2020-12-07 17:23:17 -07:00
} ;
const max_config_h_bytes = 1 * 1024 * 1024 ;
2023-01-31 00:19:51 -07:00
fn findConfigH ( b : * std . Build , config_h_path_option : ? [ ] const u8 ) ? [ ] const u8 {
2022-07-15 17:25:38 -07:00
if ( config_h_path_option ) | path | {
var config_h_or_err = fs . cwd ( ) . openFile ( path , . { } ) ;
if ( config_h_or_err ) | * file | {
file . close ( ) ;
return path ;
} else | _ | {
std . log . err ( " Could not open provided config.h: \" {s} \" " , . { path } ) ;
2024-03-18 22:39:59 -07:00
std . process . exit ( 1 ) ;
2022-07-15 17:25:38 -07:00
}
}
2024-02-01 15:44:44 -07:00
var check_dir = fs . path . dirname ( b . graph . zig_exe ) .? ;
2022-07-15 17:25:38 -07:00
while ( true ) {
var dir = fs . cwd ( ) . openDir ( check_dir , . { } ) catch unreachable ;
defer dir . close ( ) ;
// Check if config.h is present in dir
var config_h_or_err = dir . openFile ( " config.h " , . { } ) ;
if ( config_h_or_err ) | * file | {
file . close ( ) ;
return fs . path . join (
b . allocator ,
& [ _ ] [ ] const u8 { check_dir , " config.h " } ,
) catch unreachable ;
} else | e | switch ( e ) {
error . FileNotFound = > { } ,
else = > unreachable ,
}
// Check if we reached the source root by looking for .git, and bail if so
var git_dir_or_err = dir . openDir ( " .git " , . { } ) ;
if ( git_dir_or_err ) | * git_dir | {
git_dir . close ( ) ;
return null ;
} else | _ | { }
// Otherwise, continue search in the parent directory
const new_check_dir = fs . path . dirname ( check_dir ) ;
if ( new_check_dir == null or mem . eql ( u8 , new_check_dir .? , check_dir ) ) {
return null ;
}
check_dir = new_check_dir .? ;
2023-11-26 01:18:13 -08:00
}
2022-07-15 17:25:38 -07:00
}
2020-12-07 17:23:17 -07:00
2023-01-31 00:19:51 -07:00
fn parseConfigH ( b : * std . Build , config_h_text : [ ] const u8 ) ? CMakeConfig {
2020-12-07 17:23:17 -07:00
var ctx : CMakeConfig = . {
2022-07-23 09:02:51 -07:00
. llvm_linkage = undefined ,
2020-12-07 17:23:17 -07:00
. cmake_binary_dir = undefined ,
. cmake_prefix_path = undefined ,
2022-12-07 01:44:15 -07:00
. cmake_static_library_prefix = undefined ,
. cmake_static_library_suffix = undefined ,
2020-12-07 17:23:17 -07:00
. cxx_compiler = undefined ,
2023-10-16 22:49:27 +02:00
. cxx_compiler_arg1 = " " ,
2020-12-07 17:23:17 -07:00
. lld_include_dir = undefined ,
. lld_libraries = undefined ,
. clang_libraries = undefined ,
2022-10-12 18:11:46 -04:00
. llvm_lib_dir = undefined ,
. llvm_include_dir = undefined ,
2020-12-07 17:23:17 -07:00
. llvm_libraries = undefined ,
. dia_guids_lib = undefined ,
2023-09-01 10:04:26 -04:00
. system_libcxx = undefined ,
2020-12-07 17:23:17 -07:00
} ;
const mappings = [ _ ] struct { prefix : [ ] const u8 , field : [ ] const u8 } {
. {
. prefix = " #define ZIG_CMAKE_BINARY_DIR " ,
. field = " cmake_binary_dir " ,
} ,
. {
. prefix = " #define ZIG_CMAKE_PREFIX_PATH " ,
. field = " cmake_prefix_path " ,
} ,
2022-12-07 01:44:15 -07:00
. {
. prefix = " #define ZIG_CMAKE_STATIC_LIBRARY_PREFIX " ,
. field = " cmake_static_library_prefix " ,
} ,
. {
. prefix = " #define ZIG_CMAKE_STATIC_LIBRARY_SUFFIX " ,
. field = " cmake_static_library_suffix " ,
} ,
2020-12-07 17:23:17 -07:00
. {
. prefix = " #define ZIG_CXX_COMPILER " ,
. field = " cxx_compiler " ,
} ,
2023-10-16 22:49:27 +02:00
. {
. prefix = " #define ZIG_CXX_COMPILER_ARG1 " ,
. field = " cxx_compiler_arg1 " ,
} ,
2020-12-07 17:23:17 -07:00
. {
. prefix = " #define ZIG_LLD_INCLUDE_PATH " ,
. field = " lld_include_dir " ,
} ,
. {
. prefix = " #define ZIG_LLD_LIBRARIES " ,
. field = " lld_libraries " ,
} ,
. {
. prefix = " #define ZIG_CLANG_LIBRARIES " ,
. field = " clang_libraries " ,
} ,
. {
. prefix = " #define ZIG_LLVM_LIBRARIES " ,
. field = " llvm_libraries " ,
} ,
. {
. prefix = " #define ZIG_DIA_GUIDS_LIB " ,
. field = " dia_guids_lib " ,
} ,
2022-10-12 18:11:46 -04:00
. {
. prefix = " #define ZIG_LLVM_INCLUDE_PATH " ,
. field = " llvm_include_dir " ,
} ,
. {
. prefix = " #define ZIG_LLVM_LIB_PATH " ,
. field = " llvm_lib_dir " ,
} ,
2023-09-01 10:04:26 -04:00
. {
. prefix = " #define ZIG_SYSTEM_LIBCXX " ,
. field = " system_libcxx " ,
} ,
2022-07-23 09:02:51 -07:00
// .prefix = ZIG_LLVM_LINK_MODE parsed manually below
2020-12-07 17:23:17 -07:00
} ;
2023-05-04 18:05:40 -07:00
var lines_it = mem . tokenizeAny ( u8 , config_h_text , " \r \n " ) ;
2020-12-07 17:23:17 -07:00
while ( lines_it . next ( ) ) | line | {
inline for ( mappings ) | mapping | {
if ( mem . startsWith ( u8 , line , mapping . prefix ) ) {
2023-05-04 18:15:50 -07:00
var it = mem . splitScalar ( u8 , line , '"' ) ;
2022-07-25 21:04:30 +02:00
_ = it . first ( ) ; // skip the stuff before the quote
2020-12-07 17:23:17 -07:00
const quoted = it . next ( ) .? ; // the stuff inside the quote
2023-10-16 22:49:27 +02:00
const trimmed = mem . trim ( u8 , quoted , " " ) ;
@field ( ctx , mapping . field ) = toNativePathSep ( b , trimmed ) ;
2020-12-07 17:23:17 -07:00
}
}
2022-07-23 09:02:51 -07:00
if ( mem . startsWith ( u8 , line , " #define ZIG_LLVM_LINK_MODE " ) ) {
2023-05-04 18:15:50 -07:00
var it = mem . splitScalar ( u8 , line , '"' ) ;
2022-07-23 09:02:51 -07:00
_ = it . next ( ) .? ; // skip the stuff before the quote
const quoted = it . next ( ) .? ; // the stuff inside the quote
ctx . llvm_linkage = if ( mem . eql ( u8 , quoted , " shared " ) ) . dynamic else . static ;
}
2020-12-07 17:23:17 -07:00
}
return ctx ;
}
2023-01-31 00:19:51 -07:00
fn toNativePathSep ( b : * std . Build , s : [ ] const u8 ) [ ] u8 {
2021-11-30 00:13:07 -07:00
const duplicated = b . allocator . dupe ( u8 , s ) catch unreachable ;
2020-12-07 17:23:17 -07:00
for ( duplicated ) | * byte | switch ( byte .* ) {
'/' = > byte .* = fs . path . sep ,
else = > { } ,
} ;
return duplicated ;
}
ability to build stage1 using only a zig tarball
The main idea here is that there are now 2 ways to get a stage1 zig
binary:
* The cmake path. Requirements: cmake, system C++ compiler, system
LLVM, LLD, Clang libraries, compiled by the system C++ compiler.
* The zig path. Requirements: a zig installation, system LLVM, LLD,
Clang libraries, compiled by the zig installation.
Note that the former can be used to now take the latter path.
Removed config.h.in and config.zig.in. The build.zig script no longer is
coupled to the cmake script.
cmake no longer tries to determine the zig version. A build with cmake
will yield a stage1 zig binary that reports 0.0.0+zig0. This is going to
get reverted.
`zig build` now accepts `-Dstage1` which will build the stage1 compiler,
and put the stage2 backend behind a feature flag.
build.zig is simplified to only support the use case of enabling LLVM
support when the LLVM, LLD, and Clang libraries were built by zig. This
part is probably sadly going to have to get reverted to make package
maintainers happy.
Zig build system addBuildOption supports a couple new types.
The biggest reason to make this change is that the zig path is an
attractive option for doing compiler development work on Windows. It
allows people to work on the compiler without having MSVC installed,
using only a .zip file that contains Zig + LLVM/LLD/Clang libraries.
2020-12-04 21:33:29 -07:00
const zig_cpp_sources = [ _ ] [ ] const u8 {
// These are planned to stay even when we are self-hosted.
" src/zig_llvm.cpp " ,
2021-06-05 21:33:16 -03:00
" src/zig_llvm-ar.cpp " ,
ability to build stage1 using only a zig tarball
The main idea here is that there are now 2 ways to get a stage1 zig
binary:
* The cmake path. Requirements: cmake, system C++ compiler, system
LLVM, LLD, Clang libraries, compiled by the system C++ compiler.
* The zig path. Requirements: a zig installation, system LLVM, LLD,
Clang libraries, compiled by the zig installation.
Note that the former can be used to now take the latter path.
Removed config.h.in and config.zig.in. The build.zig script no longer is
coupled to the cmake script.
cmake no longer tries to determine the zig version. A build with cmake
will yield a stage1 zig binary that reports 0.0.0+zig0. This is going to
get reverted.
`zig build` now accepts `-Dstage1` which will build the stage1 compiler,
and put the stage2 backend behind a feature flag.
build.zig is simplified to only support the use case of enabling LLVM
support when the LLVM, LLD, and Clang libraries were built by zig. This
part is probably sadly going to have to get reverted to make package
maintainers happy.
Zig build system addBuildOption supports a couple new types.
The biggest reason to make this change is that the zig path is an
attractive option for doing compiler development work on Windows. It
allows people to work on the compiler without having MSVC installed,
using only a .zip file that contains Zig + LLVM/LLD/Clang libraries.
2020-12-04 21:33:29 -07:00
" src/zig_clang_driver.cpp " ,
" src/zig_clang_cc1_main.cpp " ,
" src/zig_clang_cc1as_main.cpp " ,
2018-07-10 20:18:43 -04:00
} ;
2020-04-04 11:57:28 -04:00
ability to build stage1 using only a zig tarball
The main idea here is that there are now 2 ways to get a stage1 zig
binary:
* The cmake path. Requirements: cmake, system C++ compiler, system
LLVM, LLD, Clang libraries, compiled by the system C++ compiler.
* The zig path. Requirements: a zig installation, system LLVM, LLD,
Clang libraries, compiled by the zig installation.
Note that the former can be used to now take the latter path.
Removed config.h.in and config.zig.in. The build.zig script no longer is
coupled to the cmake script.
cmake no longer tries to determine the zig version. A build with cmake
will yield a stage1 zig binary that reports 0.0.0+zig0. This is going to
get reverted.
`zig build` now accepts `-Dstage1` which will build the stage1 compiler,
and put the stage2 backend behind a feature flag.
build.zig is simplified to only support the use case of enabling LLVM
support when the LLVM, LLD, and Clang libraries were built by zig. This
part is probably sadly going to have to get reverted to make package
maintainers happy.
Zig build system addBuildOption supports a couple new types.
The biggest reason to make this change is that the zig path is an
attractive option for doing compiler development work on Windows. It
allows people to work on the compiler without having MSVC installed,
using only a .zip file that contains Zig + LLVM/LLD/Clang libraries.
2020-12-04 21:33:29 -07:00
const clang_libs = [ _ ] [ ] const u8 {
" clangFrontendTool " ,
" clangCodeGen " ,
" clangFrontend " ,
" clangDriver " ,
" clangSerialization " ,
" clangSema " ,
" clangStaticAnalyzerFrontend " ,
" clangStaticAnalyzerCheckers " ,
" clangStaticAnalyzerCore " ,
" clangAnalysis " ,
" clangASTMatchers " ,
" clangAST " ,
" clangParse " ,
" clangSema " ,
2024-04-25 23:04:36 -07:00
" clangAPINotes " ,
ability to build stage1 using only a zig tarball
The main idea here is that there are now 2 ways to get a stage1 zig
binary:
* The cmake path. Requirements: cmake, system C++ compiler, system
LLVM, LLD, Clang libraries, compiled by the system C++ compiler.
* The zig path. Requirements: a zig installation, system LLVM, LLD,
Clang libraries, compiled by the zig installation.
Note that the former can be used to now take the latter path.
Removed config.h.in and config.zig.in. The build.zig script no longer is
coupled to the cmake script.
cmake no longer tries to determine the zig version. A build with cmake
will yield a stage1 zig binary that reports 0.0.0+zig0. This is going to
get reverted.
`zig build` now accepts `-Dstage1` which will build the stage1 compiler,
and put the stage2 backend behind a feature flag.
build.zig is simplified to only support the use case of enabling LLVM
support when the LLVM, LLD, and Clang libraries were built by zig. This
part is probably sadly going to have to get reverted to make package
maintainers happy.
Zig build system addBuildOption supports a couple new types.
The biggest reason to make this change is that the zig path is an
attractive option for doing compiler development work on Windows. It
allows people to work on the compiler without having MSVC installed,
using only a .zip file that contains Zig + LLVM/LLD/Clang libraries.
2020-12-04 21:33:29 -07:00
" clangBasic " ,
" clangEdit " ,
" clangLex " ,
" clangRewriteFrontend " ,
" clangRewrite " ,
" clangCrossTU " ,
" clangIndex " ,
" clangToolingCore " ,
2022-08-02 17:14:19 -07:00
" clangExtractAPI " ,
" clangSupport " ,
2024-09-05 09:07:10 -07:00
" clangInstallAPI " ,
" clangAST " ,
ability to build stage1 using only a zig tarball
The main idea here is that there are now 2 ways to get a stage1 zig
binary:
* The cmake path. Requirements: cmake, system C++ compiler, system
LLVM, LLD, Clang libraries, compiled by the system C++ compiler.
* The zig path. Requirements: a zig installation, system LLVM, LLD,
Clang libraries, compiled by the zig installation.
Note that the former can be used to now take the latter path.
Removed config.h.in and config.zig.in. The build.zig script no longer is
coupled to the cmake script.
cmake no longer tries to determine the zig version. A build with cmake
will yield a stage1 zig binary that reports 0.0.0+zig0. This is going to
get reverted.
`zig build` now accepts `-Dstage1` which will build the stage1 compiler,
and put the stage2 backend behind a feature flag.
build.zig is simplified to only support the use case of enabling LLVM
support when the LLVM, LLD, and Clang libraries were built by zig. This
part is probably sadly going to have to get reverted to make package
maintainers happy.
Zig build system addBuildOption supports a couple new types.
The biggest reason to make this change is that the zig path is an
attractive option for doing compiler development work on Windows. It
allows people to work on the compiler without having MSVC installed,
using only a .zip file that contains Zig + LLVM/LLD/Clang libraries.
2020-12-04 21:33:29 -07:00
} ;
const lld_libs = [ _ ] [ ] const u8 {
" lldMinGW " ,
" lldELF " ,
" lldCOFF " ,
" lldWasm " ,
2022-07-03 18:41:43 -07:00
" lldMachO " ,
ability to build stage1 using only a zig tarball
The main idea here is that there are now 2 ways to get a stage1 zig
binary:
* The cmake path. Requirements: cmake, system C++ compiler, system
LLVM, LLD, Clang libraries, compiled by the system C++ compiler.
* The zig path. Requirements: a zig installation, system LLVM, LLD,
Clang libraries, compiled by the zig installation.
Note that the former can be used to now take the latter path.
Removed config.h.in and config.zig.in. The build.zig script no longer is
coupled to the cmake script.
cmake no longer tries to determine the zig version. A build with cmake
will yield a stage1 zig binary that reports 0.0.0+zig0. This is going to
get reverted.
`zig build` now accepts `-Dstage1` which will build the stage1 compiler,
and put the stage2 backend behind a feature flag.
build.zig is simplified to only support the use case of enabling LLVM
support when the LLVM, LLD, and Clang libraries were built by zig. This
part is probably sadly going to have to get reverted to make package
maintainers happy.
Zig build system addBuildOption supports a couple new types.
The biggest reason to make this change is that the zig path is an
attractive option for doing compiler development work on Windows. It
allows people to work on the compiler without having MSVC installed,
using only a .zip file that contains Zig + LLVM/LLD/Clang libraries.
2020-12-04 21:33:29 -07:00
" lldCommon " ,
} ;
// This list can be re-generated with `llvm-config --libfiles` and then
// reformatting using your favorite text editor. Note we do not execute
2021-04-15 10:58:53 -07:00
// `llvm-config` here because we are cross compiling. Also omit LLVMTableGen
// from these libs.
ability to build stage1 using only a zig tarball
The main idea here is that there are now 2 ways to get a stage1 zig
binary:
* The cmake path. Requirements: cmake, system C++ compiler, system
LLVM, LLD, Clang libraries, compiled by the system C++ compiler.
* The zig path. Requirements: a zig installation, system LLVM, LLD,
Clang libraries, compiled by the zig installation.
Note that the former can be used to now take the latter path.
Removed config.h.in and config.zig.in. The build.zig script no longer is
coupled to the cmake script.
cmake no longer tries to determine the zig version. A build with cmake
will yield a stage1 zig binary that reports 0.0.0+zig0. This is going to
get reverted.
`zig build` now accepts `-Dstage1` which will build the stage1 compiler,
and put the stage2 backend behind a feature flag.
build.zig is simplified to only support the use case of enabling LLVM
support when the LLVM, LLD, and Clang libraries were built by zig. This
part is probably sadly going to have to get reverted to make package
maintainers happy.
Zig build system addBuildOption supports a couple new types.
The biggest reason to make this change is that the zig path is an
attractive option for doing compiler development work on Windows. It
allows people to work on the compiler without having MSVC installed,
using only a .zip file that contains Zig + LLVM/LLD/Clang libraries.
2020-12-04 21:33:29 -07:00
const llvm_libs = [ _ ] [ ] const u8 {
" LLVMWindowsManifest " ,
2021-04-15 10:43:39 -07:00
" LLVMXRay " ,
ability to build stage1 using only a zig tarball
The main idea here is that there are now 2 ways to get a stage1 zig
binary:
* The cmake path. Requirements: cmake, system C++ compiler, system
LLVM, LLD, Clang libraries, compiled by the system C++ compiler.
* The zig path. Requirements: a zig installation, system LLVM, LLD,
Clang libraries, compiled by the zig installation.
Note that the former can be used to now take the latter path.
Removed config.h.in and config.zig.in. The build.zig script no longer is
coupled to the cmake script.
cmake no longer tries to determine the zig version. A build with cmake
will yield a stage1 zig binary that reports 0.0.0+zig0. This is going to
get reverted.
`zig build` now accepts `-Dstage1` which will build the stage1 compiler,
and put the stage2 backend behind a feature flag.
build.zig is simplified to only support the use case of enabling LLVM
support when the LLVM, LLD, and Clang libraries were built by zig. This
part is probably sadly going to have to get reverted to make package
maintainers happy.
Zig build system addBuildOption supports a couple new types.
The biggest reason to make this change is that the zig path is an
attractive option for doing compiler development work on Windows. It
allows people to work on the compiler without having MSVC installed,
using only a .zip file that contains Zig + LLVM/LLD/Clang libraries.
2020-12-04 21:33:29 -07:00
" LLVMLibDriver " ,
" LLVMDlltoolDriver " ,
2025-02-05 10:15:15 +01:00
" LLVMTelemetry " ,
2024-04-25 14:12:55 -07:00
" LLVMTextAPIBinaryReader " ,
ability to build stage1 using only a zig tarball
The main idea here is that there are now 2 ways to get a stage1 zig
binary:
* The cmake path. Requirements: cmake, system C++ compiler, system
LLVM, LLD, Clang libraries, compiled by the system C++ compiler.
* The zig path. Requirements: a zig installation, system LLVM, LLD,
Clang libraries, compiled by the zig installation.
Note that the former can be used to now take the latter path.
Removed config.h.in and config.zig.in. The build.zig script no longer is
coupled to the cmake script.
cmake no longer tries to determine the zig version. A build with cmake
will yield a stage1 zig binary that reports 0.0.0+zig0. This is going to
get reverted.
`zig build` now accepts `-Dstage1` which will build the stage1 compiler,
and put the stage2 backend behind a feature flag.
build.zig is simplified to only support the use case of enabling LLVM
support when the LLVM, LLD, and Clang libraries were built by zig. This
part is probably sadly going to have to get reverted to make package
maintainers happy.
Zig build system addBuildOption supports a couple new types.
The biggest reason to make this change is that the zig path is an
attractive option for doing compiler development work on Windows. It
allows people to work on the compiler without having MSVC installed,
using only a .zip file that contains Zig + LLVM/LLD/Clang libraries.
2020-12-04 21:33:29 -07:00
" LLVMCoverage " ,
2021-04-15 10:43:39 -07:00
" LLVMLineEditor " ,
ability to build stage1 using only a zig tarball
The main idea here is that there are now 2 ways to get a stage1 zig
binary:
* The cmake path. Requirements: cmake, system C++ compiler, system
LLVM, LLD, Clang libraries, compiled by the system C++ compiler.
* The zig path. Requirements: a zig installation, system LLVM, LLD,
Clang libraries, compiled by the zig installation.
Note that the former can be used to now take the latter path.
Removed config.h.in and config.zig.in. The build.zig script no longer is
coupled to the cmake script.
cmake no longer tries to determine the zig version. A build with cmake
will yield a stage1 zig binary that reports 0.0.0+zig0. This is going to
get reverted.
`zig build` now accepts `-Dstage1` which will build the stage1 compiler,
and put the stage2 backend behind a feature flag.
build.zig is simplified to only support the use case of enabling LLVM
support when the LLVM, LLD, and Clang libraries were built by zig. This
part is probably sadly going to have to get reverted to make package
maintainers happy.
Zig build system addBuildOption supports a couple new types.
The biggest reason to make this change is that the zig path is an
attractive option for doing compiler development work on Windows. It
allows people to work on the compiler without having MSVC installed,
using only a .zip file that contains Zig + LLVM/LLD/Clang libraries.
2020-12-04 21:33:29 -07:00
" LLVMXCoreDisassembler " ,
" LLVMXCoreCodeGen " ,
" LLVMXCoreDesc " ,
" LLVMXCoreInfo " ,
2022-07-03 18:41:43 -07:00
" LLVMX86TargetMCA " ,
ability to build stage1 using only a zig tarball
The main idea here is that there are now 2 ways to get a stage1 zig
binary:
* The cmake path. Requirements: cmake, system C++ compiler, system
LLVM, LLD, Clang libraries, compiled by the system C++ compiler.
* The zig path. Requirements: a zig installation, system LLVM, LLD,
Clang libraries, compiled by the zig installation.
Note that the former can be used to now take the latter path.
Removed config.h.in and config.zig.in. The build.zig script no longer is
coupled to the cmake script.
cmake no longer tries to determine the zig version. A build with cmake
will yield a stage1 zig binary that reports 0.0.0+zig0. This is going to
get reverted.
`zig build` now accepts `-Dstage1` which will build the stage1 compiler,
and put the stage2 backend behind a feature flag.
build.zig is simplified to only support the use case of enabling LLVM
support when the LLVM, LLD, and Clang libraries were built by zig. This
part is probably sadly going to have to get reverted to make package
maintainers happy.
Zig build system addBuildOption supports a couple new types.
The biggest reason to make this change is that the zig path is an
attractive option for doing compiler development work on Windows. It
allows people to work on the compiler without having MSVC installed,
using only a .zip file that contains Zig + LLVM/LLD/Clang libraries.
2020-12-04 21:33:29 -07:00
" LLVMX86Disassembler " ,
" LLVMX86AsmParser " ,
2021-04-15 10:43:39 -07:00
" LLVMX86CodeGen " ,
ability to build stage1 using only a zig tarball
The main idea here is that there are now 2 ways to get a stage1 zig
binary:
* The cmake path. Requirements: cmake, system C++ compiler, system
LLVM, LLD, Clang libraries, compiled by the system C++ compiler.
* The zig path. Requirements: a zig installation, system LLVM, LLD,
Clang libraries, compiled by the zig installation.
Note that the former can be used to now take the latter path.
Removed config.h.in and config.zig.in. The build.zig script no longer is
coupled to the cmake script.
cmake no longer tries to determine the zig version. A build with cmake
will yield a stage1 zig binary that reports 0.0.0+zig0. This is going to
get reverted.
`zig build` now accepts `-Dstage1` which will build the stage1 compiler,
and put the stage2 backend behind a feature flag.
build.zig is simplified to only support the use case of enabling LLVM
support when the LLVM, LLD, and Clang libraries were built by zig. This
part is probably sadly going to have to get reverted to make package
maintainers happy.
Zig build system addBuildOption supports a couple new types.
The biggest reason to make this change is that the zig path is an
attractive option for doing compiler development work on Windows. It
allows people to work on the compiler without having MSVC installed,
using only a .zip file that contains Zig + LLVM/LLD/Clang libraries.
2020-12-04 21:33:29 -07:00
" LLVMX86Desc " ,
" LLVMX86Info " ,
" LLVMWebAssemblyDisassembler " ,
2021-04-15 10:43:39 -07:00
" LLVMWebAssemblyAsmParser " ,
ability to build stage1 using only a zig tarball
The main idea here is that there are now 2 ways to get a stage1 zig
binary:
* The cmake path. Requirements: cmake, system C++ compiler, system
LLVM, LLD, Clang libraries, compiled by the system C++ compiler.
* The zig path. Requirements: a zig installation, system LLVM, LLD,
Clang libraries, compiled by the zig installation.
Note that the former can be used to now take the latter path.
Removed config.h.in and config.zig.in. The build.zig script no longer is
coupled to the cmake script.
cmake no longer tries to determine the zig version. A build with cmake
will yield a stage1 zig binary that reports 0.0.0+zig0. This is going to
get reverted.
`zig build` now accepts `-Dstage1` which will build the stage1 compiler,
and put the stage2 backend behind a feature flag.
build.zig is simplified to only support the use case of enabling LLVM
support when the LLVM, LLD, and Clang libraries were built by zig. This
part is probably sadly going to have to get reverted to make package
maintainers happy.
Zig build system addBuildOption supports a couple new types.
The biggest reason to make this change is that the zig path is an
attractive option for doing compiler development work on Windows. It
allows people to work on the compiler without having MSVC installed,
using only a .zip file that contains Zig + LLVM/LLD/Clang libraries.
2020-12-04 21:33:29 -07:00
" LLVMWebAssemblyCodeGen " ,
2021-10-02 12:40:07 -07:00
" LLVMWebAssemblyUtils " ,
2023-08-11 22:33:20 -07:00
" LLVMWebAssemblyDesc " ,
ability to build stage1 using only a zig tarball
The main idea here is that there are now 2 ways to get a stage1 zig
binary:
* The cmake path. Requirements: cmake, system C++ compiler, system
LLVM, LLD, Clang libraries, compiled by the system C++ compiler.
* The zig path. Requirements: a zig installation, system LLVM, LLD,
Clang libraries, compiled by the zig installation.
Note that the former can be used to now take the latter path.
Removed config.h.in and config.zig.in. The build.zig script no longer is
coupled to the cmake script.
cmake no longer tries to determine the zig version. A build with cmake
will yield a stage1 zig binary that reports 0.0.0+zig0. This is going to
get reverted.
`zig build` now accepts `-Dstage1` which will build the stage1 compiler,
and put the stage2 backend behind a feature flag.
build.zig is simplified to only support the use case of enabling LLVM
support when the LLVM, LLD, and Clang libraries were built by zig. This
part is probably sadly going to have to get reverted to make package
maintainers happy.
Zig build system addBuildOption supports a couple new types.
The biggest reason to make this change is that the zig path is an
attractive option for doing compiler development work on Windows. It
allows people to work on the compiler without having MSVC installed,
using only a .zip file that contains Zig + LLVM/LLD/Clang libraries.
2020-12-04 21:33:29 -07:00
" LLVMWebAssemblyInfo " ,
2022-07-03 18:41:43 -07:00
" LLVMVEDisassembler " ,
" LLVMVEAsmParser " ,
" LLVMVECodeGen " ,
" LLVMVEDesc " ,
" LLVMVEInfo " ,
ability to build stage1 using only a zig tarball
The main idea here is that there are now 2 ways to get a stage1 zig
binary:
* The cmake path. Requirements: cmake, system C++ compiler, system
LLVM, LLD, Clang libraries, compiled by the system C++ compiler.
* The zig path. Requirements: a zig installation, system LLVM, LLD,
Clang libraries, compiled by the zig installation.
Note that the former can be used to now take the latter path.
Removed config.h.in and config.zig.in. The build.zig script no longer is
coupled to the cmake script.
cmake no longer tries to determine the zig version. A build with cmake
will yield a stage1 zig binary that reports 0.0.0+zig0. This is going to
get reverted.
`zig build` now accepts `-Dstage1` which will build the stage1 compiler,
and put the stage2 backend behind a feature flag.
build.zig is simplified to only support the use case of enabling LLVM
support when the LLVM, LLD, and Clang libraries were built by zig. This
part is probably sadly going to have to get reverted to make package
maintainers happy.
Zig build system addBuildOption supports a couple new types.
The biggest reason to make this change is that the zig path is an
attractive option for doing compiler development work on Windows. It
allows people to work on the compiler without having MSVC installed,
using only a .zip file that contains Zig + LLVM/LLD/Clang libraries.
2020-12-04 21:33:29 -07:00
" LLVMSystemZDisassembler " ,
" LLVMSystemZAsmParser " ,
2021-04-15 10:43:39 -07:00
" LLVMSystemZCodeGen " ,
ability to build stage1 using only a zig tarball
The main idea here is that there are now 2 ways to get a stage1 zig
binary:
* The cmake path. Requirements: cmake, system C++ compiler, system
LLVM, LLD, Clang libraries, compiled by the system C++ compiler.
* The zig path. Requirements: a zig installation, system LLVM, LLD,
Clang libraries, compiled by the zig installation.
Note that the former can be used to now take the latter path.
Removed config.h.in and config.zig.in. The build.zig script no longer is
coupled to the cmake script.
cmake no longer tries to determine the zig version. A build with cmake
will yield a stage1 zig binary that reports 0.0.0+zig0. This is going to
get reverted.
`zig build` now accepts `-Dstage1` which will build the stage1 compiler,
and put the stage2 backend behind a feature flag.
build.zig is simplified to only support the use case of enabling LLVM
support when the LLVM, LLD, and Clang libraries were built by zig. This
part is probably sadly going to have to get reverted to make package
maintainers happy.
Zig build system addBuildOption supports a couple new types.
The biggest reason to make this change is that the zig path is an
attractive option for doing compiler development work on Windows. It
allows people to work on the compiler without having MSVC installed,
using only a .zip file that contains Zig + LLVM/LLD/Clang libraries.
2020-12-04 21:33:29 -07:00
" LLVMSystemZDesc " ,
" LLVMSystemZInfo " ,
2025-02-05 10:15:15 +01:00
" LLVMSPIRVCodeGen " ,
" LLVMSPIRVDesc " ,
" LLVMSPIRVInfo " ,
" LLVMSPIRVAnalysis " ,
ability to build stage1 using only a zig tarball
The main idea here is that there are now 2 ways to get a stage1 zig
binary:
* The cmake path. Requirements: cmake, system C++ compiler, system
LLVM, LLD, Clang libraries, compiled by the system C++ compiler.
* The zig path. Requirements: a zig installation, system LLVM, LLD,
Clang libraries, compiled by the zig installation.
Note that the former can be used to now take the latter path.
Removed config.h.in and config.zig.in. The build.zig script no longer is
coupled to the cmake script.
cmake no longer tries to determine the zig version. A build with cmake
will yield a stage1 zig binary that reports 0.0.0+zig0. This is going to
get reverted.
`zig build` now accepts `-Dstage1` which will build the stage1 compiler,
and put the stage2 backend behind a feature flag.
build.zig is simplified to only support the use case of enabling LLVM
support when the LLVM, LLD, and Clang libraries were built by zig. This
part is probably sadly going to have to get reverted to make package
maintainers happy.
Zig build system addBuildOption supports a couple new types.
The biggest reason to make this change is that the zig path is an
attractive option for doing compiler development work on Windows. It
allows people to work on the compiler without having MSVC installed,
using only a .zip file that contains Zig + LLVM/LLD/Clang libraries.
2020-12-04 21:33:29 -07:00
" LLVMSparcDisassembler " ,
" LLVMSparcAsmParser " ,
2021-04-15 10:43:39 -07:00
" LLVMSparcCodeGen " ,
ability to build stage1 using only a zig tarball
The main idea here is that there are now 2 ways to get a stage1 zig
binary:
* The cmake path. Requirements: cmake, system C++ compiler, system
LLVM, LLD, Clang libraries, compiled by the system C++ compiler.
* The zig path. Requirements: a zig installation, system LLVM, LLD,
Clang libraries, compiled by the zig installation.
Note that the former can be used to now take the latter path.
Removed config.h.in and config.zig.in. The build.zig script no longer is
coupled to the cmake script.
cmake no longer tries to determine the zig version. A build with cmake
will yield a stage1 zig binary that reports 0.0.0+zig0. This is going to
get reverted.
`zig build` now accepts `-Dstage1` which will build the stage1 compiler,
and put the stage2 backend behind a feature flag.
build.zig is simplified to only support the use case of enabling LLVM
support when the LLVM, LLD, and Clang libraries were built by zig. This
part is probably sadly going to have to get reverted to make package
maintainers happy.
Zig build system addBuildOption supports a couple new types.
The biggest reason to make this change is that the zig path is an
attractive option for doing compiler development work on Windows. It
allows people to work on the compiler without having MSVC installed,
using only a .zip file that contains Zig + LLVM/LLD/Clang libraries.
2020-12-04 21:33:29 -07:00
" LLVMSparcDesc " ,
" LLVMSparcInfo " ,
2023-01-29 13:12:13 -07:00
" LLVMRISCVTargetMCA " ,
ability to build stage1 using only a zig tarball
The main idea here is that there are now 2 ways to get a stage1 zig
binary:
* The cmake path. Requirements: cmake, system C++ compiler, system
LLVM, LLD, Clang libraries, compiled by the system C++ compiler.
* The zig path. Requirements: a zig installation, system LLVM, LLD,
Clang libraries, compiled by the zig installation.
Note that the former can be used to now take the latter path.
Removed config.h.in and config.zig.in. The build.zig script no longer is
coupled to the cmake script.
cmake no longer tries to determine the zig version. A build with cmake
will yield a stage1 zig binary that reports 0.0.0+zig0. This is going to
get reverted.
`zig build` now accepts `-Dstage1` which will build the stage1 compiler,
and put the stage2 backend behind a feature flag.
build.zig is simplified to only support the use case of enabling LLVM
support when the LLVM, LLD, and Clang libraries were built by zig. This
part is probably sadly going to have to get reverted to make package
maintainers happy.
Zig build system addBuildOption supports a couple new types.
The biggest reason to make this change is that the zig path is an
attractive option for doing compiler development work on Windows. It
allows people to work on the compiler without having MSVC installed,
using only a .zip file that contains Zig + LLVM/LLD/Clang libraries.
2020-12-04 21:33:29 -07:00
" LLVMRISCVDisassembler " ,
" LLVMRISCVAsmParser " ,
2021-04-15 10:43:39 -07:00
" LLVMRISCVCodeGen " ,
ability to build stage1 using only a zig tarball
The main idea here is that there are now 2 ways to get a stage1 zig
binary:
* The cmake path. Requirements: cmake, system C++ compiler, system
LLVM, LLD, Clang libraries, compiled by the system C++ compiler.
* The zig path. Requirements: a zig installation, system LLVM, LLD,
Clang libraries, compiled by the zig installation.
Note that the former can be used to now take the latter path.
Removed config.h.in and config.zig.in. The build.zig script no longer is
coupled to the cmake script.
cmake no longer tries to determine the zig version. A build with cmake
will yield a stage1 zig binary that reports 0.0.0+zig0. This is going to
get reverted.
`zig build` now accepts `-Dstage1` which will build the stage1 compiler,
and put the stage2 backend behind a feature flag.
build.zig is simplified to only support the use case of enabling LLVM
support when the LLVM, LLD, and Clang libraries were built by zig. This
part is probably sadly going to have to get reverted to make package
maintainers happy.
Zig build system addBuildOption supports a couple new types.
The biggest reason to make this change is that the zig path is an
attractive option for doing compiler development work on Windows. It
allows people to work on the compiler without having MSVC installed,
using only a .zip file that contains Zig + LLVM/LLD/Clang libraries.
2020-12-04 21:33:29 -07:00
" LLVMRISCVDesc " ,
" LLVMRISCVInfo " ,
" LLVMPowerPCDisassembler " ,
" LLVMPowerPCAsmParser " ,
2021-04-15 10:43:39 -07:00
" LLVMPowerPCCodeGen " ,
ability to build stage1 using only a zig tarball
The main idea here is that there are now 2 ways to get a stage1 zig
binary:
* The cmake path. Requirements: cmake, system C++ compiler, system
LLVM, LLD, Clang libraries, compiled by the system C++ compiler.
* The zig path. Requirements: a zig installation, system LLVM, LLD,
Clang libraries, compiled by the zig installation.
Note that the former can be used to now take the latter path.
Removed config.h.in and config.zig.in. The build.zig script no longer is
coupled to the cmake script.
cmake no longer tries to determine the zig version. A build with cmake
will yield a stage1 zig binary that reports 0.0.0+zig0. This is going to
get reverted.
`zig build` now accepts `-Dstage1` which will build the stage1 compiler,
and put the stage2 backend behind a feature flag.
build.zig is simplified to only support the use case of enabling LLVM
support when the LLVM, LLD, and Clang libraries were built by zig. This
part is probably sadly going to have to get reverted to make package
maintainers happy.
Zig build system addBuildOption supports a couple new types.
The biggest reason to make this change is that the zig path is an
attractive option for doing compiler development work on Windows. It
allows people to work on the compiler without having MSVC installed,
using only a .zip file that contains Zig + LLVM/LLD/Clang libraries.
2020-12-04 21:33:29 -07:00
" LLVMPowerPCDesc " ,
" LLVMPowerPCInfo " ,
" LLVMNVPTXCodeGen " ,
" LLVMNVPTXDesc " ,
" LLVMNVPTXInfo " ,
" LLVMMSP430Disassembler " ,
" LLVMMSP430AsmParser " ,
2021-04-15 10:43:39 -07:00
" LLVMMSP430CodeGen " ,
ability to build stage1 using only a zig tarball
The main idea here is that there are now 2 ways to get a stage1 zig
binary:
* The cmake path. Requirements: cmake, system C++ compiler, system
LLVM, LLD, Clang libraries, compiled by the system C++ compiler.
* The zig path. Requirements: a zig installation, system LLVM, LLD,
Clang libraries, compiled by the zig installation.
Note that the former can be used to now take the latter path.
Removed config.h.in and config.zig.in. The build.zig script no longer is
coupled to the cmake script.
cmake no longer tries to determine the zig version. A build with cmake
will yield a stage1 zig binary that reports 0.0.0+zig0. This is going to
get reverted.
`zig build` now accepts `-Dstage1` which will build the stage1 compiler,
and put the stage2 backend behind a feature flag.
build.zig is simplified to only support the use case of enabling LLVM
support when the LLVM, LLD, and Clang libraries were built by zig. This
part is probably sadly going to have to get reverted to make package
maintainers happy.
Zig build system addBuildOption supports a couple new types.
The biggest reason to make this change is that the zig path is an
attractive option for doing compiler development work on Windows. It
allows people to work on the compiler without having MSVC installed,
using only a .zip file that contains Zig + LLVM/LLD/Clang libraries.
2020-12-04 21:33:29 -07:00
" LLVMMSP430Desc " ,
" LLVMMSP430Info " ,
" LLVMMipsDisassembler " ,
" LLVMMipsAsmParser " ,
2021-04-15 10:43:39 -07:00
" LLVMMipsCodeGen " ,
ability to build stage1 using only a zig tarball
The main idea here is that there are now 2 ways to get a stage1 zig
binary:
* The cmake path. Requirements: cmake, system C++ compiler, system
LLVM, LLD, Clang libraries, compiled by the system C++ compiler.
* The zig path. Requirements: a zig installation, system LLVM, LLD,
Clang libraries, compiled by the zig installation.
Note that the former can be used to now take the latter path.
Removed config.h.in and config.zig.in. The build.zig script no longer is
coupled to the cmake script.
cmake no longer tries to determine the zig version. A build with cmake
will yield a stage1 zig binary that reports 0.0.0+zig0. This is going to
get reverted.
`zig build` now accepts `-Dstage1` which will build the stage1 compiler,
and put the stage2 backend behind a feature flag.
build.zig is simplified to only support the use case of enabling LLVM
support when the LLVM, LLD, and Clang libraries were built by zig. This
part is probably sadly going to have to get reverted to make package
maintainers happy.
Zig build system addBuildOption supports a couple new types.
The biggest reason to make this change is that the zig path is an
attractive option for doing compiler development work on Windows. It
allows people to work on the compiler without having MSVC installed,
using only a .zip file that contains Zig + LLVM/LLD/Clang libraries.
2020-12-04 21:33:29 -07:00
" LLVMMipsDesc " ,
" LLVMMipsInfo " ,
2023-01-29 13:12:13 -07:00
" LLVMLoongArchDisassembler " ,
" LLVMLoongArchAsmParser " ,
" LLVMLoongArchCodeGen " ,
" LLVMLoongArchDesc " ,
" LLVMLoongArchInfo " ,
ability to build stage1 using only a zig tarball
The main idea here is that there are now 2 ways to get a stage1 zig
binary:
* The cmake path. Requirements: cmake, system C++ compiler, system
LLVM, LLD, Clang libraries, compiled by the system C++ compiler.
* The zig path. Requirements: a zig installation, system LLVM, LLD,
Clang libraries, compiled by the zig installation.
Note that the former can be used to now take the latter path.
Removed config.h.in and config.zig.in. The build.zig script no longer is
coupled to the cmake script.
cmake no longer tries to determine the zig version. A build with cmake
will yield a stage1 zig binary that reports 0.0.0+zig0. This is going to
get reverted.
`zig build` now accepts `-Dstage1` which will build the stage1 compiler,
and put the stage2 backend behind a feature flag.
build.zig is simplified to only support the use case of enabling LLVM
support when the LLVM, LLD, and Clang libraries were built by zig. This
part is probably sadly going to have to get reverted to make package
maintainers happy.
Zig build system addBuildOption supports a couple new types.
The biggest reason to make this change is that the zig path is an
attractive option for doing compiler development work on Windows. It
allows people to work on the compiler without having MSVC installed,
using only a .zip file that contains Zig + LLVM/LLD/Clang libraries.
2020-12-04 21:33:29 -07:00
" LLVMLanaiDisassembler " ,
" LLVMLanaiCodeGen " ,
" LLVMLanaiAsmParser " ,
" LLVMLanaiDesc " ,
" LLVMLanaiInfo " ,
" LLVMHexagonDisassembler " ,
" LLVMHexagonCodeGen " ,
" LLVMHexagonAsmParser " ,
" LLVMHexagonDesc " ,
" LLVMHexagonInfo " ,
" LLVMBPFDisassembler " ,
" LLVMBPFAsmParser " ,
2021-04-15 10:43:39 -07:00
" LLVMBPFCodeGen " ,
ability to build stage1 using only a zig tarball
The main idea here is that there are now 2 ways to get a stage1 zig
binary:
* The cmake path. Requirements: cmake, system C++ compiler, system
LLVM, LLD, Clang libraries, compiled by the system C++ compiler.
* The zig path. Requirements: a zig installation, system LLVM, LLD,
Clang libraries, compiled by the zig installation.
Note that the former can be used to now take the latter path.
Removed config.h.in and config.zig.in. The build.zig script no longer is
coupled to the cmake script.
cmake no longer tries to determine the zig version. A build with cmake
will yield a stage1 zig binary that reports 0.0.0+zig0. This is going to
get reverted.
`zig build` now accepts `-Dstage1` which will build the stage1 compiler,
and put the stage2 backend behind a feature flag.
build.zig is simplified to only support the use case of enabling LLVM
support when the LLVM, LLD, and Clang libraries were built by zig. This
part is probably sadly going to have to get reverted to make package
maintainers happy.
Zig build system addBuildOption supports a couple new types.
The biggest reason to make this change is that the zig path is an
attractive option for doing compiler development work on Windows. It
allows people to work on the compiler without having MSVC installed,
using only a .zip file that contains Zig + LLVM/LLD/Clang libraries.
2020-12-04 21:33:29 -07:00
" LLVMBPFDesc " ,
" LLVMBPFInfo " ,
" LLVMAVRDisassembler " ,
" LLVMAVRAsmParser " ,
2021-04-15 10:43:39 -07:00
" LLVMAVRCodeGen " ,
ability to build stage1 using only a zig tarball
The main idea here is that there are now 2 ways to get a stage1 zig
binary:
* The cmake path. Requirements: cmake, system C++ compiler, system
LLVM, LLD, Clang libraries, compiled by the system C++ compiler.
* The zig path. Requirements: a zig installation, system LLVM, LLD,
Clang libraries, compiled by the zig installation.
Note that the former can be used to now take the latter path.
Removed config.h.in and config.zig.in. The build.zig script no longer is
coupled to the cmake script.
cmake no longer tries to determine the zig version. A build with cmake
will yield a stage1 zig binary that reports 0.0.0+zig0. This is going to
get reverted.
`zig build` now accepts `-Dstage1` which will build the stage1 compiler,
and put the stage2 backend behind a feature flag.
build.zig is simplified to only support the use case of enabling LLVM
support when the LLVM, LLD, and Clang libraries were built by zig. This
part is probably sadly going to have to get reverted to make package
maintainers happy.
Zig build system addBuildOption supports a couple new types.
The biggest reason to make this change is that the zig path is an
attractive option for doing compiler development work on Windows. It
allows people to work on the compiler without having MSVC installed,
using only a .zip file that contains Zig + LLVM/LLD/Clang libraries.
2020-12-04 21:33:29 -07:00
" LLVMAVRDesc " ,
" LLVMAVRInfo " ,
" LLVMARMDisassembler " ,
" LLVMARMAsmParser " ,
2021-04-15 10:43:39 -07:00
" LLVMARMCodeGen " ,
ability to build stage1 using only a zig tarball
The main idea here is that there are now 2 ways to get a stage1 zig
binary:
* The cmake path. Requirements: cmake, system C++ compiler, system
LLVM, LLD, Clang libraries, compiled by the system C++ compiler.
* The zig path. Requirements: a zig installation, system LLVM, LLD,
Clang libraries, compiled by the zig installation.
Note that the former can be used to now take the latter path.
Removed config.h.in and config.zig.in. The build.zig script no longer is
coupled to the cmake script.
cmake no longer tries to determine the zig version. A build with cmake
will yield a stage1 zig binary that reports 0.0.0+zig0. This is going to
get reverted.
`zig build` now accepts `-Dstage1` which will build the stage1 compiler,
and put the stage2 backend behind a feature flag.
build.zig is simplified to only support the use case of enabling LLVM
support when the LLVM, LLD, and Clang libraries were built by zig. This
part is probably sadly going to have to get reverted to make package
maintainers happy.
Zig build system addBuildOption supports a couple new types.
The biggest reason to make this change is that the zig path is an
attractive option for doing compiler development work on Windows. It
allows people to work on the compiler without having MSVC installed,
using only a .zip file that contains Zig + LLVM/LLD/Clang libraries.
2020-12-04 21:33:29 -07:00
" LLVMARMDesc " ,
" LLVMARMUtils " ,
" LLVMARMInfo " ,
2022-07-03 18:41:43 -07:00
" LLVMAMDGPUTargetMCA " ,
ability to build stage1 using only a zig tarball
The main idea here is that there are now 2 ways to get a stage1 zig
binary:
* The cmake path. Requirements: cmake, system C++ compiler, system
LLVM, LLD, Clang libraries, compiled by the system C++ compiler.
* The zig path. Requirements: a zig installation, system LLVM, LLD,
Clang libraries, compiled by the zig installation.
Note that the former can be used to now take the latter path.
Removed config.h.in and config.zig.in. The build.zig script no longer is
coupled to the cmake script.
cmake no longer tries to determine the zig version. A build with cmake
will yield a stage1 zig binary that reports 0.0.0+zig0. This is going to
get reverted.
`zig build` now accepts `-Dstage1` which will build the stage1 compiler,
and put the stage2 backend behind a feature flag.
build.zig is simplified to only support the use case of enabling LLVM
support when the LLVM, LLD, and Clang libraries were built by zig. This
part is probably sadly going to have to get reverted to make package
maintainers happy.
Zig build system addBuildOption supports a couple new types.
The biggest reason to make this change is that the zig path is an
attractive option for doing compiler development work on Windows. It
allows people to work on the compiler without having MSVC installed,
using only a .zip file that contains Zig + LLVM/LLD/Clang libraries.
2020-12-04 21:33:29 -07:00
" LLVMAMDGPUDisassembler " ,
" LLVMAMDGPUAsmParser " ,
2021-04-15 10:43:39 -07:00
" LLVMAMDGPUCodeGen " ,
ability to build stage1 using only a zig tarball
The main idea here is that there are now 2 ways to get a stage1 zig
binary:
* The cmake path. Requirements: cmake, system C++ compiler, system
LLVM, LLD, Clang libraries, compiled by the system C++ compiler.
* The zig path. Requirements: a zig installation, system LLVM, LLD,
Clang libraries, compiled by the zig installation.
Note that the former can be used to now take the latter path.
Removed config.h.in and config.zig.in. The build.zig script no longer is
coupled to the cmake script.
cmake no longer tries to determine the zig version. A build with cmake
will yield a stage1 zig binary that reports 0.0.0+zig0. This is going to
get reverted.
`zig build` now accepts `-Dstage1` which will build the stage1 compiler,
and put the stage2 backend behind a feature flag.
build.zig is simplified to only support the use case of enabling LLVM
support when the LLVM, LLD, and Clang libraries were built by zig. This
part is probably sadly going to have to get reverted to make package
maintainers happy.
Zig build system addBuildOption supports a couple new types.
The biggest reason to make this change is that the zig path is an
attractive option for doing compiler development work on Windows. It
allows people to work on the compiler without having MSVC installed,
using only a .zip file that contains Zig + LLVM/LLD/Clang libraries.
2020-12-04 21:33:29 -07:00
" LLVMAMDGPUDesc " ,
" LLVMAMDGPUUtils " ,
" LLVMAMDGPUInfo " ,
" LLVMAArch64Disassembler " ,
2021-04-15 10:43:39 -07:00
" LLVMAArch64AsmParser " ,
ability to build stage1 using only a zig tarball
The main idea here is that there are now 2 ways to get a stage1 zig
binary:
* The cmake path. Requirements: cmake, system C++ compiler, system
LLVM, LLD, Clang libraries, compiled by the system C++ compiler.
* The zig path. Requirements: a zig installation, system LLVM, LLD,
Clang libraries, compiled by the zig installation.
Note that the former can be used to now take the latter path.
Removed config.h.in and config.zig.in. The build.zig script no longer is
coupled to the cmake script.
cmake no longer tries to determine the zig version. A build with cmake
will yield a stage1 zig binary that reports 0.0.0+zig0. This is going to
get reverted.
`zig build` now accepts `-Dstage1` which will build the stage1 compiler,
and put the stage2 backend behind a feature flag.
build.zig is simplified to only support the use case of enabling LLVM
support when the LLVM, LLD, and Clang libraries were built by zig. This
part is probably sadly going to have to get reverted to make package
maintainers happy.
Zig build system addBuildOption supports a couple new types.
The biggest reason to make this change is that the zig path is an
attractive option for doing compiler development work on Windows. It
allows people to work on the compiler without having MSVC installed,
using only a .zip file that contains Zig + LLVM/LLD/Clang libraries.
2020-12-04 21:33:29 -07:00
" LLVMAArch64CodeGen " ,
2021-04-15 10:43:39 -07:00
" LLVMAArch64Desc " ,
" LLVMAArch64Utils " ,
" LLVMAArch64Info " ,
2024-04-25 14:12:55 -07:00
" LLVMOrcDebugging " ,
2021-04-15 10:43:39 -07:00
" LLVMOrcJIT " ,
2023-01-29 13:12:13 -07:00
" LLVMWindowsDriver " ,
2021-04-15 10:43:39 -07:00
" LLVMMCJIT " ,
" LLVMJITLink " ,
" LLVMInterpreter " ,
" LLVMExecutionEngine " ,
" LLVMRuntimeDyld " ,
2021-10-02 12:40:07 -07:00
" LLVMOrcTargetProcess " ,
" LLVMOrcShared " ,
" LLVMDWP " ,
2025-07-16 04:41:14 +02:00
" LLVMDWARFCFIChecker " ,
2023-01-29 13:12:13 -07:00
" LLVMDebugInfoLogicalView " ,
2021-04-15 10:43:39 -07:00
" LLVMOption " ,
2022-08-02 16:57:32 -07:00
" LLVMObjCopy " ,
2021-04-15 10:43:39 -07:00
" LLVMMCA " ,
" LLVMMCDisassembler " ,
" LLVMLTO " ,
2025-07-16 04:41:14 +02:00
" LLVMFrontendOpenACC " ,
" LLVMFrontendHLSL " ,
" LLVMFrontendDriver " ,
" LLVMExtensions " ,
2021-04-15 10:43:39 -07:00
" LLVMPasses " ,
2024-04-25 14:12:55 -07:00
" LLVMHipStdPar " ,
2021-04-15 10:43:39 -07:00
" LLVMCoroutines " ,
2025-07-16 04:41:14 +02:00
" LLVMCFGuard " ,
2021-04-15 10:43:39 -07:00
" LLVMipo " ,
2025-07-16 04:41:14 +02:00
" LLVMInstrumentation " ,
2021-04-15 10:43:39 -07:00
" LLVMVectorize " ,
2025-02-05 10:15:15 +01:00
" LLVMSandboxIR " ,
2021-04-15 10:43:39 -07:00
" LLVMLinker " ,
" LLVMFrontendOpenMP " ,
2025-07-16 04:41:14 +02:00
" LLVMFrontendDirective " ,
2025-02-05 10:15:15 +01:00
" LLVMFrontendAtomic " ,
2025-07-16 04:41:14 +02:00
" LLVMFrontendOffloading " ,
" LLVMObjectYAML " ,
2023-01-29 13:12:13 -07:00
" LLVMDWARFLinkerParallel " ,
2024-04-25 14:12:55 -07:00
" LLVMDWARFLinkerClassic " ,
2021-04-15 10:43:39 -07:00
" LLVMDWARFLinker " ,
ability to build stage1 using only a zig tarball
The main idea here is that there are now 2 ways to get a stage1 zig
binary:
* The cmake path. Requirements: cmake, system C++ compiler, system
LLVM, LLD, Clang libraries, compiled by the system C++ compiler.
* The zig path. Requirements: a zig installation, system LLVM, LLD,
Clang libraries, compiled by the zig installation.
Note that the former can be used to now take the latter path.
Removed config.h.in and config.zig.in. The build.zig script no longer is
coupled to the cmake script.
cmake no longer tries to determine the zig version. A build with cmake
will yield a stage1 zig binary that reports 0.0.0+zig0. This is going to
get reverted.
`zig build` now accepts `-Dstage1` which will build the stage1 compiler,
and put the stage2 backend behind a feature flag.
build.zig is simplified to only support the use case of enabling LLVM
support when the LLVM, LLD, and Clang libraries were built by zig. This
part is probably sadly going to have to get reverted to make package
maintainers happy.
Zig build system addBuildOption supports a couple new types.
The biggest reason to make this change is that the zig path is an
attractive option for doing compiler development work on Windows. It
allows people to work on the compiler without having MSVC installed,
using only a .zip file that contains Zig + LLVM/LLD/Clang libraries.
2020-12-04 21:33:29 -07:00
" LLVMGlobalISel " ,
2021-04-15 10:43:39 -07:00
" LLVMMIRParser " ,
ability to build stage1 using only a zig tarball
The main idea here is that there are now 2 ways to get a stage1 zig
binary:
* The cmake path. Requirements: cmake, system C++ compiler, system
LLVM, LLD, Clang libraries, compiled by the system C++ compiler.
* The zig path. Requirements: a zig installation, system LLVM, LLD,
Clang libraries, compiled by the zig installation.
Note that the former can be used to now take the latter path.
Removed config.h.in and config.zig.in. The build.zig script no longer is
coupled to the cmake script.
cmake no longer tries to determine the zig version. A build with cmake
will yield a stage1 zig binary that reports 0.0.0+zig0. This is going to
get reverted.
`zig build` now accepts `-Dstage1` which will build the stage1 compiler,
and put the stage2 backend behind a feature flag.
build.zig is simplified to only support the use case of enabling LLVM
support when the LLVM, LLD, and Clang libraries were built by zig. This
part is probably sadly going to have to get reverted to make package
maintainers happy.
Zig build system addBuildOption supports a couple new types.
The biggest reason to make this change is that the zig path is an
attractive option for doing compiler development work on Windows. It
allows people to work on the compiler without having MSVC installed,
using only a .zip file that contains Zig + LLVM/LLD/Clang libraries.
2020-12-04 21:33:29 -07:00
" LLVMAsmPrinter " ,
2021-04-15 10:43:39 -07:00
" LLVMSelectionDAG " ,
ability to build stage1 using only a zig tarball
The main idea here is that there are now 2 ways to get a stage1 zig
binary:
* The cmake path. Requirements: cmake, system C++ compiler, system
LLVM, LLD, Clang libraries, compiled by the system C++ compiler.
* The zig path. Requirements: a zig installation, system LLVM, LLD,
Clang libraries, compiled by the zig installation.
Note that the former can be used to now take the latter path.
Removed config.h.in and config.zig.in. The build.zig script no longer is
coupled to the cmake script.
cmake no longer tries to determine the zig version. A build with cmake
will yield a stage1 zig binary that reports 0.0.0+zig0. This is going to
get reverted.
`zig build` now accepts `-Dstage1` which will build the stage1 compiler,
and put the stage2 backend behind a feature flag.
build.zig is simplified to only support the use case of enabling LLVM
support when the LLVM, LLD, and Clang libraries were built by zig. This
part is probably sadly going to have to get reverted to make package
maintainers happy.
Zig build system addBuildOption supports a couple new types.
The biggest reason to make this change is that the zig path is an
attractive option for doing compiler development work on Windows. It
allows people to work on the compiler without having MSVC installed,
using only a .zip file that contains Zig + LLVM/LLD/Clang libraries.
2020-12-04 21:33:29 -07:00
" LLVMCodeGen " ,
2023-08-11 22:33:20 -07:00
" LLVMTarget " ,
2023-01-29 13:12:13 -07:00
" LLVMObjCARCOpts " ,
2023-08-11 22:33:20 -07:00
" LLVMCodeGenTypes " ,
2025-02-05 10:15:15 +01:00
" LLVMCGData " ,
2023-01-29 13:12:13 -07:00
" LLVMIRPrinter " ,
2021-04-15 10:43:39 -07:00
" LLVMInterfaceStub " ,
" LLVMFileCheck " ,
" LLVMFuzzMutate " ,
ability to build stage1 using only a zig tarball
The main idea here is that there are now 2 ways to get a stage1 zig
binary:
* The cmake path. Requirements: cmake, system C++ compiler, system
LLVM, LLD, Clang libraries, compiled by the system C++ compiler.
* The zig path. Requirements: a zig installation, system LLVM, LLD,
Clang libraries, compiled by the zig installation.
Note that the former can be used to now take the latter path.
Removed config.h.in and config.zig.in. The build.zig script no longer is
coupled to the cmake script.
cmake no longer tries to determine the zig version. A build with cmake
will yield a stage1 zig binary that reports 0.0.0+zig0. This is going to
get reverted.
`zig build` now accepts `-Dstage1` which will build the stage1 compiler,
and put the stage2 backend behind a feature flag.
build.zig is simplified to only support the use case of enabling LLVM
support when the LLVM, LLD, and Clang libraries were built by zig. This
part is probably sadly going to have to get reverted to make package
maintainers happy.
Zig build system addBuildOption supports a couple new types.
The biggest reason to make this change is that the zig path is an
attractive option for doing compiler development work on Windows. It
allows people to work on the compiler without having MSVC installed,
using only a .zip file that contains Zig + LLVM/LLD/Clang libraries.
2020-12-04 21:33:29 -07:00
" LLVMScalarOpts " ,
" LLVMInstCombine " ,
" LLVMAggressiveInstCombine " ,
" LLVMTransformUtils " ,
" LLVMBitWriter " ,
" LLVMAnalysis " ,
" LLVMProfileData " ,
2022-08-02 16:57:32 -07:00
" LLVMSymbolize " ,
2023-08-11 22:33:20 -07:00
" LLVMDebugInfoBTF " ,
2022-08-02 16:57:32 -07:00
" LLVMDebugInfoPDB " ,
" LLVMDebugInfoMSF " ,
2025-02-05 10:15:15 +01:00
" LLVMDebugInfoCodeView " ,
2025-07-16 04:41:14 +02:00
" LLVMDebugInfoGSYM " ,
2022-07-03 18:41:43 -07:00
" LLVMDebugInfoDWARF " ,
2025-07-16 04:41:14 +02:00
" LLVMDebugInfoDWARFLowLevel " ,
ability to build stage1 using only a zig tarball
The main idea here is that there are now 2 ways to get a stage1 zig
binary:
* The cmake path. Requirements: cmake, system C++ compiler, system
LLVM, LLD, Clang libraries, compiled by the system C++ compiler.
* The zig path. Requirements: a zig installation, system LLVM, LLD,
Clang libraries, compiled by the zig installation.
Note that the former can be used to now take the latter path.
Removed config.h.in and config.zig.in. The build.zig script no longer is
coupled to the cmake script.
cmake no longer tries to determine the zig version. A build with cmake
will yield a stage1 zig binary that reports 0.0.0+zig0. This is going to
get reverted.
`zig build` now accepts `-Dstage1` which will build the stage1 compiler,
and put the stage2 backend behind a feature flag.
build.zig is simplified to only support the use case of enabling LLVM
support when the LLVM, LLD, and Clang libraries were built by zig. This
part is probably sadly going to have to get reverted to make package
maintainers happy.
Zig build system addBuildOption supports a couple new types.
The biggest reason to make this change is that the zig path is an
attractive option for doing compiler development work on Windows. It
allows people to work on the compiler without having MSVC installed,
using only a .zip file that contains Zig + LLVM/LLD/Clang libraries.
2020-12-04 21:33:29 -07:00
" LLVMObject " ,
" LLVMTextAPI " ,
" LLVMMCParser " ,
2023-01-29 13:12:13 -07:00
" LLVMIRReader " ,
" LLVMAsmParser " ,
ability to build stage1 using only a zig tarball
The main idea here is that there are now 2 ways to get a stage1 zig
binary:
* The cmake path. Requirements: cmake, system C++ compiler, system
LLVM, LLD, Clang libraries, compiled by the system C++ compiler.
* The zig path. Requirements: a zig installation, system LLVM, LLD,
Clang libraries, compiled by the zig installation.
Note that the former can be used to now take the latter path.
Removed config.h.in and config.zig.in. The build.zig script no longer is
coupled to the cmake script.
cmake no longer tries to determine the zig version. A build with cmake
will yield a stage1 zig binary that reports 0.0.0+zig0. This is going to
get reverted.
`zig build` now accepts `-Dstage1` which will build the stage1 compiler,
and put the stage2 backend behind a feature flag.
build.zig is simplified to only support the use case of enabling LLVM
support when the LLVM, LLD, and Clang libraries were built by zig. This
part is probably sadly going to have to get reverted to make package
maintainers happy.
Zig build system addBuildOption supports a couple new types.
The biggest reason to make this change is that the zig path is an
attractive option for doing compiler development work on Windows. It
allows people to work on the compiler without having MSVC installed,
using only a .zip file that contains Zig + LLVM/LLD/Clang libraries.
2020-12-04 21:33:29 -07:00
" LLVMMC " ,
2021-04-15 10:43:39 -07:00
" LLVMBitReader " ,
2022-08-02 16:57:32 -07:00
" LLVMFuzzerCLI " ,
2021-04-15 10:43:39 -07:00
" LLVMCore " ,
" LLVMRemarks " ,
" LLVMBitstreamReader " ,
ability to build stage1 using only a zig tarball
The main idea here is that there are now 2 ways to get a stage1 zig
binary:
* The cmake path. Requirements: cmake, system C++ compiler, system
LLVM, LLD, Clang libraries, compiled by the system C++ compiler.
* The zig path. Requirements: a zig installation, system LLVM, LLD,
Clang libraries, compiled by the zig installation.
Note that the former can be used to now take the latter path.
Removed config.h.in and config.zig.in. The build.zig script no longer is
coupled to the cmake script.
cmake no longer tries to determine the zig version. A build with cmake
will yield a stage1 zig binary that reports 0.0.0+zig0. This is going to
get reverted.
`zig build` now accepts `-Dstage1` which will build the stage1 compiler,
and put the stage2 backend behind a feature flag.
build.zig is simplified to only support the use case of enabling LLVM
support when the LLVM, LLD, and Clang libraries were built by zig. This
part is probably sadly going to have to get reverted to make package
maintainers happy.
Zig build system addBuildOption supports a couple new types.
The biggest reason to make this change is that the zig path is an
attractive option for doing compiler development work on Windows. It
allows people to work on the compiler without having MSVC installed,
using only a .zip file that contains Zig + LLVM/LLD/Clang libraries.
2020-12-04 21:33:29 -07:00
" LLVMBinaryFormat " ,
2023-01-29 13:12:13 -07:00
" LLVMTargetParser " ,
ability to build stage1 using only a zig tarball
The main idea here is that there are now 2 ways to get a stage1 zig
binary:
* The cmake path. Requirements: cmake, system C++ compiler, system
LLVM, LLD, Clang libraries, compiled by the system C++ compiler.
* The zig path. Requirements: a zig installation, system LLVM, LLD,
Clang libraries, compiled by the zig installation.
Note that the former can be used to now take the latter path.
Removed config.h.in and config.zig.in. The build.zig script no longer is
coupled to the cmake script.
cmake no longer tries to determine the zig version. A build with cmake
will yield a stage1 zig binary that reports 0.0.0+zig0. This is going to
get reverted.
`zig build` now accepts `-Dstage1` which will build the stage1 compiler,
and put the stage2 backend behind a feature flag.
build.zig is simplified to only support the use case of enabling LLVM
support when the LLVM, LLD, and Clang libraries were built by zig. This
part is probably sadly going to have to get reverted to make package
maintainers happy.
Zig build system addBuildOption supports a couple new types.
The biggest reason to make this change is that the zig path is an
attractive option for doing compiler development work on Windows. It
allows people to work on the compiler without having MSVC installed,
using only a .zip file that contains Zig + LLVM/LLD/Clang libraries.
2020-12-04 21:33:29 -07:00
" LLVMSupport " ,
" LLVMDemangle " ,
} ;
2025-03-26 23:19:35 +01:00
const llvm_libs_m68k = [ _ ] [ ] const u8 {
" LLVMM68kDisassembler " ,
" LLVMM68kAsmParser " ,
" LLVMM68kCodeGen " ,
" LLVMM68kDesc " ,
" LLVMM68kInfo " ,
} ;
const llvm_libs_csky = [ _ ] [ ] const u8 {
" LLVMCSKYDisassembler " ,
" LLVMCSKYAsmParser " ,
" LLVMCSKYCodeGen " ,
" LLVMCSKYDesc " ,
" LLVMCSKYInfo " ,
} ;
const llvm_libs_arc = [ _ ] [ ] const u8 {
" LLVMARCDisassembler " ,
" LLVMARCCodeGen " ,
" LLVMARCDesc " ,
" LLVMARCInfo " ,
} ;
const llvm_libs_xtensa = [ _ ] [ ] const u8 {
" LLVMXtensaDisassembler " ,
" LLVMXtensaAsmParser " ,
" LLVMXtensaCodeGen " ,
" LLVMXtensaDesc " ,
" LLVMXtensaInfo " ,
} ;
2024-04-24 17:41:47 -07:00
fn generateLangRef ( b : * std . Build ) std . Build . LazyPath {
const doctest_exe = b . addExecutable ( . {
. name = " doctest " ,
2024-12-15 18:09:38 +00:00
. root_module = b . createModule ( . {
. root_source_file = b . path ( " tools/doctest.zig " ) ,
. target = b . graph . host ,
. optimize = . Debug ,
} ) ,
2024-04-24 17:41:47 -07:00
} ) ;
var dir = b . build_root . handle . openDir ( " doc/langref " , . { . iterate = true } ) catch | err | {
2025-06-27 20:05:22 -07:00
std . debug . panic ( " unable to open '{f}doc/langref' directory: {s} " , . {
2024-07-11 16:26:04 -07:00
b . build_root , @errorName ( err ) ,
} ) ;
2024-04-24 17:41:47 -07:00
} ;
defer dir . close ( ) ;
var wf = b . addWriteFiles ( ) ;
var it = dir . iterateAssumeFirstIteration ( ) ;
while ( it . next ( ) catch @panic ( " failed to read dir " ) ) | entry | {
if ( std . mem . startsWith ( u8 , entry . name , " . " ) or entry . kind != . file )
continue ;
const out_basename = b . fmt ( " {s}.out " , . { std . fs . path . stem ( entry . name ) } ) ;
const cmd = b . addRunArtifact ( doctest_exe ) ;
cmd . addArgs ( & . {
" --zig " , b . graph . zig_exe ,
// TODO: enhance doctest to use "--listen=-" rather than operating
// in a temporary directory
" --cache-root " , b . cache_root . path orelse " . " ,
} ) ;
2025-06-27 20:05:22 -07:00
cmd . addArgs ( & . { " --zig-lib-dir " , b . fmt ( " {f} " , . { b . graph . zig_lib_directory } ) } ) ;
2024-04-24 17:41:47 -07:00
cmd . addArgs ( & . { " -i " } ) ;
cmd . addFileArg ( b . path ( b . fmt ( " doc/langref/{s} " , . { entry . name } ) ) ) ;
cmd . addArgs ( & . { " -o " } ) ;
_ = wf . addCopyFile ( cmd . addOutputFileArg ( out_basename ) , out_basename ) ;
}
const docgen_exe = b . addExecutable ( . {
. name = " docgen " ,
2024-12-15 18:09:38 +00:00
. root_module = b . createModule ( . {
. root_source_file = b . path ( " tools/docgen.zig " ) ,
. target = b . graph . host ,
. optimize = . Debug ,
} ) ,
2024-04-24 17:41:47 -07:00
} ) ;
const docgen_cmd = b . addRunArtifact ( docgen_exe ) ;
docgen_cmd . addArgs ( & . { " --code-dir " } ) ;
docgen_cmd . addDirectoryArg ( wf . getDirectory ( ) ) ;
docgen_cmd . addFileArg ( b . path ( " doc/langref.html.in " ) ) ;
return docgen_cmd . addOutputFileArg ( " langref.html " ) ;
}
2024-06-16 20:03:14 -07:00
2024-10-12 06:27:30 +02:00
fn superHtmlCheck ( b : * std . Build , html_file : std . Build . LazyPath ) * std . Build . Step {
const run_superhtml = b . addSystemCommand ( & . {
" superhtml " , " check " ,
2024-06-16 20:03:14 -07:00
} ) ;
2024-10-12 06:27:30 +02:00
run_superhtml . addFileArg ( html_file ) ;
run_superhtml . expectExitCode ( 0 ) ;
return & run_superhtml . step ;
2024-06-16 20:03:14 -07:00
}