diff --git a/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md similarity index 100% rename from CODE_OF_CONDUCT.md rename to .github/CODE_OF_CONDUCT.md diff --git a/CONTRIBUTING.md b/.github/CONTRIBUTING.md similarity index 100% rename from CONTRIBUTING.md rename to .github/CONTRIBUTING.md diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000000..fc5f33e21f --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,7 @@ +contact_links: + - name: Language Proposal + about: Propose to improve the Zig language + url: https://github.com/ziglang/zig/wiki/Language-Proposals + - name: Question + about: Please use one of the community spaces for questions or general discussions. + url: https://github.com/ziglang/zig/wiki/Community diff --git a/.github/ISSUE_TEMPLATE/proposal.yml b/.github/ISSUE_TEMPLATE/proposal.yml deleted file mode 100644 index 83e30d2ef4..0000000000 --- a/.github/ISSUE_TEMPLATE/proposal.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: Language Proposal -description: Propose to improve the Zig language -labels: ["proposal"] -body: - - type: markdown - attributes: - value: | - Thank you for your interest in improving the Zig language. However, we are - not accepting new proposals to change the language at this time. - - type: checkboxes - id: trash - attributes: - label: Please do not file a proposal to change the language - options: - - label: "I understand, thank you. I will not submit a new proposal at this time" - required: true diff --git a/.github/ISSUE_TEMPLATE/question.yml b/.github/ISSUE_TEMPLATE/question.yml deleted file mode 100644 index 1e57fc76d4..0000000000 --- a/.github/ISSUE_TEMPLATE/question.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: Question -description: Ask a Zig-related question -labels: ["question"] -body: - - type: markdown - attributes: - value: | - Welcome! There are a bunch of great places to ask Zig-related questions. - Please take a look at - [The Community Wiki Page](https://github.com/ziglang/zig/wiki/Community) and - find a comfy place to ask questions. You will find plenty of helpful people in - these spaces. However, this issue tracker is not for questions. It is for - more actionable items such as bug reports and enhancements. - - type: checkboxes - id: trash - attributes: - label: Please do not open a question issue on the bug tracker - options: - - label: "I understand, thank you. I will take my question to one of the community spaces instead" - required: true diff --git a/CMakeLists.txt b/CMakeLists.txt index e12e040fe4..b28748fba4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,7 +12,7 @@ if(NOT CMAKE_BUILD_TYPE) endif() if(NOT CMAKE_INSTALL_PREFIX) - set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}" CACHE STRING + set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/stage1" CACHE STRING "Directory to install zig to" FORCE) endif() @@ -63,7 +63,7 @@ if("${ZIG_VERSION}" STREQUAL "") endif() endif() endif() -message("Configuring zig version ${ZIG_VERSION}") +message(STATUS "Configuring zig version ${ZIG_VERSION}") set(ZIG_STATIC off CACHE BOOL "Attempt to build a static zig executable (not compatible with glibc)") set(ZIG_STATIC_LLVM off CACHE BOOL "Prefer linking against static LLVM libraries") @@ -398,6 +398,9 @@ set(ZIG_STAGE2_SOURCES "${CMAKE_SOURCE_DIR}/lib/std/debug.zig" "${CMAKE_SOURCE_DIR}/lib/std/dwarf.zig" "${CMAKE_SOURCE_DIR}/lib/std/dwarf/AT.zig" + "${CMAKE_SOURCE_DIR}/lib/std/dwarf/ATE.zig" + "${CMAKE_SOURCE_DIR}/lib/std/dwarf/FORM.zig" + "${CMAKE_SOURCE_DIR}/lib/std/dwarf/LANG.zig" "${CMAKE_SOURCE_DIR}/lib/std/dwarf/OP.zig" "${CMAKE_SOURCE_DIR}/lib/std/dwarf/TAG.zig" "${CMAKE_SOURCE_DIR}/lib/std/elf.zig" @@ -441,9 +444,8 @@ set(ZIG_STAGE2_SOURCES "${CMAKE_SOURCE_DIR}/lib/std/math.zig" "${CMAKE_SOURCE_DIR}/lib/std/math/big.zig" "${CMAKE_SOURCE_DIR}/lib/std/math/big/int.zig" - "${CMAKE_SOURCE_DIR}/lib/std/math/floor.zig" + "${CMAKE_SOURCE_DIR}/lib/std/math/float.zig" "${CMAKE_SOURCE_DIR}/lib/std/math/frexp.zig" - "${CMAKE_SOURCE_DIR}/lib/std/math/inf.zig" "${CMAKE_SOURCE_DIR}/lib/std/math/isinf.zig" "${CMAKE_SOURCE_DIR}/lib/std/math/isnan.zig" "${CMAKE_SOURCE_DIR}/lib/std/math/ln.zig" @@ -460,12 +462,14 @@ set(ZIG_STAGE2_SOURCES "${CMAKE_SOURCE_DIR}/lib/std/meta/trait.zig" "${CMAKE_SOURCE_DIR}/lib/std/multi_array_list.zig" "${CMAKE_SOURCE_DIR}/lib/std/os.zig" + "${CMAKE_SOURCE_DIR}/lib/std/os/darwin.zig" "${CMAKE_SOURCE_DIR}/lib/std/os/linux.zig" "${CMAKE_SOURCE_DIR}/lib/std/os/linux/errno/generic.zig" "${CMAKE_SOURCE_DIR}/lib/std/os/linux/x86_64.zig" "${CMAKE_SOURCE_DIR}/lib/std/os/linux.zig" "${CMAKE_SOURCE_DIR}/lib/std/os/linux/io_uring.zig" "${CMAKE_SOURCE_DIR}/lib/std/os/linux/x86_64.zig" + "${CMAKE_SOURCE_DIR}/lib/std/os/posix_spawn.zig" "${CMAKE_SOURCE_DIR}/lib/std/os/windows.zig" "${CMAKE_SOURCE_DIR}/lib/std/os/windows/ntstatus.zig" "${CMAKE_SOURCE_DIR}/lib/std/os/windows/win32error.zig" @@ -474,74 +478,180 @@ set(ZIG_STAGE2_SOURCES "${CMAKE_SOURCE_DIR}/lib/std/process.zig" "${CMAKE_SOURCE_DIR}/lib/std/rand.zig" "${CMAKE_SOURCE_DIR}/lib/std/sort.zig" - "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt.zig" - "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/absv.zig" - "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/addXf3.zig" - "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/atomics.zig" - "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/bswap.zig" - "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/clear_cache.zig" - "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/cmp.zig" - "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/compareXf2.zig" - "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/count0bits.zig" - "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/divdf3.zig" - "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/divsf3.zig" - "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/divtf3.zig" - "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/divti3.zig" - "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/extendXfYf2.zig" - "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/fixdfdi.zig" - "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/fixdfsi.zig" - "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/fixdfti.zig" - "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/fixint.zig" - "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/fixsfdi.zig" - "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/fixsfsi.zig" - "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/fixsfti.zig" - "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/fixtfdi.zig" - "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/fixtfsi.zig" - "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/fixtfti.zig" - "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/fixuint.zig" - "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/fixunsdfdi.zig" - "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/fixunsdfsi.zig" - "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/fixunsdfti.zig" - "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/fixunssfdi.zig" - "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/fixunssfsi.zig" - "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/fixunssfti.zig" - "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/fixunstfdi.zig" - "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/fixunstfsi.zig" - "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/fixunstfti.zig" - "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/floatXisf.zig" - "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/floatdidf.zig" - "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/floatditf.zig" - "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/floatsiXf.zig" - "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/floattidf.zig" - "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/floattitf.zig" - "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/floatundidf.zig" - "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/floatundisf.zig" - "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/floatunditf.zig" - "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/floatunsidf.zig" - "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/floatunsisf.zig" - "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/floatunsitf.zig" - "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/floatuntidf.zig" - "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/floatuntisf.zig" - "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/floatuntitf.zig" - "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/int.zig" - "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/modti3.zig" - "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/mulXf3.zig" - "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/muldi3.zig" - "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/mulo.zig" - "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/multi3.zig" - "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/negXf2.zig" - "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/negXi2.zig" - "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/negv.zig" - "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/os_version_check.zig" - "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/parity.zig" - "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/popcount.zig" - "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/shift.zig" - "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/stack_probe.zig" - "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/truncXfYf2.zig" - "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/udivmod.zig" - "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/udivmodti4.zig" - "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/udivti3.zig" - "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/umodti3.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/absv.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/absvdi2.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/absvsi2.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/absvti2.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/adddf3.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/addf3.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/addo.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/addsf3.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/addtf3.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/addxf3.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/arm.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/atomics.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/aulldiv.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/aullrem.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/bswap.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/ceil.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/clear_cache.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/cmp.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/cmpdf2.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/cmpsf2.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/cmptf2.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/cmpxf2.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/common.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/comparef.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/cos.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/count0bits.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/divdf3.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/divsf3.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/divtf3.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/divti3.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/divxf3.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/emutls.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/exp.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/exp2.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/extenddftf2.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/extenddfxf2.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/extendf.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/extendhfsf2.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/extendhftf2.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/extendhfxf2.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/extendsfdf2.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/extendsftf2.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/extendsfxf2.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/extendxftf2.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/fabs.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixdfdi.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixdfsi.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixdfti.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixhfdi.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixhfsi.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixhfti.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixsfdi.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixsfsi.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixsfti.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixtfdi.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixtfsi.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixtfti.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixunsdfdi.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixunsdfsi.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixunsdfti.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixunshfdi.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixunshfsi.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixunshfti.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixunssfdi.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixunssfsi.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixunssfti.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixunstfdi.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixunstfsi.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixunstfti.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixunsxfdi.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixunsxfsi.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixunsxfti.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixxfdi.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixxfsi.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixxfti.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/float_to_int.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatdidf.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatdihf.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatdisf.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatditf.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatdixf.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatsidf.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatsihf.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatsisf.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatsitf.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatsixf.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/floattidf.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/floattihf.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/floattisf.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/floattitf.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/floattixf.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatundidf.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatundihf.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatundisf.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatunditf.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatundixf.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatunsidf.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatunsihf.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatunsisf.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatunsitf.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatunsixf.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatuntidf.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatuntihf.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatuntisf.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatuntitf.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatuntixf.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/floor.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/fma.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/fmax.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/fmin.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/fmod.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/gedf2.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/gesf2.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/getf2.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/gexf2.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/int.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/int_to_float.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/log.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/log10.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/log2.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/modti3.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/muldf3.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/muldi3.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/mulf3.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/mulo.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/mulsf3.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/multf3.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/multi3.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/mulxf3.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/negXi2.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/negv.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/os_version_check.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/parity.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/popcount.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/rem_pio2.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/rem_pio2_large.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/rem_pio2f.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/round.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/shift.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/sin.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/sincos.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/sqrt.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/stack_probe.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/subo.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/subsf3.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/subdf3.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/subtf3.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/subxf3.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/negsf2.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/negdf2.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/negtf2.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/negxf2.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/tan.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/trig.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/trunc.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/truncdfhf2.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/truncdfsf2.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/truncf.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/truncsfhf2.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/trunctfdf2.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/trunctfhf2.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/trunctfsf2.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/trunctfxf2.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/truncxfdf2.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/truncxfhf2.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/truncxfsf2.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/udivmod.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/udivmodti4.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/udivti3.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/umodti3.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/unorddf2.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/unordsf2.zig" + "${CMAKE_SOURCE_DIR}/lib/compiler_rt/unordtf2.zig" "${CMAKE_SOURCE_DIR}/lib/std/start.zig" "${CMAKE_SOURCE_DIR}/lib/std/std.zig" "${CMAKE_SOURCE_DIR}/lib/std/target.zig" @@ -561,16 +671,16 @@ set(ZIG_STAGE2_SOURCES "${CMAKE_SOURCE_DIR}/lib/std/target/wasm.zig" "${CMAKE_SOURCE_DIR}/lib/std/target/x86.zig" "${CMAKE_SOURCE_DIR}/lib/std/Thread.zig" - "${CMAKE_SOURCE_DIR}/lib/std/Thread/AutoResetEvent.zig" "${CMAKE_SOURCE_DIR}/lib/std/Thread/Futex.zig" "${CMAKE_SOURCE_DIR}/lib/std/Thread/Mutex.zig" "${CMAKE_SOURCE_DIR}/lib/std/Thread/ResetEvent.zig" - "${CMAKE_SOURCE_DIR}/lib/std/Thread/StaticResetEvent.zig" "${CMAKE_SOURCE_DIR}/lib/std/time.zig" + "${CMAKE_SOURCE_DIR}/lib/std/treap.zig" "${CMAKE_SOURCE_DIR}/lib/std/unicode.zig" "${CMAKE_SOURCE_DIR}/lib/std/zig.zig" "${CMAKE_SOURCE_DIR}/lib/std/zig/Ast.zig" "${CMAKE_SOURCE_DIR}/lib/std/zig/CrossTarget.zig" + "${CMAKE_SOURCE_DIR}/lib/std/zig/c_builtins.zig" "${CMAKE_SOURCE_DIR}/lib/std/zig/parse.zig" "${CMAKE_SOURCE_DIR}/lib/std/zig/render.zig" "${CMAKE_SOURCE_DIR}/lib/std/zig/string_literal.zig" @@ -597,14 +707,22 @@ set(ZIG_STAGE2_SOURCES "${CMAKE_SOURCE_DIR}/src/arch/aarch64/Emit.zig" "${CMAKE_SOURCE_DIR}/src/arch/aarch64/Mir.zig" "${CMAKE_SOURCE_DIR}/src/arch/aarch64/bits.zig" + "${CMAKE_SOURCE_DIR}/src/arch/aarch64/abi.zig" "${CMAKE_SOURCE_DIR}/src/arch/arm/CodeGen.zig" "${CMAKE_SOURCE_DIR}/src/arch/arm/Emit.zig" "${CMAKE_SOURCE_DIR}/src/arch/arm/Mir.zig" "${CMAKE_SOURCE_DIR}/src/arch/arm/bits.zig" + "${CMAKE_SOURCE_DIR}/src/arch/arm/abi.zig" "${CMAKE_SOURCE_DIR}/src/arch/riscv64/CodeGen.zig" "${CMAKE_SOURCE_DIR}/src/arch/riscv64/Emit.zig" "${CMAKE_SOURCE_DIR}/src/arch/riscv64/Mir.zig" "${CMAKE_SOURCE_DIR}/src/arch/riscv64/bits.zig" + "${CMAKE_SOURCE_DIR}/src/arch/riscv64/abi.zig" + "${CMAKE_SOURCE_DIR}/src/arch/sparc64/CodeGen.zig" + "${CMAKE_SOURCE_DIR}/src/arch/sparc64/Emit.zig" + "${CMAKE_SOURCE_DIR}/src/arch/sparc64/Mir.zig" + "${CMAKE_SOURCE_DIR}/src/arch/sparc64/bits.zig" + "${CMAKE_SOURCE_DIR}/src/arch/sparc64/abi.zig" "${CMAKE_SOURCE_DIR}/src/arch/wasm/CodeGen.zig" "${CMAKE_SOURCE_DIR}/src/arch/wasm/Emit.zig" "${CMAKE_SOURCE_DIR}/src/arch/wasm/Mir.zig" @@ -612,6 +730,7 @@ set(ZIG_STAGE2_SOURCES "${CMAKE_SOURCE_DIR}/src/arch/x86_64/Emit.zig" "${CMAKE_SOURCE_DIR}/src/arch/x86_64/Mir.zig" "${CMAKE_SOURCE_DIR}/src/arch/x86_64/bits.zig" + "${CMAKE_SOURCE_DIR}/src/arch/x86_64/abi.zig" "${CMAKE_SOURCE_DIR}/src/clang.zig" "${CMAKE_SOURCE_DIR}/src/clang_options.zig" "${CMAKE_SOURCE_DIR}/src/clang_options_data.zig" @@ -655,6 +774,7 @@ set(ZIG_STAGE2_SOURCES "${CMAKE_SOURCE_DIR}/src/print_env.zig" "${CMAKE_SOURCE_DIR}/src/print_targets.zig" "${CMAKE_SOURCE_DIR}/src/print_zir.zig" + "${CMAKE_SOURCE_DIR}/src/register_manager.zig" "${CMAKE_SOURCE_DIR}/src/stage1.zig" "${CMAKE_SOURCE_DIR}/src/target.zig" "${CMAKE_SOURCE_DIR}/src/tracy.zig" @@ -791,6 +911,9 @@ add_library(opt_c_util STATIC ${OPTIMIZED_C_SOURCES}) set_target_properties(opt_c_util PROPERTIES COMPILE_FLAGS "${OPTIMIZED_C_FLAGS}" ) +target_include_directories(opt_c_util PRIVATE + "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e-prebuilt" +) add_library(zigstage1 STATIC ${STAGE1_SOURCES}) set_target_properties(zigstage1 PROPERTIES @@ -834,7 +957,7 @@ else() set(ZIG1_RELEASE_ARG -OReleaseFast --strip) endif() if(ZIG_SINGLE_THREADED) - set(ZIG1_SINGLE_THREADED_ARG "--single-threaded") + set(ZIG1_SINGLE_THREADED_ARG "-fsingle-threaded") else() set(ZIG1_SINGLE_THREADED_ARG "") endif() @@ -852,7 +975,7 @@ set(BUILD_ZIG1_ARGS -lc --pkg-begin build_options "${ZIG_CONFIG_ZIG_OUT}" --pkg-end - --pkg-begin compiler_rt "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt.zig" + --pkg-begin compiler_rt "${CMAKE_SOURCE_DIR}/lib/compiler_rt.zig" --pkg-end ) diff --git a/README.md b/README.md index cd8b4b4e96..3ffd544e98 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,8 @@ A general-purpose programming language and toolchain for maintaining * [Download & Documentation](https://ziglang.org/download) * [Chapter 0 - Getting Started | ZigLearn.org](https://ziglearn.org/) * [Community](https://github.com/ziglang/zig/wiki/Community) - * [Contributing](https://github.com/ziglang/zig/blob/master/CONTRIBUTING.md) - * [Code of Conduct](https://github.com/ziglang/zig/blob/master/CODE_OF_CONDUCT.md) + * [Contributing](https://github.com/ziglang/zig/blob/master/.github/CONTRIBUTING.md) + * [Code of Conduct](https://github.com/ziglang/zig/blob/master/.github/CODE_OF_CONDUCT.md) * [Frequently Asked Questions](https://github.com/ziglang/zig/wiki/FAQ) * [Community Projects](https://github.com/ziglang/zig/wiki/Community-Projects) diff --git a/build.zig b/build.zig index f2d154c702..0ca2e0d7d7 100644 --- a/build.zig +++ b/build.zig @@ -19,7 +19,7 @@ pub fn build(b: *Builder) !void { const single_threaded = b.option(bool, "single-threaded", "Build artifacts that run in single threaded mode"); 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; - var docgen_exe = b.addExecutable("docgen", "doc/docgen.zig"); + const docgen_exe = b.addExecutable("docgen", "doc/docgen.zig"); docgen_exe.single_threaded = single_threaded; const rel_zig_exe = try fs.path.relative(b.allocator, b.build_root, b.zig_exe); @@ -27,7 +27,7 @@ pub fn build(b: *Builder) !void { b.allocator, &[_][]const u8{ b.cache_root, "langref.html" }, ) catch unreachable; - var docgen_cmd = docgen_exe.run(); + const docgen_cmd = docgen_exe.run(); docgen_cmd.addArgs(&[_][]const u8{ rel_zig_exe, "doc" ++ fs.path.sep_str ++ "langref.html.in", @@ -40,10 +40,10 @@ pub fn build(b: *Builder) !void { const toolchain_step = b.step("test-toolchain", "Run the tests for the toolchain"); - var test_stage2 = b.addTest("src/test.zig"); - test_stage2.setBuildMode(mode); - test_stage2.addPackagePath("test_cases", "test/cases.zig"); - test_stage2.single_threaded = single_threaded; + var test_cases = b.addTest("src/test.zig"); + test_cases.setBuildMode(mode); + test_cases.addPackagePath("test_cases", "test/cases.zig"); + test_cases.single_threaded = single_threaded; const fmt_build_zig = b.addFmt(&[_][]const u8{"build.zig"}); @@ -54,12 +54,14 @@ pub fn build(b: *Builder) !void { const skip_release_safe = b.option(bool, "skip-release-safe", "Main test suite skips release-safe builds") orelse skip_release; const skip_non_native = b.option(bool, "skip-non-native", "Main test suite skips non-native builds") orelse false; const skip_libc = b.option(bool, "skip-libc", "Main test suite skips tests that link libc") orelse false; - const skip_compile_errors = b.option(bool, "skip-compile-errors", "Main test suite skips compile error tests") orelse false; + const skip_single_threaded = b.option(bool, "skip-single-threaded", "Main test suite skips tests that are single-threaded") orelse false; + const skip_stage1 = b.option(bool, "skip-stage1", "Main test suite skips stage1 compile error tests") orelse false; const skip_run_translated_c = b.option(bool, "skip-run-translated-c", "Main test suite skips run-translated-c tests") orelse false; const skip_stage2_tests = b.option(bool, "skip-stage2-tests", "Main test suite skips self-hosted compiler tests") orelse false; const skip_install_lib_files = b.option(bool, "skip-install-lib-files", "Do not copy lib/ files to installation prefix") orelse false; const only_install_lib_files = b.option(bool, "lib-files-only", "Only install library files") orelse false; + const is_stage1 = b.option(bool, "stage1", "Build the stage1 compiler, put stage2 behind a feature flag") orelse false; const omit_stage2 = b.option(bool, "omit-stage2", "Do not include stage2 behind a feature flag inside stage1") orelse false; const static_llvm = b.option(bool, "static-llvm", "Disable integration with system-installed LLVM, Clang, LLD, and libc++") orelse false; @@ -128,6 +130,8 @@ pub fn build(b: *Builder) !void { const force_gpa = b.option(bool, "force-gpa", "Force the compiler to use GeneralPurposeAllocator") orelse false; const link_libc = b.option(bool, "force-link-libc", "Force self-hosted compiler to link libc") orelse enable_llvm; const strip = b.option(bool, "strip", "Omit debug information") orelse false; + const use_zig0 = b.option(bool, "zig0", "Bootstrap using zig0") orelse false; + 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; 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: { if (strip) break :blk @as(u32, 0); @@ -135,23 +139,29 @@ pub fn build(b: *Builder) !void { break :blk 4; }; - const main_file = if (is_stage1) "src/stage1.zig" else "src/main.zig"; + const main_file: ?[]const u8 = mf: { + if (!is_stage1) break :mf "src/main.zig"; + if (use_zig0) break :mf null; + break :mf "src/stage1.zig"; + }; - var exe = b.addExecutable("zig", main_file); + const exe = b.addExecutable("zig", main_file); exe.strip = strip; + exe.build_id = b.option(bool, "build-id", "Include a build id note") orelse false; exe.install(); exe.setBuildMode(mode); exe.setTarget(target); if (!skip_stage2_tests) { toolchain_step.dependOn(&exe.step); } + b.default_step.dependOn(&exe.step); exe.single_threaded = single_threaded; if (target.isWindows() and target.getAbi() == .gnu) { // LTO is currently broken on mingw, this can be removed when it's fixed. exe.want_lto = false; - test_stage2.want_lto = false; + test_cases.want_lto = false; } const exe_options = b.addOptions(); @@ -166,59 +176,9 @@ pub fn build(b: *Builder) !void { exe_options.addOption(bool, "llvm_has_arc", llvm_has_arc); exe_options.addOption(bool, "force_gpa", force_gpa); - if (enable_llvm) { - const cmake_cfg = if (static_llvm) null else findAndParseConfigH(b, config_h_path_option); - - if (is_stage1) { - exe.addIncludePath("src"); - exe.addIncludePath("deps/SoftFloat-3e/source/include"); - - test_stage2.addIncludePath("src"); - test_stage2.addIncludePath("deps/SoftFloat-3e/source/include"); - // 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"); - exe.defineCMacro("ZIG_LINK_MODE", "Static"); - test_stage2.defineCMacro("ZIG_LINK_MODE", "Static"); - - const softfloat = b.addStaticLibrary("softfloat", null); - softfloat.setBuildMode(.ReleaseFast); - softfloat.setTarget(target); - softfloat.addIncludePath("deps/SoftFloat-3e-prebuilt"); - softfloat.addIncludePath("deps/SoftFloat-3e/source/8086"); - softfloat.addIncludePath("deps/SoftFloat-3e/source/include"); - softfloat.addCSourceFiles(&softfloat_sources, &[_][]const u8{ "-std=c99", "-O3" }); - softfloat.single_threaded = single_threaded; - - exe.linkLibrary(softfloat); - test_stage2.linkLibrary(softfloat); - - exe.addCSourceFiles(&stage1_sources, &exe_cflags); - exe.addCSourceFiles(&optimized_c_sources, &[_][]const u8{ "-std=c99", "-O3" }); - - test_stage2.addCSourceFiles(&stage1_sources, &exe_cflags); - test_stage2.addCSourceFiles(&optimized_c_sources, &[_][]const u8{ "-std=c99", "-O3" }); - } - 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); - } - - try addCmakeCfgOptionsToExe(b, cfg, exe, use_zig_libcxx); - try addCmakeCfgOptionsToExe(b, cfg, test_stage2, use_zig_libcxx); - } else { - // Here we are -Denable-llvm but no cmake integration. - try addStaticLlvmOptionsToExe(exe); - try addStaticLlvmOptionsToExe(test_stage2); - } - } if (link_libc) { exe.linkLibC(); - test_stage2.linkLibC(); + test_cases.linkLibC(); } const is_debug = mode == .Debug; @@ -227,6 +187,10 @@ pub fn build(b: *Builder) !void { 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: { + 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); + } const version_string = b.fmt("{d}.{d}.{d}", .{ zig_version.major, zig_version.minor, zig_version.patch }); var code: u8 = undefined; @@ -276,6 +240,112 @@ pub fn build(b: *Builder) !void { }; exe_options.addOption([:0]const u8, "version", try b.allocator.dupeZ(u8, version)); + if (enable_llvm) { + const cmake_cfg = if (static_llvm) null else findAndParseConfigH(b, config_h_path_option); + + if (is_stage1) { + const softfloat = b.addStaticLibrary("softfloat", null); + softfloat.setBuildMode(.ReleaseFast); + softfloat.setTarget(target); + softfloat.addIncludePath("deps/SoftFloat-3e-prebuilt"); + softfloat.addIncludePath("deps/SoftFloat-3e/source/8086"); + softfloat.addIncludePath("deps/SoftFloat-3e/source/include"); + softfloat.addCSourceFiles(&softfloat_sources, &[_][]const u8{ "-std=c99", "-O3" }); + softfloat.single_threaded = single_threaded; + + const zig0 = b.addExecutable("zig0", null); + zig0.addCSourceFiles(&.{"src/stage1/zig0.cpp"}, &exe_cflags); + zig0.addIncludePath("zig-cache/tmp"); // for config.h + zig0.defineCMacro("ZIG_VERSION_MAJOR", b.fmt("{d}", .{zig_version.major})); + zig0.defineCMacro("ZIG_VERSION_MINOR", b.fmt("{d}", .{zig_version.minor})); + zig0.defineCMacro("ZIG_VERSION_PATCH", b.fmt("{d}", .{zig_version.patch})); + zig0.defineCMacro("ZIG_VERSION_STRING", b.fmt("\"{s}\"", .{version})); + + for ([_]*std.build.LibExeObjStep{ zig0, exe, test_cases }) |artifact| { + artifact.addIncludePath("src"); + artifact.addIncludePath("deps/SoftFloat-3e/source/include"); + artifact.addIncludePath("deps/SoftFloat-3e-prebuilt"); + + artifact.defineCMacro("ZIG_LINK_MODE", "Static"); + + artifact.addCSourceFiles(&stage1_sources, &exe_cflags); + artifact.addCSourceFiles(&optimized_c_sources, &[_][]const u8{ "-std=c99", "-O3" }); + + artifact.linkLibrary(softfloat); + artifact.linkLibCpp(); + } + + try addStaticLlvmOptionsToExe(zig0); + + const zig1_obj_ext = target.getObjectFormat().fileExt(target.getCpuArch()); + const zig1_obj_path = b.pathJoin(&.{ "zig-cache", "tmp", b.fmt("zig1{s}", .{zig1_obj_ext}) }); + const zig1_compiler_rt_path = b.pathJoin(&.{ b.pathFromRoot("lib"), "std", "special", "compiler_rt.zig" }); + + const zig1_obj = zig0.run(); + zig1_obj.addArgs(&.{ + "src/stage1.zig", + "-target", + try target.zigTriple(b.allocator), + "-mcpu=baseline", + "--name", + "zig1", + "--zig-lib-dir", + b.pathFromRoot("lib"), + b.fmt("-femit-bin={s}", .{b.pathFromRoot(zig1_obj_path)}), + "-fcompiler-rt", + "-lc", + }); + { + zig1_obj.addArgs(&.{ "--pkg-begin", "build_options" }); + zig1_obj.addFileSourceArg(exe_options.getSource()); + zig1_obj.addArgs(&.{ "--pkg-end", "--pkg-begin", "compiler_rt", zig1_compiler_rt_path, "--pkg-end" }); + } + switch (mode) { + .Debug => {}, + .ReleaseFast => { + zig1_obj.addArg("-OReleaseFast"); + zig1_obj.addArg("--strip"); + }, + .ReleaseSafe => { + zig1_obj.addArg("-OReleaseSafe"); + zig1_obj.addArg("--strip"); + }, + .ReleaseSmall => { + zig1_obj.addArg("-OReleaseSmall"); + zig1_obj.addArg("--strip"); + }, + } + if (single_threaded orelse false) { + zig1_obj.addArg("-fsingle-threaded"); + } + + if (use_zig0) { + exe.step.dependOn(&zig1_obj.step); + exe.addObjectFile(zig1_obj_path); + } + + // 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"); + } + 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); + } + + try addCmakeCfgOptionsToExe(b, cfg, exe, use_zig_libcxx); + try addCmakeCfgOptionsToExe(b, cfg, test_cases, use_zig_libcxx); + } else { + // Here we are -Denable-llvm but no cmake integration. + try addStaticLlvmOptionsToExe(exe); + try addStaticLlvmOptionsToExe(test_cases); + } + } + const semver = try std.SemanticVersion.parse(version); exe_options.addOption(std.SemanticVersion, "semver", semver); @@ -284,6 +354,7 @@ pub fn build(b: *Builder) !void { exe_options.addOption(bool, "enable_tracy", tracy != null); exe_options.addOption(bool, "enable_tracy_callstack", tracy_callstack); exe_options.addOption(bool, "enable_tracy_allocation", tracy_allocation); + exe_options.addOption(bool, "value_tracing", value_tracing); exe_options.addOption(bool, "is_stage1", is_stage1); exe_options.addOption(bool, "omit_stage2", omit_stage2); if (tracy) |tracy_path| { @@ -313,34 +384,37 @@ pub fn build(b: *Builder) !void { const test_filter = b.option([]const u8, "test-filter", "Skip tests that do not match filter"); - const test_stage2_options = b.addOptions(); - test_stage2.addOptions("build_options", test_stage2_options); + const test_cases_options = b.addOptions(); + test_cases.addOptions("build_options", test_cases_options); - test_stage2_options.addOption(bool, "enable_logging", enable_logging); - test_stage2_options.addOption(bool, "enable_link_snapshots", enable_link_snapshots); - test_stage2_options.addOption(bool, "skip_non_native", skip_non_native); - test_stage2_options.addOption(bool, "skip_compile_errors", skip_compile_errors); - test_stage2_options.addOption(bool, "is_stage1", is_stage1); - test_stage2_options.addOption(bool, "omit_stage2", omit_stage2); - test_stage2_options.addOption(bool, "have_llvm", enable_llvm); - test_stage2_options.addOption(bool, "llvm_has_m68k", llvm_has_m68k); - test_stage2_options.addOption(bool, "llvm_has_csky", llvm_has_csky); - test_stage2_options.addOption(bool, "llvm_has_ve", llvm_has_ve); - test_stage2_options.addOption(bool, "llvm_has_arc", llvm_has_arc); - test_stage2_options.addOption(bool, "enable_qemu", b.enable_qemu); - test_stage2_options.addOption(bool, "enable_wine", b.enable_wine); - test_stage2_options.addOption(bool, "enable_wasmtime", b.enable_wasmtime); - test_stage2_options.addOption(bool, "enable_rosetta", b.enable_rosetta); - test_stage2_options.addOption(bool, "enable_darling", b.enable_darling); - test_stage2_options.addOption(u32, "mem_leak_frames", mem_leak_frames * 2); - test_stage2_options.addOption(?[]const u8, "glibc_runtimes_dir", b.glibc_runtimes_dir); - test_stage2_options.addOption([:0]const u8, "version", try b.allocator.dupeZ(u8, version)); - test_stage2_options.addOption(std.SemanticVersion, "semver", semver); + test_cases_options.addOption(bool, "enable_logging", enable_logging); + test_cases_options.addOption(bool, "enable_link_snapshots", enable_link_snapshots); + test_cases_options.addOption(bool, "skip_non_native", skip_non_native); + test_cases_options.addOption(bool, "skip_stage1", skip_stage1); + test_cases_options.addOption(bool, "is_stage1", is_stage1); + test_cases_options.addOption(bool, "omit_stage2", omit_stage2); + test_cases_options.addOption(bool, "have_llvm", enable_llvm); + test_cases_options.addOption(bool, "llvm_has_m68k", llvm_has_m68k); + test_cases_options.addOption(bool, "llvm_has_csky", llvm_has_csky); + test_cases_options.addOption(bool, "llvm_has_ve", llvm_has_ve); + test_cases_options.addOption(bool, "llvm_has_arc", llvm_has_arc); + test_cases_options.addOption(bool, "force_gpa", force_gpa); + test_cases_options.addOption(bool, "enable_qemu", b.enable_qemu); + test_cases_options.addOption(bool, "enable_wine", b.enable_wine); + test_cases_options.addOption(bool, "enable_wasmtime", b.enable_wasmtime); + test_cases_options.addOption(bool, "enable_rosetta", b.enable_rosetta); + test_cases_options.addOption(bool, "enable_darling", b.enable_darling); + test_cases_options.addOption(u32, "mem_leak_frames", mem_leak_frames * 2); + test_cases_options.addOption(bool, "value_tracing", value_tracing); + test_cases_options.addOption(?[]const u8, "glibc_runtimes_dir", b.glibc_runtimes_dir); + test_cases_options.addOption([:0]const u8, "version", try b.allocator.dupeZ(u8, version)); + test_cases_options.addOption(std.SemanticVersion, "semver", semver); + test_cases_options.addOption(?[]const u8, "test_filter", test_filter); - const test_stage2_step = b.step("test-stage2", "Run the stage2 compiler tests"); - test_stage2_step.dependOn(&test_stage2.step); + const test_cases_step = b.step("test-cases", "Run the main compiler test cases"); + test_cases_step.dependOn(&test_cases.step); if (!skip_stage2_tests) { - toolchain_step.dependOn(test_stage2_step); + toolchain_step.dependOn(test_cases_step); } var chosen_modes: [4]builtin.Mode = undefined; @@ -375,41 +449,50 @@ pub fn build(b: *Builder) !void { "behavior", "Run the behavior tests", modes, - false, // skip_single_threaded + skip_single_threaded, skip_non_native, skip_libc, + skip_stage1, + omit_stage2, + is_stage1, )); toolchain_step.dependOn(tests.addPkgTests( b, test_filter, - "lib/std/special/compiler_rt.zig", + "lib/compiler_rt.zig", "compiler-rt", "Run the compiler_rt tests", modes, true, // skip_single_threaded skip_non_native, true, // skip_libc + skip_stage1, + omit_stage2 or true, // TODO get these all passing + is_stage1, )); toolchain_step.dependOn(tests.addPkgTests( b, test_filter, - "lib/std/special/c.zig", - "minilibc", - "Run the mini libc tests", + "lib/c.zig", + "universal-libc", + "Run the universal libc tests", modes, true, // skip_single_threaded skip_non_native, true, // skip_libc + skip_stage1, + omit_stage2 or true, // TODO get these all passing + is_stage1, )); toolchain_step.dependOn(tests.addCompareOutputTests(b, test_filter, modes)); toolchain_step.dependOn(tests.addStandaloneTests(b, test_filter, modes, skip_non_native, enable_macos_sdk, target)); + toolchain_step.dependOn(tests.addLinkTests(b, test_filter, modes, enable_macos_sdk)); toolchain_step.dependOn(tests.addStackTraceTests(b, test_filter, modes)); toolchain_step.dependOn(tests.addCliTests(b, test_filter, modes)); toolchain_step.dependOn(tests.addAssembleAndLinkTests(b, test_filter, modes)); - toolchain_step.dependOn(tests.addRuntimeSafetyTests(b, test_filter, modes)); toolchain_step.dependOn(tests.addTranslateCTests(b, test_filter)); if (!skip_run_translated_c) { toolchain_step.dependOn(tests.addRunTranslatedCTests(b, test_filter, target)); @@ -424,9 +507,12 @@ pub fn build(b: *Builder) !void { "std", "Run the standard library tests", modes, - false, + skip_single_threaded, skip_non_native, skip_libc, + skip_stage1, + omit_stage2 or true, // TODO get these all passing + is_stage1, ); const test_step = b.step("test", "Run all the tests"); @@ -499,9 +585,7 @@ fn addCmakeCfgOptionsToExe( } } -fn addStaticLlvmOptionsToExe( - exe: *std.build.LibExeObjStep, -) !void { +fn addStaticLlvmOptionsToExe(exe: *std.build.LibExeObjStep) !void { // Adds the Zig C++ sources which both stage1 and stage2 need. // // We need this because otherwise zig_clang_cc1_main.cpp ends up pulling @@ -542,11 +626,14 @@ fn addCxxKnownPath( errtxt: ?[]const u8, need_cpp_includes: bool, ) !void { + if (!std.process.can_spawn) + return error.RequiredLibraryNotFound; const path_padded = try b.exec(&[_][]const u8{ ctx.cxx_compiler, b.fmt("-print-file-name={s}", .{objname}), }); - const path_unpadded = mem.tokenize(u8, path_padded, "\r\n").next().?; + var tokenizer = mem.tokenize(u8, path_padded, "\r\n"); + const path_unpadded = tokenizer.next().?; if (mem.eql(u8, path_unpadded, objname)) { if (errtxt) |msg| { std.debug.print("{s}", .{msg}); @@ -688,15 +775,19 @@ fn toNativePathSep(b: *Builder, s: []const u8) []u8 { const softfloat_sources = [_][]const u8{ "deps/SoftFloat-3e/source/8086/f128M_isSignalingNaN.c", + "deps/SoftFloat-3e/source/8086/extF80M_isSignalingNaN.c", "deps/SoftFloat-3e/source/8086/s_commonNaNToF128M.c", + "deps/SoftFloat-3e/source/8086/s_commonNaNToExtF80M.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_extF80MToCommonNaN.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_propagateNaNExtF80M.c", "deps/SoftFloat-3e/source/8086/s_propagateNaNF16UI.c", "deps/SoftFloat-3e/source/8086/softfloat_raiseFlags.c", "deps/SoftFloat-3e/source/f128M_add.c", @@ -716,6 +807,7 @@ const softfloat_sources = [_][]const u8{ "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_extF80M.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", @@ -724,6 +816,20 @@ const softfloat_sources = [_][]const u8{ "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/extF80M_add.c", + "deps/SoftFloat-3e/source/extF80M_div.c", + "deps/SoftFloat-3e/source/extF80M_eq.c", + "deps/SoftFloat-3e/source/extF80M_le.c", + "deps/SoftFloat-3e/source/extF80M_lt.c", + "deps/SoftFloat-3e/source/extF80M_mul.c", + "deps/SoftFloat-3e/source/extF80M_rem.c", + "deps/SoftFloat-3e/source/extF80M_roundToInt.c", + "deps/SoftFloat-3e/source/extF80M_sqrt.c", + "deps/SoftFloat-3e/source/extF80M_sub.c", + "deps/SoftFloat-3e/source/extF80M_to_f16.c", + "deps/SoftFloat-3e/source/extF80M_to_f32.c", + "deps/SoftFloat-3e/source/extF80M_to_f64.c", + "deps/SoftFloat-3e/source/extF80M_to_f128M.c", "deps/SoftFloat-3e/source/f16_add.c", "deps/SoftFloat-3e/source/f16_div.c", "deps/SoftFloat-3e/source/f16_eq.c", @@ -735,9 +841,12 @@ const softfloat_sources = [_][]const u8{ "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_extF80M.c", "deps/SoftFloat-3e/source/f16_to_f128M.c", "deps/SoftFloat-3e/source/f16_to_f64.c", + "deps/SoftFloat-3e/source/f32_to_extF80M.c", "deps/SoftFloat-3e/source/f32_to_f128M.c", + "deps/SoftFloat-3e/source/f64_to_extF80M.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", @@ -745,6 +854,7 @@ const softfloat_sources = [_][]const u8{ "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_addExtF80M.c", "deps/SoftFloat-3e/source/s_addM.c", "deps/SoftFloat-3e/source/s_addMagsF16.c", "deps/SoftFloat-3e/source/s_addMagsF32.c", @@ -755,12 +865,14 @@ const softfloat_sources = [_][]const u8{ "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_compareNonnormExtF80M.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_invalidExtF80M.c", "deps/SoftFloat-3e/source/s_isNaNF128M.c", "deps/SoftFloat-3e/source/s_le128.c", "deps/SoftFloat-3e/source/s_lt128.c", @@ -771,7 +883,9 @@ const softfloat_sources = [_][]const u8{ "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_normExtF80SigM.c", "deps/SoftFloat-3e/source/s_normRoundPackMToF128M.c", + "deps/SoftFloat-3e/source/s_normRoundPackMToExtF80M.c", "deps/SoftFloat-3e/source/s_normRoundPackToF16.c", "deps/SoftFloat-3e/source/s_normRoundPackToF32.c", "deps/SoftFloat-3e/source/s_normRoundPackToF64.c", @@ -782,6 +896,7 @@ const softfloat_sources = [_][]const u8{ "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_roundPackMToExtF80M.c", "deps/SoftFloat-3e/source/s_roundPackMToF128M.c", "deps/SoftFloat-3e/source/s_roundPackToF16.c", "deps/SoftFloat-3e/source/s_roundPackToF32.c", @@ -810,9 +925,12 @@ const softfloat_sources = [_][]const u8{ "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/s_tryPropagateNaNExtF80M.c", "deps/SoftFloat-3e/source/softfloat_state.c", "deps/SoftFloat-3e/source/ui32_to_f128M.c", "deps/SoftFloat-3e/source/ui64_to_f128M.c", + "deps/SoftFloat-3e/source/ui32_to_extF80M.c", + "deps/SoftFloat-3e/source/ui64_to_extF80M.c", }; const stage1_sources = [_][]const u8{ diff --git a/ci/azure/build.zig b/ci/azure/build.zig new file mode 100644 index 0000000000..12197fdf07 --- /dev/null +++ b/ci/azure/build.zig @@ -0,0 +1,980 @@ +const std = @import("std"); +const builtin = std.builtin; +const Builder = std.build.Builder; +const BufMap = std.BufMap; +const mem = std.mem; +const ArrayList = std.ArrayList; +const io = std.io; +const fs = std.fs; +const InstallDirectoryOptions = std.build.InstallDirectoryOptions; +const assert = std.debug.assert; + +const zig_version = std.builtin.Version{ .major = 0, .minor = 10, .patch = 0 }; + +pub fn build(b: *Builder) !void { + b.setPreferredReleaseMode(.ReleaseFast); + const mode = b.standardReleaseOptions(); + const target = b.standardTargetOptions(.{}); + const single_threaded = b.option(bool, "single-threaded", "Build artifacts that run in single threaded mode"); + 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; + + const docgen_exe = b.addExecutable("docgen", "doc/docgen.zig"); + docgen_exe.single_threaded = single_threaded; + + const rel_zig_exe = try fs.path.relative(b.allocator, b.build_root, b.zig_exe); + const langref_out_path = fs.path.join( + b.allocator, + &[_][]const u8{ b.cache_root, "langref.html" }, + ) catch unreachable; + const docgen_cmd = docgen_exe.run(); + docgen_cmd.addArgs(&[_][]const u8{ + rel_zig_exe, + "doc" ++ fs.path.sep_str ++ "langref.html.in", + langref_out_path, + }); + docgen_cmd.step.dependOn(&docgen_exe.step); + + const docs_step = b.step("docs", "Build documentation"); + docs_step.dependOn(&docgen_cmd.step); + + const is_stage1 = b.option(bool, "stage1", "Build the stage1 compiler, put stage2 behind a feature flag") orelse false; + const omit_stage2 = b.option(bool, "omit-stage2", "Do not include stage2 behind a feature flag inside stage1") orelse false; + 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); + 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_ve = b.option( + bool, + "llvm-has-ve", + "Whether LLVM has the experimental target ve enabled", + ) orelse false; + const llvm_has_arc = b.option( + bool, + "llvm-has-arc", + "Whether LLVM has the experimental target arc enabled", + ) orelse false; + const config_h_path_option = b.option([]const u8, "config_h", "Path to the generated config.h"); + + b.installDirectory(InstallDirectoryOptions{ + .source_dir = "lib", + .install_dir = .lib, + .install_subdir = "zig", + .exclude_extensions = &[_][]const u8{ + // exclude files from lib/std/compress/ + ".gz", + ".z.0", + ".z.9", + "rfc1951.txt", + "rfc1952.txt", + // exclude files from lib/std/compress/deflate/testdata + ".expect", + ".expect-noinput", + ".golden", + ".input", + "compress-e.txt", + "compress-gettysburg.txt", + "compress-pi.txt", + "rfc1951.txt", + // exclude files from lib/std/tz/ + ".tzif", + // others + "README.md", + }, + .blank_extensions = &[_][]const u8{ + "test.zig", + }, + }); + + const tracy = b.option([]const u8, "tracy", "Enable Tracy integration. Supply path to Tracy source"); + const tracy_callstack = b.option(bool, "tracy-callstack", "Include callstack information with Tracy data. Does nothing if -Dtracy is not provided") orelse false; + const tracy_allocation = b.option(bool, "tracy-allocation", "Include allocation information with Tracy data. Does nothing if -Dtracy is not provided") orelse false; + const force_gpa = b.option(bool, "force-gpa", "Force the compiler to use GeneralPurposeAllocator") orelse false; + const link_libc = b.option(bool, "force-link-libc", "Force self-hosted compiler to link libc") orelse enable_llvm; + const strip = b.option(bool, "strip", "Omit debug information") orelse false; + 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; + + 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: { + if (strip) break :blk @as(u32, 0); + if (mode != .Debug) break :blk 0; + break :blk 4; + }; + + const main_file: ?[]const u8 = if (is_stage1) null else "src/main.zig"; + + const exe = b.addExecutable("zig", main_file); + exe.strip = strip; + exe.install(); + exe.setBuildMode(mode); + exe.setTarget(target); + + b.default_step.dependOn(&exe.step); + exe.single_threaded = single_threaded; + + if (target.isWindows() and target.getAbi() == .gnu) { + // LTO is currently broken on mingw, this can be removed when it's fixed. + exe.want_lto = false; + } + + const exe_options = b.addOptions(); + exe.addOptions("build_options", exe_options); + + exe_options.addOption(u32, "mem_leak_frames", mem_leak_frames); + exe_options.addOption(bool, "skip_non_native", false); + exe_options.addOption(bool, "have_llvm", enable_llvm); + 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_ve", llvm_has_ve); + exe_options.addOption(bool, "llvm_has_arc", llvm_has_arc); + exe_options.addOption(bool, "force_gpa", force_gpa); + + if (link_libc) { + exe.linkLibC(); + } + + const is_debug = mode == .Debug; + const enable_logging = b.option(bool, "log", "Enable debug logging with --debug-log") orelse is_debug; + const enable_link_snapshots = b.option(bool, "link-snapshot", "Whether to enable linker state snapshots") orelse false; + + 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: { + const version_string = b.fmt("{d}.{d}.{d}", .{ zig_version.major, zig_version.minor, zig_version.patch }); + + var code: u8 = undefined; + const git_describe_untrimmed = b.execAllowFail(&[_][]const u8{ + "git", "-C", b.build_root, "describe", "--match", "*.*.*", "--tags", + }, &code, .Ignore) catch { + break :v version_string; + }; + const git_describe = mem.trim(u8, git_describe_untrimmed, " \n\r"); + + switch (mem.count(u8, git_describe, "-")) { + 0 => { + // Tagged release version (e.g. 0.9.0). + if (!mem.eql(u8, git_describe, version_string)) { + std.debug.print("Zig version '{s}' does not match Git tag '{s}'\n", .{ version_string, git_describe }); + std.process.exit(1); + } + break :v version_string; + }, + 2 => { + // Untagged development build (e.g. 0.9.0-dev.2025+ecf0050a9). + var it = mem.split(u8, 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') { + std.debug.print("Unexpected `git describe` output: {s}\n", .{git_describe}); + break :v version_string; + } + + // The version is reformatted in accordance with the https://semver.org specification. + break :v b.fmt("{s}-dev.{s}+{s}", .{ version_string, commit_height, commit_id[1..] }); + }, + else => { + std.debug.print("Unexpected `git describe` output: {s}\n", .{git_describe}); + break :v version_string; + }, + } + }; + exe_options.addOption([:0]const u8, "version", try b.allocator.dupeZ(u8, version)); + + if (enable_llvm) { + const cmake_cfg = if (static_llvm) null else findAndParseConfigH(b, config_h_path_option); + + if (is_stage1) { + 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" }); + softfloat.single_threaded = single_threaded; + + const zig0 = b.addExecutable("zig0", null); + zig0.addCSourceFiles(&.{"src/stage1/zig0.cpp"}, &exe_cflags); + zig0.addIncludeDir("zig-cache/tmp"); // for config.h + zig0.defineCMacro("ZIG_VERSION_MAJOR", b.fmt("{d}", .{zig_version.major})); + zig0.defineCMacro("ZIG_VERSION_MINOR", b.fmt("{d}", .{zig_version.minor})); + zig0.defineCMacro("ZIG_VERSION_PATCH", b.fmt("{d}", .{zig_version.patch})); + zig0.defineCMacro("ZIG_VERSION_STRING", b.fmt("\"{s}\"", .{version})); + + for ([_]*std.build.LibExeObjStep{ zig0, exe }) |artifact| { + artifact.addIncludeDir("src"); + artifact.addIncludeDir("deps/SoftFloat-3e/source/include"); + artifact.addIncludeDir("deps/SoftFloat-3e-prebuilt"); + + artifact.defineCMacro("ZIG_LINK_MODE", "Static"); + + artifact.addCSourceFiles(&stage1_sources, &exe_cflags); + artifact.addCSourceFiles(&optimized_c_sources, &[_][]const u8{ "-std=c99", "-O3" }); + + artifact.linkLibrary(softfloat); + artifact.linkLibCpp(); + } + + try addStaticLlvmOptionsToExe(zig0); + + const zig1_obj_ext = target.getObjectFormat().fileExt(target.getCpuArch()); + const zig1_obj_path = b.pathJoin(&.{ "zig-cache", "tmp", b.fmt("zig1{s}", .{zig1_obj_ext}) }); + const zig1_compiler_rt_path = b.pathJoin(&.{ b.pathFromRoot("lib"), "std", "special", "compiler_rt.zig" }); + + const zig1_obj = zig0.run(); + zig1_obj.addArgs(&.{ + "src/stage1.zig", + "-target", + try target.zigTriple(b.allocator), + "-mcpu=baseline", + "--name", + "zig1", + "--zig-lib-dir", + b.pathFromRoot("lib"), + b.fmt("-femit-bin={s}", .{b.pathFromRoot(zig1_obj_path)}), + "-fcompiler-rt", + "-lc", + }); + { + zig1_obj.addArgs(&.{ "--pkg-begin", "build_options" }); + zig1_obj.addFileSourceArg(exe_options.getSource()); + zig1_obj.addArgs(&.{ "--pkg-end", "--pkg-begin", "compiler_rt", zig1_compiler_rt_path, "--pkg-end" }); + } + switch (mode) { + .Debug => {}, + .ReleaseFast => { + zig1_obj.addArg("-OReleaseFast"); + zig1_obj.addArg("--strip"); + }, + .ReleaseSafe => { + zig1_obj.addArg("-OReleaseSafe"); + zig1_obj.addArg("--strip"); + }, + .ReleaseSmall => { + zig1_obj.addArg("-OReleaseSmall"); + zig1_obj.addArg("--strip"); + }, + } + if (single_threaded orelse false) { + zig1_obj.addArg("-fsingle-threaded"); + } + + exe.step.dependOn(&zig1_obj.step); + exe.addObjectFile(zig1_obj_path); + + // 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"); + } + 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); + } + + try addCmakeCfgOptionsToExe(b, cfg, exe, use_zig_libcxx); + } else { + // Here we are -Denable-llvm but no cmake integration. + try addStaticLlvmOptionsToExe(exe); + } + } + + const semver = try std.SemanticVersion.parse(version); + exe_options.addOption(std.SemanticVersion, "semver", semver); + + exe_options.addOption(bool, "enable_logging", enable_logging); + exe_options.addOption(bool, "enable_link_snapshots", enable_link_snapshots); + exe_options.addOption(bool, "enable_tracy", tracy != null); + exe_options.addOption(bool, "enable_tracy_callstack", tracy_callstack); + exe_options.addOption(bool, "enable_tracy_allocation", tracy_allocation); + exe_options.addOption(bool, "value_tracing", value_tracing); + exe_options.addOption(bool, "is_stage1", is_stage1); + exe_options.addOption(bool, "omit_stage2", omit_stage2); + if (tracy) |tracy_path| { + const client_cpp = fs.path.join( + b.allocator, + &[_][]const u8{ tracy_path, "TracyClient.cpp" }, + ) catch unreachable; + + // On mingw, we need to opt into windows 7+ to get some features required by tracy. + const tracy_c_flags: []const []const u8 = if (target.isWindows() and target.getAbi() == .gnu) + &[_][]const u8{ "-DTRACY_ENABLE=1", "-fno-sanitize=undefined", "-D_WIN32_WINNT=0x601" } + else + &[_][]const u8{ "-DTRACY_ENABLE=1", "-fno-sanitize=undefined" }; + + exe.addIncludeDir(tracy_path); + exe.addCSourceFile(client_cpp, tracy_c_flags); + if (!enable_llvm) { + exe.linkSystemLibraryName("c++"); + } + exe.linkLibC(); + + if (target.isWindows()) { + exe.linkSystemLibrary("dbghelp"); + exe.linkSystemLibrary("ws2_32"); + } + } +} + +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", +}; + +fn addCmakeCfgOptionsToExe( + b: *Builder, + cfg: CMakeConfig, + exe: *std.build.LibExeObjStep, + use_zig_libcxx: bool, +) !void { + 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); + + if (use_zig_libcxx) { + exe.linkLibCpp(); + } else { + const need_cpp_includes = true; + + // 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("unwind"); + } else if (exe.target.isFreeBSD()) { + try addCxxKnownPath(b, cfg, exe, "libc++.a", null, need_cpp_includes); + exe.linkSystemLibrary("pthread"); + } 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); + } else if (exe.target.isDarwin()) { + exe.linkSystemLibrary("c++"); + } + } + + if (cfg.dia_guids_lib.len != 0) { + exe.addObjectFile(cfg.dia_guids_lib); + } +} + +fn addStaticLlvmOptionsToExe( + exe: *std.build.LibExeObjStep, +) !void { + // 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::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); + + for (clang_libs) |lib_name| { + exe.linkSystemLibrary(lib_name); + } + + for (lld_libs) |lib_name| { + exe.linkSystemLibrary(lib_name); + } + + for (llvm_libs) |lib_name| { + exe.linkSystemLibrary(lib_name); + } + + exe.linkSystemLibrary("z"); + + // This means we rely on clang-or-zig-built LLVM, Clang, LLD libraries. + exe.linkSystemLibrary("c++"); + + if (exe.target.getOs().tag == .windows) { + exe.linkSystemLibrary("version"); + exe.linkSystemLibrary("uuid"); + exe.linkSystemLibrary("ole32"); + } +} + +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, + b.fmt("-print-file-name={s}", .{objname}), + }); + const path_unpadded = mem.tokenize(u8, path_padded, "\r\n").next().?; + if (mem.eql(u8, path_unpadded, objname)) { + if (errtxt) |msg| { + std.debug.print("{s}", .{msg}); + } else { + std.debug.print("Unable to determine path to {s}\n", .{objname}); + } + 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/fvf3qjqa5qpcjjkq37pb6ypnk1mzhf5h-gcc-9.3.0/lib/gcc/x86_64-unknown-linux-gnu/9.3.0/../../../../include/c++/9.3.0"); + //exe.addIncludeDir("/nix/store/fvf3qjqa5qpcjjkq37pb6ypnk1mzhf5h-gcc-9.3.0/lib/gcc/x86_64-unknown-linux-gnu/9.3.0/../../../../include/c++/9.3.0/x86_64-unknown-linux-gnu"); + //exe.addIncludeDir("/nix/store/fvf3qjqa5qpcjjkq37pb6ypnk1mzhf5h-gcc-9.3.0/lib/gcc/x86_64-unknown-linux-gnu/9.3.0/../../../../include/c++/9.3.0/backward"); + } +} + +fn addCMakeLibraryList(exe: *std.build.LibExeObjStep, list: []const u8) void { + var it = mem.tokenize(u8, 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(u8, 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(u8, 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 = b.allocator.dupe(u8, s) catch unreachable; + for (duplicated) |*byte| switch (byte.*) { + '/' => byte.* = fs.path.sep, + else => {}, + }; + return duplicated; +} + +const softfloat_sources = [_][]const u8{ + "deps/SoftFloat-3e/source/8086/f128M_isSignalingNaN.c", + "deps/SoftFloat-3e/source/8086/extF80M_isSignalingNaN.c", + "deps/SoftFloat-3e/source/8086/s_commonNaNToF128M.c", + "deps/SoftFloat-3e/source/8086/s_commonNaNToExtF80M.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_extF80MToCommonNaN.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_propagateNaNExtF80M.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_extF80M.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/extF80M_add.c", + "deps/SoftFloat-3e/source/extF80M_div.c", + "deps/SoftFloat-3e/source/extF80M_eq.c", + "deps/SoftFloat-3e/source/extF80M_le.c", + "deps/SoftFloat-3e/source/extF80M_lt.c", + "deps/SoftFloat-3e/source/extF80M_mul.c", + "deps/SoftFloat-3e/source/extF80M_rem.c", + "deps/SoftFloat-3e/source/extF80M_roundToInt.c", + "deps/SoftFloat-3e/source/extF80M_sqrt.c", + "deps/SoftFloat-3e/source/extF80M_sub.c", + "deps/SoftFloat-3e/source/extF80M_to_f16.c", + "deps/SoftFloat-3e/source/extF80M_to_f32.c", + "deps/SoftFloat-3e/source/extF80M_to_f64.c", + "deps/SoftFloat-3e/source/extF80M_to_f128M.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_extF80M.c", + "deps/SoftFloat-3e/source/f16_to_f128M.c", + "deps/SoftFloat-3e/source/f16_to_f64.c", + "deps/SoftFloat-3e/source/f32_to_extF80M.c", + "deps/SoftFloat-3e/source/f32_to_f128M.c", + "deps/SoftFloat-3e/source/f64_to_extF80M.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_addExtF80M.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_compareNonnormExtF80M.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_invalidExtF80M.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_normExtF80SigM.c", + "deps/SoftFloat-3e/source/s_normRoundPackMToF128M.c", + "deps/SoftFloat-3e/source/s_normRoundPackMToExtF80M.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_roundPackMToExtF80M.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/s_tryPropagateNaNExtF80M.c", + "deps/SoftFloat-3e/source/softfloat_state.c", + "deps/SoftFloat-3e/source/ui32_to_f128M.c", + "deps/SoftFloat-3e/source/ui64_to_f128M.c", + "deps/SoftFloat-3e/source/ui32_to_extF80M.c", + "deps/SoftFloat-3e/source/ui64_to_extF80M.c", +}; + +const stage1_sources = [_][]const u8{ + "src/stage1/analyze.cpp", + "src/stage1/astgen.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_llvm-ar.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", +}; + +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. Also omit LLVMTableGen +// from these libs. +const llvm_libs = [_][]const u8{ + "LLVMWindowsManifest", + "LLVMXRay", + "LLVMLibDriver", + "LLVMDlltoolDriver", + "LLVMCoverage", + "LLVMLineEditor", + "LLVMXCoreDisassembler", + "LLVMXCoreCodeGen", + "LLVMXCoreDesc", + "LLVMXCoreInfo", + "LLVMX86Disassembler", + "LLVMX86AsmParser", + "LLVMX86CodeGen", + "LLVMX86Desc", + "LLVMX86Info", + "LLVMWebAssemblyDisassembler", + "LLVMWebAssemblyAsmParser", + "LLVMWebAssemblyCodeGen", + "LLVMWebAssemblyDesc", + "LLVMWebAssemblyUtils", + "LLVMWebAssemblyInfo", + "LLVMSystemZDisassembler", + "LLVMSystemZAsmParser", + "LLVMSystemZCodeGen", + "LLVMSystemZDesc", + "LLVMSystemZInfo", + "LLVMSparcDisassembler", + "LLVMSparcAsmParser", + "LLVMSparcCodeGen", + "LLVMSparcDesc", + "LLVMSparcInfo", + "LLVMRISCVDisassembler", + "LLVMRISCVAsmParser", + "LLVMRISCVCodeGen", + "LLVMRISCVDesc", + "LLVMRISCVInfo", + "LLVMPowerPCDisassembler", + "LLVMPowerPCAsmParser", + "LLVMPowerPCCodeGen", + "LLVMPowerPCDesc", + "LLVMPowerPCInfo", + "LLVMNVPTXCodeGen", + "LLVMNVPTXDesc", + "LLVMNVPTXInfo", + "LLVMMSP430Disassembler", + "LLVMMSP430AsmParser", + "LLVMMSP430CodeGen", + "LLVMMSP430Desc", + "LLVMMSP430Info", + "LLVMMipsDisassembler", + "LLVMMipsAsmParser", + "LLVMMipsCodeGen", + "LLVMMipsDesc", + "LLVMMipsInfo", + "LLVMLanaiDisassembler", + "LLVMLanaiCodeGen", + "LLVMLanaiAsmParser", + "LLVMLanaiDesc", + "LLVMLanaiInfo", + "LLVMHexagonDisassembler", + "LLVMHexagonCodeGen", + "LLVMHexagonAsmParser", + "LLVMHexagonDesc", + "LLVMHexagonInfo", + "LLVMBPFDisassembler", + "LLVMBPFAsmParser", + "LLVMBPFCodeGen", + "LLVMBPFDesc", + "LLVMBPFInfo", + "LLVMAVRDisassembler", + "LLVMAVRAsmParser", + "LLVMAVRCodeGen", + "LLVMAVRDesc", + "LLVMAVRInfo", + "LLVMARMDisassembler", + "LLVMARMAsmParser", + "LLVMARMCodeGen", + "LLVMARMDesc", + "LLVMARMUtils", + "LLVMARMInfo", + "LLVMAMDGPUDisassembler", + "LLVMAMDGPUAsmParser", + "LLVMAMDGPUCodeGen", + "LLVMAMDGPUDesc", + "LLVMAMDGPUUtils", + "LLVMAMDGPUInfo", + "LLVMAArch64Disassembler", + "LLVMAArch64AsmParser", + "LLVMAArch64CodeGen", + "LLVMAArch64Desc", + "LLVMAArch64Utils", + "LLVMAArch64Info", + "LLVMOrcJIT", + "LLVMMCJIT", + "LLVMJITLink", + "LLVMInterpreter", + "LLVMExecutionEngine", + "LLVMRuntimeDyld", + "LLVMOrcTargetProcess", + "LLVMOrcShared", + "LLVMDWP", + "LLVMSymbolize", + "LLVMDebugInfoPDB", + "LLVMDebugInfoGSYM", + "LLVMOption", + "LLVMObjectYAML", + "LLVMMCA", + "LLVMMCDisassembler", + "LLVMLTO", + "LLVMPasses", + "LLVMCFGuard", + "LLVMCoroutines", + "LLVMObjCARCOpts", + "LLVMipo", + "LLVMVectorize", + "LLVMLinker", + "LLVMInstrumentation", + "LLVMFrontendOpenMP", + "LLVMFrontendOpenACC", + "LLVMExtensions", + "LLVMDWARFLinker", + "LLVMGlobalISel", + "LLVMMIRParser", + "LLVMAsmPrinter", + "LLVMDebugInfoMSF", + "LLVMDebugInfoDWARF", + "LLVMSelectionDAG", + "LLVMCodeGen", + "LLVMIRReader", + "LLVMAsmParser", + "LLVMInterfaceStub", + "LLVMFileCheck", + "LLVMFuzzMutate", + "LLVMTarget", + "LLVMScalarOpts", + "LLVMInstCombine", + "LLVMAggressiveInstCombine", + "LLVMTransformUtils", + "LLVMBitWriter", + "LLVMAnalysis", + "LLVMProfileData", + "LLVMObject", + "LLVMTextAPI", + "LLVMMCParser", + "LLVMMC", + "LLVMDebugInfoCodeView", + "LLVMBitReader", + "LLVMCore", + "LLVMRemarks", + "LLVMBitstreamReader", + "LLVMBinaryFormat", + "LLVMSupport", + "LLVMDemangle", +}; diff --git a/ci/azure/macos_arm64_script b/ci/azure/macos_arm64_script index b8d1437e78..336de1db48 100755 --- a/ci/azure/macos_arm64_script +++ b/ci/azure/macos_arm64_script @@ -8,15 +8,15 @@ brew update && brew install ncurses s3cmd ZIGDIR="$(pwd)" HOST_ARCH="x86_64" -HOST_TARGET="$HOST_ARCH-macos-gnu" +HOST_TARGET="$HOST_ARCH-macos-none" HOST_MCPU="baseline" -HOST_CACHE_BASENAME="zig+llvm+lld+clang-$HOST_TARGET-0.9.0-dev.1249+210ef5af8" +HOST_CACHE_BASENAME="zig+llvm+lld+clang-$HOST_TARGET-0.10.0-dev.2348+d43761808" HOST_PREFIX="$HOME/$HOST_CACHE_BASENAME" ARCH="aarch64" -TARGET="$ARCH-macos-gnu" +TARGET="$ARCH-macos-none" MCPU="apple_a14" -CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.9.0-dev.1249+210ef5af8" +CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.10.0-dev.2348+d43761808" PREFIX="$HOME/$CACHE_BASENAME" JOBS="-j2" diff --git a/ci/azure/macos_script b/ci/azure/macos_script index da0e279500..149ae9245e 100755 --- a/ci/azure/macos_script +++ b/ci/azure/macos_script @@ -7,9 +7,9 @@ brew update && brew install ncurses s3cmd ZIGDIR="$(pwd)" ARCH="x86_64" -TARGET="$ARCH-macos-gnu" +TARGET="$ARCH-macos-none" MCPU="baseline" -CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.9.0-dev.1249+210ef5af8" +CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.10.0-dev.2348+d43761808" PREFIX="$HOME/$CACHE_BASENAME" JOBS="-j2" @@ -55,12 +55,28 @@ make $JOBS install cmake .. -DZIG_EXECUTABLE="$(pwd)/release/bin/zig" make $JOBS install -# TODO figure out why this causes a segmentation fault -# release/bin/zig test ../test/behavior.zig -fno-stage1 -fLLVM -I ../test +# Build stage2 standalone so that we can test stage2 against stage2 compiler-rt. +release/bin/zig build -p stage2 -Denable-llvm -release/bin/zig build test-toolchain -Denable-macos-sdk -release/bin/zig build test-std -release/bin/zig build docs +stage2/bin/zig build test-behavior + +# TODO: upgrade these to test stage2 instead of stage1 +# TODO: upgrade these to test stage3 instead of stage2 +release/bin/zig build test-behavior -Denable-macos-sdk -Domit-stage2 +release/bin/zig build test-compiler-rt -Denable-macos-sdk +release/bin/zig build test-std -Denable-macos-sdk +release/bin/zig build test-universal-libc -Denable-macos-sdk +release/bin/zig build test-compare-output -Denable-macos-sdk +release/bin/zig build test-standalone -Denable-macos-sdk +release/bin/zig build test-stack-traces -Denable-macos-sdk +release/bin/zig build test-cli -Denable-macos-sdk +release/bin/zig build test-asm-link -Denable-macos-sdk +release/bin/zig build test-translate-c -Denable-macos-sdk +release/bin/zig build test-run-translated-c -Denable-macos-sdk +release/bin/zig build docs -Denable-macos-sdk +release/bin/zig build test-fmt -Denable-macos-sdk +release/bin/zig build test-cases -Denable-macos-sdk -Dsingle-threaded +release/bin/zig build test-link -Denable-macos-sdk if [ "${BUILD_REASON}" != "PullRequest" ]; then mv ../LICENSE release/ diff --git a/ci/azure/pipelines.yml b/ci/azure/pipelines.yml index 4524ee9fb1..ef9b6dfb15 100644 --- a/ci/azure/pipelines.yml +++ b/ci/azure/pipelines.yml @@ -22,29 +22,149 @@ jobs: name: main displayName: 'Build' - job: BuildWindows + timeoutInMinutes: 360 pool: vmImage: 'windows-2019' - timeoutInMinutes: 360 + variables: + TARGET: 'x86_64-windows-gnu' + ZIG_LLVM_CLANG_LLD_NAME: 'zig+llvm+lld+clang-${{ variables.TARGET }}-0.9.1' + ZIG_LLVM_CLANG_LLD_URL: 'https://ziglang.org/deps/${{ variables.ZIG_LLVM_CLANG_LLD_NAME }}.zip' steps: - - powershell: | - (New-Object Net.WebClient).DownloadFile("https://github.com/msys2/msys2-installer/releases/download/2022-01-28/msys2-base-x86_64-20220128.sfx.exe", "sfx.exe") - .\sfx.exe -y -o\ - displayName: Download/Extract/Install MSYS2 - - script: | - @REM install updated filesystem package first without dependency checking - @REM because of: https://github.com/msys2/MSYS2-packages/issues/2021 - %CD:~0,2%\msys64\usr\bin\bash -lc "pacman --noconfirm -Sydd filesystem" - displayName: Workaround filesystem dash MSYS2 dependency issue - - script: | - %CD:~0,2%\msys64\usr\bin\bash -lc "pacman --noconfirm -Syuu" - %CD:~0,2%\msys64\usr\bin\bash -lc "pacman --noconfirm -Syuu" - displayName: Update MSYS2 + - pwsh: | + (New-Object Net.WebClient).DownloadFile("$(ZIG_LLVM_CLANG_LLD_URL)", "${ZIG_LLVM_CLANG_LLD_NAME}.zip") + & 'C:\Program Files\7-Zip\7z.exe' x "${ZIG_LLVM_CLANG_LLD_NAME}.zip" + name: install + displayName: 'Install ZIG/LLVM/CLANG/LLD' + + - pwsh: | + Set-Variable -Name ZIGBUILDDIR -Value "$(Get-Location)\build" + Set-Variable -Name ZIGINSTALLDIR -Value "${ZIGBUILDDIR}\dist" + Set-Variable -Name ZIGPREFIXPATH -Value "$(Get-Location)\$(ZIG_LLVM_CLANG_LLD_NAME)" + + # Make the `zig version` number consistent. + # This will affect the `zig build` command below which uses `git describe`. + git config core.abbrev 9 + git fetch --tags + if ((git rev-parse --is-shallow-repository) -eq "true") { + git fetch --unshallow # `git describe` won't work on a shallow repo + } + + # The dev kit zip file that we have here is old, and may be incompatible with + # the build.zig script of master branch. So we keep an old version of build.zig + # here in the CI directory. + mv build.zig build.zig.master + mv ci/azure/build.zig build.zig + + mkdir $ZIGBUILDDIR + cd $ZIGBUILDDIR + + & "${ZIGPREFIXPATH}/bin/zig.exe" build ` + --prefix "$ZIGINSTALLDIR" ` + --search-prefix "$ZIGPREFIXPATH" ` + -Dstage1 ` + <# stage2 is omitted until we resolve https://github.com/ziglang/zig/issues/6485 #> ` + -Domit-stage2 ` + -Dstatic-llvm ` + -Drelease ` + -Dstrip ` + -Duse-zig-libcxx ` + -Dtarget=$(TARGET) + + cd - + + # Now that we have built an up-to-date zig.exe, we restore the original + # build script from master branch. + rm build.zig + mv build.zig.master build.zig + + name: build + displayName: 'Build' + + - pwsh: | + Set-Variable -Name ZIGINSTALLDIR -Value "$(Get-Location)\build\dist" + + # Sadly, stage2 is omitted from this build to save memory on the CI server. Once self-hosted is + # built with itself and does not gobble as much memory, we can enable these tests. + #& "$ZIGINSTALLDIR\bin\zig.exe" test "..\test\behavior.zig" -fno-stage1 -fLLVM -I "..\test" 2>&1 + + & "$ZIGINSTALLDIR\bin\zig.exe" build test-toolchain -Dskip-non-native -Dskip-stage2-tests 2>&1 + & "$ZIGINSTALLDIR\bin\zig.exe" build test-std -Dskip-non-native 2>&1 + name: test + displayName: 'Test' + + - pwsh: | + Set-Variable -Name ZIGINSTALLDIR -Value "$(Get-Location)\build\dist" + + & "$ZIGINSTALLDIR\bin\zig.exe" build docs + timeoutInMinutes: 60 + name: doc + displayName: 'Documentation' + - task: DownloadSecureFile@1 inputs: - secureFile: s3cfg - - script: ci/azure/windows_msvc_script.bat - name: main - displayName: 'Build and test' + name: aws_credentials + secureFile: aws_credentials + + - pwsh: | + Set-Variable -Name ZIGBUILDDIR -Value "$(Get-Location)\build" + $Env:AWS_SHARED_CREDENTIALS_FILE = "$Env:DOWNLOADSECUREFILE_SECUREFILEPATH" + + # Workaround Azure networking issue + # https://github.com/aws/aws-cli/issues/5749 + $Env:AWS_EC2_METADATA_DISABLED = "true" + $Env:AWS_REGION = "us-west-2" + + cd "$ZIGBUILDDIR" + mv ../LICENSE dist/ + mv ../zig-cache/langref.html dist/ + mv dist/bin/zig.exe dist/ + rmdir dist/bin + + # Remove the unnecessary zig dir in $prefix/lib/zig/std/std.zig + mv dist/lib/zig dist/lib2 + rmdir dist/lib + mv dist/lib2 dist/lib + + Set-Variable -Name VERSION -Value $(./dist/zig.exe version) + Set-Variable -Name DIRNAME -Value "zig-windows-x86_64-$VERSION" + Set-Variable -Name TARBALL -Value "$DIRNAME.zip" + mv dist "$DIRNAME" + 7z a "$TARBALL" "$DIRNAME" + + aws s3 cp ` + "$TARBALL" ` + s3://ziglang.org/builds/ ` + --acl public-read ` + --cache-control 'public, max-age=31536000, immutable' + + Set-Variable -Name SHASUM -Value (Get-FileHash "$TARBALL" -Algorithm SHA256 | select-object -ExpandProperty Hash).ToLower() + Set-Variable -Name BYTESIZE -Value (Get-Item "$TARBALL").length + + Set-Variable -Name JSONFILE -Value "windows-${Env:BUILD_SOURCEBRANCHNAME}.json" + echo $null > $JSONFILE + echo ('{"tarball": "' + $TARBALL + '",') >> $JSONFILE + echo ('"shasum": "' + $SHASUM + '",') >> $JSONFILE + echo ('"size": ' + $BYTESIZE + '}' ) >> $JSONFILE + + aws s3 cp ` + "$JSONFILE" ` + s3://ziglang.org/builds/ ` + --acl public-read ` + --cache-control 'max-age=0, must-revalidate' + + aws s3 cp ` + "$JSONFILE" ` + "s3://ziglang.org/builds/x86_64-windows-${VERSION}.json" ` + --acl public-read + + echo "##vso[task.setvariable variable=tarball;isOutput=true]$TARBALL" + echo "##vso[task.setvariable variable=shasum;isOutput=true]$SHASUM" + echo "##vso[task.setvariable variable=bytesize;isOutput=true]$BYTESIZE" + + name: upload + condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest')) + displayName: 'Upload' + - job: OnMasterSuccess dependsOn: - BuildMacOS @@ -54,7 +174,7 @@ jobs: strategy: maxParallel: 1 pool: - vmImage: 'ubuntu-18.04' + vmImage: 'ubuntu-20.04' variables: version: $[ dependencies.BuildMacOS.outputs['main.version'] ] steps: diff --git a/ci/azure/windows_msvc_install b/ci/azure/windows_msvc_install deleted file mode 100644 index 2df445fe12..0000000000 --- a/ci/azure/windows_msvc_install +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh - -set -x -set -e - -pacman -Suy --needed --noconfirm -pacman -S --needed --noconfirm wget p7zip python3-pip tar xz - -TARBALL="llvm+clang+lld-13.0.0-x86_64-windows-msvc-release-mt.tar.xz" - -pip install s3cmd -wget -nv "https://ziglang.org/deps/$TARBALL" -# If the first extraction fails, re-try it once; this can happen if the tarball -# contains symlinks that are in the table of contents before the files that -# they point to. -tar -xf $TARBALL || tar --overwrite -xf $TARBALL diff --git a/ci/azure/windows_msvc_script.bat b/ci/azure/windows_msvc_script.bat deleted file mode 100644 index c61c88093c..0000000000 --- a/ci/azure/windows_msvc_script.bat +++ /dev/null @@ -1,39 +0,0 @@ -@echo on -SET "SRCROOT=%cd%" -SET "PREVPATH=%PATH%" -SET "PREVMSYSTEM=%MSYSTEM%" - -set "PATH=%CD:~0,2%\msys64\usr\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem" -SET "MSYSTEM=MINGW64" -bash -lc "cd ${SRCROOT} && ci/azure/windows_msvc_install" || exit /b -SET "PATH=%PREVPATH%" -SET "MSYSTEM=%PREVMSYSTEM%" - -SET "ZIGBUILDDIR=%SRCROOT%\build" -SET "ZIGINSTALLDIR=%ZIGBUILDDIR%\dist" -SET "ZIGPREFIXPATH=%SRCROOT%\llvm+clang+lld-13.0.0-x86_64-windows-msvc-release-mt" - -call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - -REM Make the `zig version` number consistent. -REM This will affect the cmake command below. -git.exe config core.abbrev 9 -git.exe fetch --unshallow -git.exe fetch --tags - -mkdir %ZIGBUILDDIR% -cd %ZIGBUILDDIR% -cmake.exe .. -Thost=x64 -G"Visual Studio 16 2019" -A x64 "-DCMAKE_INSTALL_PREFIX=%ZIGINSTALLDIR%" "-DCMAKE_PREFIX_PATH=%ZIGPREFIXPATH%" -DCMAKE_BUILD_TYPE=Release -DZIG_OMIT_STAGE2=ON || exit /b -msbuild /maxcpucount /p:Configuration=Release INSTALL.vcxproj || exit /b - -REM Sadly, stage2 is omitted from this build to save memory on the CI server. Once self-hosted is -REM built with itself and does not gobble as much memory, we can enable these tests. -REM "%ZIGINSTALLDIR%\bin\zig.exe" test "..\test\behavior.zig" -fno-stage1 -fLLVM -I "..\test" || exit /b - -"%ZIGINSTALLDIR%\bin\zig.exe" build test-toolchain -Dskip-non-native -Dskip-stage2-tests || exit /b -"%ZIGINSTALLDIR%\bin\zig.exe" build test-std -Dskip-non-native || exit /b -"%ZIGINSTALLDIR%\bin\zig.exe" build docs || exit /b - -set "PATH=%CD:~0,2%\msys64\usr\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem" -SET "MSYSTEM=MINGW64" -bash -lc "cd ${SRCROOT} && ci/azure/windows_upload" || exit /b diff --git a/ci/azure/windows_upload b/ci/azure/windows_upload deleted file mode 100755 index 9c5e07e5f9..0000000000 --- a/ci/azure/windows_upload +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/sh - -set -x -set -e - -if [ "${BUILD_REASON}" != "PullRequest" ]; then - cd "$ZIGBUILDDIR" - - mv ../LICENSE dist/ - mv ../zig-cache/langref.html dist/ - mv dist/bin/zig.exe dist/ - rmdir dist/bin - - # Remove the unnecessary zig dir in $prefix/lib/zig/std/std.zig - mv dist/lib/zig dist/lib2 - rmdir dist/lib - mv dist/lib2 dist/lib - - VERSION=$(dist/zig.exe version) - DIRNAME="zig-windows-x86_64-$VERSION" - TARBALL="$DIRNAME.zip" - mv dist "$DIRNAME" - 7z a "$TARBALL" "$DIRNAME" - - # mv "$DOWNLOADSECUREFILE_SECUREFILEPATH" "$HOME/.s3cfg" - s3cmd -c "$DOWNLOADSECUREFILE_SECUREFILEPATH" put -P --add-header="cache-control: public, max-age=31536000, immutable" "$TARBALL" s3://ziglang.org/builds/ - - SHASUM=$(sha256sum $TARBALL | cut '-d ' -f1) - BYTESIZE=$(wc -c < $TARBALL) - - JSONFILE="windows-$GITBRANCH.json" - touch $JSONFILE - echo "{\"tarball\": \"$TARBALL\"," >>$JSONFILE - echo "\"shasum\": \"$SHASUM\"," >>$JSONFILE - echo "\"size\": \"$BYTESIZE\"}" >>$JSONFILE - - s3cmd -c "$DOWNLOADSECUREFILE_SECUREFILEPATH" put -P --add-header="Cache-Control: max-age=0, must-revalidate" "$JSONFILE" "s3://ziglang.org/builds/$JSONFILE" - s3cmd -c "$DOWNLOADSECUREFILE_SECUREFILEPATH" put -P "$JSONFILE" "s3://ziglang.org/builds/x86_64-windows-$VERSION.json" - - # `set -x` causes these variables to be mangled. - # See https://developercommunity.visualstudio.com/content/problem/375679/pipeline-variable-incorrectly-inserts-single-quote.html - set +x - echo "##vso[task.setvariable variable=tarball;isOutput=true]$TARBALL" - echo "##vso[task.setvariable variable=shasum;isOutput=true]$SHASUM" - echo "##vso[task.setvariable variable=bytesize;isOutput=true]$BYTESIZE" -fi diff --git a/ci/drone/linux_script_test b/ci/drone/linux_script_test index 14f6fd85df..b748745da9 100755 --- a/ci/drone/linux_script_test +++ b/ci/drone/linux_script_test @@ -17,29 +17,28 @@ case "$1" in ;; 3) # ReleaseSafe - ./build/zig build $BUILD_FLAGS test-std -Dskip-debug -Dskip-release-fast -Dskip-release-small + ./build/zig build $BUILD_FLAGS test-std -Dskip-debug -Dskip-release-fast -Dskip-release-small -Dskip-non-native -Dskip-single-threaded ;; 4) - # Releasefast - ./build/zig build $BUILD_FLAGS test-std -Dskip-debug -Dskip-release-safe -Dskip-release-small + # ReleaseFast + ./build/zig build $BUILD_FLAGS test-std -Dskip-debug -Dskip-release-safe -Dskip-release-small -Dskip-non-native -Dskip-single-threaded ;; 5) # ReleaseSmall ./build/zig build $BUILD_FLAGS test-std -Dskip-debug -Dskip-release-safe -Dskip-release-fast ;; 6) - ./build/zig build $BUILD_FLAGS test-minilibc + ./build/zig build $BUILD_FLAGS test-universal-libc ./build/zig build $BUILD_FLAGS test-compare-output ./build/zig build $BUILD_FLAGS test-standalone -Dskip-release-safe ./build/zig build $BUILD_FLAGS test-stack-traces ./build/zig build $BUILD_FLAGS test-cli ./build/zig build $BUILD_FLAGS test-asm-link - ./build/zig build $BUILD_FLAGS test-runtime-safety ./build/zig build $BUILD_FLAGS test-translate-c ;; 7) ./build/zig build $BUILD_FLAGS # test building self-hosted without LLVM - ./build/zig build $BUILD_FLAGS test-stage2 + ./build/zig build $BUILD_FLAGS test-cases ;; '') echo "error: expecting test group argument" diff --git a/ci/srht/freebsd_script b/ci/srht/freebsd_script index a2b8d4afea..3a10cccadf 100755 --- a/ci/srht/freebsd_script +++ b/ci/srht/freebsd_script @@ -4,10 +4,10 @@ set -x set -e sudo pkg update -fq -sudo pkg install -y cmake py38-s3cmd wget curl jq samurai +sudo pkg install -y cmake py39-s3cmd wget curl jq samurai ZIGDIR="$(pwd)" -CACHE_BASENAME="zig+llvm+lld+clang-x86_64-freebsd-gnu-0.9.0-dev.1243+456d7e5f5" +CACHE_BASENAME="zig+llvm+lld+clang-x86_64-freebsd-gnu-0.9.1" PREFIX="$HOME/$CACHE_BASENAME" cd $HOME @@ -44,7 +44,7 @@ samu install #release/bin/zig test ../test/behavior.zig -fno-stage1 -fLLVM -I ../test # Here we skip some tests to save time. -release/bin/zig build test -Dskip-compile-errors -Dskip-non-native +release/bin/zig build test -Dskip-stage1 -Dskip-non-native if [ -f ~/.s3cfg ]; then mv ../LICENSE release/ diff --git a/ci/srht/index.json b/ci/srht/index.json index 98e8f4035b..aa0533af39 100644 --- a/ci/srht/index.json +++ b/ci/srht/index.json @@ -40,6 +40,77 @@ "size": "{{AARCH64_LINUX_BYTESIZE}}" } }, + "0.9.1": { + "date": "2022-02-14", + "docs": "https://ziglang.org/documentation/0.9.1/", + "stdDocs": "https://ziglang.org/documentation/0.9.1/std/", + "notes": "https://ziglang.org/download/0.9.1/release-notes.html", + "src": { + "tarball": "https://ziglang.org/download/0.9.1/zig-0.9.1.tar.xz", + "shasum": "38cf4e84481f5facc766ba72783e7462e08d6d29a5d47e3b75c8ee3142485210", + "size": "13940828" + }, + "bootstrap": { + "tarball": "https://ziglang.org/download/0.9.1/zig-bootstrap-0.9.1.tar.xz", + "shasum": "0a8e221c71860d8975c15662b3ed3bd863e81c4fe383455a596e5e0e490d6109", + "size": "42488812" + }, + "x86_64-freebsd": { + "tarball": "https://ziglang.org/download/0.9.1/zig-freebsd-x86_64-0.9.1.tar.xz", + "shasum": "4e06009bd3ede34b72757eec1b5b291b30aa0d5046dadd16ecb6b34a02411254", + "size": "39028848" + }, + "aarch64-linux": { + "tarball": "https://ziglang.org/download/0.9.1/zig-linux-aarch64-0.9.1.tar.xz", + "shasum": "5d99a39cded1870a3fa95d4de4ce68ac2610cca440336cfd252ffdddc2b90e66", + "size": "37034860" + }, + "armv7a-linux": { + "tarball": "https://ziglang.org/download/0.9.1/zig-linux-armv7a-0.9.1.tar.xz", + "shasum": "6de64456cb4757a555816611ea697f86fba7681d8da3e1863fa726a417de49be", + "size": "37974652" + }, + "i386-linux": { + "tarball": "https://ziglang.org/download/0.9.1/zig-linux-i386-0.9.1.tar.xz", + "shasum": "e776844fecd2e62fc40d94718891057a1dbca1816ff6013369e9a38c874374ca", + "size": "44969172" + }, + "riscv64-linux": { + "tarball": "https://ziglang.org/download/0.9.1/zig-linux-riscv64-0.9.1.tar.xz", + "shasum": "208dea53662c2c52777bd9e3076115d2126a4f71aed7f2ff3b8fe224dc3881aa", + "size": "39390868" + }, + "x86_64-linux": { + "tarball": "https://ziglang.org/download/0.9.1/zig-linux-x86_64-0.9.1.tar.xz", + "shasum": "be8da632c1d3273f766b69244d80669fe4f5e27798654681d77c992f17c237d7", + "size": "41011464" + }, + "aarch64-macos": { + "tarball": "https://ziglang.org/download/0.9.1/zig-macos-aarch64-0.9.1.tar.xz", + "shasum": "8c473082b4f0f819f1da05de2dbd0c1e891dff7d85d2c12b6ee876887d438287", + "size": "38995640" + }, + "x86_64-macos": { + "tarball": "https://ziglang.org/download/0.9.1/zig-macos-x86_64-0.9.1.tar.xz", + "shasum": "2d94984972d67292b55c1eb1c00de46580e9916575d083003546e9a01166754c", + "size": "43713044" + }, + "i386-windows": { + "tarball": "https://ziglang.org/download/0.9.1/zig-windows-i386-0.9.1.zip", + "shasum": "74a640ed459914b96bcc572183a8db687bed0af08c30d2ea2f8eba03ae930f69", + "size": "67929868" + }, + "x86_64-windows": { + "tarball": "https://ziglang.org/download/0.9.1/zig-windows-x86_64-0.9.1.zip", + "shasum": "443da53387d6ae8ba6bac4b3b90e9fef4ecbe545e1c5fa3a89485c36f5c0e3a2", + "size": "65047697" + }, + "aarch64-windows": { + "tarball": "https://ziglang.org/download/0.9.1/zig-windows-aarch64-0.9.1.zip", + "shasum": "621bf95f54dc3ff71466c5faae67479419951d7489e40e87fd26d195825fb842", + "size": "61478151" + } + }, "0.9.0": { "date": "2021-12-20", "docs": "https://ziglang.org/documentation/0.9.0/", diff --git a/ci/srht/netbsd_script b/ci/srht/netbsd_script index f2d2f09467..5f5b28e92f 100755 --- a/ci/srht/netbsd_script +++ b/ci/srht/netbsd_script @@ -57,7 +57,7 @@ unset CXX #release/bin/zig test ../test/behavior.zig -fno-stage1 -fLLVM -I ../test # Here we skip some tests to save time. -release/bin/zig build test -Dskip-compile-errors -Dskip-non-native +release/bin/zig build test -Dskip-stage1 -Dskip-non-native if [ -f ~/.s3cfg ]; then mv ../LICENSE release/ diff --git a/ci/zinc/drone.yml b/ci/zinc/drone.yml index e845cd350e..cb105381ae 100644 --- a/ci/zinc/drone.yml +++ b/ci/zinc/drone.yml @@ -9,20 +9,8 @@ workspace: path: /workspace steps: -- name: probe - image: ci/debian-amd64:11.1-2 - commands: - - ./ci/zinc/linux_probe.sh - -- name: build - image: ci/debian-amd64:11.1-2 - commands: - - ./ci/zinc/linux_build.sh - - name: test - depends_on: - - build - image: ci/debian-amd64:11.1-2 + image: ci/debian-amd64:11.1-3 commands: - ./ci/zinc/linux_test.sh @@ -34,7 +22,7 @@ steps: - master event: - push - image: ci/debian-amd64:11.1-2 + image: ci/debian-amd64:11.1-3 environment: AWS_ACCESS_KEY_ID: from_secret: AWS_ACCESS_KEY_ID diff --git a/ci/zinc/linux_base.sh b/ci/zinc/linux_base.sh index 5d33e19e67..f1e9924258 100755 --- a/ci/zinc/linux_base.sh +++ b/ci/zinc/linux_base.sh @@ -17,7 +17,6 @@ set -x set -e ARCH="$(uname -m)" -JOBS="-j$(nproc)" DEPS_LOCAL="/deps/local" WORKSPACE="$DRONE_WORKSPACE" diff --git a/ci/zinc/linux_build.sh b/ci/zinc/linux_build.sh deleted file mode 100755 index 1d468bbd25..0000000000 --- a/ci/zinc/linux_build.sh +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/sh - -. ./ci/zinc/linux_base.sh - -ZIG="$DEPS_LOCAL/bin/zig" -TARGET="${ARCH}-linux-musl" -MCPU="baseline" - -# Make the `zig version` number consistent. -# This will affect the cmake command below. -git config core.abbrev 9 - -# Build debug zig. -echo "BUILD debug zig with zig:$($ZIG version)" - -export CC="$ZIG cc -target $TARGET -mcpu=$MCPU" -export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU" - -mkdir _debug -cd _debug -cmake .. \ - -DCMAKE_INSTALL_PREFIX="$DEBUG_STAGING" \ - -DCMAKE_PREFIX_PATH="$DEPS_LOCAL" \ - -DCMAKE_BUILD_TYPE=Debug \ - -DZIG_TARGET_TRIPLE="$TARGET" \ - -DZIG_TARGET_MCPU="$MCPU" \ - -DZIG_STATIC=ON \ - -GNinja - -# Now cmake will use zig as the C/C++ compiler. We reset the environment variables -# so that installation and testing do not get affected by them. -unset CC -unset CXX - -ninja $JOBS install - -ZIG=$DEBUG_STAGING/bin/zig - -# Here we rebuild zig but this time using the Zig binary we just now produced to -# build zig1.o rather than relying on the one built with stage0. See -# https://github.com/ziglang/zig/issues/6830 for more details. -cmake .. -DZIG_EXECUTABLE="$ZIG" -ninja $JOBS install - -cd $WORKSPACE - -# Build release zig. -echo "BUILD release zig with zig:$($ZIG version)" -export CC="$ZIG cc -target $TARGET -mcpu=$MCPU" -export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU" -mkdir _release -cd _release -cmake .. \ - -DCMAKE_INSTALL_PREFIX="$RELEASE_STAGING" \ - -DCMAKE_PREFIX_PATH="$DEPS_LOCAL" \ - -DCMAKE_BUILD_TYPE=Release \ - -DZIG_TARGET_TRIPLE="$TARGET" \ - -DZIG_TARGET_MCPU="$MCPU" \ - -DZIG_STATIC=ON \ - -GNinja -unset CC -unset CXX -ninja $JOBS install - -cd $WORKSPACE - -# Look for non-conforming code formatting. -# Formatting errors can be fixed by running `zig fmt` on the files printed here. -$ZIG fmt --check . - -# Explicit exit helps show last command duration. -exit diff --git a/ci/zinc/linux_probe.sh b/ci/zinc/linux_probe.sh deleted file mode 100755 index 7c7d6c52fe..0000000000 --- a/ci/zinc/linux_probe.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -. ./ci/zinc/linux_base.sh - -# Probe CPU/brand details. -echo "lscpu:" -(lscpu | sed 's,^, : ,') 1>&2 - -# Explicit exit helps show last command duration. -exit diff --git a/ci/zinc/linux_test.sh b/ci/zinc/linux_test.sh index d9f42e6876..0bb176d4ad 100755 --- a/ci/zinc/linux_test.sh +++ b/ci/zinc/linux_test.sh @@ -2,34 +2,82 @@ . ./ci/zinc/linux_base.sh -ZIG=$DEBUG_STAGING/bin/zig +ZIG="$DEPS_LOCAL/bin/zig" +TARGET="${ARCH}-linux-musl" +MCPU="baseline" -$ZIG test test/behavior.zig -fno-stage1 -I test -fLLVM -$ZIG test test/behavior.zig -fno-stage1 -I test -ofmt=c -$ZIG test test/behavior.zig -fno-stage1 -I test -target wasm32-wasi --test-cmd wasmtime --test-cmd-bin -$ZIG test test/behavior.zig -fno-stage1 -I test -target arm-linux --test-cmd qemu-arm --test-cmd-bin -$ZIG test test/behavior.zig -fno-stage1 -I test +# Make the `zig version` number consistent. +# This will affect the cmake command below. +git config core.abbrev 9 -$ZIG build test-behavior -fqemu -fwasmtime +echo "BUILD debug zig with zig:$($ZIG version)" + +export CC="$ZIG cc -target $TARGET -mcpu=$MCPU" +export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU" + +mkdir _debug +cd _debug +cmake .. \ + -DCMAKE_INSTALL_PREFIX="$DEBUG_STAGING" \ + -DCMAKE_PREFIX_PATH="$DEPS_LOCAL" \ + -DCMAKE_BUILD_TYPE=Debug \ + -DZIG_TARGET_TRIPLE="$TARGET" \ + -DZIG_TARGET_MCPU="$MCPU" \ + -DZIG_STATIC=ON \ + -GNinja + +# Now cmake will use zig as the C/C++ compiler. We reset the environment variables +# so that installation and testing do not get affected by them. +unset CC +unset CXX + +ninja install + +ZIG="$DEBUG_STAGING/bin/zig" + +# Here we rebuild zig but this time using the Zig binary we just now produced to +# build zig1.o rather than relying on the one built with stage0. See +# https://github.com/ziglang/zig/issues/6830 for more details. +cmake .. -DZIG_EXECUTABLE="$ZIG" +ninja install + +cd $WORKSPACE + +# Look for non-conforming code formatting. +# Formatting errors can be fixed by running `zig fmt` on the files printed here. +$ZIG fmt --check . --exclude test/cases/ + +# Build stage2 standalone so that we can test stage2 against stage2 compiler-rt. +$ZIG build -p stage2 -Dstatic-llvm -Dtarget=native-native-musl --search-prefix "$DEPS_LOCAL" + +# Ensure that stage2 can build itself. +stage2/bin/zig build -p stage3 -Dstatic-llvm -Dtarget=native-native-musl --search-prefix "$DEPS_LOCAL" +stage2/bin/zig build # test building self-hosted without LLVM +stage2/bin/zig build -Dtarget=arm-linux-musleabihf # test building self-hosted for 32-bit arm + +# Here we use stage2 instead of stage3 because of two bugs remaining: +# * https://github.com/ziglang/zig/issues/11367 (and corresponding workaround in compiler source) +# * https://github.com/ziglang/zig/pull/11492#issuecomment-1112871321 +stage2/bin/zig build test-behavior -fqemu -fwasmtime +stage2/bin/zig test lib/std/std.zig --zig-lib-dir lib + +$ZIG build test-behavior -fqemu -fwasmtime -Domit-stage2 $ZIG build test-compiler-rt -fqemu -fwasmtime $ZIG build test-std -fqemu -fwasmtime -$ZIG build test-minilibc -fqemu -fwasmtime +$ZIG build test-universal-libc -fqemu -fwasmtime $ZIG build test-compare-output -fqemu -fwasmtime $ZIG build test-standalone -fqemu -fwasmtime $ZIG build test-stack-traces -fqemu -fwasmtime $ZIG build test-cli -fqemu -fwasmtime $ZIG build test-asm-link -fqemu -fwasmtime -$ZIG build test-runtime-safety -fqemu -fwasmtime $ZIG build test-translate-c -fqemu -fwasmtime $ZIG build test-run-translated-c -fqemu -fwasmtime $ZIG build docs -fqemu -fwasmtime -$ZIG build # test building self-hosted without LLVM -$ZIG build -Dtarget=arm-linux-musleabihf # test building self-hosted for 32-bit arm $ZIG build test-fmt -fqemu -fwasmtime -$ZIG build test-stage2 -fqemu -fwasmtime +$ZIG build test-cases -fqemu -fwasmtime # Produce the experimental std lib documentation. -mkdir -p $RELEASE_STAGING/docs/std +mkdir -p "$RELEASE_STAGING/docs/std" $ZIG test lib/std/std.zig \ --zig-lib-dir lib \ -femit-docs=$RELEASE_STAGING/docs/std \ @@ -38,5 +86,15 @@ $ZIG test lib/std/std.zig \ # Look for HTML errors. tidy --drop-empty-elements no -qe zig-cache/langref.html +# Build release zig. +$ZIG build \ + --prefix "$RELEASE_STAGING" \ + --search-prefix "$DEPS_LOCAL" \ + -Dstatic-llvm \ + -Drelease \ + -Dstrip \ + -Dtarget="$TARGET" \ + -Dstage1 + # Explicit exit helps show last command duration. exit diff --git a/cmake/Findlld.cmake b/cmake/Findlld.cmake index 943248da57..ea57b0f8c0 100644 --- a/cmake/Findlld.cmake +++ b/cmake/Findlld.cmake @@ -49,6 +49,7 @@ else() FIND_AND_ADD_LLD_LIB(lldELF) FIND_AND_ADD_LLD_LIB(lldCOFF) FIND_AND_ADD_LLD_LIB(lldWasm) + FIND_AND_ADD_LLD_LIB(lldMachO) FIND_AND_ADD_LLD_LIB(lldReaderWriter) FIND_AND_ADD_LLD_LIB(lldCore) FIND_AND_ADD_LLD_LIB(lldYAML) diff --git a/cmake/Findllvm.cmake b/cmake/Findllvm.cmake index feb1017e72..39ab79f514 100644 --- a/cmake/Findllvm.cmake +++ b/cmake/Findllvm.cmake @@ -12,6 +12,7 @@ find_path(LLVM_INCLUDE_DIRS NAMES llvm/IR/IRBuilder.h /usr/lib/llvm/14/include /usr/lib/llvm-14/include /usr/lib/llvm-14.0/include + /usr/lib/llvm14/include /usr/local/llvm14/include /usr/local/llvm140/include /usr/local/opt/llvm@14/include @@ -31,6 +32,7 @@ if(ZIG_PREFER_CLANG_CPP_DYLIB) /usr/lib/llvm/14/lib /usr/lib/llvm/14/lib64 /usr/lib/llvm-14/lib + /usr/lib/llvm14/lib /usr/local/llvm14/lib /usr/local/llvm140/lib /usr/local/opt/llvm@14/lib @@ -181,19 +183,7 @@ else() macro(FIND_AND_ADD_LLVM_LIB _libname_) string(TOUPPER ${_libname_} _prettylibname_) - find_library(LLVM_${_prettylibname_}_LIB NAMES ${_libname_} - PATHS - ${LLVM_LIBDIRS} - /usr/lib/llvm/14/lib - /usr/lib/llvm-14/lib - /usr/lib/llvm-14.0/lib - /usr/local/llvm140/lib - /usr/local/llvm14/lib - /usr/local/opt/llvm@14/lib - /opt/homebrew/opt/llvm@14/lib - /mingw64/lib - /c/msys64/mingw64/lib - c:\\msys64\\mingw64\\lib) + find_library(LLVM_${_prettylibname_}_LIB NAMES ${_libname_} PATHS ${LLVM_LIBDIRS}) set(LLVM_LIBRARIES ${LLVM_LIBRARIES} ${LLVM_${_prettylibname_}_LIB}) endmacro(FIND_AND_ADD_LLVM_LIB) diff --git a/deps/SoftFloat-3e-prebuilt/platform.h b/deps/SoftFloat-3e-prebuilt/platform.h index ef99e21b97..588c548c60 100644 --- a/deps/SoftFloat-3e-prebuilt/platform.h +++ b/deps/SoftFloat-3e-prebuilt/platform.h @@ -17,8 +17,6 @@ #define BIGENDIAN 1 #elif defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ #define BIGENDIAN 1 -#elif defined(_BIG_ENDIAN) -#define BIGENDIAN 1 #elif defined(__sparc) #define BIGENDIAN 1 #elif defined(__sparc__) @@ -37,7 +35,9 @@ #define BIGENDIAN 1 #elif defined(__s390__) #define BIGENDIAN 1 -#elif defined(__LITTLE_ENDIAN__) +#endif + +#if defined(__LITTLE_ENDIAN__) #define LITTLEENDIAN 1 #elif defined(__ARMEL__) #define LITTLEENDIAN 1 @@ -53,8 +53,6 @@ #define LITTLEENDIAN 1 #elif defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ #define LITTLEENDIAN 1 -#elif defined(_LITTLE_ENDIAN) -#define LITTLEENDIAN 1 #elif defined(__i386__) #define LITTLEENDIAN 1 #elif defined(__alpha__) @@ -83,7 +81,11 @@ #define LITTLEENDIAN 1 #elif defined(__bfin__) #define LITTLEENDIAN 1 -#else +#endif + +#if defined(LITTLEENDIAN) && defined(BIGENDIAN) +#error unable to detect endianness +#elif !defined(LITTLEENDIAN) && !defined(BIGENDIAN) #error unable to detect endianness #endif diff --git a/deps/SoftFloat-3e/source/include/primitiveTypes.h b/deps/SoftFloat-3e/source/include/primitiveTypes.h index a4a6dd11c6..4407f5e7cb 100644 --- a/deps/SoftFloat-3e/source/include/primitiveTypes.h +++ b/deps/SoftFloat-3e/source/include/primitiveTypes.h @@ -37,6 +37,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef primitiveTypes_h #define primitiveTypes_h 1 +#include "platform.h" #include #ifdef SOFTFLOAT_FAST_INT64 diff --git a/deps/SoftFloat-3e/source/include/softfloat_types.h b/deps/SoftFloat-3e/source/include/softfloat_types.h index bc30e31440..27507741af 100644 --- a/deps/SoftFloat-3e/source/include/softfloat_types.h +++ b/deps/SoftFloat-3e/source/include/softfloat_types.h @@ -37,6 +37,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef softfloat_types_h #define softfloat_types_h 1 +#include "platform.h" #include /*---------------------------------------------------------------------------- diff --git a/doc/docgen.zig b/doc/docgen.zig index 760ebb71d3..a101b96be7 100644 --- a/doc/docgen.zig +++ b/doc/docgen.zig @@ -1196,7 +1196,7 @@ fn genHtml( do_code_tests: bool, ) !void { var progress = Progress{}; - const root_node = try progress.start("Generating docgen examples", toc.nodes.len); + const root_node = progress.start("Generating docgen examples", toc.nodes.len); defer root_node.end(); var env_map = try process.getEnvMap(allocator); @@ -1708,7 +1708,7 @@ fn genHtml( } } -fn exec(allocator: Allocator, env_map: *std.BufMap, args: []const []const u8) !ChildProcess.ExecResult { +fn exec(allocator: Allocator, env_map: *process.EnvMap, args: []const []const u8) !ChildProcess.ExecResult { const result = try ChildProcess.exec(.{ .allocator = allocator, .argv = args, @@ -1732,7 +1732,7 @@ fn exec(allocator: Allocator, env_map: *std.BufMap, args: []const []const u8) !C return result; } -fn getBuiltinCode(allocator: Allocator, env_map: *std.BufMap, zig_exe: []const u8) ![]const u8 { +fn getBuiltinCode(allocator: Allocator, env_map: *process.EnvMap, zig_exe: []const u8) ![]const u8 { const result = try exec(allocator, env_map, &[_][]const u8{ zig_exe, "build-obj", "--show-builtin" }); return result.stdout; } diff --git a/doc/langref.html.in b/doc/langref.html.in index 955d17f253..9170cf5b62 100644 --- a/doc/langref.html.in +++ b/doc/langref.html.in @@ -52,255 +52,255 @@ #contents-wrapper { margin-left: calc(var(--nav-width) + var(--nav-margin-l)); } - } - - a:hover,a:focus { - background: #fff2a8; - } - dt { - font-weight: bold; - } - table, th, td { - border-collapse: collapse; - border: 1px solid grey; - } - th, td { - padding: 0.1em; - } - th[scope=row] { - text-align: left; - font-weight: normal; - } - .t0_1, .t37, .t37_1 { - font-weight: bold; - } - .t2_0 { - color: #575757; - } - .t31_1 { - color: #b40000; - } - .t32_1 { - color: green; - } - .t36_1 { - color: #005C7A; - } - .file { - font-weight: bold; - border: unset; - } - code { - background: #f8f8f8; - border: 1px dotted silver; - padding-left: 0.3em; - padding-right: 0.3em; - } - pre > code { - display: block; - overflow: auto; - padding: 0.5em; - border: 1px solid #eee; - line-height: normal; - } - samp { - background: #fafafa; - } - pre > samp { - display: block; - overflow: auto; - padding: 0.5em; - border: 1px solid #eee; - line-height: normal; - } - kbd { - font-weight: bold; - } - .table-wrapper { - width: 100%; - overflow-x: auto; - } - - .tok-kw { - color: #333; - font-weight: bold; - } - .tok-str { - color: #d14; - } - .tok-builtin { - color: #005C7A; - } - .tok-comment { - color: #545454; - font-style: italic; - } - .tok-fn { - color: #900; - font-weight: bold; - } - .tok-null { - color: #005C5C; - } - .tok-number { - color: #005C5C; - } - .tok-type { - color: #458; - font-weight: bold; - } - - figure { - margin: auto 0; - } - figure pre { - margin-top: 0; - } - - figcaption { - padding-left: 0.5em; - font-size: small; - border-top-left-radius: 5px; - border-top-right-radius: 5px; - } - figcaption.zig-cap { - background: #fcdba5; - } - figcaption.c-cap { - background: #a8b9cc; - color: #000; - } - figcaption.peg-cap { - background: #fcdba5; - } - figcaption.javascript-cap { - background: #365d95; - color: #fff; - } - figcaption.shell-cap { - background: #ccc; - color: #000; - } - - aside { - border-left: 0.25em solid #f7a41d; - padding: 0 1em 0 1em; - } - - h1 a, h2 a, h3 a, h4 a, h5 a { - text-decoration: none; - color: #333; - } - - a.hdr { - visibility: hidden; - } - h1:hover > a.hdr, h2:hover > a.hdr, h3:hover > a.hdr, h4:hover > a.hdr, h5:hover > a.hdr { - visibility: visible; - } - - pre { - counter-reset: line; - } - pre .line:before { - counter-increment: line; - content: counter(line); - display: inline-block; - padding-right: 1em; - width: 2em; - text-align: right; - color: #999; - } - th pre code { - background: none; - } - th .line:before { - display: none; - } - - @media (prefers-color-scheme: dark) { - body{ - background:#121212; - color: #ccc; - } - a { - color: #88f; } + a:hover,a:focus { - color: #000; + background: #fff2a8; + } + dt { + font-weight: bold; } table, th, td { - border-color: grey; + border-collapse: collapse; + border: 1px solid grey; + } + th, td { + padding: 0.1em; + } + th[scope=row] { + text-align: left; + font-weight: normal; + } + .t0_1, .t37, .t37_1 { + font-weight: bold; } .t2_0 { - color: grey; + color: #575757; } .t31_1 { - color: red; + color: #b40000; } .t32_1 { - color: #00B800; + color: green; } .t36_1 { - color: #0086b3; + color: #005C7A; } - code { - background: #222; - border-color: #444; - } - pre > code { - color: #ccc; - background: #222; - border: unset; - } - samp { - background: #000; - color: #ccc; - } - pre > samp { + .file { + font-weight: bold; border: unset; } + code { + background: #f8f8f8; + border: 1px dotted silver; + padding-left: 0.3em; + padding-right: 0.3em; + } + pre > code { + display: block; + overflow: auto; + padding: 0.5em; + border: 1px solid #eee; + line-height: normal; + } + samp { + background: #fafafa; + } + pre > samp { + display: block; + overflow: auto; + padding: 0.5em; + border: 1px solid #eee; + line-height: normal; + } + kbd { + font-weight: bold; + } + .table-wrapper { + width: 100%; + overflow-x: auto; + } + .tok-kw { - color: #eee; + color: #333; + font-weight: bold; } .tok-str { - color: #2e5; + color: #d14; } .tok-builtin { - color: #ff894c; + color: #005C7A; } .tok-comment { - color: #aa7; + color: #545454; + font-style: italic; } .tok-fn { - color: #B1A0F8; + color: #900; + font-weight: bold; } .tok-null { - color: #ff8080; + color: #005C5C; } .tok-number { - color: #ff8080; + color: #005C5C; } .tok-type { - color: #68f; + color: #458; + font-weight: bold; } - h1 a, h2 a, h3 a, h4 a, h5 a { - color: #aaa; + + figure { + margin: auto 0; + } + figure pre { + margin-top: 0; + } + + figcaption { + padding-left: 0.5em; + font-size: small; + border-top-left-radius: 5px; + border-top-right-radius: 5px; } figcaption.zig-cap { - background-color: #b27306; - color: #000; + background: #fcdba5; + } + figcaption.c-cap { + background: #a8b9cc; + color: #000; } figcaption.peg-cap { - background-color: #b27306; - color: #000; + background: #fcdba5; } - figcaption.shell-cap { - background: #2a2a2a; + figcaption.javascript-cap { + background: #365d95; color: #fff; } - } - + figcaption.shell-cap { + background: #ccc; + color: #000; + } + + aside { + border-left: 0.25em solid #f7a41d; + padding: 0 1em 0 1em; + } + + h1 a, h2 a, h3 a, h4 a, h5 a { + text-decoration: none; + color: #333; + } + + a.hdr { + visibility: hidden; + } + h1:hover > a.hdr, h2:hover > a.hdr, h3:hover > a.hdr, h4:hover > a.hdr, h5:hover > a.hdr { + visibility: visible; + } + + pre { + counter-reset: line; + } + pre .line:before { + counter-increment: line; + content: counter(line); + display: inline-block; + padding-right: 1em; + width: 2em; + text-align: right; + color: #999; + } + th pre code { + background: none; + } + th .line:before { + display: none; + } + + @media (prefers-color-scheme: dark) { + body{ + background:#121212; + color: #ccc; + } + a { + color: #88f; + } + a:hover,a:focus { + color: #000; + } + table, th, td { + border-color: grey; + } + .t2_0 { + color: grey; + } + .t31_1 { + color: red; + } + .t32_1 { + color: #00B800; + } + .t36_1 { + color: #0086b3; + } + code { + background: #222; + border-color: #444; + } + pre > code { + color: #ccc; + background: #222; + border: unset; + } + samp { + background: #000; + color: #ccc; + } + pre > samp { + border: unset; + } + .tok-kw { + color: #eee; + } + .tok-str { + color: #2e5; + } + .tok-builtin { + color: #ff894c; + } + .tok-comment { + color: #aa7; + } + .tok-fn { + color: #B1A0F8; + } + .tok-null { + color: #ff8080; + } + .tok-number { + color: #ff8080; + } + .tok-type { + color: #68f; + } + h1 a, h2 a, h3 a, h4 a, h5 a { + color: #aaa; + } + figcaption.zig-cap { + background-color: #b27306; + color: #000; + } + figcaption.peg-cap { + background-color: #b27306; + color: #000; + } + figcaption.shell-cap { + background: #2a2a2a; + color: #fff; + } + } +

Zig Language Reference

@@ -316,7 +316,7 @@ 0.6.0 | 0.7.1 | 0.8.1 | - 0.9.0 | + 0.9.1 | master