2017-12-27 00:44:08 +00:00
const builtin = @import ( " builtin " ) ;
2017-12-12 04:34:59 +00:00
const std = @import ( " std " ) ;
const Builder = std . build . Builder ;
2017-04-19 05:13:15 +00:00
const tests = @import ( " test/tests.zig " ) ;
2017-12-12 04:34:59 +00:00
const BufMap = std . BufMap ;
const warn = std . debug . warn ;
const mem = std . mem ;
const ArrayList = std . ArrayList ;
const io = std . io ;
2019-05-26 17:17:34 +00:00
const fs = std . fs ;
2019-07-14 07:06:20 +00:00
const InstallDirectoryOptions = std . build . InstallDirectoryOptions ;
2020-09-04 03:23:00 +00:00
const assert = std . debug . assert ;
2017-04-19 05:13:15 +00:00
2021-01-02 04:01:51 +00:00
const zig_version = std . builtin . Version { . major = 0 , . minor = 8 , . patch = 0 } ;
2020-08-15 21:17:40 +00:00
2018-05-31 14:56:59 +00:00
pub fn build ( b : * Builder ) ! void {
2019-07-04 21:43:56 +00:00
b . setPreferredReleaseMode ( . ReleaseFast ) ;
2017-10-21 21:31:06 +00:00
const mode = b . standardReleaseOptions ( ) ;
2020-07-21 18:18:51 +00:00
const target = b . standardTargetOptions ( . { } ) ;
2017-10-21 21:31:06 +00:00
2017-11-07 08:22:27 +00:00
var docgen_exe = b . addExecutable ( " docgen " , " doc/docgen.zig " ) ;
2019-05-26 17:17:34 +00:00
const rel_zig_exe = try fs . path . relative ( b . allocator , b . build_root , b . zig_exe ) ;
const langref_out_path = fs . path . join (
2019-02-07 05:42:41 +00:00
b . allocator ,
2019-11-27 08:30:39 +00:00
& [ _ ] [ ] const u8 { b . cache_root , " langref.html " } ,
2019-02-07 05:42:41 +00:00
) catch unreachable ;
breaking changes to zig build API and improved caching
* in Zig build scripts, getOutputPath() is no longer a valid function
to call, unless setOutputDir() was used, or within a custom make()
function. Instead there is more convenient API to use which takes
advantage of the caching system. Search this commit diff for
`exe.run()` for an example.
* Zig build by default enables caching. All build artifacts will go
into zig-cache. If you want to access build artifacts in a convenient
location, it is recommended to add an `install` step. Otherwise
you can use the `run()` API mentioned above to execute programs
directly from their location in the cache. Closes #330.
`addSystemCommand` is available for programs not built with Zig
build.
* Please note that Zig does no cache evicting yet. You may have to
manually delete zig-cache directories periodically to keep disk
usage down. It's planned for this to be a simple Least Recently
Used eviction system eventually.
* `--output`, `--output-lib`, and `--output-h` are removed. Instead,
use `--output-dir` which defaults to the current working directory.
Or take advantage of `--cache on`, which will print the main output
path to stdout, and the other artifacts will be in the same directory
with predictable file names. `--disable-gen-h` is available when
one wants to prevent .h file generation.
* `@cImport` is always independently cached now. Closes #2015.
It always writes the generated Zig code to disk which makes debug
info and compile errors better. No more "TODO: remember C source
location to display here"
* Fix .d file parsing. (Fixes the MacOS CI failure)
* Zig no longer creates "temporary files" other than inside a
zig-cache directory.
This breaks the CLI API that Godbolt uses. The suggested new invocation
can be found in this commit diff, in the changes to `test/cli.zig`.
2019-03-09 03:53:35 +00:00
var docgen_cmd = docgen_exe . run ( ) ;
2019-11-27 08:30:39 +00:00
docgen_cmd . addArgs ( & [ _ ] [ ] const u8 {
2018-01-17 06:50:35 +00:00
rel_zig_exe ,
2019-05-26 17:17:34 +00:00
" doc " + + fs . path . sep_str + + " langref.html.in " ,
2018-09-12 15:49:46 +00:00
langref_out_path ,
2017-11-07 08:22:27 +00:00
} ) ;
docgen_cmd . step . dependOn ( & docgen_exe . step ) ;
const docs_step = b . step ( " docs " , " Build documentation " ) ;
docs_step . dependOn ( & docgen_cmd . step ) ;
2018-01-03 23:25:17 +00:00
const test_step = b . step ( " test " , " Run all the tests " ) ;
2020-09-22 01:38:55 +00:00
var test_stage2 = b . addTest ( " src/test.zig " ) ;
2020-08-20 20:16:04 +00:00
test_stage2 . setBuildMode ( mode ) ;
2019-11-23 20:56:05 +00:00
test_stage2 . addPackagePath ( " stage2_tests " , " test/stage2/test.zig " ) ;
2018-01-04 02:32:50 +00:00
2019-11-27 08:30:39 +00:00
const fmt_build_zig = b . addFmt ( & [ _ ] [ ] const u8 { " build.zig " } ) ;
2019-02-26 23:10:40 +00:00
2018-07-11 18:09:05 +00:00
const skip_release = b . option ( bool , " skip-release " , " Main test suite skips release builds " ) orelse false ;
2018-09-12 18:50:26 +00: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 ;
2019-05-15 01:21:59 +00:00
const skip_non_native = b . option ( bool , " skip-non-native " , " Main test suite skips non-native builds " ) orelse false ;
2019-09-22 03:55:56 +00:00
const skip_libc = b . option ( bool , " skip-libc " , " Main test suite skips tests that link libc " ) orelse false ;
2020-08-31 21:54:05 +00:00
const skip_compile_errors = b . option ( bool , " skip-compile-errors " , " Main test suite skips compile error tests " ) orelse false ;
2017-10-21 21:31:06 +00:00
2019-07-14 07:06:20 +00:00
const only_install_lib_files = b . option ( bool , " lib-files-only " , " Only install library files " ) orelse false ;
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-05 04:33:29 +00:00
const is_stage1 = b . option ( bool , " stage1 " , " Build the stage1 compiler, put stage2 behind a feature flag " ) orelse false ;
2020-12-08 00:23:17 +00:00
const static_llvm = b . option ( bool , " static-llvm " , " Disable integration with system-installed LLVM, Clang, LLD, and libc++ " ) orelse false ;
const enable_llvm = b . option ( bool , " enable-llvm " , " Build self-hosted compiler with LLVM backend enabled " ) orelse ( is_stage1 or static_llvm ) ;
2020-07-04 01:15:01 +00:00
const config_h_path_option = b . option ( [ ] const u8 , " config_h " , " Path to the generated config.h " ) ;
2020-04-06 17:07:19 +00:00
2019-07-14 07:06:20 +00:00
b . installDirectory ( InstallDirectoryOptions {
2019-07-15 21:54:50 +00:00
. source_dir = " lib " ,
2019-07-14 07:06:20 +00:00
. install_dir = . Lib ,
2019-07-15 21:54:50 +00:00
. install_subdir = " zig " ,
2020-09-07 22:15:48 +00:00
. exclude_extensions = & [ _ ] [ ] const u8 {
" test.zig " ,
" README.md " ,
" .z.0 " ,
" .z.9 " ,
2020-09-11 20:17:08 +00:00
" .gz " ,
2020-09-07 22:15:48 +00:00
" rfc1951.txt " ,
} ,
2019-07-14 07:06:20 +00:00
} ) ;
2017-10-21 21:31:06 +00:00
2020-09-08 18:15:32 +00:00
if ( only_install_lib_files )
return ;
2020-09-17 00:17:37 +00:00
const tracy = b . option ( [ ] const u8 , " tracy " , " Enable Tracy integration. Supply path to Tracy source " ) ;
const link_libc = b . option ( bool , " force-link-libc " , " Force self-hosted compiler to link libc " ) orelse enable_llvm ;
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-05 04:33:29 +00:00
const main_file = if ( is_stage1 ) " src/stage1.zig " else " src/main.zig " ;
2020-12-05 05:24:04 +00:00
var exe = b . addExecutable ( " zig " , main_file ) ;
2020-09-08 18:15:32 +00:00
exe . install ( ) ;
exe . setBuildMode ( mode ) ;
exe . setTarget ( target ) ;
test_step . dependOn ( & exe . step ) ;
b . default_step . dependOn ( & exe . step ) ;
2020-12-02 21:51:22 +00:00
exe . addBuildOption ( bool , " skip_non_native " , skip_non_native ) ;
2020-09-08 18:15:32 +00:00
exe . addBuildOption ( bool , " have_llvm " , enable_llvm ) ;
if ( enable_llvm ) {
2020-12-08 00:23:17 +00:00
const cmake_cfg = if ( static_llvm ) null else findAndParseConfigH ( b , config_h_path_option ) ;
2020-12-29 17:52:53 +00:00
const exe_cflags = [ _ ] [ ] const u8 {
" -std=c++14 " ,
" -D__STDC_CONSTANT_MACROS " ,
" -D__STDC_FORMAT_MACROS " ,
" -D__STDC_LIMIT_MACROS " ,
" -D_GNU_SOURCE " ,
" -fvisibility-inlines-hidden " ,
" -fno-exceptions " ,
" -fno-rtti " ,
" -Werror=type-limits " ,
" -Wno-missing-braces " ,
" -Wno-comment " ,
} ;
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-05 04:33:29 +00:00
if ( is_stage1 ) {
exe . addIncludeDir ( " src " ) ;
exe . addIncludeDir ( " deps/SoftFloat-3e/source/include " ) ;
2020-12-05 05:24:04 +00:00
// This is intentionally a dummy path. stage1.zig tries to @import("compiler_rt") in case
// of being built by cmake. But when built by zig it's gonna get a compiler_rt so that
// is pointless.
exe . addPackagePath ( " compiler_rt " , " src/empty.zig " ) ;
2020-12-08 00:23:17 +00:00
exe . defineCMacro ( " ZIG_LINK_MODE=Static " ) ;
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-05 04:33:29 +00:00
const softfloat = b . addStaticLibrary ( " softfloat " , null ) ;
softfloat . setBuildMode ( . ReleaseFast ) ;
softfloat . setTarget ( target ) ;
softfloat . addIncludeDir ( " deps/SoftFloat-3e-prebuilt " ) ;
softfloat . addIncludeDir ( " deps/SoftFloat-3e/source/8086 " ) ;
softfloat . addIncludeDir ( " deps/SoftFloat-3e/source/include " ) ;
softfloat . addCSourceFiles ( & softfloat_sources , & [ _ ] [ ] const u8 { " -std=c99 " , " -O3 " } ) ;
exe . linkLibrary ( softfloat ) ;
2020-12-05 05:55:50 +00:00
exe . addCSourceFiles ( & stage1_sources , & exe_cflags ) ;
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-05 04:33:29 +00:00
exe . addCSourceFiles ( & optimized_c_sources , & [ _ ] [ ] const u8 { " -std=c99 " , " -O3 " } ) ;
}
2020-12-08 00:23:17 +00: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 ) {
b . addSearchPrefix ( cfg . cmake_prefix_path ) ;
}
exe . addObjectFile ( fs . path . join ( b . allocator , & [ _ ] [ ] const u8 {
cfg . cmake_binary_dir ,
" zigcpp " ,
b . fmt ( " {s}{s}{s} " , . { exe . target . libPrefix ( ) , " zigcpp " , exe . target . staticLibSuffix ( ) } ) ,
} ) catch unreachable ) ;
assert ( cfg . lld_include_dir . len ! = 0 ) ;
exe . addIncludeDir ( cfg . lld_include_dir ) ;
addCMakeLibraryList ( exe , cfg . clang_libraries ) ;
addCMakeLibraryList ( exe , cfg . lld_libraries ) ;
addCMakeLibraryList ( exe , cfg . llvm_libraries ) ;
const need_cpp_includes = tracy ! = null ;
// System -lc++ must be used because in this code path we are attempting to link
// against system-provided LLVM, Clang, LLD.
if ( exe . target . getOsTag ( ) = = . linux ) {
// First we try to static link against gcc libstdc++. If that doesn't work,
// we fall back to -lc++ and cross our fingers.
addCxxKnownPath ( b , cfg , exe , " libstdc++.a " , " " , need_cpp_includes ) catch | err | switch ( err ) {
error . RequiredLibraryNotFound = > {
exe . linkSystemLibrary ( " c++ " ) ;
} ,
else = > | e | return e ,
} ;
exe . linkSystemLibrary ( " pthread " ) ;
} else if ( exe . target . isFreeBSD ( ) ) {
try addCxxKnownPath ( b , cfg , exe , " libc++.a " , null , need_cpp_includes ) ;
exe . linkSystemLibrary ( " pthread " ) ;
2020-12-15 19:45:48 +00:00
} else if ( exe . target . getOsTag ( ) = = . openbsd ) {
try addCxxKnownPath ( b , cfg , exe , " libc++.a " , null , need_cpp_includes ) ;
try addCxxKnownPath ( b , cfg , exe , " libc++abi.a " , null , need_cpp_includes ) ;
2020-12-08 00:23:17 +00:00
} else if ( exe . target . isDarwin ( ) ) {
if ( addCxxKnownPath ( b , cfg , exe , " libgcc_eh.a " , " " , need_cpp_includes ) ) {
// Compiler is GCC.
try addCxxKnownPath ( b , cfg , exe , " libstdc++.a " , null , need_cpp_includes ) ;
exe . linkSystemLibrary ( " pthread " ) ;
// TODO LLD cannot perform this link.
// Set ZIG_SYSTEM_LINKER_HACK env var to use system linker ld instead.
// See https://github.com/ziglang/zig/issues/1535
} else | err | switch ( err ) {
error . RequiredLibraryNotFound = > {
// System compiler, not gcc.
exe . linkSystemLibrary ( " c++ " ) ;
} ,
else = > | e | return e ,
}
}
2020-09-08 18:15:32 +00:00
2020-12-08 00:23:17 +00:00
if ( cfg . dia_guids_lib . len ! = 0 ) {
exe . addObjectFile ( cfg . dia_guids_lib ) ;
}
} else {
// Here we are -Denable-llvm but no cmake integration.
2020-12-29 17:52:53 +00: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 " } ;
exe . addCSourceFiles ( & zig_cpp_sources , & zig_cpp_cflags ) ;
2020-12-08 00:23:17 +00:00
for ( clang_libs ) | lib_name | {
exe . linkSystemLibrary ( lib_name ) ;
}
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-05 04:33:29 +00:00
2020-12-08 00:23:17 +00:00
for ( lld_libs ) | lib_name | {
exe . linkSystemLibrary ( lib_name ) ;
}
2020-09-08 18:15:32 +00:00
2020-12-08 00:23:17 +00:00
for ( llvm_libs ) | lib_name | {
exe . linkSystemLibrary ( lib_name ) ;
}
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-05 04:33:29 +00:00
2020-12-08 00:23:17 +00:00
// This means we rely on clang-or-zig-built LLVM, Clang, LLD libraries.
exe . linkSystemLibrary ( " c++ " ) ;
2020-12-05 05:55:50 +00:00
2020-12-08 00:23:17 +00:00
if ( target . getOs ( ) . tag = = . windows ) {
exe . linkSystemLibrary ( " version " ) ;
exe . linkSystemLibrary ( " uuid " ) ;
}
2020-12-05 05:55:50 +00:00
}
2020-09-08 18:15:32 +00:00
}
if ( link_libc ) {
exe . linkLibC ( ) ;
test_stage2 . linkLibC ( ) ;
}
const log_scopes = b . option ( [ ] const [ ] const u8 , " log " , " Which log scopes to enable " ) orelse & [ 0 ] [ ] const u8 { } ;
const opt_version_string = b . option ( [ ] const u8 , " version-string " , " Override Zig version string. Default is to find out with git. " ) ;
const version = if ( opt_version_string ) | version | version else v : {
2020-11-26 12:28:38 +00:00
const version_string = b . fmt ( " {d}.{d}.{d} " , . { zig_version . major , zig_version . minor , zig_version . patch } ) ;
2020-09-08 18:15:32 +00:00
var code : u8 = undefined ;
2021-01-02 04:01:51 +00:00
const git_describe_untrimmed = b . execAllowFail ( & [ _ ] [ ] const u8 {
" git " , " -C " , b . build_root , " describe " , " --match " , " *.*.* " , " --tags " ,
2020-09-08 18:15:32 +00:00
} , & code , . Ignore ) catch {
break : v version_string ;
} ;
2021-01-02 04:01:51 +00:00
const git_describe = mem . trim ( u8 , git_describe_untrimmed , " \n \r " ) ;
switch ( mem . count ( u8 , git_describe , " - " ) ) {
0 = > {
// Tagged release version (e.g. 0.7.0).
if ( ! mem . eql ( u8 , git_describe , version_string ) ) {
2020-11-26 12:28:38 +00:00
std . debug . print ( " Zig version '{s}' does not match Git tag '{s}' \n " , . { version_string , git_describe } ) ;
2021-01-02 04:01:51 +00:00
std . process . exit ( 1 ) ;
}
break : v version_string ;
} ,
2 = > {
// Untagged development build (e.g. 0.7.0-684-gbbe2cca1a).
var it = mem . split ( git_describe , " - " ) ;
const tagged_ancestor = it . next ( ) orelse unreachable ;
const commit_height = it . next ( ) orelse unreachable ;
const commit_id = it . next ( ) orelse unreachable ;
const ancestor_ver = try std . builtin . Version . parse ( tagged_ancestor ) ;
if ( zig_version . order ( ancestor_ver ) ! = . gt ) {
std . debug . print ( " Zig version '{}' must be greater than tagged ancestor '{}' \n " , . { zig_version , ancestor_ver } ) ;
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 12:28:38 +00:00
std . debug . print ( " Unexpected `git describe` output: {s} \n " , . { git_describe } ) ;
2021-01-02 04:01:51 +00:00
break : v version_string ;
}
// The version is reformatted in accordance with the https://semver.org specification.
2020-11-26 12:28:38 +00:00
break : v b . fmt ( " {s}-dev.{s}+{s} " , . { version_string , commit_height , commit_id [ 1 . . ] } ) ;
2021-01-02 04:01:51 +00:00
} ,
else = > {
2020-11-26 12:28:38 +00:00
std . debug . print ( " Unexpected `git describe` output: {s} \n " , . { git_describe } ) ;
2021-01-02 04:01:51 +00:00
break : v version_string ;
} ,
2020-09-08 18:15:32 +00: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-05 04:33:29 +00:00
exe . addBuildOption ( [ : 0 ] const u8 , " version " , try b . allocator . dupeZ ( u8 , version ) ) ;
const semver = try std . SemanticVersion . parse ( version ) ;
exe . addBuildOption ( std . SemanticVersion , " semver " , semver ) ;
2020-09-08 18:15:32 +00:00
exe . addBuildOption ( [ ] const [ ] const u8 , " log_scopes " , log_scopes ) ;
exe . addBuildOption ( bool , " enable_tracy " , tracy ! = null ) ;
2020-12-05 05:24:04 +00:00
exe . addBuildOption ( bool , " is_stage1 " , is_stage1 ) ;
2020-09-08 18:15:32 +00:00
if ( tracy ) | tracy_path | {
const client_cpp = fs . path . join (
b . allocator ,
& [ _ ] [ ] const u8 { tracy_path , " TracyClient.cpp " } ,
) catch unreachable ;
exe . addIncludeDir ( tracy_path ) ;
exe . addCSourceFile ( client_cpp , & [ _ ] [ ] const u8 { " -DTRACY_ENABLE=1 " , " -fno-sanitize=undefined " } ) ;
2020-09-17 00:17:37 +00:00
if ( ! enable_llvm ) {
exe . linkSystemLibraryName ( " c++ " ) ;
}
2020-09-08 18:15:32 +00:00
exe . linkLibC ( ) ;
}
2017-04-19 05:13:15 +00:00
const test_filter = b . option ( [ ] const u8 , " test-filter " , " Skip tests that do not match filter " ) ;
2019-09-22 03:55:56 +00:00
const is_wine_enabled = b . option ( bool , " enable-wine " , " Use Wine to run cross compiled Windows tests " ) orelse false ;
const is_qemu_enabled = b . option ( bool , " enable-qemu " , " Use QEMU to run cross compiled foreign architecture tests " ) orelse false ;
2020-05-13 06:08:16 +00:00
const is_wasmtime_enabled = b . option ( bool , " enable-wasmtime " , " Use Wasmtime to enable and run WASI libstd tests " ) orelse false ;
2019-09-22 03:55:56 +00:00
const glibc_multi_dir = b . option ( [ ] const u8 , " enable-foreign-glibc " , " Provide directory with glibc installations to run cross compiled tests that link glibc " ) ;
2020-12-02 21:51:22 +00:00
test_stage2 . addBuildOption ( bool , " skip_non_native " , skip_non_native ) ;
2020-12-05 05:24:04 +00:00
test_stage2 . addBuildOption ( bool , " is_stage1 " , is_stage1 ) ;
2020-09-08 08:11:10 +00:00
test_stage2 . addBuildOption ( bool , " have_llvm " , enable_llvm ) ;
2020-08-04 22:32:16 +00:00
test_stage2 . addBuildOption ( bool , " enable_qemu " , is_qemu_enabled ) ;
test_stage2 . addBuildOption ( bool , " enable_wine " , is_wine_enabled ) ;
test_stage2 . addBuildOption ( bool , " enable_wasmtime " , is_wasmtime_enabled ) ;
test_stage2 . addBuildOption ( ? [ ] const u8 , " glibc_multi_install_dir " , glibc_multi_dir ) ;
2020-09-08 18:15:32 +00:00
test_stage2 . addBuildOption ( [ ] const u8 , " version " , version ) ;
2020-08-04 22:32:16 +00:00
2018-07-11 00:18:43 +00:00
const test_stage2_step = b . step ( " test-stage2 " , " Run the stage2 compiler tests " ) ;
test_stage2_step . dependOn ( & test_stage2 . step ) ;
2019-11-23 20:56:05 +00:00
test_step . dependOn ( test_stage2_step ) ;
2018-07-11 00:18:43 +00:00
2018-09-12 18:50:26 +00:00
var chosen_modes : [ 4 ] builtin . Mode = undefined ;
var chosen_mode_index : usize = 0 ;
chosen_modes [ chosen_mode_index ] = builtin . Mode . Debug ;
chosen_mode_index + = 1 ;
if ( ! skip_release_safe ) {
chosen_modes [ chosen_mode_index ] = builtin . Mode . ReleaseSafe ;
chosen_mode_index + = 1 ;
}
if ( ! skip_release_fast ) {
chosen_modes [ chosen_mode_index ] = builtin . Mode . ReleaseFast ;
chosen_mode_index + = 1 ;
}
if ( ! skip_release_small ) {
chosen_modes [ chosen_mode_index ] = builtin . Mode . ReleaseSmall ;
chosen_mode_index + = 1 ;
}
const modes = chosen_modes [ 0 . . chosen_mode_index ] ;
2017-11-07 08:22:27 +00:00
2019-02-26 23:10:40 +00:00
// run stage1 `zig fmt` on this build.zig file just to make sure it works
test_step . dependOn ( & fmt_build_zig . step ) ;
const fmt_step = b . step ( " test-fmt " , " Run zig fmt against build.zig to make sure it works " ) ;
fmt_step . dependOn ( & fmt_build_zig . step ) ;
Add/fix missing WASI functionality to pass libstd tests
This rather large commit adds/fixes missing WASI functionality
in `libstd` needed to pass the `libstd` tests. As such, now by
default tests targeting `wasm32-wasi` target are enabled in
`test/tests.zig` module. However, they can be disabled by passing
the `-Dskip-wasi=true` flag when invoking the `zig build test`
command. When the flag is set to `false`, i.e., when WASI tests are
included, `wasmtime` with `--dir=.` is used as the default testing
command.
Since the majority of `libstd` tests were relying on `fs.cwd()`
call to get current working directory handle wrapped in `Dir`
struct, in order to make the tests WASI-friendly, `fs.cwd()`
call was replaced with `testing.getTestDir()` function which
resolved to either `fs.cwd()` for non-WASI targets, or tries to
fetch the preopen list from the WASI runtime and extract a
preopen for '.' path.
The summary of changes introduced by this commit:
* implement `Dir.makeDir` and `Dir.openDir` targeting WASI
* implement `Dir.deleteFile` and `Dir.deleteDir` targeting WASI
* fix `os.close` and map errors in `unlinkat`
* move WASI-specific `mkdirat` and `unlinkat` from `std.fs.wasi`
to `std.os` module
* implement `lseek_{SET, CUR, END}` targeting WASI
* implement `futimens` targeting WASI
* implement `ftruncate` targeting WASI
* implement `readv`, `writev`, `pread{v}`, `pwrite{v}` targeting WASI
* make sure ANSI escape codes are _not_ used in stderr or stdout
in WASI, as WASI always sanitizes stderr, and sanitizes stdout if
fd is a TTY
* fix specifying WASI rights when opening/creating files/dirs
* tweak `AtomicFile` to be WASI-compatible
* implement `os.renameatWasi` for WASI-compliant `os.renameat` function
* implement sleep() targeting WASI
* fix `process.getEnvMap` targeting WASI
2020-05-05 15:23:49 +00:00
// TODO for the moment, skip wasm32-wasi until bugs are sorted out.
2020-05-18 15:45:06 +00:00
test_step . dependOn ( tests . addPkgTests ( b , test_filter , " test/stage1/behavior.zig " , " behavior " , " Run the behavior tests " , modes , false , skip_non_native , skip_libc , is_wine_enabled , is_qemu_enabled , is_wasmtime_enabled , glibc_multi_dir ) ) ;
2017-04-19 08:12:22 +00:00
2020-05-13 06:08:16 +00:00
test_step . dependOn ( tests . addPkgTests ( b , test_filter , " lib/std/std.zig " , " std " , " Run the standard library tests " , modes , false , skip_non_native , skip_libc , is_wine_enabled , is_qemu_enabled , is_wasmtime_enabled , glibc_multi_dir ) ) ;
2017-04-20 06:26:36 +00:00
2020-05-13 06:08:16 +00:00
test_step . dependOn ( tests . addPkgTests ( b , test_filter , " lib/std/special/compiler_rt.zig " , " compiler-rt " , " Run the compiler_rt tests " , modes , true , skip_non_native , true , is_wine_enabled , is_qemu_enabled , is_wasmtime_enabled , glibc_multi_dir ) ) ;
2017-08-18 17:51:16 +00:00
2018-07-11 23:38:01 +00:00
test_step . dependOn ( tests . addCompareOutputTests ( b , test_filter , modes ) ) ;
2019-07-16 16:15:46 +00:00
test_step . dependOn ( tests . addStandaloneTests ( b , test_filter , modes ) ) ;
2019-09-03 14:08:39 +00:00
test_step . dependOn ( tests . addStackTraceTests ( b , test_filter , modes ) ) ;
2020-09-27 04:03:38 +00:00
test_step . dependOn ( tests . addCliTests ( b , test_filter , modes ) ) ;
2018-07-11 23:38:01 +00:00
test_step . dependOn ( tests . addAssembleAndLinkTests ( b , test_filter , modes ) ) ;
test_step . dependOn ( tests . addRuntimeSafetyTests ( b , test_filter , modes ) ) ;
2017-11-24 19:56:05 +00:00
test_step . dependOn ( tests . addTranslateCTests ( b , test_filter ) ) ;
2020-12-08 20:46:05 +00:00
test_step . dependOn ( tests . addRunTranslatedCTests ( b , test_filter , target ) ) ;
2020-03-20 22:33:36 +00:00
// tests for this feature are disabled until we have the self-hosted compiler available
Add/fix missing WASI functionality to pass libstd tests
This rather large commit adds/fixes missing WASI functionality
in `libstd` needed to pass the `libstd` tests. As such, now by
default tests targeting `wasm32-wasi` target are enabled in
`test/tests.zig` module. However, they can be disabled by passing
the `-Dskip-wasi=true` flag when invoking the `zig build test`
command. When the flag is set to `false`, i.e., when WASI tests are
included, `wasmtime` with `--dir=.` is used as the default testing
command.
Since the majority of `libstd` tests were relying on `fs.cwd()`
call to get current working directory handle wrapped in `Dir`
struct, in order to make the tests WASI-friendly, `fs.cwd()`
call was replaced with `testing.getTestDir()` function which
resolved to either `fs.cwd()` for non-WASI targets, or tries to
fetch the preopen list from the WASI runtime and extract a
preopen for '.' path.
The summary of changes introduced by this commit:
* implement `Dir.makeDir` and `Dir.openDir` targeting WASI
* implement `Dir.deleteFile` and `Dir.deleteDir` targeting WASI
* fix `os.close` and map errors in `unlinkat`
* move WASI-specific `mkdirat` and `unlinkat` from `std.fs.wasi`
to `std.os` module
* implement `lseek_{SET, CUR, END}` targeting WASI
* implement `futimens` targeting WASI
* implement `ftruncate` targeting WASI
* implement `readv`, `writev`, `pread{v}`, `pwrite{v}` targeting WASI
* make sure ANSI escape codes are _not_ used in stderr or stdout
in WASI, as WASI always sanitizes stderr, and sanitizes stdout if
fd is a TTY
* fix specifying WASI rights when opening/creating files/dirs
* tweak `AtomicFile` to be WASI-compatible
* implement `os.renameatWasi` for WASI-compliant `os.renameat` function
* implement sleep() targeting WASI
* fix `process.getEnvMap` targeting WASI
2020-05-05 15:23:49 +00:00
// test_step.dependOn(tests.addGenHTests(b, test_filter));
2020-08-31 21:54:05 +00:00
if ( ! skip_compile_errors ) {
test_step . dependOn ( tests . addCompileErrorTests ( b , test_filter , modes ) ) ;
}
2018-07-11 18:09:05 +00:00
test_step . dependOn ( docs_step ) ;
2017-04-19 05:13:15 +00:00
}
2017-12-12 04:34:59 +00:00
2020-12-08 00:23:17 +00:00
fn addCxxKnownPath (
b : * Builder ,
ctx : CMakeConfig ,
exe : * std . build . LibExeObjStep ,
objname : [ ] const u8 ,
errtxt : ? [ ] const u8 ,
need_cpp_includes : bool ,
) ! void {
const path_padded = try b . exec ( & [ _ ] [ ] const u8 {
ctx . cxx_compiler ,
2020-11-26 12:28:38 +00:00
b . fmt ( " -print-file-name={s} " , . { objname } ) ,
2020-12-08 00:23:17 +00:00
} ) ;
const path_unpadded = mem . tokenize ( path_padded , " \r \n " ) . next ( ) . ? ;
if ( mem . eql ( u8 , path_unpadded , objname ) ) {
if ( errtxt ) | msg | {
2020-11-26 12:28:38 +00:00
warn ( " {s} " , . { msg } ) ;
2020-12-08 00:23:17 +00:00
} else {
2020-11-26 12:28:38 +00:00
warn ( " Unable to determine path to {s} \n " , . { objname } ) ;
2020-12-08 00:23:17 +00:00
}
return error . RequiredLibraryNotFound ;
}
exe . addObjectFile ( path_unpadded ) ;
// TODO a way to integrate with system c++ include files here
// cc -E -Wp,-v -xc++ /dev/null
if ( need_cpp_includes ) {
// I used these temporarily for testing something but we obviously need a
// more general purpose solution here.
//exe.addIncludeDir("/nix/store/b3zsk4ihlpiimv3vff86bb5bxghgdzb9-gcc-9.2.0/lib/gcc/x86_64-unknown-linux-gnu/9.2.0/../../../../include/c++/9.2.0");
//exe.addIncludeDir("/nix/store/b3zsk4ihlpiimv3vff86bb5bxghgdzb9-gcc-9.2.0/lib/gcc/x86_64-unknown-linux-gnu/9.2.0/../../../../include/c++/9.2.0/x86_64-unknown-linux-gnu");
//exe.addIncludeDir("/nix/store/b3zsk4ihlpiimv3vff86bb5bxghgdzb9-gcc-9.2.0/lib/gcc/x86_64-unknown-linux-gnu/9.2.0/../../../../include/c++/9.2.0/backward");
}
}
fn addCMakeLibraryList ( exe : * std . build . LibExeObjStep , list : [ ] const u8 ) void {
var it = mem . tokenize ( list , " ; " ) ;
while ( it . next ( ) ) | lib | {
if ( mem . startsWith ( u8 , lib , " -l " ) ) {
exe . linkSystemLibrary ( lib [ " -l " . len . . ] ) ;
} else {
exe . addObjectFile ( lib ) ;
}
}
}
const CMakeConfig = struct {
cmake_binary_dir : [ ] const u8 ,
cmake_prefix_path : [ ] const u8 ,
cxx_compiler : [ ] const u8 ,
lld_include_dir : [ ] const u8 ,
lld_libraries : [ ] const u8 ,
clang_libraries : [ ] const u8 ,
llvm_libraries : [ ] const u8 ,
dia_guids_lib : [ ] const u8 ,
} ;
const max_config_h_bytes = 1 * 1024 * 1024 ;
fn findAndParseConfigH ( b : * Builder , config_h_path_option : ? [ ] const u8 ) ? CMakeConfig {
const config_h_text : [ ] const u8 = if ( config_h_path_option ) | config_h_path | blk : {
break : blk fs . cwd ( ) . readFileAlloc ( b . allocator , config_h_path , max_config_h_bytes ) catch unreachable ;
} else blk : {
// TODO this should stop looking for config.h once it detects we hit the
// zig source root directory.
var check_dir = fs . path . dirname ( b . zig_exe ) . ? ;
while ( true ) {
var dir = fs . cwd ( ) . openDir ( check_dir , . { } ) catch unreachable ;
defer dir . close ( ) ;
break : blk dir . readFileAlloc ( b . allocator , " config.h " , max_config_h_bytes ) catch | err | switch ( err ) {
error . FileNotFound = > {
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 . ? ;
continue ;
} ,
else = > unreachable ,
} ;
} else unreachable ; // TODO should not need `else unreachable`.
} ;
var ctx : CMakeConfig = . {
. cmake_binary_dir = undefined ,
. cmake_prefix_path = undefined ,
. cxx_compiler = undefined ,
. lld_include_dir = undefined ,
. lld_libraries = undefined ,
. clang_libraries = undefined ,
. llvm_libraries = undefined ,
. dia_guids_lib = undefined ,
} ;
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 " ,
} ,
. {
. prefix = " #define ZIG_CXX_COMPILER " ,
. field = " cxx_compiler " ,
} ,
. {
. 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 " ,
} ,
} ;
var lines_it = mem . tokenize ( config_h_text , " \r \n " ) ;
while ( lines_it . next ( ) ) | line | {
inline for ( mappings ) | mapping | {
if ( mem . startsWith ( u8 , line , mapping . prefix ) ) {
var it = mem . split ( line , " \" " ) ;
_ = it . next ( ) . ? ; // skip the stuff before the quote
const quoted = it . next ( ) . ? ; // the stuff inside the quote
@field ( ctx , mapping . field ) = toNativePathSep ( b , quoted ) ;
}
}
}
return ctx ;
}
fn toNativePathSep ( b : * Builder , s : [ ] const u8 ) [ ] u8 {
const duplicated = mem . dupe ( b . allocator , u8 , s ) catch unreachable ;
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-05 04:33:29 +00:00
const softfloat_sources = [ _ ] [ ] const u8 {
" deps/SoftFloat-3e/source/8086/f128M_isSignalingNaN.c " ,
" deps/SoftFloat-3e/source/8086/s_commonNaNToF128M.c " ,
" deps/SoftFloat-3e/source/8086/s_commonNaNToF16UI.c " ,
" deps/SoftFloat-3e/source/8086/s_commonNaNToF32UI.c " ,
" deps/SoftFloat-3e/source/8086/s_commonNaNToF64UI.c " ,
" deps/SoftFloat-3e/source/8086/s_f128MToCommonNaN.c " ,
" deps/SoftFloat-3e/source/8086/s_f16UIToCommonNaN.c " ,
" deps/SoftFloat-3e/source/8086/s_f32UIToCommonNaN.c " ,
" deps/SoftFloat-3e/source/8086/s_f64UIToCommonNaN.c " ,
" deps/SoftFloat-3e/source/8086/s_propagateNaNF128M.c " ,
" deps/SoftFloat-3e/source/8086/s_propagateNaNF16UI.c " ,
" deps/SoftFloat-3e/source/8086/softfloat_raiseFlags.c " ,
" deps/SoftFloat-3e/source/f128M_add.c " ,
" deps/SoftFloat-3e/source/f128M_div.c " ,
" deps/SoftFloat-3e/source/f128M_eq.c " ,
" deps/SoftFloat-3e/source/f128M_eq_signaling.c " ,
" deps/SoftFloat-3e/source/f128M_le.c " ,
" deps/SoftFloat-3e/source/f128M_le_quiet.c " ,
" deps/SoftFloat-3e/source/f128M_lt.c " ,
" deps/SoftFloat-3e/source/f128M_lt_quiet.c " ,
" deps/SoftFloat-3e/source/f128M_mul.c " ,
" deps/SoftFloat-3e/source/f128M_mulAdd.c " ,
" deps/SoftFloat-3e/source/f128M_rem.c " ,
" deps/SoftFloat-3e/source/f128M_roundToInt.c " ,
" deps/SoftFloat-3e/source/f128M_sqrt.c " ,
" deps/SoftFloat-3e/source/f128M_sub.c " ,
" deps/SoftFloat-3e/source/f128M_to_f16.c " ,
" deps/SoftFloat-3e/source/f128M_to_f32.c " ,
" deps/SoftFloat-3e/source/f128M_to_f64.c " ,
" deps/SoftFloat-3e/source/f128M_to_i32.c " ,
" deps/SoftFloat-3e/source/f128M_to_i32_r_minMag.c " ,
" deps/SoftFloat-3e/source/f128M_to_i64.c " ,
" deps/SoftFloat-3e/source/f128M_to_i64_r_minMag.c " ,
" deps/SoftFloat-3e/source/f128M_to_ui32.c " ,
" deps/SoftFloat-3e/source/f128M_to_ui32_r_minMag.c " ,
" deps/SoftFloat-3e/source/f128M_to_ui64.c " ,
" deps/SoftFloat-3e/source/f128M_to_ui64_r_minMag.c " ,
" deps/SoftFloat-3e/source/f16_add.c " ,
" deps/SoftFloat-3e/source/f16_div.c " ,
" deps/SoftFloat-3e/source/f16_eq.c " ,
" deps/SoftFloat-3e/source/f16_isSignalingNaN.c " ,
" deps/SoftFloat-3e/source/f16_lt.c " ,
" deps/SoftFloat-3e/source/f16_mul.c " ,
" deps/SoftFloat-3e/source/f16_mulAdd.c " ,
" deps/SoftFloat-3e/source/f16_rem.c " ,
" deps/SoftFloat-3e/source/f16_roundToInt.c " ,
" deps/SoftFloat-3e/source/f16_sqrt.c " ,
" deps/SoftFloat-3e/source/f16_sub.c " ,
" deps/SoftFloat-3e/source/f16_to_f128M.c " ,
" deps/SoftFloat-3e/source/f16_to_f64.c " ,
" deps/SoftFloat-3e/source/f32_to_f128M.c " ,
" deps/SoftFloat-3e/source/f64_to_f128M.c " ,
" deps/SoftFloat-3e/source/f64_to_f16.c " ,
" deps/SoftFloat-3e/source/i32_to_f128M.c " ,
" deps/SoftFloat-3e/source/s_add256M.c " ,
" deps/SoftFloat-3e/source/s_addCarryM.c " ,
" deps/SoftFloat-3e/source/s_addComplCarryM.c " ,
" deps/SoftFloat-3e/source/s_addF128M.c " ,
" deps/SoftFloat-3e/source/s_addM.c " ,
" deps/SoftFloat-3e/source/s_addMagsF16.c " ,
" deps/SoftFloat-3e/source/s_addMagsF32.c " ,
" deps/SoftFloat-3e/source/s_addMagsF64.c " ,
" deps/SoftFloat-3e/source/s_approxRecip32_1.c " ,
" deps/SoftFloat-3e/source/s_approxRecipSqrt32_1.c " ,
" deps/SoftFloat-3e/source/s_approxRecipSqrt_1Ks.c " ,
" deps/SoftFloat-3e/source/s_approxRecip_1Ks.c " ,
" deps/SoftFloat-3e/source/s_compare128M.c " ,
" deps/SoftFloat-3e/source/s_compare96M.c " ,
" deps/SoftFloat-3e/source/s_countLeadingZeros16.c " ,
" deps/SoftFloat-3e/source/s_countLeadingZeros32.c " ,
" deps/SoftFloat-3e/source/s_countLeadingZeros64.c " ,
" deps/SoftFloat-3e/source/s_countLeadingZeros8.c " ,
" deps/SoftFloat-3e/source/s_eq128.c " ,
" deps/SoftFloat-3e/source/s_invalidF128M.c " ,
" deps/SoftFloat-3e/source/s_isNaNF128M.c " ,
" deps/SoftFloat-3e/source/s_le128.c " ,
" deps/SoftFloat-3e/source/s_lt128.c " ,
" deps/SoftFloat-3e/source/s_mul128MTo256M.c " ,
" deps/SoftFloat-3e/source/s_mul64To128M.c " ,
" deps/SoftFloat-3e/source/s_mulAddF128M.c " ,
" deps/SoftFloat-3e/source/s_mulAddF16.c " ,
" deps/SoftFloat-3e/source/s_mulAddF32.c " ,
" deps/SoftFloat-3e/source/s_mulAddF64.c " ,
" deps/SoftFloat-3e/source/s_negXM.c " ,
" deps/SoftFloat-3e/source/s_normRoundPackMToF128M.c " ,
" deps/SoftFloat-3e/source/s_normRoundPackToF16.c " ,
" deps/SoftFloat-3e/source/s_normRoundPackToF32.c " ,
" deps/SoftFloat-3e/source/s_normRoundPackToF64.c " ,
" deps/SoftFloat-3e/source/s_normSubnormalF128SigM.c " ,
" deps/SoftFloat-3e/source/s_normSubnormalF16Sig.c " ,
" deps/SoftFloat-3e/source/s_normSubnormalF32Sig.c " ,
" deps/SoftFloat-3e/source/s_normSubnormalF64Sig.c " ,
" deps/SoftFloat-3e/source/s_remStepMBy32.c " ,
" deps/SoftFloat-3e/source/s_roundMToI64.c " ,
" deps/SoftFloat-3e/source/s_roundMToUI64.c " ,
" deps/SoftFloat-3e/source/s_roundPackMToF128M.c " ,
" deps/SoftFloat-3e/source/s_roundPackToF16.c " ,
" deps/SoftFloat-3e/source/s_roundPackToF32.c " ,
" deps/SoftFloat-3e/source/s_roundPackToF64.c " ,
" deps/SoftFloat-3e/source/s_roundToI32.c " ,
" deps/SoftFloat-3e/source/s_roundToI64.c " ,
" deps/SoftFloat-3e/source/s_roundToUI32.c " ,
" deps/SoftFloat-3e/source/s_roundToUI64.c " ,
" deps/SoftFloat-3e/source/s_shiftLeftM.c " ,
" deps/SoftFloat-3e/source/s_shiftNormSigF128M.c " ,
" deps/SoftFloat-3e/source/s_shiftRightJam256M.c " ,
" deps/SoftFloat-3e/source/s_shiftRightJam32.c " ,
" deps/SoftFloat-3e/source/s_shiftRightJam64.c " ,
" deps/SoftFloat-3e/source/s_shiftRightJamM.c " ,
" deps/SoftFloat-3e/source/s_shiftRightM.c " ,
" deps/SoftFloat-3e/source/s_shortShiftLeft64To96M.c " ,
" deps/SoftFloat-3e/source/s_shortShiftLeftM.c " ,
" deps/SoftFloat-3e/source/s_shortShiftRightExtendM.c " ,
" deps/SoftFloat-3e/source/s_shortShiftRightJam64.c " ,
" deps/SoftFloat-3e/source/s_shortShiftRightJamM.c " ,
" deps/SoftFloat-3e/source/s_shortShiftRightM.c " ,
" deps/SoftFloat-3e/source/s_sub1XM.c " ,
" deps/SoftFloat-3e/source/s_sub256M.c " ,
" deps/SoftFloat-3e/source/s_subM.c " ,
" deps/SoftFloat-3e/source/s_subMagsF16.c " ,
" deps/SoftFloat-3e/source/s_subMagsF32.c " ,
" deps/SoftFloat-3e/source/s_subMagsF64.c " ,
" deps/SoftFloat-3e/source/s_tryPropagateNaNF128M.c " ,
" deps/SoftFloat-3e/source/softfloat_state.c " ,
" deps/SoftFloat-3e/source/ui32_to_f128M.c " ,
" deps/SoftFloat-3e/source/ui64_to_f128M.c " ,
2017-12-12 04:34:59 +00: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-05 04:33:29 +00:00
const stage1_sources = [ _ ] [ ] const u8 {
" src/stage1/analyze.cpp " ,
" src/stage1/ast_render.cpp " ,
" src/stage1/bigfloat.cpp " ,
" src/stage1/bigint.cpp " ,
" src/stage1/buffer.cpp " ,
" src/stage1/codegen.cpp " ,
" src/stage1/dump_analysis.cpp " ,
" src/stage1/errmsg.cpp " ,
" src/stage1/error.cpp " ,
" src/stage1/heap.cpp " ,
" src/stage1/ir.cpp " ,
" src/stage1/ir_print.cpp " ,
" src/stage1/mem.cpp " ,
" src/stage1/os.cpp " ,
" src/stage1/parser.cpp " ,
" src/stage1/range_set.cpp " ,
" src/stage1/stage1.cpp " ,
" src/stage1/target.cpp " ,
" src/stage1/tokenizer.cpp " ,
" src/stage1/util.cpp " ,
" src/stage1/softfloat_ext.cpp " ,
} ;
const optimized_c_sources = [ _ ] [ ] const u8 {
" src/stage1/parse_f128.c " ,
} ;
const zig_cpp_sources = [ _ ] [ ] const u8 {
// These are planned to stay even when we are self-hosted.
" src/zig_llvm.cpp " ,
" src/zig_clang.cpp " ,
" src/zig_clang_driver.cpp " ,
" src/zig_clang_cc1_main.cpp " ,
" src/zig_clang_cc1as_main.cpp " ,
// https://github.com/ziglang/zig/issues/6363
" src/windows_sdk.cpp " ,
2018-07-11 00:18:43 +00:00
} ;
2020-04-04 15:57:28 +00: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-05 04:33:29 +00:00
const clang_libs = [ _ ] [ ] const u8 {
" clangFrontendTool " ,
" clangCodeGen " ,
" clangFrontend " ,
" clangDriver " ,
" clangSerialization " ,
" clangSema " ,
" clangStaticAnalyzerFrontend " ,
" clangStaticAnalyzerCheckers " ,
" clangStaticAnalyzerCore " ,
" clangAnalysis " ,
" clangASTMatchers " ,
" clangAST " ,
" clangParse " ,
" clangSema " ,
" clangBasic " ,
" clangEdit " ,
" clangLex " ,
" clangARCMigrate " ,
" clangRewriteFrontend " ,
" clangRewrite " ,
" clangCrossTU " ,
" clangIndex " ,
" clangToolingCore " ,
} ;
const lld_libs = [ _ ] [ ] const u8 {
" lldDriver " ,
" lldMinGW " ,
" lldELF " ,
" lldCOFF " ,
" lldMachO " ,
" lldWasm " ,
" lldReaderWriter " ,
" lldCore " ,
" lldYAML " ,
" lldCommon " ,
} ;
// This list can be re-generated with `llvm-config --libfiles` and then
// reformatting using your favorite text editor. Note we do not execute
// `llvm-config` here because we are cross compiling.
const llvm_libs = [ _ ] [ ] const u8 {
" LLVMXRay " ,
" LLVMWindowsManifest " ,
" LLVMSymbolize " ,
" LLVMDebugInfoPDB " ,
" LLVMOrcJIT " ,
" LLVMOrcError " ,
" LLVMJITLink " ,
" LLVMObjectYAML " ,
" LLVMMCA " ,
" LLVMLTO " ,
" LLVMPasses " ,
" LLVMCoroutines " ,
" LLVMObjCARCOpts " ,
" LLVMExtensions " ,
" LLVMLineEditor " ,
" LLVMLibDriver " ,
" LLVMInterpreter " ,
" LLVMFuzzMutate " ,
" LLVMMCJIT " ,
" LLVMExecutionEngine " ,
" LLVMRuntimeDyld " ,
" LLVMDWARFLinker " ,
" LLVMDlltoolDriver " ,
" LLVMOption " ,
" LLVMDebugInfoGSYM " ,
" LLVMCoverage " ,
" LLVMXCoreDisassembler " ,
" LLVMXCoreCodeGen " ,
" LLVMXCoreDesc " ,
" LLVMXCoreInfo " ,
" LLVMX86Disassembler " ,
" LLVMX86CodeGen " ,
" LLVMX86AsmParser " ,
" LLVMX86Desc " ,
" LLVMX86Info " ,
" LLVMWebAssemblyDisassembler " ,
" LLVMWebAssemblyCodeGen " ,
" LLVMWebAssemblyDesc " ,
" LLVMWebAssemblyAsmParser " ,
" LLVMWebAssemblyInfo " ,
" LLVMSystemZDisassembler " ,
" LLVMSystemZCodeGen " ,
" LLVMSystemZAsmParser " ,
" LLVMSystemZDesc " ,
" LLVMSystemZInfo " ,
" LLVMSparcDisassembler " ,
" LLVMSparcCodeGen " ,
" LLVMSparcAsmParser " ,
" LLVMSparcDesc " ,
" LLVMSparcInfo " ,
" LLVMRISCVDisassembler " ,
" LLVMRISCVCodeGen " ,
" LLVMRISCVAsmParser " ,
" LLVMRISCVDesc " ,
" LLVMRISCVUtils " ,
" LLVMRISCVInfo " ,
" LLVMPowerPCDisassembler " ,
" LLVMPowerPCCodeGen " ,
" LLVMPowerPCAsmParser " ,
" LLVMPowerPCDesc " ,
" LLVMPowerPCInfo " ,
" LLVMNVPTXCodeGen " ,
" LLVMNVPTXDesc " ,
" LLVMNVPTXInfo " ,
" LLVMMSP430Disassembler " ,
" LLVMMSP430CodeGen " ,
" LLVMMSP430AsmParser " ,
" LLVMMSP430Desc " ,
" LLVMMSP430Info " ,
" LLVMMipsDisassembler " ,
" LLVMMipsCodeGen " ,
" LLVMMipsAsmParser " ,
" LLVMMipsDesc " ,
" LLVMMipsInfo " ,
" LLVMLanaiDisassembler " ,
" LLVMLanaiCodeGen " ,
" LLVMLanaiAsmParser " ,
" LLVMLanaiDesc " ,
" LLVMLanaiInfo " ,
" LLVMHexagonDisassembler " ,
" LLVMHexagonCodeGen " ,
" LLVMHexagonAsmParser " ,
" LLVMHexagonDesc " ,
" LLVMHexagonInfo " ,
" LLVMBPFDisassembler " ,
" LLVMBPFCodeGen " ,
" LLVMBPFAsmParser " ,
" LLVMBPFDesc " ,
" LLVMBPFInfo " ,
" LLVMAVRDisassembler " ,
" LLVMAVRCodeGen " ,
" LLVMAVRAsmParser " ,
" LLVMAVRDesc " ,
" LLVMAVRInfo " ,
" LLVMARMDisassembler " ,
" LLVMARMCodeGen " ,
" LLVMARMAsmParser " ,
" LLVMARMDesc " ,
" LLVMARMUtils " ,
" LLVMARMInfo " ,
" LLVMAMDGPUDisassembler " ,
" LLVMAMDGPUCodeGen " ,
" LLVMMIRParser " ,
" LLVMipo " ,
" LLVMInstrumentation " ,
" LLVMVectorize " ,
" LLVMLinker " ,
" LLVMIRReader " ,
" LLVMAsmParser " ,
" LLVMFrontendOpenMP " ,
" LLVMAMDGPUAsmParser " ,
" LLVMAMDGPUDesc " ,
" LLVMAMDGPUUtils " ,
" LLVMAMDGPUInfo " ,
" LLVMAArch64Disassembler " ,
" LLVMMCDisassembler " ,
" LLVMAArch64CodeGen " ,
" LLVMCFGuard " ,
" LLVMGlobalISel " ,
" LLVMSelectionDAG " ,
" LLVMAsmPrinter " ,
" LLVMDebugInfoDWARF " ,
" LLVMCodeGen " ,
" LLVMTarget " ,
" LLVMScalarOpts " ,
" LLVMInstCombine " ,
" LLVMAggressiveInstCombine " ,
" LLVMTransformUtils " ,
" LLVMBitWriter " ,
" LLVMAnalysis " ,
" LLVMProfileData " ,
" LLVMObject " ,
" LLVMTextAPI " ,
" LLVMBitReader " ,
" LLVMCore " ,
" LLVMRemarks " ,
" LLVMBitstreamReader " ,
" LLVMAArch64AsmParser " ,
" LLVMMCParser " ,
" LLVMAArch64Desc " ,
" LLVMMC " ,
" LLVMDebugInfoCodeView " ,
" LLVMDebugInfoMSF " ,
" LLVMBinaryFormat " ,
" LLVMAArch64Utils " ,
" LLVMAArch64Info " ,
" LLVMSupport " ,
" LLVMDemangle " ,
} ;