Compare commits
95 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6d44a6222d | ||
|
|
be097cdba8 | ||
|
|
9f6b9850ac | ||
|
|
f9af406341 | ||
|
|
8bf14231b2 | ||
|
|
d2398cf009 | ||
|
|
0d006afb23 | ||
|
|
bf6af1963c | ||
|
|
45d4e2f816 | ||
|
|
46c3d9c571 | ||
|
|
c4458e1b45 | ||
|
|
fbde43524f | ||
|
|
8e10c80c5f | ||
|
|
a8bd36c3d2 | ||
|
|
2e95bb0e29 | ||
|
|
3c40cf1693 | ||
|
|
5cfc22bd36 | ||
|
|
a418c59546 | ||
|
|
a0cd4c0f32 | ||
|
|
d107ef8697 | ||
|
|
cee0f082df | ||
|
|
23d148e5c7 | ||
|
|
eace6906ce | ||
|
|
ac3ac255a2 | ||
|
|
69f46cab55 | ||
|
|
452c35656e | ||
|
|
a24f4d8da4 | ||
|
|
5762b6d218 | ||
|
|
8b5e4af78e | ||
|
|
aad6ef1fc3 | ||
|
|
b54f6186ac | ||
|
|
e2f36c292e | ||
|
|
e9d916571a | ||
|
|
021c1190af | ||
|
|
45cd1114f7 | ||
|
|
d7feeaaa2c | ||
|
|
2b29424efd | ||
|
|
8f89056dc2 | ||
|
|
e8c4fec1b2 | ||
|
|
ac3d9759ed | ||
|
|
922d33e5b9 | ||
|
|
936294e32a | ||
|
|
7e61bdbaa4 | ||
|
|
340bb8198f | ||
|
|
e37c55bae0 | ||
|
|
93545fe74f | ||
|
|
8ed432fe3c | ||
|
|
148b963a60 | ||
|
|
b713ce0249 | ||
|
|
4d5a598599 | ||
|
|
aa8112c847 | ||
|
|
3d52a322ab | ||
|
|
af844d865f | ||
|
|
252fb642d5 | ||
|
|
dcbab17b62 | ||
|
|
881e507ac5 | ||
|
|
18fabd99cc | ||
|
|
afd1f7ed47 | ||
|
|
2ac7aefe2f | ||
|
|
bb9399cc5d | ||
|
|
bc90a2a083 | ||
|
|
1e6de105c8 | ||
|
|
385b7e4808 | ||
|
|
57d7ad9172 | ||
|
|
e67e15a29a | ||
|
|
06ae13fe35 | ||
|
|
dafbc6eb25 | ||
|
|
6f49233ac6 | ||
|
|
bb8eef8d24 | ||
|
|
511990c83b | ||
|
|
9fa55ae777 | ||
|
|
53e41682ba | ||
|
|
3542dcad33 | ||
|
|
9b97edb012 | ||
|
|
1c61038255 | ||
|
|
73cbc13a97 | ||
|
|
adf7c654d4 | ||
|
|
2304dbaba4 | ||
|
|
675590cd44 | ||
|
|
4d38f456ea | ||
|
|
8771ef897a | ||
|
|
1676729c66 | ||
|
|
eee395287f | ||
|
|
419499b252 | ||
|
|
47e3deeeaa | ||
|
|
c4b4192d20 | ||
|
|
64a2b14f26 | ||
|
|
9a0010b186 | ||
|
|
b86aadfa38 | ||
|
|
4d9377923d | ||
|
|
cfc00e743e | ||
|
|
f5cb3fc688 | ||
|
|
acdb859644 | ||
|
|
20f073dcdd | ||
|
|
69e2b712bc |
8
.builds/freebsd.yml
Normal file
8
.builds/freebsd.yml
Normal file
@@ -0,0 +1,8 @@
|
||||
image: freebsd/latest
|
||||
secrets:
|
||||
- 51bfddf5-86a6-4e01-8576-358c72a4a0a4
|
||||
- 512ed797-0927-475a-83fd-bc997792860c
|
||||
sources:
|
||||
- https://github.com/ziglang/zig
|
||||
tasks:
|
||||
- build: cd zig && ./ci/srht/freebsd_script
|
||||
4
.github/CODEOWNERS
vendored
4
.github/CODEOWNERS
vendored
@@ -1,4 +0,0 @@
|
||||
# Autodoc
|
||||
/src/Autodoc.zig @kristoff-it
|
||||
/src/autodoc/* @kristoff-it
|
||||
/lib/docs/* @kristoff-it
|
||||
12
.github/ISSUE_TEMPLATE/autodoc-issue.md
vendored
12
.github/ISSUE_TEMPLATE/autodoc-issue.md
vendored
@@ -1,12 +0,0 @@
|
||||
---
|
||||
name: Autodoc Issue
|
||||
about: Issues with automatically generated docs, including stdlib docs.
|
||||
title: 'Autodoc: {your issue}'
|
||||
labels: autodoc
|
||||
assignees: kristoff-it
|
||||
|
||||
---
|
||||
|
||||
Autodoc is still work in progress and as such many bugs and missing features are already known.
|
||||
|
||||
# Please report only <ins>regressions</ins>, i.e. things that worked in a previous build of new Autodoc (orange banner) that now don't work any more.
|
||||
15
.github/ISSUE_TEMPLATE/bug.yml
vendored
15
.github/ISSUE_TEMPLATE/bug.yml
vendored
@@ -14,20 +14,27 @@ body:
|
||||
attributes:
|
||||
label: Zig Version
|
||||
description: "The output of `zig version`"
|
||||
placeholder: "0.10.0-dev.4583+875e98a57"
|
||||
placeholder: "0.9.0-dev.1275+ac52e0056"
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: repro
|
||||
attributes:
|
||||
label: Steps to Reproduce and Observed Behavior
|
||||
description: What exactly can someone else do, in order to observe the problem that you observed? Include the output and all error messages.
|
||||
label: Steps to Reproduce
|
||||
description: What exactly can someone else do, in order to observe the problem that you observed?
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: expected
|
||||
attributes:
|
||||
label: Expected Behavior
|
||||
description: What did you expect to happen instead?
|
||||
description: What did you expect to happen?
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: actual
|
||||
attributes:
|
||||
label: Actual Behavior
|
||||
description: What happened instead? Be sure to include all error messages if any.
|
||||
validations:
|
||||
required: true
|
||||
|
||||
7
.github/ISSUE_TEMPLATE/config.yml
vendored
7
.github/ISSUE_TEMPLATE/config.yml
vendored
@@ -1,7 +0,0 @@
|
||||
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
|
||||
16
.github/ISSUE_TEMPLATE/proposal.yml
vendored
Normal file
16
.github/ISSUE_TEMPLATE/proposal.yml
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
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
|
||||
20
.github/ISSUE_TEMPLATE/question.yml
vendored
Normal file
20
.github/ISSUE_TEMPLATE/question.yml
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
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
|
||||
47
.github/workflows/ci.yaml
vendored
47
.github/workflows/ci.yaml
vendored
@@ -1,47 +0,0 @@
|
||||
name: ci
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 0.10.x
|
||||
concurrency:
|
||||
# Cancels pending runs when a PR gets updated.
|
||||
group: ${{ github.head_ref || github.run_id }}-${{ github.actor }}
|
||||
cancel-in-progress: true
|
||||
jobs:
|
||||
x86_64-linux-debug:
|
||||
runs-on: [self-hosted, Linux, x86_64]
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
- name: Build and Test
|
||||
run: sh ci/x86_64-linux-debug.sh
|
||||
x86_64-linux-release:
|
||||
runs-on: [self-hosted, Linux, x86_64]
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
- name: Build and Test
|
||||
run: sh ci/x86_64-linux-release.sh
|
||||
aarch64-linux-debug:
|
||||
runs-on: [self-hosted, Linux, aarch64]
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
- name: Build and Test
|
||||
run: sh ci/aarch64-linux-debug.sh
|
||||
aarch64-linux-release:
|
||||
runs-on: [self-hosted, Linux, aarch64]
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
- name: Build and Test
|
||||
run: sh ci/aarch64-linux-release.sh
|
||||
x86_64-macos:
|
||||
runs-on: "macos-11"
|
||||
env:
|
||||
ARCH: "x86_64"
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
- name: Build and Test
|
||||
run: ci/x86_64-macos.sh
|
||||
535
CMakeLists.txt
535
CMakeLists.txt
@@ -12,26 +12,10 @@ if(NOT CMAKE_BUILD_TYPE)
|
||||
endif()
|
||||
|
||||
if(NOT CMAKE_INSTALL_PREFIX)
|
||||
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/stage3" CACHE STRING
|
||||
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}" CACHE STRING
|
||||
"Directory to install zig to" FORCE)
|
||||
endif()
|
||||
|
||||
# CMake recognizes the CMAKE_PREFIX_PATH environment variable for some things,
|
||||
# and also the CMAKE_PREFIX_PATH cache variable for other things. However, it
|
||||
# does not relate these two things, i.e. if the environment variable is set,
|
||||
# CMake does not populate the cache variable in a corresponding manner. Some
|
||||
# package systems, such as Homebrew, set the environment variable but not the
|
||||
# cache variable. Furthermore, the environment variable follows the system path
|
||||
# separator, such as ':' on POSIX and ';' on Windows, but the cache variable
|
||||
# follows CMake's array behavior, i.e. always ';' for a separator.
|
||||
list(APPEND ZIG_CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH}")
|
||||
if(WIN32)
|
||||
list(APPEND ZIG_CMAKE_PREFIX_PATH $ENV{CMAKE_PREFIX_PATH})
|
||||
else()
|
||||
string(REGEX REPLACE ":" ";" ZIG_CMAKE_PREFIX_PATH_STRING "$ENV{CMAKE_PREFIX_PATH}")
|
||||
list(APPEND ZIG_CMAKE_PREFIX_PATH "${ZIG_CMAKE_PREFIX_PATH_STRING}")
|
||||
endif()
|
||||
|
||||
set(CMAKE_USER_MAKE_RULES_OVERRIDE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cmake/c_flag_overrides.cmake)
|
||||
set(CMAKE_USER_MAKE_RULES_OVERRIDE_CXX
|
||||
@@ -41,13 +25,13 @@ project(zig C CXX)
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
|
||||
|
||||
set(ZIG_VERSION_MAJOR 0)
|
||||
set(ZIG_VERSION_MINOR 10)
|
||||
set(ZIG_VERSION_MINOR 9)
|
||||
set(ZIG_VERSION_PATCH 1)
|
||||
set(ZIG_VERSION "" CACHE STRING "Override Zig version string. Default is to find out with git.")
|
||||
|
||||
if("${ZIG_VERSION}" STREQUAL "")
|
||||
set(ZIG_VERSION "${ZIG_VERSION_MAJOR}.${ZIG_VERSION_MINOR}.${ZIG_VERSION_PATCH}")
|
||||
find_program(GIT_EXE NAMES git NAMES_PER_DIR)
|
||||
find_program(GIT_EXE NAMES git)
|
||||
if(GIT_EXE)
|
||||
execute_process(
|
||||
COMMAND ${GIT_EXE} -C ${CMAKE_SOURCE_DIR} describe --match *.*.* --tags
|
||||
@@ -79,22 +63,12 @@ if("${ZIG_VERSION}" STREQUAL "")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
message(STATUS "Configuring zig version ${ZIG_VERSION}")
|
||||
|
||||
set(ZIG_NO_LIB off CACHE BOOL
|
||||
"Disable copying lib/ files to install prefix during the build phase")
|
||||
|
||||
set(ZIG_SKIP_INSTALL_LIB_FILES off CACHE BOOL "Deprecated. Use ZIG_NO_LIB")
|
||||
if(ZIG_SKIP_INSTALL_LIB_FILES)
|
||||
message(WARNING "ZIG_SKIP_INSTALL_LIB_FILES is deprecated. Use ZIG_NO_LIB instead.")
|
||||
set(ZIG_NO_LIB ON)
|
||||
endif()
|
||||
message("Configuring zig version ${ZIG_VERSION}")
|
||||
|
||||
set(ZIG_STATIC off CACHE BOOL "Attempt to build a static zig executable (not compatible with glibc)")
|
||||
set(ZIG_SHARED_LLVM off CACHE BOOL "Prefer linking against shared LLVM libraries")
|
||||
set(ZIG_STATIC_LLVM off CACHE BOOL "Prefer linking against static LLVM libraries")
|
||||
set(ZIG_STATIC_ZLIB off CACHE BOOL "Prefer linking against static zlib")
|
||||
set(ZIG_STATIC_ZSTD off CACHE BOOL "Prefer linking against static zstd")
|
||||
set(ZIG_PREFER_CLANG_CPP_DYLIB off CACHE BOOL "Try to link against -lclang-cpp")
|
||||
set(ZIG_USE_CCACHE off CACHE BOOL "Use ccache if available")
|
||||
|
||||
if(CCACHE_PROGRAM AND ZIG_USE_CCACHE)
|
||||
@@ -104,11 +78,6 @@ endif()
|
||||
if(ZIG_STATIC)
|
||||
set(ZIG_STATIC_LLVM ON)
|
||||
set(ZIG_STATIC_ZLIB ON)
|
||||
set(ZIG_STATIC_ZSTD ON)
|
||||
endif()
|
||||
|
||||
if (ZIG_SHARED_LLVM AND ZIG_STATIC_LLVM)
|
||||
message(SEND_ERROR "-DZIG_SHARED_LLVM and -DZIG_STATIC_LLVM cannot both be enabled simultaneously")
|
||||
endif()
|
||||
|
||||
string(REGEX REPLACE "\\\\" "\\\\\\\\" ZIG_LIBC_LIB_DIR_ESCAPED "${ZIG_LIBC_LIB_DIR}")
|
||||
@@ -118,7 +87,7 @@ string(REGEX REPLACE "\\\\" "\\\\\\\\" ZIG_LIBC_INCLUDE_DIR_ESCAPED "${ZIG_LIBC_
|
||||
option(ZIG_TEST_COVERAGE "Build Zig with test coverage instrumentation" OFF)
|
||||
|
||||
set(ZIG_TARGET_TRIPLE "native" CACHE STRING "arch-os-abi to output binaries for")
|
||||
set(ZIG_TARGET_MCPU "native" CACHE STRING "-mcpu parameter to output binaries for")
|
||||
set(ZIG_TARGET_MCPU "baseline" CACHE STRING "-mcpu parameter to output binaries for")
|
||||
set(ZIG_EXECUTABLE "" CACHE STRING "(when cross compiling) path to already-built zig binary")
|
||||
set(ZIG_SINGLE_THREADED off CACHE BOOL "limit the zig compiler to use only 1 thread")
|
||||
set(ZIG_OMIT_STAGE2 off CACHE BOOL "omit the stage2 backend from stage1")
|
||||
@@ -135,25 +104,19 @@ else()
|
||||
set(ZIG_USE_LLVM_CONFIG OFF CACHE BOOL "use llvm-config to find LLVM libraries")
|
||||
endif()
|
||||
|
||||
find_package(llvm 15)
|
||||
find_package(clang 15)
|
||||
find_package(lld 15)
|
||||
find_package(llvm 13)
|
||||
find_package(clang 13)
|
||||
find_package(lld 13)
|
||||
|
||||
if(ZIG_STATIC_ZLIB)
|
||||
list(REMOVE_ITEM LLVM_LIBRARIES "-lz")
|
||||
find_library(ZLIB NAMES libz.a libzlibstatic.a z zlib libz NAMES_PER_DIR)
|
||||
find_library(ZLIB NAMES libz.a libzlibstatic.a z zlib libz)
|
||||
list(APPEND LLVM_LIBRARIES "${ZLIB}")
|
||||
endif()
|
||||
|
||||
if(ZIG_STATIC_ZSTD)
|
||||
list(REMOVE_ITEM LLVM_LIBRARIES "-lzstd")
|
||||
find_library(ZSTD NAMES libzstd.a libzstdstatic.a zstd NAMES_PER_DIR)
|
||||
list(APPEND LLVM_LIBRARIES "${ZSTD}")
|
||||
endif()
|
||||
|
||||
if(APPLE AND ZIG_STATIC)
|
||||
list(REMOVE_ITEM LLVM_LIBRARIES "-lcurses")
|
||||
find_library(CURSES NAMES libcurses.a libncurses.a NAMES_PER_DIR
|
||||
find_library(CURSES NAMES libcurses.a libncurses.a
|
||||
PATHS
|
||||
/usr/local/opt/ncurses/lib
|
||||
/opt/homebrew/opt/ncurses/lib)
|
||||
@@ -179,19 +142,15 @@ include_directories(${CLANG_INCLUDE_DIRS})
|
||||
# No patches have been applied to SoftFloat-3e
|
||||
set(EMBEDDED_SOFTFLOAT_SOURCES
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/8086/f128M_isSignalingNaN.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/8086/extF80M_isSignalingNaN.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/8086/s_commonNaNToF128M.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/8086/s_commonNaNToExtF80M.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/8086/s_commonNaNToF16UI.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/8086/s_commonNaNToF32UI.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/8086/s_commonNaNToF64UI.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/8086/s_f128MToCommonNaN.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/8086/s_extF80MToCommonNaN.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/8086/s_f16UIToCommonNaN.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/8086/s_f32UIToCommonNaN.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/8086/s_f64UIToCommonNaN.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/8086/s_propagateNaNF128M.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/8086/s_propagateNaNExtF80M.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/8086/s_propagateNaNF16UI.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/8086/softfloat_raiseFlags.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_add.c"
|
||||
@@ -211,7 +170,6 @@ set(EMBEDDED_SOFTFLOAT_SOURCES
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_to_f16.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_to_f32.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_to_f64.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_to_extF80M.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_to_i32.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_to_i32_r_minMag.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_to_i64.c"
|
||||
@@ -220,20 +178,6 @@ set(EMBEDDED_SOFTFLOAT_SOURCES
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_to_ui32_r_minMag.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_to_ui64.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_to_ui64_r_minMag.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/extF80M_add.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/extF80M_div.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/extF80M_eq.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/extF80M_le.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/extF80M_lt.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/extF80M_mul.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/extF80M_rem.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/extF80M_roundToInt.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/extF80M_sqrt.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/extF80M_sub.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/extF80M_to_f16.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/extF80M_to_f32.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/extF80M_to_f64.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/extF80M_to_f128M.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f16_add.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f16_div.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f16_eq.c"
|
||||
@@ -244,12 +188,9 @@ set(EMBEDDED_SOFTFLOAT_SOURCES
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f16_roundToInt.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f16_sqrt.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f16_sub.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f16_to_extF80M.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f16_to_f128M.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f16_to_f64.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f32_to_extF80M.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f32_to_f128M.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f64_to_extF80M.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f64_to_f128M.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f64_to_f16.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/i32_to_f128M.c"
|
||||
@@ -257,7 +198,6 @@ set(EMBEDDED_SOFTFLOAT_SOURCES
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_addCarryM.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_addComplCarryM.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_addF128M.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_addExtF80M.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_addM.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_addMagsF16.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_addMagsF32.c"
|
||||
@@ -268,14 +208,12 @@ set(EMBEDDED_SOFTFLOAT_SOURCES
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_approxRecip_1Ks.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_compare128M.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_compare96M.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_compareNonnormExtF80M.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_countLeadingZeros16.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_countLeadingZeros32.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_countLeadingZeros64.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_countLeadingZeros8.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_eq128.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_invalidF128M.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_invalidExtF80M.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_isNaNF128M.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_le128.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_lt128.c"
|
||||
@@ -286,9 +224,7 @@ set(EMBEDDED_SOFTFLOAT_SOURCES
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_mulAddF32.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_mulAddF64.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_negXM.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_normExtF80SigM.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_normRoundPackMToF128M.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_normRoundPackMToExtF80M.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_normRoundPackToF16.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_normRoundPackToF32.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_normRoundPackToF64.c"
|
||||
@@ -299,7 +235,6 @@ set(EMBEDDED_SOFTFLOAT_SOURCES
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_remStepMBy32.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_roundMToI64.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_roundMToUI64.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_roundPackMToExtF80M.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_roundPackMToF128M.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_roundPackToF16.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_roundPackToF32.c"
|
||||
@@ -328,25 +263,16 @@ set(EMBEDDED_SOFTFLOAT_SOURCES
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_subMagsF32.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_subMagsF64.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_tryPropagateNaNF128M.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_tryPropagateNaNExtF80M.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f16_mulAdd.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_mulAdd.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/softfloat_state.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/ui32_to_f128M.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/ui64_to_f128M.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/ui32_to_extF80M.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/ui64_to_extF80M.c"
|
||||
)
|
||||
add_library(embedded_softfloat STATIC ${EMBEDDED_SOFTFLOAT_SOURCES})
|
||||
if(MSVC)
|
||||
set(SOFTFLOAT_CFLAGS "/w")
|
||||
|
||||
if(NOT "${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
|
||||
set(SOFTFLOAT_CFLAGS "${SOFTFLOAT_CFLAGS} /O2")
|
||||
endif()
|
||||
|
||||
set_target_properties(embedded_softfloat PROPERTIES
|
||||
COMPILE_FLAGS ${SOFTFLOAT_CFLAGS}
|
||||
COMPILE_FLAGS "/w /O2"
|
||||
)
|
||||
else()
|
||||
set_target_properties(embedded_softfloat PROPERTIES
|
||||
@@ -372,7 +298,7 @@ set(ZIG_CONFIG_H_OUT "${CMAKE_BINARY_DIR}/config.h")
|
||||
set(ZIG_CONFIG_ZIG_OUT "${CMAKE_BINARY_DIR}/config.zig")
|
||||
|
||||
# This is our shim which will be replaced by stage1.zig.
|
||||
set(ZIG1_SOURCES
|
||||
set(ZIG0_SOURCES
|
||||
"${CMAKE_SOURCE_DIR}/src/stage1/zig0.cpp"
|
||||
)
|
||||
|
||||
@@ -383,6 +309,7 @@ set(STAGE1_SOURCES
|
||||
"${CMAKE_SOURCE_DIR}/src/stage1/bigint.cpp"
|
||||
"${CMAKE_SOURCE_DIR}/src/stage1/buffer.cpp"
|
||||
"${CMAKE_SOURCE_DIR}/src/stage1/codegen.cpp"
|
||||
"${CMAKE_SOURCE_DIR}/src/stage1/dump_analysis.cpp"
|
||||
"${CMAKE_SOURCE_DIR}/src/stage1/errmsg.cpp"
|
||||
"${CMAKE_SOURCE_DIR}/src/stage1/error.cpp"
|
||||
"${CMAKE_SOURCE_DIR}/src/stage1/heap.cpp"
|
||||
@@ -412,9 +339,9 @@ set(ZIG_CPP_SOURCES
|
||||
# https://github.com/ziglang/zig/issues/6363
|
||||
"${CMAKE_SOURCE_DIR}/src/windows_sdk.cpp"
|
||||
)
|
||||
# Needed because we use cmake, not the zig build system, to build zig2.o.
|
||||
# Needed because we use cmake, not the zig build system, to build zig1.o.
|
||||
# This list is generated by building zig and then clearing the zig-cache directory,
|
||||
# then manually running the build-obj command (see BUILD_ZIG2_ARGS), and then looking
|
||||
# then manually running the build-obj command (see BUILD_ZIG1_ARGS), and then looking
|
||||
# in the zig-cache directory for the compiler-generated list of zig file dependencies.
|
||||
set(ZIG_STAGE2_SOURCES
|
||||
"${ZIG_CONFIG_ZIG_OUT}"
|
||||
@@ -440,9 +367,6 @@ 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"
|
||||
@@ -486,8 +410,9 @@ 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/float.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/math/floor.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"
|
||||
@@ -504,14 +429,12 @@ 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"
|
||||
@@ -520,180 +443,72 @@ 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/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/special/compiler_rt.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/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/std/start.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/std.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/target.zig"
|
||||
@@ -709,20 +524,20 @@ set(ZIG_STAGE2_SOURCES
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/target/powerpc.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/target/riscv.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/target/sparc.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/target/s390x.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/target/systemz.zig"
|
||||
"${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"
|
||||
@@ -745,34 +560,11 @@ set(ZIG_STAGE2_SOURCES
|
||||
"${CMAKE_SOURCE_DIR}/src/TypedValue.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/WaitGroup.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/Zir.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/arch/aarch64/CodeGen.zig"
|
||||
"${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"
|
||||
"${CMAKE_SOURCE_DIR}/src/arch/x86_64/CodeGen.zig"
|
||||
"${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/arch/wasm/CodeGen.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/clang.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/clang_options.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/clang_options_data.zig"
|
||||
@@ -788,30 +580,22 @@ set(ZIG_STAGE2_SOURCES
|
||||
"${CMAKE_SOURCE_DIR}/src/libunwind.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/C.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/C/zig.h"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/Coff.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/Coff/Atom.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/Coff/Object.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/Coff/lld.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/Elf.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/MachO.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/MachO/Archive.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/MachO/Atom.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/MachO/CodeSignature.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/MachO/DebugSymbols.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/MachO/DwarfInfo.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/MachO/Dylib.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/MachO/Object.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/MachO/Trie.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/MachO/ZldAtom.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/MachO/bind.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/MachO/dead_strip.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/MachO/thunks.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/MachO/zld.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/Plan9.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/Plan9/aout.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/Wasm.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/msdos-stub.bin"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/strtab.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/tapi.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/tapi/Tokenizer.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/tapi/parse.zig"
|
||||
@@ -824,7 +608,6 @@ 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"
|
||||
@@ -911,9 +694,7 @@ else()
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
if(NOT "${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
|
||||
set(OPTIMIZED_C_FLAGS "/O2")
|
||||
endif()
|
||||
set(OPTIMIZED_C_FLAGS "/O2")
|
||||
else(MSVC)
|
||||
set(OPTIMIZED_C_FLAGS "-std=c99 -O3")
|
||||
endif(MSVC)
|
||||
@@ -963,9 +744,6 @@ 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
|
||||
@@ -990,116 +768,111 @@ if(MSVC OR MINGW)
|
||||
endif()
|
||||
|
||||
if("${ZIG_EXECUTABLE}" STREQUAL "")
|
||||
add_executable(zig1 ${ZIG1_SOURCES})
|
||||
set_target_properties(zig1 PROPERTIES
|
||||
add_executable(zig0 ${ZIG0_SOURCES})
|
||||
set_target_properties(zig0 PROPERTIES
|
||||
COMPILE_FLAGS ${EXE_CFLAGS}
|
||||
LINK_FLAGS ${EXE_LDFLAGS}
|
||||
)
|
||||
target_link_libraries(zig1 zigstage1)
|
||||
target_link_libraries(zig0 zigstage1)
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
set(ZIG2_OBJECT "${CMAKE_BINARY_DIR}/zig2.obj")
|
||||
set(ZIG1_OBJECT "${CMAKE_BINARY_DIR}/zig1.obj")
|
||||
else()
|
||||
set(ZIG2_OBJECT "${CMAKE_BINARY_DIR}/zig2.o")
|
||||
set(ZIG1_OBJECT "${CMAKE_BINARY_DIR}/zig1.o")
|
||||
endif()
|
||||
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
|
||||
set(ZIG_RELEASE_ARG "")
|
||||
elseif("${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo")
|
||||
set(ZIG_RELEASE_ARG -Drelease)
|
||||
set(ZIG1_RELEASE_ARG "")
|
||||
else()
|
||||
set(ZIG_RELEASE_ARG -Drelease -Dstrip)
|
||||
endif()
|
||||
if(ZIG_NO_LIB)
|
||||
set(ZIG_NO_LIB_ARG "-Dno-lib")
|
||||
else()
|
||||
set(ZIG_NO_LIB_ARG "")
|
||||
set(ZIG1_RELEASE_ARG -OReleaseFast --strip)
|
||||
endif()
|
||||
if(ZIG_SINGLE_THREADED)
|
||||
set(ZIG_SINGLE_THREADED_ARG "-fsingle-threaded")
|
||||
set(ZIG1_SINGLE_THREADED_ARG "-fsingle-threaded")
|
||||
else()
|
||||
set(ZIG_SINGLE_THREADED_ARG "")
|
||||
endif()
|
||||
if(ZIG_STATIC)
|
||||
set(ZIG_STATIC_ARG "-Duse-zig-libcxx")
|
||||
else()
|
||||
set(ZIG_STATIC_ARG "")
|
||||
set(ZIG1_SINGLE_THREADED_ARG "")
|
||||
endif()
|
||||
|
||||
set(BUILD_ZIG2_ARGS
|
||||
set(BUILD_ZIG1_ARGS
|
||||
"src/stage1.zig"
|
||||
--name zig2
|
||||
-target "${ZIG_TARGET_TRIPLE}"
|
||||
"-mcpu=${ZIG_TARGET_MCPU}"
|
||||
--name zig1
|
||||
--zig-lib-dir "${CMAKE_SOURCE_DIR}/lib"
|
||||
"-femit-bin=${ZIG2_OBJECT}"
|
||||
"-femit-bin=${ZIG1_OBJECT}"
|
||||
-fcompiler-rt
|
||||
${ZIG_SINGLE_THREADED_ARG}
|
||||
-target native
|
||||
-mcpu native
|
||||
"${ZIG1_RELEASE_ARG}"
|
||||
"${ZIG1_SINGLE_THREADED_ARG}"
|
||||
-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-end
|
||||
)
|
||||
|
||||
if("${ZIG_EXECUTABLE}" STREQUAL "")
|
||||
add_custom_command(
|
||||
OUTPUT "${ZIG2_OBJECT}"
|
||||
COMMAND zig1 ${BUILD_ZIG2_ARGS}
|
||||
DEPENDS zig1 "${ZIG_STAGE2_SOURCES}"
|
||||
COMMENT STATUS "Building stage2 object ${ZIG2_OBJECT}"
|
||||
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
||||
OUTPUT "${ZIG1_OBJECT}"
|
||||
COMMAND zig0 ${BUILD_ZIG1_ARGS}
|
||||
DEPENDS zig0 "${ZIG_STAGE2_SOURCES}"
|
||||
COMMENT STATUS "Building self-hosted component ${ZIG1_OBJECT}"
|
||||
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
||||
)
|
||||
set(ZIG_EXECUTABLE "${zig_BINARY_DIR}/zig")
|
||||
if (WIN32)
|
||||
set(ZIG_EXECUTABLE "${CMAKE_BINARY_DIR}/zig2.exe")
|
||||
else()
|
||||
set(ZIG_EXECUTABLE "${CMAKE_BINARY_DIR}/zig2")
|
||||
set(ZIG_EXECUTABLE "${ZIG_EXECUTABLE}.exe")
|
||||
endif()
|
||||
else()
|
||||
add_custom_command(
|
||||
OUTPUT "${ZIG2_OBJECT}"
|
||||
COMMAND "${ZIG_EXECUTABLE}" "build-obj" ${BUILD_ZIG2_ARGS}
|
||||
DEPENDS ${ZIG_STAGE2_SOURCES}
|
||||
COMMENT STATUS "Building stage2 component ${ZIG2_OBJECT}"
|
||||
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
||||
OUTPUT "${ZIG1_OBJECT}"
|
||||
COMMAND "${ZIG_EXECUTABLE}" "build-obj" ${BUILD_ZIG1_ARGS}
|
||||
DEPENDS ${ZIG_STAGE2_SOURCES}
|
||||
COMMENT STATUS "Building self-hosted component ${ZIG1_OBJECT}"
|
||||
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
||||
)
|
||||
endif()
|
||||
|
||||
# cmake won't let us configure an executable without C sources.
|
||||
add_executable(zig2 "${CMAKE_SOURCE_DIR}/src/stage1/empty.cpp" "${ZIG2_OBJECT}")
|
||||
add_executable(zig "${CMAKE_SOURCE_DIR}/src/stage1/empty.cpp" "${ZIG1_OBJECT}")
|
||||
|
||||
set_target_properties(zig2 PROPERTIES
|
||||
set_target_properties(zig PROPERTIES
|
||||
COMPILE_FLAGS ${EXE_CFLAGS}
|
||||
LINK_FLAGS ${EXE_LDFLAGS}
|
||||
)
|
||||
target_link_libraries(zig2 zigstage1)
|
||||
target_link_libraries(zig zigstage1)
|
||||
if(MSVC)
|
||||
target_link_libraries(zig2 ntdll.lib)
|
||||
target_link_libraries(zig ntdll.lib)
|
||||
elseif(MINGW)
|
||||
target_link_libraries(zig2 ntdll)
|
||||
target_link_libraries(zig ntdll)
|
||||
endif()
|
||||
|
||||
set(ZIG_BUILD_ARGS
|
||||
--zig-lib-dir "${CMAKE_SOURCE_DIR}/lib"
|
||||
"-Dconfig_h=${ZIG_CONFIG_H_OUT}"
|
||||
"-Denable-llvm"
|
||||
"-Denable-stage1"
|
||||
${ZIG_RELEASE_ARG}
|
||||
${ZIG_STATIC_ARG}
|
||||
${ZIG_NO_LIB_ARG}
|
||||
${ZIG_SINGLE_THREADED_ARG}
|
||||
"-Dtarget=${ZIG_TARGET_TRIPLE}"
|
||||
"-Dcpu=${ZIG_TARGET_MCPU}"
|
||||
"-Dversion-string=${ZIG_VERSION}"
|
||||
)
|
||||
install(TARGETS zig DESTINATION bin)
|
||||
|
||||
add_custom_target(stage3 ALL
|
||||
COMMAND zig2 build compile ${ZIG_BUILD_ARGS}
|
||||
DEPENDS zig2
|
||||
COMMENT STATUS "Building stage3"
|
||||
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
||||
)
|
||||
set(ZIG_SKIP_INSTALL_LIB_FILES off CACHE BOOL
|
||||
"Disable copying lib/ files to install prefix during the build phase")
|
||||
|
||||
install(CODE "set(ZIG_EXECUTABLE \"${ZIG_EXECUTABLE}\")")
|
||||
install(CODE "set(ZIG_BUILD_ARGS \"${ZIG_BUILD_ARGS}\")")
|
||||
install(CODE "set(CMAKE_INSTALL_PREFIX \"${CMAKE_INSTALL_PREFIX}\")")
|
||||
install(CODE "set(CMAKE_SOURCE_DIR \"${CMAKE_SOURCE_DIR}\")")
|
||||
install(SCRIPT "${CMAKE_SOURCE_DIR}/cmake/install.cmake")
|
||||
if(NOT ZIG_SKIP_INSTALL_LIB_FILES)
|
||||
set(ZIG_INSTALL_ARGS "build"
|
||||
--zig-lib-dir "${CMAKE_SOURCE_DIR}/lib"
|
||||
"-Dlib-files-only"
|
||||
--prefix "${CMAKE_INSTALL_PREFIX}"
|
||||
"-Dconfig_h=${ZIG_CONFIG_H_OUT}"
|
||||
install
|
||||
)
|
||||
|
||||
# CODE has no effect with Visual Studio build system generator, therefore
|
||||
# when using Visual Studio build system generator we resort to running
|
||||
# `zig build install` during the build phase.
|
||||
if(MSVC)
|
||||
add_custom_target(zig_install_lib_files ALL
|
||||
COMMAND zig ${ZIG_INSTALL_ARGS}
|
||||
DEPENDS zig
|
||||
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
||||
)
|
||||
else()
|
||||
get_target_property(zig_BINARY_DIR zig BINARY_DIR)
|
||||
install(CODE "set(zig_EXE \"${ZIG_EXECUTABLE}\")")
|
||||
install(CODE "set(ZIG_INSTALL_ARGS \"${ZIG_INSTALL_ARGS}\")")
|
||||
install(CODE "set(CMAKE_SOURCE_DIR \"${CMAKE_SOURCE_DIR}\")")
|
||||
install(SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/cmake/install.cmake)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -68,7 +68,7 @@ test and debug from a git working tree.
|
||||
- `make` is typically sufficient to build zig during development iterations.
|
||||
- `make install` performs a build __and__ install.
|
||||
- `msbuild -p:Configuration=Release INSTALL.vcxproj` on Windows performs a
|
||||
build and install. To avoid install, pass cmake option `-DZIG_NO_LIB=ON`.
|
||||
build and install. To avoid install, pass cmake option `-DZIG_SKIP_INSTALL_LIB_FILES=ON`.
|
||||
|
||||
To test changes, do the following from the build directory:
|
||||
|
||||
2
LICENSE
2
LICENSE
@@ -1,6 +1,6 @@
|
||||
The MIT License (Expat)
|
||||
|
||||
Copyright (c) 2015-2023, Zig contributors
|
||||
Copyright (c) 2015-2022, Zig contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -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/.github/CONTRIBUTING.md)
|
||||
* [Code of Conduct](https://github.com/ziglang/zig/blob/master/.github/CODE_OF_CONDUCT.md)
|
||||
* [Contributing](https://github.com/ziglang/zig/blob/master/CONTRIBUTING.md)
|
||||
* [Code of Conduct](https://github.com/ziglang/zig/blob/master/CODE_OF_CONDUCT.md)
|
||||
* [Frequently Asked Questions](https://github.com/ziglang/zig/wiki/FAQ)
|
||||
* [Community Projects](https://github.com/ziglang/zig/wiki/Community-Projects)
|
||||
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Requires cmake ninja-build
|
||||
|
||||
set -x
|
||||
set -e
|
||||
|
||||
ARCH="$(uname -m)"
|
||||
TARGET="$ARCH-linux-musl"
|
||||
MCPU="baseline"
|
||||
CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.11.0-dev.971+19056cb68"
|
||||
PREFIX="$HOME/deps/$CACHE_BASENAME"
|
||||
ZIG="$PREFIX/bin/zig"
|
||||
|
||||
export PATH="$HOME/deps/wasmtime-v2.0.2-$ARCH-linux:$PATH"
|
||||
|
||||
# Make the `zig version` number consistent.
|
||||
# This will affect the cmake command below.
|
||||
git config core.abbrev 9
|
||||
git fetch --unshallow || true
|
||||
git fetch --tags
|
||||
|
||||
export CC="$ZIG cc -target $TARGET -mcpu=$MCPU"
|
||||
export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU"
|
||||
|
||||
rm -rf build-debug
|
||||
mkdir build-debug
|
||||
cd build-debug
|
||||
|
||||
# Override the cache directories because they won't actually help other CI runs
|
||||
# which will be testing alternate versions of zig, and ultimately would just
|
||||
# fill up space on the hard drive for no reason.
|
||||
export ZIG_GLOBAL_CACHE_DIR="$(pwd)/zig-global-cache"
|
||||
export ZIG_LOCAL_CACHE_DIR="$(pwd)/zig-local-cache"
|
||||
|
||||
cmake .. \
|
||||
-DCMAKE_INSTALL_PREFIX="stage3-debug" \
|
||||
-DCMAKE_PREFIX_PATH="$PREFIX" \
|
||||
-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
|
||||
|
||||
echo "Looking for non-conforming code formatting..."
|
||||
stage3-debug/bin/zig fmt --check .. \
|
||||
--exclude ../test/cases/ \
|
||||
--exclude ../build-debug
|
||||
|
||||
# simultaneously test building self-hosted without LLVM and with 32-bit arm
|
||||
stage3-debug/bin/zig build -Dtarget=arm-linux-musleabihf
|
||||
|
||||
stage3-debug/bin/zig build test docs \
|
||||
-fwasmtime \
|
||||
-Dstatic-llvm \
|
||||
-Dtarget=native-native-musl \
|
||||
--search-prefix "$PREFIX" \
|
||||
--zig-lib-dir "$(pwd)/../lib"
|
||||
|
||||
# Look for HTML errors.
|
||||
tidy --drop-empty-elements no -qe "$ZIG_LOCAL_CACHE_DIR/langref.html"
|
||||
|
||||
# Produce the experimental std lib documentation.
|
||||
stage3-debug/bin/zig test ../lib/std/std.zig -femit-docs -fno-emit-bin --zig-lib-dir ../lib
|
||||
@@ -1,71 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Requires cmake ninja-build
|
||||
|
||||
set -x
|
||||
set -e
|
||||
|
||||
ARCH="$(uname -m)"
|
||||
TARGET="$ARCH-linux-musl"
|
||||
MCPU="baseline"
|
||||
CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.11.0-dev.971+19056cb68"
|
||||
PREFIX="$HOME/deps/$CACHE_BASENAME"
|
||||
ZIG="$PREFIX/bin/zig"
|
||||
|
||||
export PATH="$HOME/deps/wasmtime-v2.0.2-$ARCH-linux:$PATH"
|
||||
|
||||
# Make the `zig version` number consistent.
|
||||
# This will affect the cmake command below.
|
||||
git config core.abbrev 9
|
||||
git fetch --unshallow || true
|
||||
git fetch --tags
|
||||
|
||||
export CC="$ZIG cc -target $TARGET -mcpu=$MCPU"
|
||||
export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU"
|
||||
|
||||
rm -rf build-release
|
||||
mkdir build-release
|
||||
cd build-release
|
||||
|
||||
# Override the cache directories because they won't actually help other CI runs
|
||||
# which will be testing alternate versions of zig, and ultimately would just
|
||||
# fill up space on the hard drive for no reason.
|
||||
export ZIG_GLOBAL_CACHE_DIR="$(pwd)/zig-global-cache"
|
||||
export ZIG_LOCAL_CACHE_DIR="$(pwd)/zig-local-cache"
|
||||
|
||||
cmake .. \
|
||||
-DCMAKE_INSTALL_PREFIX="stage3-release" \
|
||||
-DCMAKE_PREFIX_PATH="$PREFIX" \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-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
|
||||
|
||||
echo "Looking for non-conforming code formatting..."
|
||||
stage3-release/bin/zig fmt --check .. \
|
||||
--exclude ../test/cases/ \
|
||||
--exclude ../build-release
|
||||
|
||||
# simultaneously test building self-hosted without LLVM and with 32-bit arm
|
||||
stage3-release/bin/zig build -Dtarget=arm-linux-musleabihf
|
||||
|
||||
stage3-release/bin/zig build test docs \
|
||||
-fwasmtime \
|
||||
-Dstatic-llvm \
|
||||
-Dtarget=native-native-musl \
|
||||
--search-prefix "$PREFIX" \
|
||||
--zig-lib-dir "$(pwd)/../lib"
|
||||
|
||||
# Look for HTML errors.
|
||||
tidy --drop-empty-elements no -qe "$ZIG_LOCAL_CACHE_DIR/langref.html"
|
||||
|
||||
# Produce the experimental std lib documentation.
|
||||
stage3-release/bin/zig test ../lib/std/std.zig -femit-docs -fno-emit-bin --zig-lib-dir ../lib
|
||||
@@ -1,70 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -x
|
||||
set -e
|
||||
|
||||
# Script assumes the presence of the following:
|
||||
# s3cmd
|
||||
|
||||
ZIGDIR="$(pwd)"
|
||||
TARGET="$ARCH-macos-none"
|
||||
MCPU="baseline"
|
||||
CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.11.0-dev.534+b0b1cc356-1"
|
||||
PREFIX="$HOME/$CACHE_BASENAME"
|
||||
ZIG="$PREFIX/bin/zig"
|
||||
|
||||
cd $ZIGDIR
|
||||
|
||||
# Make the `zig version` number consistent.
|
||||
# This will affect the cmake command below.
|
||||
git config core.abbrev 9
|
||||
git fetch --unshallow || true
|
||||
git fetch --tags
|
||||
|
||||
mkdir build
|
||||
cd build
|
||||
|
||||
# Override the cache directories because they won't actually help other CI runs
|
||||
# which will be testing alternate versions of zig, and ultimately would just
|
||||
# fill up space on the hard drive for no reason.
|
||||
export ZIG_GLOBAL_CACHE_DIR="$(pwd)/zig-global-cache"
|
||||
export ZIG_LOCAL_CACHE_DIR="$(pwd)/zig-local-cache"
|
||||
|
||||
PATH="$HOME/local/bin:$PATH" cmake .. \
|
||||
-DCMAKE_INSTALL_PREFIX="stage3-release" \
|
||||
-DCMAKE_PREFIX_PATH="$PREFIX" \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_C_COMPILER="$ZIG;cc;-target;$TARGET;-mcpu=$MCPU" \
|
||||
-DCMAKE_CXX_COMPILER="$ZIG;c++;-target;$TARGET;-mcpu=$MCPU" \
|
||||
-DZIG_TARGET_TRIPLE="$TARGET" \
|
||||
-DZIG_TARGET_MCPU="$MCPU" \
|
||||
-DZIG_STATIC=ON \
|
||||
-GNinja
|
||||
|
||||
$HOME/local/bin/ninja install
|
||||
|
||||
stage3-release/bin/zig build test docs \
|
||||
--zig-lib-dir "$(pwd)/../lib" \
|
||||
-Denable-macos-sdk \
|
||||
-Dstatic-llvm \
|
||||
-Dskip-non-native \
|
||||
--search-prefix "$PREFIX"
|
||||
|
||||
# Produce the experimental std lib documentation.
|
||||
stage3-release/bin/zig test ../lib/std/std.zig -femit-docs -fno-emit-bin --zig-lib-dir ../lib
|
||||
|
||||
# Ensure that stage3 and stage4 are byte-for-byte identical.
|
||||
stage3-release/bin/zig build \
|
||||
--prefix stage4-release \
|
||||
-Denable-llvm \
|
||||
-Dno-lib \
|
||||
-Drelease \
|
||||
-Dstrip \
|
||||
-Dtarget=$TARGET \
|
||||
-Duse-zig-libcxx \
|
||||
-Dversion-string="$(stage3-release/bin/zig version)"
|
||||
|
||||
# diff returns an error code if the files differ.
|
||||
echo "If the following command fails, it means nondeterminism has been"
|
||||
echo "introduced, making stage3 and stage4 no longer byte-for-byte identical."
|
||||
diff stage3-release/bin/zig stage4-release/bin/zig
|
||||
132
ci/azure/macos_arm64_script
Executable file
132
ci/azure/macos_arm64_script
Executable file
@@ -0,0 +1,132 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -x
|
||||
set -e
|
||||
|
||||
brew update && brew install ncurses s3cmd
|
||||
|
||||
ZIGDIR="$(pwd)"
|
||||
|
||||
HOST_ARCH="x86_64"
|
||||
HOST_TARGET="$HOST_ARCH-macos-gnu"
|
||||
HOST_MCPU="baseline"
|
||||
HOST_CACHE_BASENAME="zig+llvm+lld+clang-$HOST_TARGET-0.9.0-dev.1249+210ef5af8"
|
||||
HOST_PREFIX="$HOME/$HOST_CACHE_BASENAME"
|
||||
|
||||
ARCH="aarch64"
|
||||
TARGET="$ARCH-macos-gnu"
|
||||
MCPU="apple_a14"
|
||||
CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.9.0-dev.1249+210ef5af8"
|
||||
PREFIX="$HOME/$CACHE_BASENAME"
|
||||
|
||||
JOBS="-j2"
|
||||
|
||||
rm -rf $HOST_PREFIX $PREFIX
|
||||
cd $HOME
|
||||
|
||||
wget -nv "https://ziglang.org/deps/$HOST_CACHE_BASENAME.tar.xz"
|
||||
wget -nv "https://ziglang.org/deps/$CACHE_BASENAME.tar.xz"
|
||||
tar xf "$HOST_CACHE_BASENAME.tar.xz"
|
||||
tar xf "$CACHE_BASENAME.tar.xz"
|
||||
|
||||
cd $ZIGDIR
|
||||
|
||||
# Make the `zig version` number consistent.
|
||||
# This will affect the cmake command below.
|
||||
git config core.abbrev 9
|
||||
git fetch --unshallow || true
|
||||
git fetch --tags
|
||||
|
||||
# Build host zig compiler in debug so that we can get the
|
||||
# current version when packaging
|
||||
|
||||
ZIG="$HOST_PREFIX/bin/zig"
|
||||
|
||||
export CC="$ZIG cc -target $HOST_TARGET -mcpu=$HOST_MCPU"
|
||||
export CXX="$ZIG c++ -target $HOST_TARGET -mcpu=$HOST_MCPU"
|
||||
|
||||
mkdir build.host
|
||||
cd build.host
|
||||
cmake .. \
|
||||
-DCMAKE_INSTALL_PREFIX="$(pwd)/release" \
|
||||
-DCMAKE_PREFIX_PATH="$HOST_PREFIX" \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DZIG_TARGET_TRIPLE="$HOST_TARGET" \
|
||||
-DZIG_TARGET_MCPU="$HOST_MCPU" \
|
||||
-DZIG_STATIC=ON \
|
||||
-DZIG_OMIT_STAGE2=ON
|
||||
|
||||
unset CC
|
||||
unset CXX
|
||||
|
||||
make $JOBS install
|
||||
|
||||
# Build zig compiler cross-compiled for arm64
|
||||
cd $ZIGDIR
|
||||
|
||||
ZIG="$ZIGDIR/build.host/release/bin/zig"
|
||||
|
||||
export CC="$ZIG cc -target $TARGET -mcpu=$MCPU"
|
||||
export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU"
|
||||
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. \
|
||||
-DCMAKE_INSTALL_PREFIX="$(pwd)/release" \
|
||||
-DCMAKE_PREFIX_PATH="$PREFIX" \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DZIG_TARGET_TRIPLE="$TARGET" \
|
||||
-DZIG_TARGET_MCPU="$MCPU" \
|
||||
-DZIG_EXECUTABLE="$ZIG" \
|
||||
-DZIG_STATIC=ON
|
||||
|
||||
unset CC
|
||||
unset CXX
|
||||
|
||||
make $JOBS install
|
||||
|
||||
if [ "${BUILD_REASON}" != "PullRequest" ]; then
|
||||
mv ../LICENSE release/
|
||||
|
||||
# We do not run test suite but still need langref.
|
||||
mkdir -p release/docs
|
||||
$ZIG run ../doc/docgen.zig -- $ZIG ../doc/langref.html.in release/docs/langref.html
|
||||
|
||||
# Produce the experimental std lib documentation.
|
||||
mkdir -p release/docs/std
|
||||
$ZIG test ../lib/std/std.zig \
|
||||
--zig-lib-dir ../lib \
|
||||
-femit-docs=release/docs/std \
|
||||
-fno-emit-bin
|
||||
|
||||
mv release/bin/zig release/
|
||||
rmdir release/bin
|
||||
|
||||
VERSION=$(../build.host/release/bin/zig version)
|
||||
DIRNAME="zig-macos-$ARCH-$VERSION"
|
||||
TARBALL="$DIRNAME.tar.xz"
|
||||
mv release "$DIRNAME"
|
||||
tar cfJ "$TARBALL" "$DIRNAME"
|
||||
|
||||
mv "$DOWNLOADSECUREFILE_SECUREFILEPATH" "$HOME/.s3cfg"
|
||||
s3cmd put -P --add-header="cache-control: public, max-age=31536000, immutable" "$TARBALL" s3://ziglang.org/builds/
|
||||
|
||||
SHASUM=$(shasum -a 256 $TARBALL | cut '-d ' -f1)
|
||||
BYTESIZE=$(wc -c < $TARBALL)
|
||||
|
||||
JSONFILE="macos-$GITBRANCH.json"
|
||||
touch $JSONFILE
|
||||
echo "{\"tarball\": \"$TARBALL\"," >>$JSONFILE
|
||||
echo "\"shasum\": \"$SHASUM\"," >>$JSONFILE
|
||||
echo "\"size\": \"$BYTESIZE\"}" >>$JSONFILE
|
||||
|
||||
s3cmd put -P --add-header="Cache-Control: max-age=0, must-revalidate" "$JSONFILE" "s3://ziglang.org/builds/$JSONFILE"
|
||||
s3cmd put -P "$JSONFILE" "s3://ziglang.org/builds/$ARCH-macos-$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
|
||||
99
ci/azure/macos_script
Executable file
99
ci/azure/macos_script
Executable file
@@ -0,0 +1,99 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -x
|
||||
set -e
|
||||
|
||||
brew update && brew install ncurses s3cmd
|
||||
|
||||
ZIGDIR="$(pwd)"
|
||||
ARCH="x86_64"
|
||||
TARGET="$ARCH-macos-gnu"
|
||||
MCPU="baseline"
|
||||
CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.9.0-dev.1249+210ef5af8"
|
||||
PREFIX="$HOME/$CACHE_BASENAME"
|
||||
JOBS="-j2"
|
||||
|
||||
rm -rf $PREFIX
|
||||
cd $HOME
|
||||
|
||||
wget -nv "https://ziglang.org/deps/$CACHE_BASENAME.tar.xz"
|
||||
tar xf "$CACHE_BASENAME.tar.xz"
|
||||
|
||||
ZIG="$PREFIX/bin/zig"
|
||||
export CC="$ZIG cc -target $TARGET -mcpu=$MCPU"
|
||||
export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU"
|
||||
|
||||
cd $ZIGDIR
|
||||
|
||||
# Make the `zig version` number consistent.
|
||||
# This will affect the cmake command below.
|
||||
git config core.abbrev 9
|
||||
git fetch --unshallow || true
|
||||
git fetch --tags
|
||||
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. \
|
||||
-DCMAKE_INSTALL_PREFIX="$(pwd)/release" \
|
||||
-DCMAKE_PREFIX_PATH="$PREFIX" \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DZIG_TARGET_TRIPLE="$TARGET" \
|
||||
-DZIG_TARGET_MCPU="$MCPU" \
|
||||
-DZIG_STATIC=ON \
|
||||
-DZIG_OMIT_STAGE2=ON
|
||||
|
||||
# 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
|
||||
|
||||
make $JOBS install
|
||||
|
||||
# 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="$(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
|
||||
|
||||
release/bin/zig build test-toolchain -Denable-macos-sdk
|
||||
release/bin/zig build test-std
|
||||
release/bin/zig build docs
|
||||
|
||||
if [ "${BUILD_REASON}" != "PullRequest" ]; then
|
||||
mv ../LICENSE release/
|
||||
mv ../zig-cache/langref.html release/
|
||||
mv release/bin/zig release/
|
||||
rmdir release/bin
|
||||
|
||||
VERSION=$(release/zig version)
|
||||
DIRNAME="zig-macos-$ARCH-$VERSION"
|
||||
TARBALL="$DIRNAME.tar.xz"
|
||||
mv release "$DIRNAME"
|
||||
tar cfJ "$TARBALL" "$DIRNAME"
|
||||
|
||||
mv "$DOWNLOADSECUREFILE_SECUREFILEPATH" "$HOME/.s3cfg"
|
||||
s3cmd put -P --add-header="cache-control: public, max-age=31536000, immutable" "$TARBALL" s3://ziglang.org/builds/
|
||||
|
||||
SHASUM=$(shasum -a 256 $TARBALL | cut '-d ' -f1)
|
||||
BYTESIZE=$(wc -c < $TARBALL)
|
||||
|
||||
JSONFILE="macos-$GITBRANCH.json"
|
||||
touch $JSONFILE
|
||||
echo "{\"tarball\": \"$TARBALL\"," >>$JSONFILE
|
||||
echo "\"shasum\": \"$SHASUM\"," >>$JSONFILE
|
||||
echo "\"size\": \"$BYTESIZE\"}" >>$JSONFILE
|
||||
|
||||
s3cmd put -P --add-header="Cache-Control: max-age=0, must-revalidate" "$JSONFILE" "s3://ziglang.org/builds/$JSONFILE"
|
||||
s3cmd put -P "$JSONFILE" "s3://ziglang.org/builds/$ARCH-macos-$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"
|
||||
echo "##vso[task.setvariable variable=version;isOutput=true]$VERSION"
|
||||
fi
|
||||
12
ci/azure/on_master_success
Executable file
12
ci/azure/on_master_success
Executable file
@@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
|
||||
# We do not set -x because this would leak the oauth access token.
|
||||
set +x
|
||||
|
||||
set -e
|
||||
|
||||
sudo apt-get update -y
|
||||
sudo apt-get install -y curl jq
|
||||
|
||||
OAUTH_TOKEN="$(cat "$DOWNLOADSECUREFILE_SECUREFILEPATH")"
|
||||
./ci/srht/on_master_success "$VERSION" "$OAUTH_TOKEN"
|
||||
65
ci/azure/pipelines.yml
Normal file
65
ci/azure/pipelines.yml
Normal file
@@ -0,0 +1,65 @@
|
||||
jobs:
|
||||
- job: BuildMacOS
|
||||
pool:
|
||||
vmImage: 'macOS-10.15'
|
||||
timeoutInMinutes: 360
|
||||
steps:
|
||||
- task: DownloadSecureFile@1
|
||||
inputs:
|
||||
secureFile: s3cfg
|
||||
- script: ci/azure/macos_script
|
||||
name: main
|
||||
displayName: 'Build and test'
|
||||
- job: BuildMacOS_arm64
|
||||
pool:
|
||||
vmImage: 'macOS-10.15'
|
||||
timeoutInMinutes: 180
|
||||
steps:
|
||||
- task: DownloadSecureFile@1
|
||||
inputs:
|
||||
secureFile: s3cfg
|
||||
- script: ci/azure/macos_arm64_script
|
||||
name: main
|
||||
displayName: 'Build'
|
||||
- job: BuildWindows
|
||||
pool:
|
||||
vmImage: 'windows-2019'
|
||||
timeoutInMinutes: 360
|
||||
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
|
||||
- task: DownloadSecureFile@1
|
||||
inputs:
|
||||
secureFile: s3cfg
|
||||
- script: ci/azure/windows_msvc_script.bat
|
||||
name: main
|
||||
displayName: 'Build and test'
|
||||
- job: OnMasterSuccess
|
||||
dependsOn:
|
||||
- BuildMacOS
|
||||
- BuildMacOS_arm64
|
||||
- BuildWindows
|
||||
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
|
||||
strategy:
|
||||
maxParallel: 1
|
||||
pool:
|
||||
vmImage: 'ubuntu-18.04'
|
||||
variables:
|
||||
version: $[ dependencies.BuildMacOS.outputs['main.version'] ]
|
||||
steps:
|
||||
- task: DownloadSecureFile@1
|
||||
inputs:
|
||||
secureFile: oauth_token
|
||||
- script: ci/azure/on_master_success
|
||||
displayName: 'master branch success hook'
|
||||
16
ci/azure/windows_msvc_install
Normal file
16
ci/azure/windows_msvc_install
Normal file
@@ -0,0 +1,16 @@
|
||||
#!/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
|
||||
39
ci/azure/windows_msvc_script.bat
Normal file
39
ci/azure/windows_msvc_script.bat
Normal file
@@ -0,0 +1,39 @@
|
||||
@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
|
||||
46
ci/azure/windows_upload
Executable file
46
ci/azure/windows_upload
Executable file
@@ -0,0 +1,46 @@
|
||||
#!/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
|
||||
82
ci/drone/drone.yml
Normal file
82
ci/drone/drone.yml
Normal file
@@ -0,0 +1,82 @@
|
||||
---
|
||||
kind: pipeline
|
||||
name: test-aarch64-linux-musl
|
||||
|
||||
platform:
|
||||
arch: arm64
|
||||
|
||||
steps:
|
||||
- name: build
|
||||
image: ziglang/static-base:llvm13-aarch64-1
|
||||
commands:
|
||||
- ./ci/drone/linux_script_build
|
||||
|
||||
- name: test-1
|
||||
depends_on:
|
||||
- build
|
||||
image: ziglang/static-base:llvm13-aarch64-1
|
||||
commands:
|
||||
- ./ci/drone/linux_script_test 1
|
||||
|
||||
- name: test-2
|
||||
depends_on:
|
||||
- build
|
||||
image: ziglang/static-base:llvm13-aarch64-1
|
||||
commands:
|
||||
- ./ci/drone/linux_script_test 2
|
||||
|
||||
- name: test-3
|
||||
depends_on:
|
||||
- build
|
||||
image: ziglang/static-base:llvm13-aarch64-1
|
||||
commands:
|
||||
- ./ci/drone/linux_script_test 3
|
||||
|
||||
- name: test-4
|
||||
depends_on:
|
||||
- build
|
||||
image: ziglang/static-base:llvm13-aarch64-1
|
||||
commands:
|
||||
- ./ci/drone/linux_script_test 4
|
||||
|
||||
- name: test-5
|
||||
depends_on:
|
||||
- build
|
||||
image: ziglang/static-base:llvm13-aarch64-1
|
||||
commands:
|
||||
- ./ci/drone/linux_script_test 5
|
||||
|
||||
- name: test-6
|
||||
depends_on:
|
||||
- build
|
||||
image: ziglang/static-base:llvm13-aarch64-1
|
||||
commands:
|
||||
- ./ci/drone/linux_script_test 6
|
||||
|
||||
- name: test-7
|
||||
depends_on:
|
||||
- build
|
||||
image: ziglang/static-base:llvm13-aarch64-1
|
||||
commands:
|
||||
- ./ci/drone/linux_script_test 7
|
||||
|
||||
- name: finalize
|
||||
depends_on:
|
||||
- build
|
||||
- test-1
|
||||
- test-2
|
||||
- test-3
|
||||
- test-4
|
||||
- test-5
|
||||
- test-6
|
||||
- test-7
|
||||
image: ziglang/static-base:llvm13-aarch64-1
|
||||
environment:
|
||||
SRHT_OAUTH_TOKEN:
|
||||
from_secret: SRHT_OAUTH_TOKEN
|
||||
AWS_ACCESS_KEY_ID:
|
||||
from_secret: AWS_ACCESS_KEY_ID
|
||||
AWS_SECRET_ACCESS_KEY:
|
||||
from_secret: AWS_SECRET_ACCESS_KEY
|
||||
commands:
|
||||
- ./ci/drone/linux_script_finalize
|
||||
22
ci/drone/linux_script_base
Executable file
22
ci/drone/linux_script_base
Executable file
@@ -0,0 +1,22 @@
|
||||
#!/bin/sh
|
||||
|
||||
# https://docs.drone.io/pipeline/docker/syntax/workspace/
|
||||
#
|
||||
# Drone automatically creates a temporary volume, known as your workspace,
|
||||
# where it clones your repository. The workspace is the current working
|
||||
# directory for each step in your pipeline.
|
||||
#
|
||||
# Because the workspace is a volume, filesystem changes are persisted between
|
||||
# pipeline steps. In other words, individual steps can communicate and share
|
||||
# state using the filesystem.
|
||||
#
|
||||
# Workspace volumes are ephemeral. They are created when the pipeline starts
|
||||
# and destroyed after the pipeline completes.
|
||||
|
||||
set -x
|
||||
set -e
|
||||
|
||||
TRIPLEARCH="$(uname -m)"
|
||||
DISTDIR="$DRONE_WORKSPACE/dist"
|
||||
|
||||
export ZIG_GLOBAL_CACHE_DIR="$DRONE_WORKSPACE/zig-cache"
|
||||
65
ci/drone/linux_script_build
Executable file
65
ci/drone/linux_script_build
Executable file
@@ -0,0 +1,65 @@
|
||||
#!/bin/sh
|
||||
|
||||
. ./ci/drone/linux_script_base
|
||||
|
||||
# Probe CPU/brand details.
|
||||
# TODO: `lscpu` is changing package names in EDGE to `util-linux-misc`
|
||||
apk update
|
||||
apk add util-linux
|
||||
echo "lscpu:"
|
||||
lscpu | sed 's,^, : ,'
|
||||
|
||||
PREFIX="/deps/local"
|
||||
ZIG="$PREFIX/bin/zig"
|
||||
TARGET="$TRIPLEARCH-linux-musl"
|
||||
MCPU="baseline"
|
||||
|
||||
export CC="$ZIG cc -target $TARGET -mcpu=$MCPU"
|
||||
export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU"
|
||||
|
||||
# The `CMAKE_AR` parameter will consider any spaces to
|
||||
# be part of the executable path rather than CLI args, so we have
|
||||
# to create wrapper scripts for `zig ar` and zig ranlib`.
|
||||
cat <<'ENDFILE' >$PREFIX/bin/ar
|
||||
#!/bin/sh
|
||||
/deps/local/bin/zig ar $@
|
||||
ENDFILE
|
||||
|
||||
cat <<'ENDFILE' >$PREFIX/bin/ranlib
|
||||
#!/bin/sh
|
||||
/deps/local/bin/zig ranlib $@
|
||||
ENDFILE
|
||||
|
||||
chmod +x $PREFIX/bin/ar
|
||||
chmod +x $PREFIX/bin/ranlib
|
||||
|
||||
# Make the `zig version` number consistent.
|
||||
# This will affect the cmake command below.
|
||||
git config core.abbrev 9
|
||||
git fetch --unshallow || true
|
||||
git fetch --tags
|
||||
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. \
|
||||
-DCMAKE_INSTALL_PREFIX="$DISTDIR" \
|
||||
-DCMAKE_PREFIX_PATH="$PREFIX" \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_AR="$PREFIX/bin/ar" \
|
||||
-DCMAKE_RANLIB="$PREFIX/bin/ranlib" \
|
||||
-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
|
||||
samu install
|
||||
|
||||
# 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="$DISTDIR/bin/zig"
|
||||
samu install
|
||||
45
ci/drone/linux_script_finalize
Executable file
45
ci/drone/linux_script_finalize
Executable file
@@ -0,0 +1,45 @@
|
||||
#!/bin/sh
|
||||
|
||||
. ./ci/drone/linux_script_base
|
||||
|
||||
if [ -n "$DRONE_PULL_REQUEST" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
apk update
|
||||
apk add py3-pip perl-utils jq curl
|
||||
pip3 install s3cmd
|
||||
|
||||
cd build
|
||||
|
||||
mv ../LICENSE "$DISTDIR/"
|
||||
mv ../zig-cache/langref.html "$DISTDIR/"
|
||||
mv "$DISTDIR/bin/zig" "$DISTDIR/"
|
||||
rmdir "$DISTDIR/bin"
|
||||
|
||||
GITBRANCH="$DRONE_BRANCH"
|
||||
VERSION="$("$DISTDIR/zig" version)"
|
||||
DIRNAME="zig-linux-$TRIPLEARCH-$VERSION"
|
||||
TARBALL="$DIRNAME.tar.xz"
|
||||
mv "$DISTDIR" "$DIRNAME"
|
||||
tar cfJ "$TARBALL" "$DIRNAME"
|
||||
|
||||
s3cmd put -P --add-header="cache-control: public, max-age=31536000, immutable" "$TARBALL" s3://ziglang.org/builds/
|
||||
|
||||
SHASUM=$(shasum -a 256 $TARBALL | cut '-d ' -f1)
|
||||
BYTESIZE=$(wc -c < $TARBALL)
|
||||
|
||||
JSONFILE="tarball.json"
|
||||
touch $JSONFILE
|
||||
echo "{\"tarball\": \"$TARBALL\"," >>$JSONFILE
|
||||
echo "\"shasum\": \"$SHASUM\"," >>$JSONFILE
|
||||
echo "\"size\": \"$BYTESIZE\"}" >>$JSONFILE
|
||||
|
||||
s3cmd put -P "$JSONFILE" "s3://ziglang.org/builds/$TRIPLEARCH-linux-$VERSION.json"
|
||||
if [ "$GITBRANCH" = "master" ]; then
|
||||
# avoid leaking oauth token
|
||||
set +x
|
||||
|
||||
cd "$DRONE_WORKSPACE"
|
||||
./ci/srht/on_master_success "$VERSION" "$SRHT_OAUTH_TOKEN"
|
||||
fi
|
||||
52
ci/drone/linux_script_test
Executable file
52
ci/drone/linux_script_test
Executable file
@@ -0,0 +1,52 @@
|
||||
#!/bin/sh
|
||||
|
||||
. ./ci/drone/linux_script_base
|
||||
|
||||
BUILD_FLAGS="-Dskip-non-native"
|
||||
|
||||
case "$1" in
|
||||
1)
|
||||
./build/zig build $BUILD_FLAGS test-behavior
|
||||
./build/zig build $BUILD_FLAGS test-compiler-rt
|
||||
./build/zig build $BUILD_FLAGS test-fmt
|
||||
./build/zig build $BUILD_FLAGS docs
|
||||
;;
|
||||
2)
|
||||
# Debug
|
||||
./build/zig build $BUILD_FLAGS test-std -Dskip-release-safe -Dskip-release-fast -Dskip-release-small
|
||||
;;
|
||||
3)
|
||||
# ReleaseSafe
|
||||
./build/zig build $BUILD_FLAGS test-std -Dskip-debug -Dskip-release-fast -Dskip-release-small
|
||||
;;
|
||||
4)
|
||||
# Releasefast
|
||||
./build/zig build $BUILD_FLAGS test-std -Dskip-debug -Dskip-release-safe -Dskip-release-small
|
||||
;;
|
||||
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-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
|
||||
;;
|
||||
'')
|
||||
echo "error: expecting test group argument"
|
||||
exit 1
|
||||
;;
|
||||
*)
|
||||
echo "error: unknown test group: $1"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
84
ci/srht/freebsd_script
Executable file
84
ci/srht/freebsd_script
Executable file
@@ -0,0 +1,84 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -x
|
||||
set -e
|
||||
|
||||
sudo pkg update -fq
|
||||
sudo pkg install -y cmake py38-s3cmd wget curl jq samurai
|
||||
|
||||
ZIGDIR="$(pwd)"
|
||||
CACHE_BASENAME="zig+llvm+lld+clang-x86_64-freebsd-gnu-0.9.0-dev.1243+456d7e5f5"
|
||||
PREFIX="$HOME/$CACHE_BASENAME"
|
||||
|
||||
cd $HOME
|
||||
wget -nv "https://ziglang.org/deps/$CACHE_BASENAME.tar.xz"
|
||||
tar xf "$CACHE_BASENAME.tar.xz"
|
||||
|
||||
cd $ZIGDIR
|
||||
|
||||
# Make the `zig version` number consistent.
|
||||
# This will affect the cmake command below.
|
||||
git config core.abbrev 9
|
||||
git fetch --unshallow || true
|
||||
git fetch --tags
|
||||
|
||||
# SourceHut reports that it is a terminal that supports escape codes, but it
|
||||
# is a filthy liar. Here we tell Zig to not try to send any terminal escape
|
||||
# codes to show progress.
|
||||
export TERM=dumb
|
||||
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_PREFIX_PATH=$PREFIX \
|
||||
"-DCMAKE_INSTALL_PREFIX=$(pwd)/release" \
|
||||
-DZIG_STATIC=ON \
|
||||
-DZIG_TARGET_TRIPLE=x86_64-freebsd-gnu \
|
||||
-GNinja
|
||||
samu install
|
||||
|
||||
# TODO ld.lld: error: undefined symbol: main
|
||||
# >>> referenced by crt1_c.c:75 (/usr/src/lib/csu/amd64/crt1_c.c:75)
|
||||
# >>> /usr/lib/crt1.o:(_start)
|
||||
#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
|
||||
|
||||
if [ -f ~/.s3cfg ]; then
|
||||
mv ../LICENSE release/
|
||||
mv ../zig-cache/langref.html release/
|
||||
mv release/bin/zig release/
|
||||
rmdir release/bin
|
||||
|
||||
GITBRANCH=$(basename $GITHUB_REF)
|
||||
VERSION=$(release/zig version)
|
||||
DIRNAME="zig-freebsd-x86_64-$VERSION"
|
||||
TARBALL="$DIRNAME.tar.xz"
|
||||
mv release "$DIRNAME"
|
||||
tar cfJ "$TARBALL" "$DIRNAME"
|
||||
|
||||
s3cmd put -P --add-header="cache-control: public, max-age=31536000, immutable" "$TARBALL" s3://ziglang.org/builds/
|
||||
|
||||
SHASUM=$(shasum -a 256 $TARBALL | cut '-d ' -f1)
|
||||
BYTESIZE=$(wc -c < $TARBALL)
|
||||
|
||||
JSONFILE="freebsd-$GITBRANCH.json"
|
||||
touch $JSONFILE
|
||||
echo "{\"tarball\": \"$TARBALL\"," >>$JSONFILE
|
||||
echo "\"shasum\": \"$SHASUM\"," >>$JSONFILE
|
||||
echo "\"size\": \"$BYTESIZE\"}" >>$JSONFILE
|
||||
|
||||
s3cmd put -P --add-header="Cache-Control: max-age=0, must-revalidate" "$JSONFILE" "s3://ziglang.org/builds/$JSONFILE"
|
||||
s3cmd put -P "$JSONFILE" "s3://ziglang.org/builds/x86_64-freebsd-$VERSION.json"
|
||||
|
||||
if [ "$GITBRANCH" = "master" ]; then
|
||||
# avoid leaking oauth token
|
||||
set +x
|
||||
|
||||
OAUTH_TOKEN="$(cat ~/.oauth_token)"
|
||||
cd "$ZIGDIR"
|
||||
./ci/srht/on_master_success "$VERSION" "$OAUTH_TOKEN"
|
||||
fi
|
||||
fi
|
||||
488
ci/srht/index.json
Normal file
488
ci/srht/index.json
Normal file
@@ -0,0 +1,488 @@
|
||||
{
|
||||
"master": {
|
||||
"version": "{{MASTER_VERSION}}",
|
||||
"date": "{{MASTER_DATE}}",
|
||||
"docs": "https://ziglang.org/documentation/master/",
|
||||
"stdDocs": "https://ziglang.org/documentation/master/std/",
|
||||
"src": {
|
||||
"tarball": "https://ziglang.org/builds/{{SRC_TARBALL}}",
|
||||
"shasum": "{{SRC_SHASUM}}",
|
||||
"size": "{{SRC_BYTESIZE}}"
|
||||
},
|
||||
"x86_64-freebsd": {
|
||||
"tarball": "https://ziglang.org/builds/{{X86_64_FREEBSD_TARBALL}}",
|
||||
"shasum": "{{X86_64_FREEBSD_SHASUM}}",
|
||||
"size": "{{X86_64_FREEBSD_BYTESIZE}}"
|
||||
},
|
||||
"x86_64-macos": {
|
||||
"tarball": "https://ziglang.org/builds/{{X86_64_MACOS_TARBALL}}",
|
||||
"shasum": "{{X86_64_MACOS_SHASUM}}",
|
||||
"size": "{{X86_64_MACOS_BYTESIZE}}"
|
||||
},
|
||||
"aarch64-macos": {
|
||||
"tarball": "https://ziglang.org/builds/{{AARCH64_MACOS_TARBALL}}",
|
||||
"shasum": "{{AARCH64_MACOS_SHASUM}}",
|
||||
"size": "{{AARCH64_MACOS_BYTESIZE}}"
|
||||
},
|
||||
"x86_64-windows": {
|
||||
"tarball": "https://ziglang.org/builds/{{X86_64_WINDOWS_TARBALL}}",
|
||||
"shasum": "{{X86_64_WINDOWS_SHASUM}}",
|
||||
"size": "{{X86_64_WINDOWS_BYTESIZE}}"
|
||||
},
|
||||
"x86_64-linux": {
|
||||
"tarball": "https://ziglang.org/builds/{{X86_64_LINUX_TARBALL}}",
|
||||
"shasum": "{{X86_64_LINUX_SHASUM}}",
|
||||
"size": "{{X86_64_LINUX_BYTESIZE}}"
|
||||
},
|
||||
"aarch64-linux": {
|
||||
"tarball": "https://ziglang.org/builds/{{AARCH64_LINUX_TARBALL}}",
|
||||
"shasum": "{{AARCH64_LINUX_SHASUM}}",
|
||||
"size": "{{AARCH64_LINUX_BYTESIZE}}"
|
||||
}
|
||||
},
|
||||
"0.8.1": {
|
||||
"date": "2021-09-06",
|
||||
"docs": "https://ziglang.org/documentation/0.8.1/",
|
||||
"stdDocs": "https://ziglang.org/documentation/0.8.1/std/",
|
||||
"notes": "https://ziglang.org/download/0.8.1/release-notes.html",
|
||||
"src": {
|
||||
"tarball": "https://ziglang.org/download/0.8.1/zig-0.8.1.tar.xz",
|
||||
"shasum": "8c428e14a0a89cb7a15a6768424a37442292858cdb695e2eb503fa3c7bf47f1a",
|
||||
"size": "12650228"
|
||||
},
|
||||
"bootstrap": {
|
||||
"tarball": "https://ziglang.org/download/0.8.1/zig-bootstrap-0.8.1.tar.xz",
|
||||
"shasum": "fa1239247f830ecd51c42537043f5220e4d1dfefdc54356fa419616a0efb3902",
|
||||
"size": "43613464"
|
||||
},
|
||||
"x86_64-freebsd": {
|
||||
"tarball": "https://ziglang.org/download/0.8.1/zig-freebsd-x86_64-0.8.1.tar.xz",
|
||||
"shasum": "fc4f6478bcf3a9fce1b8ef677a91694f476dd35be6d6c9c4f44a8b76eedbe176",
|
||||
"size": "39150924"
|
||||
},
|
||||
"aarch64-linux": {
|
||||
"tarball": "https://ziglang.org/download/0.8.1/zig-linux-aarch64-0.8.1.tar.xz",
|
||||
"shasum": "2166dc9f2d8df387e8b4122883bb979d739281e1ff3f3d5483fec3a23b957510",
|
||||
"size": "37605932"
|
||||
},
|
||||
"armv7a-linux": {
|
||||
"tarball": "https://ziglang.org/download/0.8.1/zig-linux-armv7a-0.8.1.tar.xz",
|
||||
"shasum": "5ba58141805e2519f38cf8e715933cbf059f4f3dade92c71838cce341045de05",
|
||||
"size": "39185876"
|
||||
},
|
||||
"i386-linux": {
|
||||
"tarball": "https://ziglang.org/download/0.8.1/zig-linux-i386-0.8.1.tar.xz",
|
||||
"shasum": "2f3e84f30492b5f1c5f97cecc0166f07a8a8d50c5f85dbb3a6ef2a4ee6f915e6",
|
||||
"size": "44782932"
|
||||
},
|
||||
"riscv64-linux": {
|
||||
"tarball": "https://ziglang.org/download/0.8.1/zig-linux-riscv64-0.8.1.tar.xz",
|
||||
"shasum": "4adfaf147b025917c03367462fe5018aaa9edbc6439ef9cd0da2b074ae960554",
|
||||
"size": "41234480"
|
||||
},
|
||||
"x86_64-linux": {
|
||||
"tarball": "https://ziglang.org/download/0.8.1/zig-linux-x86_64-0.8.1.tar.xz",
|
||||
"shasum": "6c032fc61b5d77a3f3cf781730fa549f8f059ffdb3b3f6ad1c2994d2b2d87983",
|
||||
"size": "41250060"
|
||||
},
|
||||
"aarch64-macos": {
|
||||
"tarball": "https://ziglang.org/download/0.8.1/zig-macos-aarch64-0.8.1.tar.xz",
|
||||
"shasum": "5351297e3b8408213514b29c0a938002c5cf9f97eee28c2f32920e1227fd8423",
|
||||
"size": "35340712"
|
||||
},
|
||||
"x86_64-macos": {
|
||||
"tarball": "https://ziglang.org/download/0.8.1/zig-macos-x86_64-0.8.1.tar.xz",
|
||||
"shasum": "16b0e1defe4c1807f2e128f72863124bffdd906cefb21043c34b673bf85cd57f",
|
||||
"size": "39946200"
|
||||
},
|
||||
"i386-windows": {
|
||||
"tarball": "https://ziglang.org/download/0.8.1/zig-windows-i386-0.8.1.zip",
|
||||
"shasum": "099605051eb0452a947c8eab8fbbc7e43833c8376d267e94e41131c289a1c535",
|
||||
"size": "64152358"
|
||||
},
|
||||
"x86_64-windows": {
|
||||
"tarball": "https://ziglang.org/download/0.8.1/zig-windows-x86_64-0.8.1.zip",
|
||||
"shasum": "43573db14cd238f7111d6bdf37492d363f11ecd1eba802567a172f277d003926",
|
||||
"size": "61897838"
|
||||
}
|
||||
},
|
||||
"0.8.0": {
|
||||
"date": "2021-06-04",
|
||||
"docs": "https://ziglang.org/documentation/0.8.0/",
|
||||
"stdDocs": "https://ziglang.org/documentation/0.8.0/std/",
|
||||
"notes": "https://ziglang.org/download/0.8.0/release-notes.html",
|
||||
"src": {
|
||||
"tarball": "https://ziglang.org/download/0.8.0/zig-0.8.0.tar.xz",
|
||||
"shasum": "03a828d00c06b2e3bb8b7ff706997fd76bf32503b08d759756155b6e8c981e77",
|
||||
"size": "12614896"
|
||||
},
|
||||
"bootstrap": {
|
||||
"tarball": "https://ziglang.org/download/0.8.0/zig-bootstrap-0.8.0.tar.xz",
|
||||
"shasum": "10600bc9c01f92e343f40d6ecc0ad05d67d27c3e382bce75524c0639cd8ca178",
|
||||
"size": "43574248"
|
||||
},
|
||||
"x86_64-freebsd": {
|
||||
"tarball": "https://ziglang.org/download/0.8.0/zig-freebsd-x86_64-0.8.0.tar.xz",
|
||||
"shasum": "0d3ccc436c8c0f50fd55462f72f8492d98723c7218ffc2a8a1831967d81b4bdc",
|
||||
"size": "39125332"
|
||||
},
|
||||
"aarch64-linux": {
|
||||
"tarball": "https://ziglang.org/download/0.8.0/zig-linux-aarch64-0.8.0.tar.xz",
|
||||
"shasum": "ee204ca2c2037952cf3f8b10c609373a08a291efa4af7b3c73be0f2b27720470",
|
||||
"size": "37575428"
|
||||
},
|
||||
"armv7a-linux": {
|
||||
"tarball": "https://ziglang.org/download/0.8.0/zig-linux-armv7a-0.8.0.tar.xz",
|
||||
"shasum": "d00b8bd97b79f45d6f5da956983bafeaa082e6c2ae8c6e1c6d4faa22fa29b320",
|
||||
"size": "38884212"
|
||||
},
|
||||
"i386-linux": {
|
||||
"tarball": "https://ziglang.org/download/0.8.0/zig-linux-i386-0.8.0.tar.xz",
|
||||
"shasum": "96e43ee6ed81c3c63401f456bd1c58ee6d42373a43cb324f5cf4974ca0998865",
|
||||
"size": "42136032"
|
||||
},
|
||||
"riscv64-linux": {
|
||||
"tarball": "https://ziglang.org/download/0.8.0/zig-linux-riscv64-0.8.0.tar.xz",
|
||||
"shasum": "75997527a78cdab64c40c43d9df39c01c4cdb557bb3992a869838371a204cfea",
|
||||
"size": "40016268"
|
||||
},
|
||||
"x86_64-linux": {
|
||||
"tarball": "https://ziglang.org/download/0.8.0/zig-linux-x86_64-0.8.0.tar.xz",
|
||||
"shasum": "502625d3da3ae595c5f44a809a87714320b7a40e6dff4a895b5fa7df3391d01e",
|
||||
"size": "41211184"
|
||||
},
|
||||
"aarch64-macos": {
|
||||
"tarball": "https://ziglang.org/download/0.8.0/zig-macos-aarch64-0.8.0.tar.xz",
|
||||
"shasum": "b32d13f66d0e1ff740b3326d66a469ee6baddbd7211fa111c066d3bd57683111",
|
||||
"size": "35292180"
|
||||
},
|
||||
"x86_64-macos": {
|
||||
"tarball": "https://ziglang.org/download/0.8.0/zig-macos-x86_64-0.8.0.tar.xz",
|
||||
"shasum": "279f9360b5cb23103f0395dc4d3d0d30626e699b1b4be55e98fd985b62bc6fbe",
|
||||
"size": "39969312"
|
||||
},
|
||||
"i386-windows": {
|
||||
"tarball": "https://ziglang.org/download/0.8.0/zig-windows-i386-0.8.0.zip",
|
||||
"shasum": "b6ec9aa6cd6f3872fcb30d43ff411802d82008a0c4142ee49e208a09b2c1c5fe",
|
||||
"size": "61507213"
|
||||
},
|
||||
"x86_64-windows": {
|
||||
"tarball": "https://ziglang.org/download/0.8.0/zig-windows-x86_64-0.8.0.zip",
|
||||
"shasum": "8580fbbf3afb72e9b495c7f8aeac752a03475ae0bbcf5d787f3775c7e1f4f807",
|
||||
"size": "61766193"
|
||||
}
|
||||
},
|
||||
"0.7.1": {
|
||||
"date": "2020-12-13",
|
||||
"docs": "https://ziglang.org/documentation/0.7.1/",
|
||||
"stdDocs": "https://ziglang.org/documentation/0.7.1/std/",
|
||||
"notes": "https://ziglang.org/download/0.7.1/release-notes.html",
|
||||
"src": {
|
||||
"tarball": "https://ziglang.org/download/0.7.1/zig-0.7.1.tar.xz",
|
||||
"shasum": "2db3b944ab368d955b48743d9f7c963b8f96de1a441ba5a35e197237cc6dae44",
|
||||
"size": "10711824"
|
||||
},
|
||||
"bootstrap": {
|
||||
"tarball": "https://ziglang.org/download/0.7.1/zig-bootstrap-0.7.1.tar.xz",
|
||||
"shasum": "040f27c1fae4b0cac0a2782aecdb691f6a2f8e89db6a6ed35024c31c304fd9b2",
|
||||
"size": "40232612"
|
||||
},
|
||||
"x86_64-freebsd": {
|
||||
"tarball": "https://ziglang.org/download/0.7.1/zig-freebsd-x86_64-0.7.1.tar.xz",
|
||||
"shasum": "e73c1dca35791a3183fdd5ecde0443ebbe180942efceafe651886034fb8def09",
|
||||
"size": "39066808"
|
||||
},
|
||||
"aarch64-linux": {
|
||||
"tarball": "https://ziglang.org/download/0.7.1/zig-linux-aarch64-0.7.1.tar.xz",
|
||||
"shasum": "48ec90eba407e4587ddef7eecef25fec7e13587eb98e3b83c5f2f5fff2a5cbe7",
|
||||
"size": "33780552"
|
||||
},
|
||||
"armv7a-linux": {
|
||||
"tarball": "https://ziglang.org/download/0.7.1/zig-linux-armv7a-0.7.1.tar.xz",
|
||||
"shasum": "5a0662e07b4c4968665e1f97558f8591f6facec45d2e0ff5715e661743107ceb",
|
||||
"size": "35813504"
|
||||
},
|
||||
"i386-linux": {
|
||||
"tarball": "https://ziglang.org/download/0.7.1/zig-linux-i386-0.7.1.tar.xz",
|
||||
"shasum": "4882e052e5f83690bd0334bb4fc1702b5403cb3a3d2aa63fd7d6043d8afecba3",
|
||||
"size": "39230912"
|
||||
},
|
||||
"riscv64-linux": {
|
||||
"tarball": "https://ziglang.org/download/0.7.1/zig-linux-riscv64-0.7.1.tar.xz",
|
||||
"shasum": "187294bfd35983348c3fe042901b42e67e7e36ab7f77a5f969d21c0051f4d21f",
|
||||
"size": "37454812"
|
||||
},
|
||||
"x86_64-linux": {
|
||||
"tarball": "https://ziglang.org/download/0.7.1/zig-linux-x86_64-0.7.1.tar.xz",
|
||||
"shasum": "18c7b9b200600f8bcde1cd8d7f1f578cbc3676241ce36d771937ce19a8159b8d",
|
||||
"size": "37848176"
|
||||
},
|
||||
"x86_64-macos": {
|
||||
"tarball": "https://ziglang.org/download/0.7.1/zig-macos-x86_64-0.7.1.tar.xz",
|
||||
"shasum": "845cb17562978af0cf67e3993f4e33330525eaf01ead9386df9105111e3bc519",
|
||||
"size": "36211076"
|
||||
},
|
||||
"i386-windows": {
|
||||
"tarball": "https://ziglang.org/download/0.7.1/zig-windows-i386-0.7.1.zip",
|
||||
"shasum": "a1b9a7421e13153e07fd2e2c93ff29aad64d83105b8fcdafa633dbe689caf1c0",
|
||||
"size": "54374983"
|
||||
},
|
||||
"x86_64-windows": {
|
||||
"tarball": "https://ziglang.org/download/0.7.1/zig-windows-x86_64-0.7.1.zip",
|
||||
"shasum": "4818a8a65b4672bc52c0ae7f14d014e0eb8caf10f12c0745176820384cea296a",
|
||||
"size": "54909997"
|
||||
}
|
||||
},
|
||||
"0.7.0": {
|
||||
"date": "2020-11-08",
|
||||
"docs": "https://ziglang.org/documentation/0.7.0/",
|
||||
"stdDocs": "https://ziglang.org/documentation/0.7.0/std/",
|
||||
"notes": "https://ziglang.org/download/0.7.0/release-notes.html",
|
||||
"src": {
|
||||
"tarball": "https://ziglang.org/download/0.7.0/zig-0.7.0.tar.xz",
|
||||
"shasum": "0efd2cf6c3b05723db80e9cf193bc55150bba84ca41f855a90f53fc756445f83",
|
||||
"size": "10683920"
|
||||
},
|
||||
"bootstrap": {
|
||||
"tarball": "https://ziglang.org/download/0.7.0/zig-bootstrap-0.7.0.tar.xz",
|
||||
"shasum": "f073beaf5c53c8c57c0d374cbfcb332ef92ad703173edba0d9e0f2ed28401b72",
|
||||
"size": "40200436"
|
||||
},
|
||||
"x86_64-freebsd": {
|
||||
"tarball": "https://ziglang.org/download/0.7.0/zig-freebsd-x86_64-0.7.0.tar.xz",
|
||||
"shasum": "a0c926272ee4ae720034b4a6a1dc98399d76156dd84182554740f0ca8a41fc99",
|
||||
"size": "34798992"
|
||||
},
|
||||
"aarch64-linux": {
|
||||
"tarball": "https://ziglang.org/download/0.7.0/zig-linux-aarch64-0.7.0.tar.xz",
|
||||
"shasum": "f89933bac87d44be82325754ff88423020c81c7032a6fc41cfeb81e982eeab9b",
|
||||
"size": "33096140"
|
||||
},
|
||||
"armv7a-linux": {
|
||||
"tarball": "https://ziglang.org/download/0.7.0/zig-linux-armv7a-0.7.0.tar.xz",
|
||||
"shasum": "011c267e25a96ee160505a560c441daa045359a9d50e13ab1bada9d75c95db2d",
|
||||
"size": "35157584"
|
||||
},
|
||||
"i386-linux": {
|
||||
"tarball": "https://ziglang.org/download/0.7.0/zig-linux-i386-0.7.0.tar.xz",
|
||||
"shasum": "4bb2072cd363bcb1cbeb4872ff5cbc1f683b02d0cc1f90c46e3ea7422ce53222",
|
||||
"size": "38530596"
|
||||
},
|
||||
"riscv64-linux": {
|
||||
"tarball": "https://ziglang.org/download/0.7.0/zig-linux-riscv64-0.7.0.tar.xz",
|
||||
"shasum": "40dff81faa6f232ac40abbf88b9371f3cc932b6e09c423b94387c9ea580cb7be",
|
||||
"size": "36759992"
|
||||
},
|
||||
"x86_64-linux": {
|
||||
"tarball": "https://ziglang.org/download/0.7.0/zig-linux-x86_64-0.7.0.tar.xz",
|
||||
"shasum": "e619b1c6094c095b932767f527aee2507f847ea981513ff8a08aab0fd730e0ac",
|
||||
"size": "37154432"
|
||||
},
|
||||
"aarch64-macos": {
|
||||
"tarball": "https://ziglang.org/download/0.7.0/zig-macos-aarch64-0.7.0.tar.xz",
|
||||
"shasum": "338238035734db74ea4f30e500a4893bf741d38305c10952d5e39fa05bdb057d",
|
||||
"size": "33739424"
|
||||
},
|
||||
"x86_64-macos": {
|
||||
"tarball": "https://ziglang.org/download/0.7.0/zig-macos-x86_64-0.7.0.tar.xz",
|
||||
"shasum": "94063f9a311cbbf7a2e0a12295e09437182cf950f18cb0eb30ea9893f3677f24",
|
||||
"size": "35258328"
|
||||
},
|
||||
"i386-windows": {
|
||||
"tarball": "https://ziglang.org/download/0.7.0/zig-windows-i386-0.7.0.zip",
|
||||
"shasum": "b1e520aacbfbd645ff3521b3eb4d44166d9a0288b8725e4b001f8b50a425eb2e",
|
||||
"size": "53390517"
|
||||
},
|
||||
"x86_64-windows": {
|
||||
"tarball": "https://ziglang.org/download/0.7.0/zig-windows-x86_64-0.7.0.zip",
|
||||
"shasum": "965f56c0a36f9cda2125e3a348bc654f7f155e2804c3667d231775ec228f8553",
|
||||
"size": "53943784"
|
||||
}
|
||||
},
|
||||
"0.6.0": {
|
||||
"date": "2020-04-13",
|
||||
"docs": "https://ziglang.org/documentation/0.6.0/",
|
||||
"stdDocs": "https://ziglang.org/documentation/0.6.0/std/",
|
||||
"notes": "https://ziglang.org/download/0.6.0/release-notes.html",
|
||||
"src": {
|
||||
"tarball": "https://ziglang.org/download/0.6.0/zig-0.6.0.tar.xz",
|
||||
"shasum": "5d167dc19354282dd35dd17b38e99e1763713b9be8a4ba9e9e69284e059e7204",
|
||||
"size": "10349552"
|
||||
},
|
||||
"bootstrap": {
|
||||
"tarball": "https://ziglang.org/download/0.6.0/zig-bootstrap-0.6.0.tar.xz",
|
||||
"shasum": "5e0e4dc878b3dd0c1852a442b174f0732e8c07869a8fcd226b71a93b89b381ab",
|
||||
"size": "38469948"
|
||||
},
|
||||
"x86_64-freebsd": {
|
||||
"tarball": "https://ziglang.org/download/0.6.0/zig-freebsd-x86_64-0.6.0.tar.xz",
|
||||
"shasum": "190ff79c1eb56805a315d7c7a51082e32f62926250c0702b36760c225e1634a3",
|
||||
"size": "36974604"
|
||||
},
|
||||
"aarch64-linux": {
|
||||
"tarball": "https://ziglang.org/download/0.6.0/zig-linux-aarch64-0.6.0.tar.xz",
|
||||
"shasum": "e7520efd42cfa02be48c2e430d08fe1f3cbb999d21d9f0d3ffd0febb976b2f41",
|
||||
"size": "37090044"
|
||||
},
|
||||
"armv6kz-linux": {
|
||||
"tarball": "https://ziglang.org/download/0.6.0/zig-linux-armv6kz-0.6.0.tar.xz",
|
||||
"shasum": "36b6493b3fed43eb1f0000e765798ad31a6bb7d7fd3f553ac1c3761dbc919b82",
|
||||
"size": "39133452"
|
||||
},
|
||||
"armv7a-linux": {
|
||||
"tarball": "https://ziglang.org/download/0.6.0/zig-linux-armv7a-0.6.0.tar.xz",
|
||||
"shasum": "946969abe357def95ca9cbbfcebfcf2d90cf967bcd3f48ee87662e32d91d8f35",
|
||||
"size": "39143748"
|
||||
},
|
||||
"i386-linux": {
|
||||
"tarball": "https://ziglang.org/download/0.6.0/zig-linux-i386-0.6.0.tar.xz",
|
||||
"shasum": "a97a2f9ae21575743cdd763c1917d49400d83fc562ef64582b18bade43eb24ce",
|
||||
"size": "44877640"
|
||||
},
|
||||
"riscv64-linux": {
|
||||
"tarball": "https://ziglang.org/download/0.6.0/zig-linux-riscv64-0.6.0.tar.xz",
|
||||
"shasum": "68ddee43f7503c8ae5f26a921f3602c34719a02ed2241f528c0b8b888cc14b38",
|
||||
"size": "41993144"
|
||||
},
|
||||
"x86_64-linux": {
|
||||
"tarball": "https://ziglang.org/download/0.6.0/zig-linux-x86_64-0.6.0.tar.xz",
|
||||
"shasum": "08fd3c757963630645441c2772362e9c2294020c44f14fce1b89f45de0dc1253",
|
||||
"size": "44766320"
|
||||
},
|
||||
"x86_64-macos": {
|
||||
"tarball": "https://ziglang.org/download/0.6.0/zig-macos-x86_64-0.6.0.tar.xz",
|
||||
"shasum": "17270360e87ddc49f737e760047b2fac49f1570a824a306119b1194ac4093895",
|
||||
"size": "42573184"
|
||||
},
|
||||
"i386-windows": {
|
||||
"tarball": "https://ziglang.org/download/0.6.0/zig-windows-i386-0.6.0.zip",
|
||||
"shasum": "3b0a02618743e92175990dc6d1a787bb95ff62c4cda016f1c14c7786f575f8ca",
|
||||
"size": "60446431"
|
||||
},
|
||||
"x86_64-windows": {
|
||||
"tarball": "https://ziglang.org/download/0.6.0/zig-windows-x86_64-0.6.0.zip",
|
||||
"shasum": "c3b897832523e1026e10b2d8d55d7f895185c0a27a63681f3a23219c3f1c38f4",
|
||||
"size": "49065511"
|
||||
}
|
||||
},
|
||||
"0.5.0": {
|
||||
"date": "2019-09-30",
|
||||
"docs": "https://ziglang.org/documentation/0.5.0/",
|
||||
"notes": "https://ziglang.org/download/0.5.0/release-notes.html",
|
||||
"src": {
|
||||
"tarball": "https://ziglang.org/download/0.5.0/zig-0.5.0.tar.xz",
|
||||
"shasum": "55ae16960f152bcb9cf98b4f8570902d0e559a141abf927f0d3555b7cc838a31",
|
||||
"size": "10956132"
|
||||
},
|
||||
"x86_64-freebsd": {
|
||||
"tarball": "https://ziglang.org/download/0.5.0/zig-freebsd-x86_64-0.5.0.tar.xz",
|
||||
"shasum": "9e1f4d36c3d584c0aa01f20eb4cd0a0eef3eee5af23e483b8414de55feab6ab6",
|
||||
"size": "33650744"
|
||||
},
|
||||
"x86_64-macos": {
|
||||
"tarball": "https://ziglang.org/download/0.5.0/zig-macos-x86_64-0.5.0.tar.xz",
|
||||
"shasum": "28702cc05745c7c0bd450487d5f4091bf0a1ad279b35eb9a640ce3e3a15b300d",
|
||||
"size": "37898664"
|
||||
},
|
||||
"x86_64-windows": {
|
||||
"tarball": "https://ziglang.org/download/0.5.0/zig-windows-x86_64-0.5.0.zip",
|
||||
"shasum": "58141323db8d84a5af62746be5f9140bc161ee760ef33dc91a887bf9ac021976",
|
||||
"size": "44871804"
|
||||
},
|
||||
"x86_64-linux": {
|
||||
"tarball": "https://ziglang.org/download/0.5.0/zig-linux-x86_64-0.5.0.tar.xz",
|
||||
"shasum": "43e8f8a8b8556edd373ddf9c1ef3ca6cf852d4d09fe07d5736d12fefedd2b4f7",
|
||||
"size": "40895068"
|
||||
}
|
||||
},
|
||||
"0.4.0": {
|
||||
"date": "2019-04-08",
|
||||
"docs": "https://ziglang.org/documentation/0.4.0/",
|
||||
"notes": "https://ziglang.org/download/0.4.0/release-notes.html",
|
||||
"src": {
|
||||
"tarball": "https://ziglang.org/download/0.4.0/zig-0.4.0.tar.xz",
|
||||
"shasum": "fec1f3f6b359a3d942e0a7f9157b3b30cde83927627a0e1ea95c54de3c526cfc",
|
||||
"size": "5348776"
|
||||
},
|
||||
"x86_64-freebsd": {
|
||||
"tarball": "https://ziglang.org/download/0.4.0/zig-freebsd-x86_64-0.4.0.tar.xz",
|
||||
"shasum": "3d557c91ac36d8262eb1733bb5f261c95944f9b635e43386e3d00a3272818c30",
|
||||
"size": "27269672"
|
||||
},
|
||||
"x86_64-macos": {
|
||||
"tarball": "https://ziglang.org/download/0.4.0/zig-macos-x86_64-0.4.0.tar.xz",
|
||||
"shasum": "67c932982484d017c5111e54af9f33f15e8e05c6bc5346a55e04052159c964a8",
|
||||
"size": "30841504"
|
||||
},
|
||||
"x86_64-windows": {
|
||||
"tarball": "https://ziglang.org/download/0.4.0/zig-windows-x86_64-0.4.0.zip",
|
||||
"shasum": "fbc3dd205e064c263063f69f600bedb18e3d0aa2efa747a63ef6cafb6d73f127",
|
||||
"size": "35800101"
|
||||
},
|
||||
"x86_64-linux": {
|
||||
"tarball": "https://ziglang.org/download/0.4.0/zig-linux-x86_64-0.4.0.tar.xz",
|
||||
"shasum": "fb1954e2fb556a01f8079a08130e88f70084e08978ff853bb2b1986d8c39d84e",
|
||||
"size": "32876100"
|
||||
}
|
||||
},
|
||||
"0.3.0": {
|
||||
"date": "2018-09-28",
|
||||
"docs": "https://ziglang.org/documentation/0.3.0/",
|
||||
"notes": "https://ziglang.org/download/0.3.0/release-notes.html",
|
||||
"src": {
|
||||
"tarball": "https://ziglang.org/download/0.3.0/zig-0.3.0.tar.xz",
|
||||
"shasum": "d70af604f3a8622f3393d93abb3e056bf60351e32d121e6fa4fe03d8d41e1f5a",
|
||||
"size": "2335592"
|
||||
},
|
||||
"x86_64-macos": {
|
||||
"tarball": "https://ziglang.org/download/0.3.0/zig-macos-x86_64-0.3.0.tar.xz",
|
||||
"shasum": "19dec1f1943ab7be26823376d466f7e456143deb34e17502778a949034dc2e7e",
|
||||
"size": "23712696"
|
||||
},
|
||||
"x86_64-windows": {
|
||||
"tarball": "https://ziglang.org/download/0.3.0/zig-windows-x86_64-0.3.0.zip",
|
||||
"shasum": "bb568c03950958f8bb3472139c3ab5ed74547c8c694ab50f404c202faf51baf4",
|
||||
"size": "22524425"
|
||||
},
|
||||
"x86_64-linux": {
|
||||
"tarball": "https://ziglang.org/download/0.3.0/zig-linux-x86_64-0.3.0.tar.xz",
|
||||
"shasum": "b378d0aae30cb54f28494e7bc4efbc9bfb6326f47bfb302e8b5287af777b2f3c",
|
||||
"size": "25209304"
|
||||
}
|
||||
},
|
||||
"0.2.0": {
|
||||
"date": "2018-03-15",
|
||||
"docs": "https://ziglang.org/documentation/0.2.0/",
|
||||
"notes": "https://ziglang.org/download/0.2.0/release-notes.html",
|
||||
"src": {
|
||||
"tarball": "https://ziglang.org/download/0.2.0/zig-0.2.0.tar.xz",
|
||||
"shasum": "29c9beb172737f4d5019b88ceae829ae8bc6512fb4386cfbf895ae2b42aa6965",
|
||||
"size": "1940832"
|
||||
},
|
||||
"x86_64-windows": {
|
||||
"tarball": "https://ziglang.org/download/0.2.0/zig-win64-0.2.0.zip",
|
||||
"shasum": "4f8a2979941a1f081ec8e545cca0b72608c0db1c5a3fd377a94db40649dcd3d4",
|
||||
"size": "21076274"
|
||||
},
|
||||
"x86_64-linux": {
|
||||
"tarball": "https://ziglang.org/download/0.2.0/zig-linux-x86_64-0.2.0.tar.xz",
|
||||
"shasum": "209c6fb745d42474c0a73d6f291c7ae3a38b6a1b6b641eea285a7f840cc1a890",
|
||||
"size": "22551928"
|
||||
}
|
||||
},
|
||||
"0.1.1": {
|
||||
"date": "2017-10-17",
|
||||
"docs": "https://ziglang.org/documentation/0.1.1/",
|
||||
"notes": "https://ziglang.org/download/0.1.1/release-notes.html",
|
||||
"src": {
|
||||
"tarball": "https://ziglang.org/download/0.1.1/zig-0.1.1.tar.xz",
|
||||
"shasum": "ffca0cfb263485287e19cc997b08701fcd5f24b700345bcdc3dd8074f5a104e0",
|
||||
"size": "1659716"
|
||||
},
|
||||
"x86_64-windows": {
|
||||
"tarball": "https://ziglang.org/download/0.1.1/zig-win64-0.1.1.zip",
|
||||
"shasum": "6fc88bef531af7e567fe30bf60da1487b86833cbee84c7a2f3e317030aa5b660",
|
||||
"size": "19757776"
|
||||
}
|
||||
}
|
||||
}
|
||||
97
ci/srht/netbsd_script
Executable file
97
ci/srht/netbsd_script
Executable file
@@ -0,0 +1,97 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -x
|
||||
set -e
|
||||
|
||||
sudo pkgin -y update
|
||||
sudo pkgin -y upgrade
|
||||
sudo pkgin -y install cmake samurai curl jq py27-s3cmd wget clang
|
||||
|
||||
ZIGDIR="$(pwd)"
|
||||
CACHE_BASENAME="zig+llvm+lld+clang-x86_64-netbsd-gnu-0.8.0"
|
||||
PREFIX="$HOME/$CACHE_BASENAME"
|
||||
|
||||
cd $HOME
|
||||
wget -nv "https://ziglang.org/deps/$CACHE_BASENAME.tar.xz"
|
||||
tar xf "$CACHE_BASENAME.tar.xz"
|
||||
|
||||
cd $ZIGDIR
|
||||
|
||||
# Make the `zig version` number consistent.
|
||||
# This will affect the cmake command below.
|
||||
git config core.abbrev 9
|
||||
git fetch --unshallow || true
|
||||
git fetch --tags
|
||||
|
||||
# SourceHut reports that it is a terminal that supports escape codes, but it
|
||||
# is a filthy liar. Here we tell Zig to not try to send any terminal escape
|
||||
# codes to show progress.
|
||||
export TERM=dumb
|
||||
|
||||
mkdir build
|
||||
cd build
|
||||
export CC="$PREFIX/bin/zigcc"
|
||||
export CXX="$PREFIX/bin/zigcxx"
|
||||
echo "#!/bin/sh
|
||||
env CC=\"clang\" $PREFIX/bin/zig cc \"\$@\"" > $CC
|
||||
echo "#!/bin/sh
|
||||
env CC=\"clang\" $PREFIX/bin/zig c++ \"\$@\"" > $CXX
|
||||
chmod +x $CC
|
||||
chmod +x $CXX
|
||||
|
||||
cmake .. \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_PREFIX_PATH=$PREFIX \
|
||||
"-DCMAKE_INSTALL_PREFIX=$(pwd)/release" \
|
||||
-DZIG_STATIC=ON \
|
||||
-DZIG_TARGET_TRIPLE=x86_64-netbsd-none \
|
||||
-GNinja
|
||||
samu install
|
||||
|
||||
unset CC
|
||||
unset CXX
|
||||
|
||||
# TODO ld.lld: error: undefined symbol: main
|
||||
#>>> referenced by crt0-common.c
|
||||
#>>> /usr/lib/crt0.o:(___start)
|
||||
#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
|
||||
|
||||
if [ -f ~/.s3cfg ]; then
|
||||
mv ../LICENSE release/
|
||||
mv ../zig-cache/langref.html release/
|
||||
mv release/bin/zig release/
|
||||
rmdir release/bin
|
||||
|
||||
GITBRANCH=$(basename $GITHUB_REF)
|
||||
VERSION=$(release/zig version)
|
||||
DIRNAME="zig-netbsd-x86_64-$VERSION"
|
||||
TARBALL="$DIRNAME.tar.xz"
|
||||
mv release "$DIRNAME"
|
||||
tar cfJ "$TARBALL" "$DIRNAME"
|
||||
|
||||
s3cmd put -P --add-header="cache-control: public, max-age=31536000, immutable" "$TARBALL" s3://ziglang.org/builds/
|
||||
|
||||
SHASUM=$(shasum -a 256 $TARBALL | cut '-d ' -f1)
|
||||
BYTESIZE=$(wc -c < $TARBALL)
|
||||
|
||||
JSONFILE="netbsd-$GITBRANCH.json"
|
||||
touch $JSONFILE
|
||||
echo "{\"tarball\": \"$TARBALL\"," >>$JSONFILE
|
||||
echo "\"shasum\": \"$SHASUM\"," >>$JSONFILE
|
||||
echo "\"size\": \"$BYTESIZE\"}" >>$JSONFILE
|
||||
|
||||
s3cmd put -P --add-header="Cache-Control: max-age=0, must-revalidate" "$JSONFILE" "s3://ziglang.org/builds/$JSONFILE"
|
||||
s3cmd put -P "$JSONFILE" "s3://ziglang.org/builds/x86_64-netbsd-$VERSION.json"
|
||||
|
||||
if [ "$GITBRANCH" = "master" ]; then
|
||||
# avoid leaking oauth token
|
||||
set +x
|
||||
|
||||
OAUTH_TOKEN="$(cat ~/.oauth_token)"
|
||||
cd "$ZIGDIR"
|
||||
./ci/srht/on_master_success "$VERSION" "$OAUTH_TOKEN"
|
||||
fi
|
||||
fi
|
||||
50
ci/srht/on_master_success
Executable file
50
ci/srht/on_master_success
Executable file
@@ -0,0 +1,50 @@
|
||||
#!/bin/sh
|
||||
|
||||
# This script must run on a lot of different platforms.
|
||||
# It assumes that the following things are installed:
|
||||
# * curl
|
||||
# * jq
|
||||
# * cat
|
||||
|
||||
# We do not set -x because this would leak the oauth access token.
|
||||
set +x
|
||||
|
||||
set -e
|
||||
|
||||
VERSION="$1"
|
||||
OAUTH_TOKEN="$2"
|
||||
YML_FILE="tmp.yml"
|
||||
|
||||
if [ -z "$VERSION" ]; then
|
||||
echo "missing VERSION parameter"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$OAUTH_TOKEN" ]; then
|
||||
echo "missing OAUTH_TOKEN parameter"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cat <<EOF >"$YML_FILE"
|
||||
image: alpine/latest
|
||||
packages:
|
||||
- py3-pip
|
||||
- curl
|
||||
- jq
|
||||
- xz
|
||||
secrets:
|
||||
- 51bfddf5-86a6-4e01-8576-358c72a4a0a4
|
||||
- 44e2bd57-1d07-42bf-925e-22a36119041d
|
||||
sources:
|
||||
- https://github.com/ziglang/zig
|
||||
tasks:
|
||||
- build: cd zig && ./ci/srht/update_download_page $VERSION
|
||||
EOF
|
||||
|
||||
jq <$YML_FILE -sR '{
|
||||
"manifest": .,
|
||||
}' | curl \
|
||||
-H Authorization:"token $OAUTH_TOKEN" \
|
||||
-H Content-Type:application/json \
|
||||
-X POST \
|
||||
-d @- "https://builds.hut.lavatech.top/api/jobs"
|
||||
99
ci/srht/update-download-page.zig
Normal file
99
ci/srht/update-download-page.zig
Normal file
@@ -0,0 +1,99 @@
|
||||
const std = @import("std");
|
||||
const path = std.fs.path;
|
||||
const mem = std.mem;
|
||||
|
||||
pub fn main() !void {
|
||||
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
|
||||
defer arena.deinit();
|
||||
|
||||
const allocator = arena.allocator();
|
||||
|
||||
const out_dir = "out";
|
||||
try std.fs.cwd().makePath(out_dir);
|
||||
{
|
||||
const out_file = out_dir ++ path.sep_str ++ "index.json";
|
||||
const in_file = "index.json";
|
||||
try render(allocator, in_file, out_file, .plain);
|
||||
}
|
||||
}
|
||||
|
||||
fn render(
|
||||
allocator: mem.Allocator,
|
||||
in_file: []const u8,
|
||||
out_file: []const u8,
|
||||
fmt: enum {
|
||||
html,
|
||||
plain,
|
||||
},
|
||||
) !void {
|
||||
const in_contents = try std.fs.cwd().readFileAlloc(allocator, in_file, 1 * 1024 * 1024);
|
||||
|
||||
var vars = try std.process.getEnvMap(allocator);
|
||||
|
||||
var buffer = std.ArrayList(u8).init(allocator);
|
||||
defer buffer.deinit();
|
||||
|
||||
const State = enum {
|
||||
Start,
|
||||
OpenBrace,
|
||||
VarName,
|
||||
EndBrace,
|
||||
};
|
||||
const writer = buffer.writer();
|
||||
var state = State.Start;
|
||||
var var_name_start: usize = undefined;
|
||||
var line: usize = 1;
|
||||
for (in_contents) |byte, index| {
|
||||
switch (state) {
|
||||
State.Start => switch (byte) {
|
||||
'{' => {
|
||||
state = State.OpenBrace;
|
||||
},
|
||||
else => try writer.writeByte(byte),
|
||||
},
|
||||
State.OpenBrace => switch (byte) {
|
||||
'{' => {
|
||||
state = State.VarName;
|
||||
var_name_start = index + 1;
|
||||
},
|
||||
else => {
|
||||
try writer.writeByte('{');
|
||||
try writer.writeByte(byte);
|
||||
state = State.Start;
|
||||
},
|
||||
},
|
||||
State.VarName => switch (byte) {
|
||||
'}' => {
|
||||
const var_name = in_contents[var_name_start..index];
|
||||
if (vars.get(var_name)) |value| {
|
||||
const trimmed = mem.trim(u8, value, " \r\n");
|
||||
if (fmt == .html and mem.endsWith(u8, var_name, "BYTESIZE")) {
|
||||
const size = try std.fmt.parseInt(u64, trimmed, 10);
|
||||
try writer.print("{:.1}", .{std.fmt.fmtIntSizeDec(size)});
|
||||
} else {
|
||||
try writer.writeAll(trimmed);
|
||||
}
|
||||
} else {
|
||||
std.debug.print("line {d}: missing variable: {s}\n", .{ line, var_name });
|
||||
try writer.writeAll("(missing)");
|
||||
}
|
||||
state = State.EndBrace;
|
||||
},
|
||||
else => {},
|
||||
},
|
||||
State.EndBrace => switch (byte) {
|
||||
'}' => {
|
||||
state = State.Start;
|
||||
},
|
||||
else => {
|
||||
std.debug.print("line {d}: invalid byte: '0x{x}'", .{ line, byte });
|
||||
std.process.exit(1);
|
||||
},
|
||||
},
|
||||
}
|
||||
if (byte == '\n') {
|
||||
line += 1;
|
||||
}
|
||||
}
|
||||
try std.fs.cwd().writeFile(out_file, buffer.items);
|
||||
}
|
||||
119
ci/srht/update_download_page
Executable file
119
ci/srht/update_download_page
Executable file
@@ -0,0 +1,119 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -x
|
||||
set -e
|
||||
|
||||
VERSION="$1"
|
||||
SRCDIR="$(pwd)"
|
||||
NATIVE_TARBALL="zig-linux-$(uname -m)-$VERSION.tar.xz"
|
||||
|
||||
# Check for all the builds being completed. It's expected that this script is run several times
|
||||
# before they are all complete.
|
||||
AARCH64_LINUX_JSON_URL="https://ziglang.org/builds/aarch64-linux-$VERSION.json"
|
||||
X86_64_LINUX_JSON_URL="https://ziglang.org/builds/x86_64-linux-$VERSION.json"
|
||||
X86_64_WINDOWS_JSON_URL="https://ziglang.org/builds/x86_64-windows-$VERSION.json"
|
||||
AARCH64_MACOS_JSON_URL="https://ziglang.org/builds/aarch64-macos-$VERSION.json"
|
||||
X86_64_MACOS_JSON_URL="https://ziglang.org/builds/x86_64-macos-$VERSION.json"
|
||||
X86_64_FREEBSD_JSON_URL="https://ziglang.org/builds/x86_64-freebsd-$VERSION.json"
|
||||
#X86_64_NETBSD_JSON_URL="https://ziglang.org/builds/x86_64-netbsd-$VERSION.json"
|
||||
|
||||
# If any of these fail, it's not really this job failing; rather we have detected
|
||||
# that this job will be called again later when other jobs have completed.
|
||||
curl --fail -I "$AARCH64_LINUX_JSON_URL" >/dev/null || exit 0
|
||||
curl --fail -I "$X86_64_LINUX_JSON_URL" >/dev/null || exit 0
|
||||
curl --fail -I "$X86_64_WINDOWS_JSON_URL" >/dev/null || exit 0
|
||||
curl --fail -I "$AARCH64_MACOS_JSON_URL" >/dev/null || exit 0
|
||||
curl --fail -I "$X86_64_MACOS_JSON_URL" >/dev/null || exit 0
|
||||
curl --fail -I "$X86_64_FREEBSD_JSON_URL" >/dev/null || exit 0
|
||||
#curl --fail -I "$X86_64_NETBSD_JSON_URL" >/dev/null || exit 0
|
||||
|
||||
# Without --user, this gave me:
|
||||
# ERROR: Could not install packages due to an EnvironmentError: [Errno 13] Permission denied
|
||||
pip3 install s3cmd --user
|
||||
S3CMD="$HOME/.local/bin/s3cmd"
|
||||
|
||||
# This is the user when pushing to the website repo.
|
||||
git config --global user.email "ziggy@ziglang.org"
|
||||
git config --global user.name "Ziggy"
|
||||
|
||||
# Refresh this with `ssh-keyscan github.com` from a trusted Internet connection.
|
||||
# We hard code the public key here to detect man-in-the-middle attacks.
|
||||
echo "github.com ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==" >> ~/.ssh/known_hosts
|
||||
|
||||
# We don't want the .git folder inside the tarball.
|
||||
rm -rf .git
|
||||
|
||||
cd "$HOME"
|
||||
wget "https://ziglang.org/builds/$NATIVE_TARBALL"
|
||||
tar xf "$NATIVE_TARBALL"
|
||||
ZIGDIR="$(pwd)/$(basename $NATIVE_TARBALL .tar.xz)"
|
||||
ZIG="$ZIGDIR/zig"
|
||||
LANGREF="$ZIGDIR/docs/langref.html"
|
||||
SRCTARBALLDIR="zig-$VERSION"
|
||||
export SRC_TARBALL="$SRCTARBALLDIR.tar.xz"
|
||||
mv "$SRCDIR" "$SRCTARBALLDIR"
|
||||
tar cfJ "$SRC_TARBALL" "$SRCTARBALLDIR"
|
||||
export SRC_SHASUM=$(sha256sum $SRC_TARBALL | cut '-d ' -f1)
|
||||
export SRC_BYTESIZE=$(wc -c < $SRC_TARBALL)
|
||||
|
||||
X86_64_WINDOWS_JSON=$(curl --fail "$X86_64_WINDOWS_JSON_URL" || exit 1)
|
||||
export X86_64_WINDOWS_TARBALL="$(echo "$X86_64_WINDOWS_JSON" | jq .tarball -r)"
|
||||
export X86_64_WINDOWS_BYTESIZE="$(echo "$X86_64_WINDOWS_JSON" | jq .size -r)"
|
||||
export X86_64_WINDOWS_SHASUM="$(echo "$X86_64_WINDOWS_JSON" | jq .shasum -r)"
|
||||
|
||||
AARCH64_MACOS_JSON=$(curl --fail "$AARCH64_MACOS_JSON_URL" || exit 1)
|
||||
export AARCH64_MACOS_TARBALL="$(echo "$AARCH64_MACOS_JSON" | jq .tarball -r)"
|
||||
export AARCH64_MACOS_BYTESIZE="$(echo "$AARCH64_MACOS_JSON" | jq .size -r)"
|
||||
export AARCH64_MACOS_SHASUM="$(echo "$AARCH64_MACOS_JSON" | jq .shasum -r)"
|
||||
|
||||
X86_64_MACOS_JSON=$(curl --fail "$X86_64_MACOS_JSON_URL" || exit 1)
|
||||
export X86_64_MACOS_TARBALL="$(echo "$X86_64_MACOS_JSON" | jq .tarball -r)"
|
||||
export X86_64_MACOS_BYTESIZE="$(echo "$X86_64_MACOS_JSON" | jq .size -r)"
|
||||
export X86_64_MACOS_SHASUM="$(echo "$X86_64_MACOS_JSON" | jq .shasum -r)"
|
||||
|
||||
X86_64_LINUX_JSON=$(curl --fail "$X86_64_LINUX_JSON_URL" || exit 1)
|
||||
export X86_64_LINUX_TARBALL="$(echo "$X86_64_LINUX_JSON" | jq .tarball -r)"
|
||||
export X86_64_LINUX_BYTESIZE="$(echo "$X86_64_LINUX_JSON" | jq .size -r)"
|
||||
export X86_64_LINUX_SHASUM="$(echo "$X86_64_LINUX_JSON" | jq .shasum -r)"
|
||||
|
||||
AARCH64_LINUX_JSON=$(curl --fail "$AARCH64_LINUX_JSON_URL" || exit 1)
|
||||
export AARCH64_LINUX_TARBALL="$(echo "$AARCH64_LINUX_JSON" | jq .tarball -r)"
|
||||
export AARCH64_LINUX_BYTESIZE="$(echo "$AARCH64_LINUX_JSON" | jq .size -r)"
|
||||
export AARCH64_LINUX_SHASUM="$(echo "$AARCH64_LINUX_JSON" | jq .shasum -r)"
|
||||
|
||||
X86_64_FREEBSD_JSON=$(curl --fail "$X86_64_FREEBSD_JSON_URL" || exit 1)
|
||||
export X86_64_FREEBSD_TARBALL="$(echo "$X86_64_FREEBSD_JSON" | jq .tarball -r)"
|
||||
export X86_64_FREEBSD_BYTESIZE="$(echo "$X86_64_FREEBSD_JSON" | jq .size -r)"
|
||||
export X86_64_FREEBSD_SHASUM="$(echo "$X86_64_FREEBSD_JSON" | jq .shasum -r)"
|
||||
|
||||
#X86_64_NETBSD_JSON=$(curl --fail "$X86_64_NETBSD_JSON_URL" || exit 1)
|
||||
#export X86_64_NETBSD_TARBALL="$(echo "$X86_64_NETBSD_JSON" | jq .tarball -r)"
|
||||
#export X86_64_NETBSD_BYTESIZE="$(echo "$X86_64_NETBSD_JSON" | jq .size -r)"
|
||||
#export X86_64_NETBSD_SHASUM="$(echo "$X86_64_NETBSD_JSON" | jq .shasum -r)"
|
||||
|
||||
export MASTER_DATE="$(date +%Y-%m-%d)"
|
||||
export MASTER_VERSION="$VERSION"
|
||||
|
||||
# Create index.json and update the website repo.
|
||||
cd "$SRCTARBALLDIR/ci/srht"
|
||||
"$ZIG" run update-download-page.zig
|
||||
CIDIR="$(pwd)"
|
||||
|
||||
cd "$HOME"
|
||||
git clone --depth 1 git@github.com:ziglang/www.ziglang.org.git
|
||||
cd www.ziglang.org
|
||||
WWWDIR="$(pwd)"
|
||||
|
||||
$S3CMD put -P --no-mime-magic --add-header="cache-control: public, max-age=31536000, immutable" "$HOME/$SRC_TARBALL" s3://ziglang.org/builds/
|
||||
|
||||
cd "$WWWDIR"
|
||||
cp "$CIDIR/out/index.json" data/releases.json
|
||||
mkdir -p content/documentation/master/std
|
||||
cp "$LANGREF" content/documentation/master/index.html
|
||||
cp "$ZIGDIR/docs/std/index.html" content/documentation/master/std/index.html
|
||||
cp "$ZIGDIR/docs/std/data.js" content/documentation/master/std/data.js
|
||||
cp "$ZIGDIR/docs/std/main.js" content/documentation/master/std/main.js
|
||||
git add data/releases.json
|
||||
git add content/
|
||||
git commit -m "CI: update releases and docs"
|
||||
git push origin master
|
||||
@@ -1,72 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Requires cmake ninja-build
|
||||
|
||||
set -x
|
||||
set -e
|
||||
|
||||
ARCH="$(uname -m)"
|
||||
TARGET="$ARCH-linux-musl"
|
||||
MCPU="baseline"
|
||||
CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.11.0-dev.971+19056cb68"
|
||||
PREFIX="$HOME/deps/$CACHE_BASENAME"
|
||||
ZIG="$PREFIX/bin/zig"
|
||||
|
||||
export PATH="$HOME/deps/wasmtime-v2.0.2-$ARCH-linux:$HOME/deps/qemu-linux-x86_64-6.1.0.1/bin:$PATH"
|
||||
|
||||
# Make the `zig version` number consistent.
|
||||
# This will affect the cmake command below.
|
||||
git config core.abbrev 9
|
||||
git fetch --unshallow || true
|
||||
git fetch --tags
|
||||
|
||||
export CC="$ZIG cc -target $TARGET -mcpu=$MCPU"
|
||||
export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU"
|
||||
|
||||
rm -rf build-debug
|
||||
mkdir build-debug
|
||||
cd build-debug
|
||||
|
||||
# Override the cache directories because they won't actually help other CI runs
|
||||
# which will be testing alternate versions of zig, and ultimately would just
|
||||
# fill up space on the hard drive for no reason.
|
||||
export ZIG_GLOBAL_CACHE_DIR="$(pwd)/zig-global-cache"
|
||||
export ZIG_LOCAL_CACHE_DIR="$(pwd)/zig-local-cache"
|
||||
|
||||
cmake .. \
|
||||
-DCMAKE_INSTALL_PREFIX="stage3-debug" \
|
||||
-DCMAKE_PREFIX_PATH="$PREFIX" \
|
||||
-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
|
||||
|
||||
echo "Looking for non-conforming code formatting..."
|
||||
stage3-debug/bin/zig fmt --check .. \
|
||||
--exclude ../test/cases/ \
|
||||
--exclude ../build-debug
|
||||
|
||||
# simultaneously test building self-hosted without LLVM and with 32-bit arm
|
||||
stage3-debug/bin/zig build -Dtarget=arm-linux-musleabihf
|
||||
|
||||
stage3-debug/bin/zig build test docs \
|
||||
-fqemu \
|
||||
-fwasmtime \
|
||||
-Dstatic-llvm \
|
||||
-Dtarget=native-native-musl \
|
||||
--search-prefix "$PREFIX" \
|
||||
--zig-lib-dir "$(pwd)/../lib"
|
||||
|
||||
# Look for HTML errors.
|
||||
tidy --drop-empty-elements no -qe "$ZIG_LOCAL_CACHE_DIR/langref.html"
|
||||
|
||||
# Produce the experimental std lib documentation.
|
||||
stage3-debug/bin/zig test ../lib/std/std.zig -femit-docs -fno-emit-bin --zig-lib-dir ../lib
|
||||
@@ -1,73 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Requires cmake ninja-build
|
||||
|
||||
set -x
|
||||
set -e
|
||||
|
||||
ARCH="$(uname -m)"
|
||||
TARGET="$ARCH-linux-musl"
|
||||
MCPU="baseline"
|
||||
CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.11.0-dev.971+19056cb68"
|
||||
PREFIX="$HOME/deps/$CACHE_BASENAME"
|
||||
ZIG="$PREFIX/bin/zig"
|
||||
|
||||
export PATH="$HOME/deps/wasmtime-v2.0.2-$ARCH-linux:$HOME/deps/qemu-linux-x86_64-6.1.0.1/bin:$PATH"
|
||||
|
||||
# Make the `zig version` number consistent.
|
||||
# This will affect the cmake command below.
|
||||
git config core.abbrev 9
|
||||
git fetch --unshallow || true
|
||||
git fetch --tags
|
||||
|
||||
export CC="$ZIG cc -target $TARGET -mcpu=$MCPU"
|
||||
export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU"
|
||||
|
||||
rm -rf build-release
|
||||
mkdir build-release
|
||||
cd build-release
|
||||
|
||||
# Override the cache directories because they won't actually help other CI runs
|
||||
# which will be testing alternate versions of zig, and ultimately would just
|
||||
# fill up space on the hard drive for no reason.
|
||||
export ZIG_GLOBAL_CACHE_DIR="$(pwd)/zig-global-cache"
|
||||
export ZIG_LOCAL_CACHE_DIR="$(pwd)/zig-local-cache"
|
||||
|
||||
cmake .. \
|
||||
-DCMAKE_INSTALL_PREFIX="stage3-release" \
|
||||
-DCMAKE_PREFIX_PATH="$PREFIX" \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-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
|
||||
|
||||
echo "Looking for non-conforming code formatting..."
|
||||
stage3-release/bin/zig fmt --check .. \
|
||||
--exclude ../test/cases/ \
|
||||
--exclude ../build-debug \
|
||||
--exclude ../build-release
|
||||
|
||||
# simultaneously test building self-hosted without LLVM and with 32-bit arm
|
||||
stage3-release/bin/zig build -Dtarget=arm-linux-musleabihf
|
||||
|
||||
stage3-release/bin/zig build test docs \
|
||||
-fqemu \
|
||||
-fwasmtime \
|
||||
-Dstatic-llvm \
|
||||
-Dtarget=native-native-musl \
|
||||
--search-prefix "$PREFIX" \
|
||||
--zig-lib-dir "$(pwd)/../lib"
|
||||
|
||||
# Look for HTML errors.
|
||||
tidy --drop-empty-elements no -qe "$ZIG_LOCAL_CACHE_DIR/langref.html"
|
||||
|
||||
# Produce the experimental std lib documentation.
|
||||
stage3-release/bin/zig test ../lib/std/std.zig -femit-docs -fno-emit-bin --zig-lib-dir ../lib
|
||||
@@ -1,62 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -x
|
||||
set -e
|
||||
|
||||
# Script assumes the presence of the following:
|
||||
# s3cmd
|
||||
|
||||
ZIGDIR="$(pwd)"
|
||||
TARGET="$ARCH-macos-none"
|
||||
MCPU="baseline"
|
||||
CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.11.0-dev.534+b0b1cc356"
|
||||
PREFIX="$HOME/$CACHE_BASENAME"
|
||||
JOBS="-j3"
|
||||
|
||||
rm -rf $PREFIX
|
||||
cd $HOME
|
||||
|
||||
curl -L -O "https://ziglang.org/deps/$CACHE_BASENAME.tar.xz"
|
||||
tar xf "$CACHE_BASENAME.tar.xz"
|
||||
|
||||
ZIG="$PREFIX/bin/zig"
|
||||
|
||||
cd $ZIGDIR
|
||||
|
||||
# Make the `zig version` number consistent.
|
||||
# This will affect the cmake command below.
|
||||
git config core.abbrev 9
|
||||
git fetch --unshallow || true
|
||||
git fetch --tags
|
||||
|
||||
rm -rf build
|
||||
mkdir build
|
||||
cd build
|
||||
|
||||
# Override the cache directories because they won't actually help other CI runs
|
||||
# which will be testing alternate versions of zig, and ultimately would just
|
||||
# fill up space on the hard drive for no reason.
|
||||
export ZIG_GLOBAL_CACHE_DIR="$(pwd)/zig-global-cache"
|
||||
export ZIG_LOCAL_CACHE_DIR="$(pwd)/zig-local-cache"
|
||||
|
||||
cmake .. \
|
||||
-DCMAKE_INSTALL_PREFIX="stage3-release" \
|
||||
-DCMAKE_PREFIX_PATH="$PREFIX" \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_C_COMPILER="$ZIG;cc;-target;$TARGET;-mcpu=$MCPU" \
|
||||
-DCMAKE_CXX_COMPILER="$ZIG;c++;-target;$TARGET;-mcpu=$MCPU" \
|
||||
-DZIG_TARGET_TRIPLE="$TARGET" \
|
||||
-DZIG_TARGET_MCPU="$MCPU" \
|
||||
-DZIG_STATIC=ON
|
||||
|
||||
make $JOBS install
|
||||
|
||||
stage3-release/bin/zig build test docs \
|
||||
--zig-lib-dir "$(pwd)/../lib" \
|
||||
-Denable-macos-sdk \
|
||||
-Dstatic-llvm \
|
||||
-Dskip-non-native \
|
||||
--search-prefix "$PREFIX"
|
||||
|
||||
# Produce the experimental std lib documentation.
|
||||
stage3-release/bin/zig test ../lib/std/std.zig -femit-docs -fno-emit-bin --zig-lib-dir ../lib
|
||||
46
ci/zinc/drone.yml
Normal file
46
ci/zinc/drone.yml
Normal file
@@ -0,0 +1,46 @@
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: x86_64-linux
|
||||
platform:
|
||||
os: linux
|
||||
arch: amd64
|
||||
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
|
||||
commands:
|
||||
- ./ci/zinc/linux_test.sh
|
||||
|
||||
- name: package
|
||||
depends_on:
|
||||
- test
|
||||
when:
|
||||
branch:
|
||||
- master
|
||||
event:
|
||||
- push
|
||||
image: ci/debian-amd64:11.1-2
|
||||
environment:
|
||||
AWS_ACCESS_KEY_ID:
|
||||
from_secret: AWS_ACCESS_KEY_ID
|
||||
AWS_SECRET_ACCESS_KEY:
|
||||
from_secret: AWS_SECRET_ACCESS_KEY
|
||||
SRHT_OAUTH_TOKEN:
|
||||
from_secret: SRHT_OAUTH_TOKEN
|
||||
commands:
|
||||
- ./ci/zinc/linux_package.sh
|
||||
28
ci/zinc/linux_base.sh
Executable file
28
ci/zinc/linux_base.sh
Executable file
@@ -0,0 +1,28 @@
|
||||
#!/bin/sh
|
||||
|
||||
# https://docs.drone.io/pipeline/docker/syntax/workspace/
|
||||
#
|
||||
# Drone automatically creates a temporary volume, known as your workspace,
|
||||
# where it clones your repository. The workspace is the current working
|
||||
# directory for each step in your pipeline.
|
||||
#
|
||||
# Because the workspace is a volume, filesystem changes are persisted between
|
||||
# pipeline steps. In other words, individual steps can communicate and share
|
||||
# state using the filesystem.
|
||||
#
|
||||
# Workspace volumes are ephemeral. They are created when the pipeline starts
|
||||
# and destroyed after the pipeline completes.
|
||||
|
||||
set -x
|
||||
set -e
|
||||
|
||||
ARCH="$(uname -m)"
|
||||
JOBS="-j$(nproc)"
|
||||
|
||||
DEPS_LOCAL="/deps/local"
|
||||
WORKSPACE="$DRONE_WORKSPACE"
|
||||
|
||||
DEBUG_STAGING="$WORKSPACE/_debug/staging"
|
||||
RELEASE_STAGING="$WORKSPACE/_release/staging"
|
||||
|
||||
export PATH=$DEPS_LOCAL/bin:$PATH
|
||||
72
ci/zinc/linux_build.sh
Executable file
72
ci/zinc/linux_build.sh
Executable file
@@ -0,0 +1,72 @@
|
||||
#!/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
|
||||
48
ci/zinc/linux_package.sh
Executable file
48
ci/zinc/linux_package.sh
Executable file
@@ -0,0 +1,48 @@
|
||||
#!/bin/sh
|
||||
|
||||
. ./ci/zinc/linux_base.sh
|
||||
|
||||
cp LICENSE $RELEASE_STAGING/
|
||||
cp zig-cache/langref.html $RELEASE_STAGING/docs/
|
||||
|
||||
# Remove the unnecessary bin dir in $prefix/bin/zig
|
||||
mv $RELEASE_STAGING/bin/zig $RELEASE_STAGING/
|
||||
rmdir $RELEASE_STAGING/bin
|
||||
|
||||
# Remove the unnecessary zig dir in $prefix/lib/zig/std/std.zig
|
||||
mv $RELEASE_STAGING/lib/zig $RELEASE_STAGING/lib2
|
||||
rmdir $RELEASE_STAGING/lib
|
||||
mv $RELEASE_STAGING/lib2 $RELEASE_STAGING/lib
|
||||
|
||||
VERSION=$($RELEASE_STAGING/zig version)
|
||||
BASENAME="zig-linux-$ARCH-$VERSION"
|
||||
TARBALL="$BASENAME.tar.xz"
|
||||
mv "$RELEASE_STAGING" "$BASENAME"
|
||||
tar cfJ "$TARBALL" "$BASENAME"
|
||||
ls -l "$TARBALL"
|
||||
|
||||
SHASUM=$(sha256sum $TARBALL | cut '-d ' -f1)
|
||||
BYTESIZE=$(wc -c < $TARBALL)
|
||||
|
||||
MANIFEST="manifest.json"
|
||||
touch $MANIFEST
|
||||
echo "{\"tarball\": \"$TARBALL\"," >>$MANIFEST
|
||||
echo "\"shasum\": \"$SHASUM\"," >>$MANIFEST
|
||||
echo "\"size\": \"$BYTESIZE\"}" >>$MANIFEST
|
||||
|
||||
# Publish artifact.
|
||||
s3cmd put -P --add-header="cache-control: public, max-age=31536000, immutable" "$TARBALL" s3://ziglang.org/builds/
|
||||
|
||||
# Publish manifest.
|
||||
s3cmd put -P --add-header="cache-control: max-age=0, must-revalidate" "$MANIFEST" "s3://ziglang.org/builds/$ARCH-linux-$VERSION.json"
|
||||
|
||||
# Avoid leaking oauth token.
|
||||
set +x
|
||||
|
||||
cd $WORKSPACE
|
||||
./ci/srht/on_master_success "$VERSION" "$SRHT_OAUTH_TOKEN"
|
||||
|
||||
set -x
|
||||
|
||||
# Explicit exit helps show last command duration.
|
||||
exit
|
||||
10
ci/zinc/linux_probe.sh
Executable file
10
ci/zinc/linux_probe.sh
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/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
|
||||
40
ci/zinc/linux_test.sh
Executable file
40
ci/zinc/linux_test.sh
Executable file
@@ -0,0 +1,40 @@
|
||||
#!/bin/sh
|
||||
|
||||
. ./ci/zinc/linux_base.sh
|
||||
|
||||
ZIG=$DEBUG_STAGING/bin/zig
|
||||
|
||||
$ZIG test test/behavior.zig -fno-stage1 -fLLVM -I test
|
||||
$ZIG test test/behavior.zig -fno-stage1 -ofmt=c -I test
|
||||
$ZIG test test/behavior.zig -fno-stage1 -target wasm32-wasi --test-cmd wasmtime --test-cmd-bin
|
||||
|
||||
$ZIG build test-behavior -fqemu -fwasmtime
|
||||
$ZIG build test-compiler-rt -fqemu -fwasmtime
|
||||
$ZIG build test-std -fqemu -fwasmtime
|
||||
$ZIG build test-minilibc -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
|
||||
|
||||
# Produce the experimental std lib documentation.
|
||||
mkdir -p $RELEASE_STAGING/docs/std
|
||||
$ZIG test lib/std/std.zig \
|
||||
--zig-lib-dir lib \
|
||||
-femit-docs=$RELEASE_STAGING/docs/std \
|
||||
-fno-emit-bin
|
||||
|
||||
# Look for HTML errors.
|
||||
tidy --drop-empty-elements no -qe zig-cache/langref.html
|
||||
|
||||
# Explicit exit helps show last command duration.
|
||||
exit
|
||||
@@ -8,33 +8,51 @@
|
||||
# CLANG_LIBDIRS
|
||||
|
||||
find_path(CLANG_INCLUDE_DIRS NAMES clang/Frontend/ASTUnit.h
|
||||
HINTS ${LLVM_INCLUDE_DIRS}
|
||||
# Only look for Clang next to LLVM or in { CMAKE_PREFIX_PATH, CMAKE_LIBRARY_PATH, CMAKE_FRAMEWORK_PATH }
|
||||
NO_SYSTEM_ENVIRONMENT_PATH
|
||||
NO_CMAKE_SYSTEM_PATH
|
||||
PATHS
|
||||
/usr/lib/llvm/13/include
|
||||
/usr/lib/llvm-13/include
|
||||
/usr/lib/llvm-13.0/include
|
||||
/usr/local/llvm130/include
|
||||
/usr/local/llvm13/include
|
||||
/usr/local/opt/llvm@13/include
|
||||
/opt/homebrew/opt/llvm@13/include
|
||||
/mingw64/include
|
||||
)
|
||||
|
||||
if(${LLVM_LINK_MODE} STREQUAL "shared")
|
||||
if(ZIG_PREFER_CLANG_CPP_DYLIB)
|
||||
find_library(CLANG_LIBRARIES
|
||||
NAMES
|
||||
libclang-cpp.so.15
|
||||
clang-cpp-15.0
|
||||
clang-cpp150
|
||||
clang-cpp-13.0
|
||||
clang-cpp130
|
||||
clang-cpp
|
||||
NAMES_PER_DIR
|
||||
HINTS "${LLVM_LIBDIRS}"
|
||||
# Only look for Clang next to LLVM or in { CMAKE_PREFIX_PATH, CMAKE_LIBRARY_PATH, CMAKE_FRAMEWORK_PATH }
|
||||
NO_SYSTEM_ENVIRONMENT_PATH
|
||||
NO_CMAKE_SYSTEM_PATH
|
||||
PATHS
|
||||
${CLANG_LIBDIRS}
|
||||
/usr/lib/llvm/13/lib
|
||||
/usr/lib/llvm/13/lib64
|
||||
/usr/lib/llvm-13/lib
|
||||
/usr/local/llvm130/lib
|
||||
/usr/local/llvm13/lib
|
||||
/usr/local/opt/llvm@13/lib
|
||||
/opt/homebrew/opt/llvm@13/lib
|
||||
)
|
||||
else()
|
||||
endif()
|
||||
|
||||
if(NOT CLANG_LIBRARIES)
|
||||
macro(FIND_AND_ADD_CLANG_LIB _libname_)
|
||||
string(TOUPPER ${_libname_} _prettylibname_)
|
||||
find_library(CLANG_${_prettylibname_}_LIB NAMES ${_libname_} NAMES_PER_DIR
|
||||
HINTS "${LLVM_LIBDIRS}"
|
||||
# Only look for Clang next to LLVM or in { CMAKE_PREFIX_PATH, CMAKE_LIBRARY_PATH, CMAKE_FRAMEWORK_PATH }
|
||||
NO_SYSTEM_ENVIRONMENT_PATH
|
||||
NO_CMAKE_SYSTEM_PATH
|
||||
find_library(CLANG_${_prettylibname_}_LIB NAMES ${_libname_}
|
||||
PATHS
|
||||
${CLANG_LIBDIRS}
|
||||
/usr/lib/llvm/13/lib
|
||||
/usr/lib/llvm-13/lib
|
||||
/usr/lib/llvm-13.0/lib
|
||||
/usr/local/llvm130/lib
|
||||
/usr/local/llvm13/lib
|
||||
/usr/local/opt/llvm@13/lib
|
||||
/opt/homebrew/opt/llvm@13/lib
|
||||
/mingw64/lib
|
||||
/c/msys64/mingw64/lib
|
||||
c:\\msys64\\mingw64\\lib
|
||||
)
|
||||
if(CLANG_${_prettylibname_}_LIB)
|
||||
set(CLANG_LIBRARIES ${CLANG_LIBRARIES} ${CLANG_${_prettylibname_}_LIB})
|
||||
@@ -64,8 +82,6 @@ else()
|
||||
FIND_AND_ADD_CLANG_LIB(clangCrossTU)
|
||||
FIND_AND_ADD_CLANG_LIB(clangIndex)
|
||||
FIND_AND_ADD_CLANG_LIB(clangToolingCore)
|
||||
FIND_AND_ADD_CLANG_LIB(clangExtractAPI)
|
||||
FIND_AND_ADD_CLANG_LIB(clangSupport)
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
@@ -7,51 +7,52 @@
|
||||
# LLD_LIBRARIES
|
||||
|
||||
find_path(LLD_INCLUDE_DIRS NAMES lld/Common/Driver.h
|
||||
HINTS ${LLVM_INCLUDE_DIRS}
|
||||
PATHS
|
||||
/usr/lib/llvm-15/include
|
||||
/usr/local/llvm150/include
|
||||
/usr/local/llvm15/include
|
||||
/usr/local/opt/llvm@15/include
|
||||
/opt/homebrew/opt/llvm@15/include
|
||||
/usr/lib/llvm-13/include
|
||||
/usr/local/llvm130/include
|
||||
/usr/local/llvm13/include
|
||||
/usr/local/opt/llvm@13/include
|
||||
/opt/homebrew/opt/llvm@13/include
|
||||
/mingw64/include)
|
||||
|
||||
find_library(LLD_LIBRARY NAMES lld-15.0 lld150 lld NAMES_PER_DIR
|
||||
HINTS ${LLVM_LIBDIRS}
|
||||
find_library(LLD_LIBRARY NAMES lld-13.0 lld130 lld
|
||||
PATHS
|
||||
/usr/lib/llvm-15/lib
|
||||
/usr/local/llvm150/lib
|
||||
/usr/local/llvm15/lib
|
||||
/usr/local/opt/llvm@15/lib
|
||||
/opt/homebrew/opt/llvm@15/lib
|
||||
/usr/lib/llvm-13/lib
|
||||
/usr/local/llvm130/lib
|
||||
/usr/local/llvm13/lib
|
||||
/usr/local/opt/llvm@13/lib
|
||||
/opt/homebrew/opt/llvm@13/lib
|
||||
)
|
||||
if(EXISTS ${LLD_LIBRARY})
|
||||
set(LLD_LIBRARIES ${LLD_LIBRARY})
|
||||
else()
|
||||
macro(FIND_AND_ADD_LLD_LIB _libname_)
|
||||
string(TOUPPER ${_libname_} _prettylibname_)
|
||||
find_library(LLD_${_prettylibname_}_LIB NAMES ${_libname_} NAMES_PER_DIR
|
||||
HINTS ${LLVM_LIBDIRS}
|
||||
find_library(LLD_${_prettylibname_}_LIB NAMES ${_libname_}
|
||||
PATHS
|
||||
${LLD_LIBDIRS}
|
||||
/usr/lib/llvm-15/lib
|
||||
/usr/local/llvm150/lib
|
||||
/usr/local/llvm15/lib
|
||||
/usr/local/opt/llvm@15/lib
|
||||
/opt/homebrew/opt/llvm@15/lib
|
||||
/usr/lib/llvm-13/lib
|
||||
/usr/local/llvm130/lib
|
||||
/usr/local/llvm13/lib
|
||||
/usr/local/opt/llvm@13/lib
|
||||
/opt/homebrew/opt/llvm@13/lib
|
||||
/mingw64/lib
|
||||
/c/msys64/mingw64/lib
|
||||
c:/msys64/mingw64/lib)
|
||||
if(LLD_${_prettylibname_}_LIB)
|
||||
set(LLD_LIBRARIES ${LLD_LIBRARIES} ${LLD_${_prettylibname_}_LIB})
|
||||
if(LLD_${_prettylibname_}_LIB)
|
||||
set(LLD_LIBRARIES ${LLD_LIBRARIES} ${LLD_${_prettylibname_}_LIB})
|
||||
endif()
|
||||
endmacro(FIND_AND_ADD_LLD_LIB)
|
||||
|
||||
FIND_AND_ADD_LLD_LIB(lldDriver)
|
||||
FIND_AND_ADD_LLD_LIB(lldMinGW)
|
||||
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)
|
||||
FIND_AND_ADD_LLD_LIB(lldCommon)
|
||||
endif()
|
||||
|
||||
|
||||
@@ -6,139 +6,154 @@
|
||||
# LLVM_INCLUDE_DIRS
|
||||
# LLVM_LIBRARIES
|
||||
# LLVM_LIBDIRS
|
||||
# LLVM_LINK_MODE
|
||||
|
||||
find_path(LLVM_INCLUDE_DIRS NAMES llvm/IR/IRBuilder.h
|
||||
PATHS
|
||||
/usr/lib/llvm/13/include
|
||||
/usr/lib/llvm-13/include
|
||||
/usr/lib/llvm-13.0/include
|
||||
/usr/local/llvm13/include
|
||||
/usr/local/llvm130/include
|
||||
/usr/local/opt/llvm@13/include
|
||||
/opt/homebrew/opt/llvm@13/include
|
||||
/mingw64/include
|
||||
)
|
||||
|
||||
if(ZIG_USE_LLVM_CONFIG)
|
||||
set(LLVM_CONFIG_ERROR_MESSAGES "")
|
||||
while(1)
|
||||
unset(LLVM_CONFIG_EXE CACHE)
|
||||
find_program(LLVM_CONFIG_EXE
|
||||
NAMES llvm-config-15 llvm-config-15.0 llvm-config150 llvm-config15 llvm-config NAMES_PER_DIR
|
||||
PATHS
|
||||
"/mingw64/bin"
|
||||
"/c/msys64/mingw64/bin"
|
||||
"c:/msys64/mingw64/bin"
|
||||
"C:/Libraries/llvm-15.0.0/bin")
|
||||
if(ZIG_PREFER_CLANG_CPP_DYLIB)
|
||||
find_library(LLVM_LIBRARIES
|
||||
NAMES
|
||||
LLVM-13.0
|
||||
LLVM-13
|
||||
LLVM-130
|
||||
LLVM
|
||||
PATHS
|
||||
${LLVM_LIBDIRS}
|
||||
/usr/lib/llvm/13/lib
|
||||
/usr/lib/llvm/13/lib64
|
||||
/usr/lib/llvm-13/lib
|
||||
/usr/local/llvm13/lib
|
||||
/usr/local/llvm130/lib
|
||||
/usr/local/opt/llvm@13/lib
|
||||
/opt/homebrew/opt/llvm@13/lib
|
||||
)
|
||||
|
||||
if ("${LLVM_CONFIG_EXE}" STREQUAL "LLVM_CONFIG_EXE-NOTFOUND")
|
||||
if (NOT LLVM_CONFIG_ERROR_MESSAGES STREQUAL "")
|
||||
list(JOIN LLVM_CONFIG_ERROR_MESSAGES "\n" LLVM_CONFIG_ERROR_MESSAGE)
|
||||
message(FATAL_ERROR ${LLVM_CONFIG_ERROR_MESSAGE})
|
||||
else()
|
||||
message(FATAL_ERROR "unable to find llvm-config")
|
||||
endif()
|
||||
endif()
|
||||
find_program(LLVM_CONFIG_EXE
|
||||
NAMES llvm-config-13 llvm-config-13.0 llvm-config130 llvm-config13 llvm-config
|
||||
PATHS
|
||||
"/mingw64/bin"
|
||||
"/c/msys64/mingw64/bin"
|
||||
"c:/msys64/mingw64/bin"
|
||||
"C:/Libraries/llvm-13.0.0/bin")
|
||||
|
||||
# Check that this LLVM is the right version
|
||||
execute_process(
|
||||
COMMAND ${LLVM_CONFIG_EXE} --version
|
||||
OUTPUT_VARIABLE LLVM_CONFIG_VERSION
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
if ("${LLVM_CONFIG_EXE}" STREQUAL "LLVM_CONFIG_EXE-NOTFOUND")
|
||||
message(FATAL_ERROR "unable to find llvm-config")
|
||||
endif()
|
||||
|
||||
get_filename_component(LLVM_CONFIG_DIR "${LLVM_CONFIG_EXE}" DIRECTORY)
|
||||
if("${LLVM_CONFIG_VERSION}" VERSION_LESS 15 OR "${LLVM_CONFIG_VERSION}" VERSION_EQUAL 16 OR "${LLVM_CONFIG_VERSION}" VERSION_GREATER 16)
|
||||
# Save the error message, in case this is the last llvm-config we find
|
||||
list(APPEND LLVM_CONFIG_ERROR_MESSAGES "expected LLVM 15.x but found ${LLVM_CONFIG_VERSION} using ${LLVM_CONFIG_EXE}")
|
||||
if ("${LLVM_CONFIG_EXE}" STREQUAL "LLVM_CONFIG_EXE-NOTFOUND")
|
||||
message(FATAL_ERROR "unable to find llvm-config")
|
||||
endif()
|
||||
|
||||
# Ignore this directory and try the search again
|
||||
list(APPEND CMAKE_IGNORE_PATH "${LLVM_CONFIG_DIR}")
|
||||
continue()
|
||||
endif()
|
||||
execute_process(
|
||||
COMMAND ${LLVM_CONFIG_EXE} --version
|
||||
OUTPUT_VARIABLE LLVM_CONFIG_VERSION
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
# Check that this LLVM supports linking as a shared/static library, if requested
|
||||
if (ZIG_SHARED_LLVM OR ZIG_STATIC_LLVM)
|
||||
if (ZIG_SHARED_LLVM)
|
||||
set(STATIC_OR_SHARED_LINK "--link-shared")
|
||||
elseif (ZIG_STATIC_LLVM)
|
||||
set(STATIC_OR_SHARED_LINK "--link-static")
|
||||
endif()
|
||||
if("${LLVM_CONFIG_VERSION}" VERSION_LESS 13)
|
||||
message(FATAL_ERROR "expected LLVM 13.x but found ${LLVM_CONFIG_VERSION} using ${LLVM_CONFIG_EXE}")
|
||||
endif()
|
||||
if("${LLVM_CONFIG_VERSION}" VERSION_EQUAL 14)
|
||||
message(FATAL_ERROR "expected LLVM 13.x but found ${LLVM_CONFIG_VERSION} using ${LLVM_CONFIG_EXE}")
|
||||
endif()
|
||||
if("${LLVM_CONFIG_VERSION}" VERSION_GREATER 14)
|
||||
message(FATAL_ERROR "expected LLVM 13.x but found ${LLVM_CONFIG_VERSION} using ${LLVM_CONFIG_EXE}")
|
||||
endif()
|
||||
elseif(ZIG_USE_LLVM_CONFIG)
|
||||
find_program(LLVM_CONFIG_EXE
|
||||
NAMES llvm-config-13 llvm-config-13.0 llvm-config130 llvm-config13 llvm-config
|
||||
PATHS
|
||||
"/mingw64/bin"
|
||||
"/c/msys64/mingw64/bin"
|
||||
"c:/msys64/mingw64/bin"
|
||||
"C:/Libraries/llvm-13.0.0/bin")
|
||||
|
||||
execute_process(
|
||||
COMMAND ${LLVM_CONFIG_EXE} --libs ${STATIC_OR_SHARED_LINK}
|
||||
OUTPUT_QUIET
|
||||
ERROR_VARIABLE LLVM_CONFIG_ERROR
|
||||
ERROR_STRIP_TRAILING_WHITESPACE)
|
||||
if ("${LLVM_CONFIG_EXE}" STREQUAL "LLVM_CONFIG_EXE-NOTFOUND")
|
||||
message(FATAL_ERROR "unable to find llvm-config")
|
||||
endif()
|
||||
|
||||
if (LLVM_CONFIG_ERROR)
|
||||
# Save the error message, in case this is the last llvm-config we find
|
||||
if (ZIG_SHARED_LLVM)
|
||||
list(APPEND LLVM_CONFIG_ERROR_MESSAGES "LLVM 15.x found at ${LLVM_CONFIG_EXE} does not support linking as a shared library")
|
||||
else()
|
||||
list(APPEND LLVM_CONFIG_ERROR_MESSAGES "LLVM 15.x found at ${LLVM_CONFIG_EXE} does not support linking as a static library")
|
||||
endif()
|
||||
if ("${LLVM_CONFIG_EXE}" STREQUAL "LLVM_CONFIG_EXE-NOTFOUND")
|
||||
message(FATAL_ERROR "unable to find llvm-config")
|
||||
endif()
|
||||
|
||||
# Ignore this directory and try the search again
|
||||
list(APPEND CMAKE_IGNORE_PATH "${LLVM_CONFIG_DIR}")
|
||||
continue()
|
||||
endif()
|
||||
endif()
|
||||
execute_process(
|
||||
COMMAND ${LLVM_CONFIG_EXE} --version
|
||||
OUTPUT_VARIABLE LLVM_CONFIG_VERSION
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
execute_process(
|
||||
COMMAND ${LLVM_CONFIG_EXE} --targets-built
|
||||
OUTPUT_VARIABLE LLVM_TARGETS_BUILT_SPACES
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
string(REPLACE " " ";" LLVM_TARGETS_BUILT "${LLVM_TARGETS_BUILT_SPACES}")
|
||||
if("${LLVM_CONFIG_VERSION}" VERSION_LESS 13)
|
||||
message(FATAL_ERROR "expected LLVM 13.x but found ${LLVM_CONFIG_VERSION} using ${LLVM_CONFIG_EXE}")
|
||||
endif()
|
||||
if("${LLVM_CONFIG_VERSION}" VERSION_EQUAL 14)
|
||||
message(FATAL_ERROR "expected LLVM 13.x but found ${LLVM_CONFIG_VERSION} using ${LLVM_CONFIG_EXE}")
|
||||
endif()
|
||||
if("${LLVM_CONFIG_VERSION}" VERSION_GREATER 14)
|
||||
message(FATAL_ERROR "expected LLVM 13.x but found ${LLVM_CONFIG_VERSION} using ${LLVM_CONFIG_EXE}")
|
||||
endif()
|
||||
|
||||
set(ZIG_LLVM_REQUIRED_TARGETS "AArch64;AMDGPU;ARM;AVR;BPF;Hexagon;Lanai;Mips;MSP430;NVPTX;PowerPC;RISCV;Sparc;SystemZ;VE;WebAssembly;X86;XCore")
|
||||
|
||||
set(ZIG_LLVM_REQUIRED_TARGETS_ENABLED TRUE)
|
||||
foreach(TARGET_NAME IN LISTS ZIG_LLVM_REQUIRED_TARGETS)
|
||||
execute_process(
|
||||
COMMAND ${LLVM_CONFIG_EXE} --targets-built
|
||||
OUTPUT_VARIABLE LLVM_TARGETS_BUILT_SPACES
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
string(REPLACE " " ";" LLVM_TARGETS_BUILT "${LLVM_TARGETS_BUILT_SPACES}")
|
||||
function(NEED_TARGET TARGET_NAME)
|
||||
list (FIND LLVM_TARGETS_BUILT "${TARGET_NAME}" _index)
|
||||
if (${_index} EQUAL -1)
|
||||
# Save the error message, in case this is the last llvm-config we find
|
||||
list(APPEND LLVM_CONFIG_ERROR_MESSAGES "LLVM (according to ${LLVM_CONFIG_EXE}) is missing target ${TARGET_NAME}. Zig requires LLVM to be built with all default targets enabled.")
|
||||
|
||||
# Ignore this directory and try the search again
|
||||
list(APPEND CMAKE_IGNORE_PATH "${LLVM_CONFIG_DIR}")
|
||||
set(ZIG_LLVM_REQUIRED_TARGETS_ENABLED FALSE)
|
||||
break()
|
||||
message(FATAL_ERROR "LLVM (according to ${LLVM_CONFIG_EXE}) is missing target ${TARGET_NAME}. Zig requires LLVM to be built with all default targets enabled.")
|
||||
endif()
|
||||
endforeach()
|
||||
if (NOT ZIG_LLVM_REQUIRED_TARGETS_ENABLED)
|
||||
continue()
|
||||
endif()
|
||||
endfunction(NEED_TARGET)
|
||||
NEED_TARGET("AArch64")
|
||||
NEED_TARGET("AMDGPU")
|
||||
NEED_TARGET("ARM")
|
||||
NEED_TARGET("AVR")
|
||||
NEED_TARGET("BPF")
|
||||
NEED_TARGET("Hexagon")
|
||||
NEED_TARGET("Lanai")
|
||||
NEED_TARGET("Mips")
|
||||
NEED_TARGET("MSP430")
|
||||
NEED_TARGET("NVPTX")
|
||||
NEED_TARGET("PowerPC")
|
||||
NEED_TARGET("RISCV")
|
||||
NEED_TARGET("Sparc")
|
||||
NEED_TARGET("SystemZ")
|
||||
NEED_TARGET("WebAssembly")
|
||||
NEED_TARGET("X86")
|
||||
NEED_TARGET("XCore")
|
||||
|
||||
# Got it!
|
||||
break()
|
||||
endwhile()
|
||||
|
||||
if(ZIG_SHARED_LLVM OR ZIG_STATIC_LLVM)
|
||||
if(ZIG_STATIC_LLVM)
|
||||
execute_process(
|
||||
COMMAND ${LLVM_CONFIG_EXE} --libfiles ${STATIC_OR_SHARED_LINK}
|
||||
COMMAND ${LLVM_CONFIG_EXE} --libfiles --link-static
|
||||
OUTPUT_VARIABLE LLVM_LIBRARIES_SPACES
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
string(REPLACE " " ";" LLVM_LIBRARIES "${LLVM_LIBRARIES_SPACES}")
|
||||
|
||||
execute_process(
|
||||
COMMAND ${LLVM_CONFIG_EXE} --libdir ${STATIC_OR_SHARED_LINK}
|
||||
OUTPUT_VARIABLE LLVM_LIBDIRS_SPACES
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
string(REPLACE " " ";" LLVM_LIBDIRS "${LLVM_LIBDIRS_SPACES}")
|
||||
|
||||
execute_process(
|
||||
COMMAND ${LLVM_CONFIG_EXE} --system-libs ${STATIC_OR_SHARED_LINK}
|
||||
COMMAND ${LLVM_CONFIG_EXE} --system-libs --link-static
|
||||
OUTPUT_VARIABLE LLVM_SYSTEM_LIBS_SPACES
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
string(REPLACE " " ";" LLVM_SYSTEM_LIBS "${LLVM_SYSTEM_LIBS_SPACES}")
|
||||
|
||||
execute_process(
|
||||
COMMAND ${LLVM_CONFIG_EXE} --shared-mode ${STATIC_OR_SHARED_LINK}
|
||||
OUTPUT_VARIABLE LLVM_LINK_MODE
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
else()
|
||||
COMMAND ${LLVM_CONFIG_EXE} --libdir --link-static
|
||||
OUTPUT_VARIABLE LLVM_LIBDIRS_SPACES
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
string(REPLACE " " ";" LLVM_LIBDIRS "${LLVM_LIBDIRS_SPACES}")
|
||||
endif()
|
||||
if(NOT LLVM_LIBRARIES)
|
||||
execute_process(
|
||||
COMMAND ${LLVM_CONFIG_EXE} --libs
|
||||
OUTPUT_VARIABLE LLVM_LIBRARIES_SPACES
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
string(REPLACE " " ";" LLVM_LIBRARIES "${LLVM_LIBRARIES_SPACES}")
|
||||
|
||||
execute_process(
|
||||
COMMAND ${LLVM_CONFIG_EXE} --libdir
|
||||
OUTPUT_VARIABLE LLVM_LIBDIRS_SPACES
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
string(REPLACE " " ";" LLVM_LIBDIRS "${LLVM_LIBDIRS_SPACES}")
|
||||
|
||||
execute_process(
|
||||
COMMAND ${LLVM_CONFIG_EXE} --system-libs
|
||||
OUTPUT_VARIABLE LLVM_SYSTEM_LIBS_SPACES
|
||||
@@ -146,32 +161,17 @@ if(ZIG_USE_LLVM_CONFIG)
|
||||
string(REPLACE " " ";" LLVM_SYSTEM_LIBS "${LLVM_SYSTEM_LIBS_SPACES}")
|
||||
|
||||
execute_process(
|
||||
COMMAND ${LLVM_CONFIG_EXE} --shared-mode
|
||||
OUTPUT_VARIABLE LLVM_LINK_MODE
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
endif()
|
||||
|
||||
if (${LLVM_LINK_MODE} STREQUAL "shared")
|
||||
# We always ask for the system libs corresponding to static linking,
|
||||
# since on some distros LLD is only available as a static library
|
||||
# and we need these libraries to link it successfully
|
||||
execute_process(
|
||||
COMMAND ${LLVM_CONFIG_EXE} --system-libs --link-static
|
||||
OUTPUT_VARIABLE LLVM_STATIC_SYSTEM_LIBS_SPACES
|
||||
ERROR_QUIET # Some installations have no static libs, we just ignore the failure
|
||||
COMMAND ${LLVM_CONFIG_EXE} --libdir
|
||||
OUTPUT_VARIABLE LLVM_LIBDIRS_SPACES
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
string(REPLACE " " ";" LLVM_STATIC_SYSTEM_LIBS "${LLVM_STATIC_SYSTEM_LIBS_SPACES}")
|
||||
|
||||
set(LLVM_LIBRARIES ${LLVM_LIBRARIES} ${LLVM_SYSTEM_LIBS} ${LLVM_STATIC_SYSTEM_LIBS})
|
||||
else()
|
||||
set(LLVM_LIBRARIES ${LLVM_LIBRARIES} ${LLVM_SYSTEM_LIBS})
|
||||
string(REPLACE " " ";" LLVM_LIBDIRS "${LLVM_LIBDIRS_SPACES}")
|
||||
endif()
|
||||
|
||||
execute_process(
|
||||
COMMAND ${LLVM_CONFIG_EXE} --includedir
|
||||
OUTPUT_VARIABLE LLVM_INCLUDE_DIRS_SPACES
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
string(REPLACE " " ";" LLVM_INCLUDE_DIRS "${LLVM_INCLUDE_DIRS_SPACES}")
|
||||
set(LLVM_LIBRARIES ${LLVM_LIBRARIES} ${LLVM_SYSTEM_LIBS})
|
||||
|
||||
if(NOT LLVM_LIBRARIES)
|
||||
find_library(LLVM_LIBRARIES NAMES LLVM LLVM-13 LLVM-13.0)
|
||||
endif()
|
||||
|
||||
link_directories("${CMAKE_PREFIX_PATH}/lib")
|
||||
link_directories("${LLVM_LIBDIRS}")
|
||||
@@ -181,18 +181,26 @@ else()
|
||||
|
||||
macro(FIND_AND_ADD_LLVM_LIB _libname_)
|
||||
string(TOUPPER ${_libname_} _prettylibname_)
|
||||
find_library(LLVM_${_prettylibname_}_LIB
|
||||
NAMES ${_libname_} NAMES_PER_DIR)
|
||||
find_library(LLVM_${_prettylibname_}_LIB NAMES ${_libname_}
|
||||
PATHS
|
||||
${LLVM_LIBDIRS}
|
||||
/usr/lib/llvm/13/lib
|
||||
/usr/lib/llvm-13/lib
|
||||
/usr/lib/llvm-13.0/lib
|
||||
/usr/local/llvm130/lib
|
||||
/usr/local/llvm13/lib
|
||||
/usr/local/opt/llvm@13/lib
|
||||
/opt/homebrew/opt/llvm@13/lib
|
||||
/mingw64/lib
|
||||
/c/msys64/mingw64/lib
|
||||
c:\\msys64\\mingw64\\lib)
|
||||
set(LLVM_LIBRARIES ${LLVM_LIBRARIES} ${LLVM_${_prettylibname_}_LIB})
|
||||
endmacro(FIND_AND_ADD_LLVM_LIB)
|
||||
|
||||
set(LLVM_LINK_MODE "static")
|
||||
|
||||
# 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.
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMWindowsManifest)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMWindowsDriver)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMXRay)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMLibDriver)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMDlltoolDriver)
|
||||
@@ -202,7 +210,6 @@ else()
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMXCoreCodeGen)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMXCoreDesc)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMXCoreInfo)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMX86TargetMCA)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMX86Disassembler)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMX86AsmParser)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMX86CodeGen)
|
||||
@@ -214,11 +221,6 @@ else()
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMWebAssemblyDesc)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMWebAssemblyUtils)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMWebAssemblyInfo)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMVEDisassembler)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMVEAsmParser)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMVECodeGen)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMVEDesc)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMVEInfo)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMSystemZDisassembler)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMSystemZAsmParser)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMSystemZCodeGen)
|
||||
@@ -278,7 +280,6 @@ else()
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMARMDesc)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMARMUtils)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMARMInfo)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMAMDGPUTargetMCA)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMAMDGPUDisassembler)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMAMDGPUAsmParser)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMAMDGPUCodeGen)
|
||||
@@ -300,10 +301,11 @@ else()
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMOrcTargetProcess)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMOrcShared)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMDWP)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMSymbolize)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMDebugInfoPDB)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMDebugInfoGSYM)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMOption)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMObjectYAML)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMObjCopy)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMMCA)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMMCDisassembler)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMLTO)
|
||||
@@ -322,6 +324,8 @@ else()
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMGlobalISel)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMMIRParser)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMAsmPrinter)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMDebugInfoMSF)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMDebugInfoDWARF)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMSelectionDAG)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMCodeGen)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMIRReader)
|
||||
@@ -337,26 +341,18 @@ else()
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMBitWriter)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMAnalysis)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMProfileData)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMSymbolize)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMDebugInfoPDB)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMDebugInfoMSF)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMDebugInfoDWARF)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMObject)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMTextAPI)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMMCParser)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMMC)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMDebugInfoCodeView)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMBitReader)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMFuzzerCLI)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMCore)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMRemarks)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMBitstreamReader)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMBinaryFormat)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMSupport)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMDemangle)
|
||||
|
||||
get_filename_component(LLVM_LIBDIRS "${LLVM_LLVMCORE_LIB}" DIRECTORY)
|
||||
find_path(LLVM_INCLUDE_DIRS NAMES llvm/IR/IRBuilder.h)
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
@@ -1,19 +1,29 @@
|
||||
set(ZIG_INSTALL_ARGS build ${ZIG_BUILD_ARGS} --prefix "${CMAKE_INSTALL_PREFIX}")
|
||||
execute_process(
|
||||
COMMAND "${ZIG_EXECUTABLE}" ${ZIG_INSTALL_ARGS}
|
||||
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
||||
RESULT_VARIABLE _result)
|
||||
message("-- Installing: ${CMAKE_INSTALL_PREFIX}/lib")
|
||||
|
||||
if(NOT EXISTS ${zig_EXE})
|
||||
message("::")
|
||||
message(":: ERROR: Executable not found")
|
||||
message(":: (execute_process)")
|
||||
message("::")
|
||||
message(":: executable: ${zig_EXE}")
|
||||
message("::")
|
||||
message(FATAL_ERROR)
|
||||
endif()
|
||||
|
||||
execute_process(COMMAND ${zig_EXE} ${ZIG_INSTALL_ARGS}
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
RESULT_VARIABLE _result
|
||||
)
|
||||
if(_result)
|
||||
message("::")
|
||||
message(":: ERROR: ${_result}")
|
||||
message(":: (execute_process)")
|
||||
|
||||
list(JOIN ZIG_INSTALL_ARGS " " s_INSTALL_LIBSTAGE2_ARGS)
|
||||
string(REPLACE ";" " " s_INSTALL_LIBSTAGE2_ARGS "${ZIG_INSTALL_ARGS}")
|
||||
message("::")
|
||||
message(":: argv: ${ZIG_EXECUTABLE} ${s_INSTALL_LIBSTAGE2_ARGS}")
|
||||
message(":: argv: ${zig_EXE} ${s_INSTALL_LIBSTAGE2_ARGS}")
|
||||
|
||||
set(_args ${ZIG_EXECUTABLE} ${ZIG_INSTALL_ARGS})
|
||||
set(_args ${zig_EXE} ${ZIG_INSTALL_ARGS})
|
||||
list(LENGTH _args _len)
|
||||
math(EXPR _len "${_len} - 1")
|
||||
message("::")
|
||||
|
||||
30
deps/SoftFloat-3e-prebuilt/platform.h
vendored
30
deps/SoftFloat-3e-prebuilt/platform.h
vendored
@@ -3,10 +3,6 @@
|
||||
|
||||
#if defined(__BIG_ENDIAN__)
|
||||
#define BIGENDIAN 1
|
||||
#elif defined(_BIG_ENDIAN) && (_BIG_ENDIAN == 1)
|
||||
#define BIGENDIAN 1
|
||||
#elif defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
|
||||
#define BIGENDIAN 1
|
||||
#elif defined(__ARMEB__)
|
||||
#define BIGENDIAN 1
|
||||
#elif defined(__THUMBEB__)
|
||||
@@ -19,12 +15,20 @@
|
||||
#define BIGENDIAN 1
|
||||
#elif defined(__MIPSEB__)
|
||||
#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__)
|
||||
#define BIGENDIAN 1
|
||||
#elif defined(_POWER)
|
||||
#define BIGENDIAN 1
|
||||
#elif defined(__powerpc__)
|
||||
#define BIGENDIAN 1
|
||||
#elif defined(__ppc__)
|
||||
#define BIGENDIAN 1
|
||||
#elif defined(__hpux)
|
||||
#define BIGENDIAN 1
|
||||
#elif defined(__hppa)
|
||||
@@ -33,13 +37,7 @@
|
||||
#define BIGENDIAN 1
|
||||
#elif defined(__s390__)
|
||||
#define BIGENDIAN 1
|
||||
#endif
|
||||
|
||||
#if defined(__LITTLE_ENDIAN__)
|
||||
#define LITTLEENDIAN 1
|
||||
#elif defined(_LITTLE_ENDIAN) && (_LITTLE_ENDIAN == 1)
|
||||
#define LITTLEENDIAN 1
|
||||
#elif defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
|
||||
#elif defined(__LITTLE_ENDIAN__)
|
||||
#define LITTLEENDIAN 1
|
||||
#elif defined(__ARMEL__)
|
||||
#define LITTLEENDIAN 1
|
||||
@@ -53,6 +51,10 @@
|
||||
#define LITTLEENDIAN 1
|
||||
#elif defined(__MIPSEL__)
|
||||
#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__)
|
||||
@@ -81,11 +83,7 @@
|
||||
#define LITTLEENDIAN 1
|
||||
#elif defined(__bfin__)
|
||||
#define LITTLEENDIAN 1
|
||||
#endif
|
||||
|
||||
#if defined(LITTLEENDIAN) && defined(BIGENDIAN)
|
||||
#error unable to detect endianness
|
||||
#elif !defined(LITTLEENDIAN) && !defined(BIGENDIAN)
|
||||
#else
|
||||
#error unable to detect endianness
|
||||
#endif
|
||||
|
||||
|
||||
@@ -37,7 +37,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#ifndef primitiveTypes_h
|
||||
#define primitiveTypes_h 1
|
||||
|
||||
#include "platform.h"
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
@@ -37,7 +37,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#ifndef softfloat_types_h
|
||||
#define softfloat_types_h 1
|
||||
|
||||
#include "platform.h"
|
||||
#include <stdint.h>
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
|
||||
129
doc/docgen.zig
129
doc/docgen.zig
@@ -23,29 +23,29 @@ pub fn main() !void {
|
||||
|
||||
const allocator = arena.allocator();
|
||||
|
||||
var args_it = try process.argsWithAllocator(allocator);
|
||||
var args_it = process.args();
|
||||
|
||||
if (!args_it.skip()) @panic("expected self arg");
|
||||
|
||||
const zig_exe = args_it.next() orelse @panic("expected zig exe arg");
|
||||
const zig_exe = try (args_it.next(allocator) orelse @panic("expected zig exe arg"));
|
||||
defer allocator.free(zig_exe);
|
||||
|
||||
const in_file_name = args_it.next() orelse @panic("expected input arg");
|
||||
const in_file_name = try (args_it.next(allocator) orelse @panic("expected input arg"));
|
||||
defer allocator.free(in_file_name);
|
||||
|
||||
const out_file_name = args_it.next() orelse @panic("expected output arg");
|
||||
const out_file_name = try (args_it.next(allocator) orelse @panic("expected output arg"));
|
||||
defer allocator.free(out_file_name);
|
||||
|
||||
var do_code_tests = true;
|
||||
if (args_it.next()) |arg| {
|
||||
if (mem.eql(u8, arg, "--skip-code-tests")) {
|
||||
if (args_it.next(allocator)) |arg| {
|
||||
if (mem.eql(u8, try arg, "--skip-code-tests")) {
|
||||
do_code_tests = false;
|
||||
} else {
|
||||
@panic("unrecognized arg");
|
||||
}
|
||||
}
|
||||
|
||||
var in_file = try fs.cwd().openFile(in_file_name, .{ .mode = .read_only });
|
||||
var in_file = try fs.cwd().openFile(in_file_name, .{ .read = true });
|
||||
defer in_file.close();
|
||||
|
||||
var out_file = try fs.cwd().createFile(out_file_name, .{});
|
||||
@@ -285,7 +285,6 @@ const Code = struct {
|
||||
link_objects: []const []const u8,
|
||||
target_str: ?[]const u8,
|
||||
link_libc: bool,
|
||||
backend_stage1: bool,
|
||||
link_mode: ?std.builtin.LinkMode,
|
||||
disable_cache: bool,
|
||||
verbose_cimport: bool,
|
||||
@@ -555,7 +554,6 @@ fn genToc(allocator: Allocator, tokenizer: *Tokenizer) !Toc {
|
||||
var link_mode: ?std.builtin.LinkMode = null;
|
||||
var disable_cache = false;
|
||||
var verbose_cimport = false;
|
||||
var backend_stage1 = false;
|
||||
|
||||
const source_token = while (true) {
|
||||
const content_tok = try eatToken(tokenizer, Token.Id.Content);
|
||||
@@ -588,8 +586,6 @@ fn genToc(allocator: Allocator, tokenizer: *Tokenizer) !Toc {
|
||||
link_libc = true;
|
||||
} else if (mem.eql(u8, end_tag_name, "link_mode_dynamic")) {
|
||||
link_mode = .Dynamic;
|
||||
} else if (mem.eql(u8, end_tag_name, "backend_stage1")) {
|
||||
backend_stage1 = true;
|
||||
} else if (mem.eql(u8, end_tag_name, "code_end")) {
|
||||
_ = try eatToken(tokenizer, Token.Id.BracketClose);
|
||||
break content_tok;
|
||||
@@ -613,7 +609,6 @@ fn genToc(allocator: Allocator, tokenizer: *Tokenizer) !Toc {
|
||||
.link_objects = link_objects.toOwnedSlice(),
|
||||
.target_str = target_str,
|
||||
.link_libc = link_libc,
|
||||
.backend_stage1 = backend_stage1,
|
||||
.link_mode = link_mode,
|
||||
.disable_cache = disable_cache,
|
||||
.verbose_cimport = verbose_cimport,
|
||||
@@ -858,11 +853,10 @@ fn termColor(allocator: Allocator, input: []const u8) ![]u8 {
|
||||
}
|
||||
|
||||
const builtin_types = [_][]const u8{
|
||||
"f16", "f32", "f64", "f80", "f128",
|
||||
"c_longdouble", "c_short", "c_ushort", "c_int", "c_uint",
|
||||
"c_long", "c_ulong", "c_longlong", "c_ulonglong", "c_char",
|
||||
"anyopaque", "void", "bool", "isize", "usize",
|
||||
"noreturn", "type", "anyerror", "comptime_int", "comptime_float",
|
||||
"f16", "f32", "f64", "f128", "c_longdouble", "c_short",
|
||||
"c_ushort", "c_int", "c_uint", "c_long", "c_ulong", "c_longlong",
|
||||
"c_ulonglong", "c_char", "anyopaque", "void", "bool", "isize",
|
||||
"usize", "noreturn", "type", "anyerror", "comptime_int", "comptime_float",
|
||||
};
|
||||
|
||||
fn isType(name: []const u8) bool {
|
||||
@@ -1058,7 +1052,9 @@ fn tokenizeAndPrintRaw(
|
||||
}
|
||||
},
|
||||
|
||||
.number_literal => {
|
||||
.integer_literal,
|
||||
.float_literal,
|
||||
=> {
|
||||
try out.writeAll("<span class=\"tok-number\">");
|
||||
try writeEscaped(out, src[token.loc.start..token.loc.end]);
|
||||
try out.writeAll("</span>");
|
||||
@@ -1168,7 +1164,7 @@ fn printSourceBlock(allocator: Allocator, docgen_tokenizer: *Tokenizer, out: any
|
||||
try out.writeAll("</pre></figure>");
|
||||
}
|
||||
|
||||
fn printShell(out: anytype, shell_content: []const u8, escape: bool) !void {
|
||||
fn printShell(out: anytype, shell_content: []const u8) !void {
|
||||
const trimmed_shell_content = mem.trim(u8, shell_content, " \n");
|
||||
try out.writeAll("<figure><figcaption class=\"shell-cap\">Shell</figcaption><pre><samp>");
|
||||
var cmd_cont: bool = false;
|
||||
@@ -1176,50 +1172,21 @@ fn printShell(out: anytype, shell_content: []const u8, escape: bool) !void {
|
||||
while (iter.next()) |orig_line| {
|
||||
const line = mem.trimRight(u8, orig_line, " ");
|
||||
if (!cmd_cont and line.len > 1 and mem.eql(u8, line[0..2], "$ ") and line[line.len - 1] != '\\') {
|
||||
try out.writeAll(start_line ++ "$ <kbd>");
|
||||
const s = std.mem.trimLeft(u8, line[1..], " ");
|
||||
if (escape) {
|
||||
try writeEscaped(out, s);
|
||||
} else {
|
||||
try out.writeAll(s);
|
||||
}
|
||||
try out.writeAll("</kbd>" ++ end_line ++ "\n");
|
||||
try out.print(start_line ++ "$ <kbd>{s}</kbd>" ++ end_line ++ "\n", .{std.mem.trimLeft(u8, line[1..], " ")});
|
||||
} else if (!cmd_cont and line.len > 1 and mem.eql(u8, line[0..2], "$ ") and line[line.len - 1] == '\\') {
|
||||
try out.writeAll(start_line ++ "$ <kbd>");
|
||||
const s = std.mem.trimLeft(u8, line[1..], " ");
|
||||
if (escape) {
|
||||
try writeEscaped(out, s);
|
||||
} else {
|
||||
try out.writeAll(s);
|
||||
}
|
||||
try out.writeAll(end_line ++ "\n");
|
||||
try out.print(start_line ++ "$ <kbd>{s}" ++ end_line ++ "\n", .{std.mem.trimLeft(u8, line[1..], " ")});
|
||||
cmd_cont = true;
|
||||
} else if (line.len > 0 and line[line.len - 1] != '\\' and cmd_cont) {
|
||||
try out.writeAll(start_line);
|
||||
if (escape) {
|
||||
try writeEscaped(out, line);
|
||||
} else {
|
||||
try out.writeAll(line);
|
||||
}
|
||||
try out.writeAll("</kbd>" ++ end_line ++ "\n");
|
||||
try out.print(start_line ++ "{s}</kbd>" ++ end_line ++ "\n", .{line});
|
||||
cmd_cont = false;
|
||||
} else {
|
||||
try out.writeAll(start_line);
|
||||
if (escape) {
|
||||
try writeEscaped(out, line);
|
||||
} else {
|
||||
try out.writeAll(line);
|
||||
}
|
||||
try out.writeAll(end_line ++ "\n");
|
||||
try out.print(start_line ++ "{s}" ++ end_line ++ "\n", .{line});
|
||||
}
|
||||
}
|
||||
|
||||
try out.writeAll("</samp></pre></figure>");
|
||||
}
|
||||
|
||||
// Override this to skip to later tests
|
||||
const debug_start_line = 0;
|
||||
|
||||
fn genHtml(
|
||||
allocator: Allocator,
|
||||
tokenizer: *Tokenizer,
|
||||
@@ -1229,13 +1196,13 @@ fn genHtml(
|
||||
do_code_tests: bool,
|
||||
) !void {
|
||||
var progress = Progress{};
|
||||
const root_node = progress.start("Generating docgen examples", toc.nodes.len);
|
||||
const root_node = try progress.start("Generating docgen examples", toc.nodes.len);
|
||||
defer root_node.end();
|
||||
|
||||
var env_map = try process.getEnvMap(allocator);
|
||||
try env_map.put("ZIG_DEBUG_COLOR", "1");
|
||||
|
||||
const host = try std.zig.system.NativeTargetInfo.detect(.{});
|
||||
const host = try std.zig.system.NativeTargetInfo.detect(allocator, .{});
|
||||
const builtin_code = try getBuiltinCode(allocator, &env_map, zig_exe);
|
||||
|
||||
for (toc.nodes) |node| {
|
||||
@@ -1280,7 +1247,7 @@ fn genHtml(
|
||||
},
|
||||
.Shell => |content_tok| {
|
||||
const raw_shell_content = tokenizer.buffer[content_tok.start..content_tok.end];
|
||||
try printShell(out, raw_shell_content, true);
|
||||
try printShell(out, raw_shell_content);
|
||||
},
|
||||
.SyntaxBlock => |syntax_block| {
|
||||
try printSourceBlock(allocator, tokenizer, out, syntax_block);
|
||||
@@ -1299,13 +1266,6 @@ fn genHtml(
|
||||
continue;
|
||||
}
|
||||
|
||||
if (debug_start_line > 0) {
|
||||
const loc = tokenizer.getTokenLocation(code.source_token);
|
||||
if (debug_start_line > loc.line) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
const raw_source = tokenizer.buffer[code.source_token.start..code.source_token.end];
|
||||
const trimmed_raw_source = mem.trim(u8, raw_source, " \n");
|
||||
const tmp_source_file_name = try fs.path.join(
|
||||
@@ -1351,10 +1311,6 @@ fn genHtml(
|
||||
try build_args.append("-lc");
|
||||
try shell_out.print("-lc ", .{});
|
||||
}
|
||||
if (code.backend_stage1) {
|
||||
try build_args.append("-fstage1");
|
||||
try shell_out.print("-fstage1", .{});
|
||||
}
|
||||
const target = try std.zig.CrossTarget.parse(.{
|
||||
.arch_os_abi = code.target_str orelse "native",
|
||||
});
|
||||
@@ -1487,10 +1443,6 @@ fn genHtml(
|
||||
try test_args.append("-lc");
|
||||
try shell_out.print("-lc ", .{});
|
||||
}
|
||||
if (code.backend_stage1) {
|
||||
try test_args.append("-fstage1");
|
||||
try shell_out.print("-fstage1", .{});
|
||||
}
|
||||
if (code.target_str) |triple| {
|
||||
try test_args.appendSlice(&[_][]const u8{ "-target", triple });
|
||||
try shell_out.print("-target {s} ", .{triple});
|
||||
@@ -1499,6 +1451,7 @@ fn genHtml(
|
||||
.arch_os_abi = triple,
|
||||
});
|
||||
const target_info = try std.zig.system.NativeTargetInfo.detect(
|
||||
allocator,
|
||||
cross_target,
|
||||
);
|
||||
switch (host.getExternalExecutor(target_info, .{
|
||||
@@ -1537,14 +1490,6 @@ fn genHtml(
|
||||
try shell_out.print("-O {s} ", .{@tagName(code.mode)});
|
||||
},
|
||||
}
|
||||
if (code.link_libc) {
|
||||
try test_args.append("-lc");
|
||||
try shell_out.print("-lc ", .{});
|
||||
}
|
||||
if (code.backend_stage1) {
|
||||
try test_args.append("-fstage1");
|
||||
try shell_out.print("-fstage1", .{});
|
||||
}
|
||||
const result = try ChildProcess.exec(.{
|
||||
.allocator = allocator,
|
||||
.argv = test_args.items,
|
||||
@@ -1756,14 +1701,14 @@ fn genHtml(
|
||||
}
|
||||
|
||||
if (!code.just_check_syntax) {
|
||||
try printShell(out, shell_buffer.items, false);
|
||||
try printShell(out, shell_buffer.items);
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn exec(allocator: Allocator, env_map: *process.EnvMap, args: []const []const u8) !ChildProcess.ExecResult {
|
||||
fn exec(allocator: Allocator, env_map: *std.BufMap, args: []const []const u8) !ChildProcess.ExecResult {
|
||||
const result = try ChildProcess.exec(.{
|
||||
.allocator = allocator,
|
||||
.argv = args,
|
||||
@@ -1787,7 +1732,7 @@ fn exec(allocator: Allocator, env_map: *process.EnvMap, args: []const []const u8
|
||||
return result;
|
||||
}
|
||||
|
||||
fn getBuiltinCode(allocator: Allocator, env_map: *process.EnvMap, zig_exe: []const u8) ![]const u8 {
|
||||
fn getBuiltinCode(allocator: Allocator, env_map: *std.BufMap, zig_exe: []const u8) ![]const u8 {
|
||||
const result = try exec(allocator, env_map, &[_][]const u8{ zig_exe, "build-obj", "--show-builtin" });
|
||||
return result.stdout;
|
||||
}
|
||||
@@ -1814,7 +1759,7 @@ test "shell parsed" {
|
||||
var buffer = std.ArrayList(u8).init(test_allocator);
|
||||
defer buffer.deinit();
|
||||
|
||||
try printShell(buffer.writer(), shell_out, false);
|
||||
try printShell(buffer.writer(), shell_out);
|
||||
std.log.emerg("{s}", .{buffer.items});
|
||||
try testing.expectEqualSlices(u8, expected, buffer.items);
|
||||
}
|
||||
@@ -1832,7 +1777,7 @@ test "shell parsed" {
|
||||
var buffer = std.ArrayList(u8).init(test_allocator);
|
||||
defer buffer.deinit();
|
||||
|
||||
try printShell(buffer.writer(), shell_out, false);
|
||||
try printShell(buffer.writer(), shell_out);
|
||||
try testing.expectEqualSlices(u8, expected, buffer.items);
|
||||
}
|
||||
{
|
||||
@@ -1851,7 +1796,7 @@ test "shell parsed" {
|
||||
var buffer = std.ArrayList(u8).init(test_allocator);
|
||||
defer buffer.deinit();
|
||||
|
||||
try printShell(buffer.writer(), shell_out, false);
|
||||
try printShell(buffer.writer(), shell_out);
|
||||
try testing.expectEqualSlices(u8, expected, buffer.items);
|
||||
}
|
||||
{
|
||||
@@ -1872,7 +1817,7 @@ test "shell parsed" {
|
||||
var buffer = std.ArrayList(u8).init(test_allocator);
|
||||
defer buffer.deinit();
|
||||
|
||||
try printShell(buffer.writer(), shell_out, false);
|
||||
try printShell(buffer.writer(), shell_out);
|
||||
try testing.expectEqualSlices(u8, expected, buffer.items);
|
||||
}
|
||||
{
|
||||
@@ -1891,7 +1836,7 @@ test "shell parsed" {
|
||||
var buffer = std.ArrayList(u8).init(test_allocator);
|
||||
defer buffer.deinit();
|
||||
|
||||
try printShell(buffer.writer(), shell_out, false);
|
||||
try printShell(buffer.writer(), shell_out);
|
||||
try testing.expectEqualSlices(u8, expected, buffer.items);
|
||||
}
|
||||
{
|
||||
@@ -1914,14 +1859,14 @@ test "shell parsed" {
|
||||
var buffer = std.ArrayList(u8).init(test_allocator);
|
||||
defer buffer.deinit();
|
||||
|
||||
try printShell(buffer.writer(), shell_out, false);
|
||||
try printShell(buffer.writer(), shell_out);
|
||||
try testing.expectEqualSlices(u8, expected, buffer.items);
|
||||
}
|
||||
{
|
||||
// intentional space after "--build-option1 \"
|
||||
const shell_out =
|
||||
\\$ zig build test.zig \
|
||||
\\ --build-option1 \
|
||||
\\ --build-option1 \
|
||||
\\ --build-option2
|
||||
\\$ ./test
|
||||
;
|
||||
@@ -1936,7 +1881,7 @@ test "shell parsed" {
|
||||
var buffer = std.ArrayList(u8).init(test_allocator);
|
||||
defer buffer.deinit();
|
||||
|
||||
try printShell(buffer.writer(), shell_out, false);
|
||||
try printShell(buffer.writer(), shell_out);
|
||||
try testing.expectEqualSlices(u8, expected, buffer.items);
|
||||
}
|
||||
{
|
||||
@@ -1953,7 +1898,7 @@ test "shell parsed" {
|
||||
var buffer = std.ArrayList(u8).init(test_allocator);
|
||||
defer buffer.deinit();
|
||||
|
||||
try printShell(buffer.writer(), shell_out, false);
|
||||
try printShell(buffer.writer(), shell_out);
|
||||
try testing.expectEqualSlices(u8, expected, buffer.items);
|
||||
}
|
||||
{
|
||||
@@ -1972,7 +1917,7 @@ test "shell parsed" {
|
||||
var buffer = std.ArrayList(u8).init(test_allocator);
|
||||
defer buffer.deinit();
|
||||
|
||||
try printShell(buffer.writer(), shell_out, false);
|
||||
try printShell(buffer.writer(), shell_out);
|
||||
try testing.expectEqualSlices(u8, expected, buffer.items);
|
||||
}
|
||||
{
|
||||
@@ -1987,7 +1932,7 @@ test "shell parsed" {
|
||||
var buffer = std.ArrayList(u8).init(test_allocator);
|
||||
defer buffer.deinit();
|
||||
|
||||
try printShell(buffer.writer(), shell_out, false);
|
||||
try printShell(buffer.writer(), shell_out);
|
||||
try testing.expectEqualSlices(u8, expected, buffer.items);
|
||||
}
|
||||
}
|
||||
|
||||
1395
doc/langref.html.in
1395
doc/langref.html.in
File diff suppressed because it is too large
Load Diff
555
lib/c.zig
555
lib/c.zig
@@ -1,555 +0,0 @@
|
||||
//! This is Zig's multi-target implementation of libc.
|
||||
//! When builtin.link_libc is true, we need to export all the functions and
|
||||
//! provide an entire C API.
|
||||
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const math = std.math;
|
||||
const isNan = std.math.isNan;
|
||||
const maxInt = std.math.maxInt;
|
||||
const native_os = builtin.os.tag;
|
||||
const native_arch = builtin.cpu.arch;
|
||||
const native_abi = builtin.abi;
|
||||
|
||||
const is_wasm = switch (native_arch) {
|
||||
.wasm32, .wasm64 => true,
|
||||
else => false,
|
||||
};
|
||||
const is_msvc = switch (native_abi) {
|
||||
.msvc => true,
|
||||
else => false,
|
||||
};
|
||||
const is_freestanding = switch (native_os) {
|
||||
.freestanding => true,
|
||||
else => false,
|
||||
};
|
||||
|
||||
comptime {
|
||||
if (is_freestanding and is_wasm and builtin.link_libc) {
|
||||
@export(wasm_start, .{ .name = "_start", .linkage = .Strong });
|
||||
}
|
||||
|
||||
if (native_os == .linux) {
|
||||
@export(clone, .{ .name = "clone" });
|
||||
}
|
||||
|
||||
if (builtin.link_libc) {
|
||||
@export(strcmp, .{ .name = "strcmp", .linkage = .Strong });
|
||||
@export(strncmp, .{ .name = "strncmp", .linkage = .Strong });
|
||||
@export(strerror, .{ .name = "strerror", .linkage = .Strong });
|
||||
@export(strlen, .{ .name = "strlen", .linkage = .Strong });
|
||||
@export(strcpy, .{ .name = "strcpy", .linkage = .Strong });
|
||||
@export(strncpy, .{ .name = "strncpy", .linkage = .Strong });
|
||||
@export(strcat, .{ .name = "strcat", .linkage = .Strong });
|
||||
@export(strncat, .{ .name = "strncat", .linkage = .Strong });
|
||||
} else if (is_msvc) {
|
||||
@export(_fltused, .{ .name = "_fltused", .linkage = .Strong });
|
||||
}
|
||||
}
|
||||
|
||||
// Avoid dragging in the runtime safety mechanisms into this .o file,
|
||||
// unless we're trying to test this file.
|
||||
pub fn panic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
|
||||
@setCold(true);
|
||||
_ = error_return_trace;
|
||||
if (builtin.is_test) {
|
||||
std.debug.panic("{s}", .{msg});
|
||||
}
|
||||
switch (native_os) {
|
||||
.freestanding, .other, .amdhsa, .amdpal => while (true) {},
|
||||
else => std.os.abort(),
|
||||
}
|
||||
}
|
||||
|
||||
extern fn main(argc: c_int, argv: [*:null]?[*:0]u8) c_int;
|
||||
fn wasm_start() callconv(.C) void {
|
||||
_ = main(0, undefined);
|
||||
}
|
||||
|
||||
var _fltused: c_int = 1;
|
||||
|
||||
fn strcpy(dest: [*:0]u8, src: [*:0]const u8) callconv(.C) [*:0]u8 {
|
||||
var i: usize = 0;
|
||||
while (src[i] != 0) : (i += 1) {
|
||||
dest[i] = src[i];
|
||||
}
|
||||
dest[i] = 0;
|
||||
|
||||
return dest;
|
||||
}
|
||||
|
||||
test "strcpy" {
|
||||
var s1: [9:0]u8 = undefined;
|
||||
|
||||
s1[0] = 0;
|
||||
_ = strcpy(&s1, "foobarbaz");
|
||||
try std.testing.expectEqualSlices(u8, "foobarbaz", std.mem.sliceTo(&s1, 0));
|
||||
}
|
||||
|
||||
fn strncpy(dest: [*:0]u8, src: [*:0]const u8, n: usize) callconv(.C) [*:0]u8 {
|
||||
var i: usize = 0;
|
||||
while (i < n and src[i] != 0) : (i += 1) {
|
||||
dest[i] = src[i];
|
||||
}
|
||||
while (i < n) : (i += 1) {
|
||||
dest[i] = 0;
|
||||
}
|
||||
|
||||
return dest;
|
||||
}
|
||||
|
||||
test "strncpy" {
|
||||
var s1: [9:0]u8 = undefined;
|
||||
|
||||
s1[0] = 0;
|
||||
_ = strncpy(&s1, "foobarbaz", @sizeOf(@TypeOf(s1)));
|
||||
try std.testing.expectEqualSlices(u8, "foobarbaz", std.mem.sliceTo(&s1, 0));
|
||||
}
|
||||
|
||||
fn strcat(dest: [*:0]u8, src: [*:0]const u8) callconv(.C) [*:0]u8 {
|
||||
var dest_end: usize = 0;
|
||||
while (dest[dest_end] != 0) : (dest_end += 1) {}
|
||||
|
||||
var i: usize = 0;
|
||||
while (src[i] != 0) : (i += 1) {
|
||||
dest[dest_end + i] = src[i];
|
||||
}
|
||||
dest[dest_end + i] = 0;
|
||||
|
||||
return dest;
|
||||
}
|
||||
|
||||
test "strcat" {
|
||||
var s1: [9:0]u8 = undefined;
|
||||
|
||||
s1[0] = 0;
|
||||
_ = strcat(&s1, "foo");
|
||||
_ = strcat(&s1, "bar");
|
||||
_ = strcat(&s1, "baz");
|
||||
try std.testing.expectEqualSlices(u8, "foobarbaz", std.mem.sliceTo(&s1, 0));
|
||||
}
|
||||
|
||||
fn strncat(dest: [*:0]u8, src: [*:0]const u8, avail: usize) callconv(.C) [*:0]u8 {
|
||||
var dest_end: usize = 0;
|
||||
while (dest[dest_end] != 0) : (dest_end += 1) {}
|
||||
|
||||
var i: usize = 0;
|
||||
while (i < avail and src[i] != 0) : (i += 1) {
|
||||
dest[dest_end + i] = src[i];
|
||||
}
|
||||
dest[dest_end + i] = 0;
|
||||
|
||||
return dest;
|
||||
}
|
||||
|
||||
test "strncat" {
|
||||
var s1: [9:0]u8 = undefined;
|
||||
|
||||
s1[0] = 0;
|
||||
_ = strncat(&s1, "foo1111", 3);
|
||||
_ = strncat(&s1, "bar1111", 3);
|
||||
_ = strncat(&s1, "baz1111", 3);
|
||||
try std.testing.expectEqualSlices(u8, "foobarbaz", std.mem.sliceTo(&s1, 0));
|
||||
}
|
||||
|
||||
fn strcmp(s1: [*:0]const u8, s2: [*:0]const u8) callconv(.C) c_int {
|
||||
return std.cstr.cmp(s1, s2);
|
||||
}
|
||||
|
||||
fn strlen(s: [*:0]const u8) callconv(.C) usize {
|
||||
return std.mem.len(s);
|
||||
}
|
||||
|
||||
fn strncmp(_l: [*:0]const u8, _r: [*:0]const u8, _n: usize) callconv(.C) c_int {
|
||||
if (_n == 0) return 0;
|
||||
var l = _l;
|
||||
var r = _r;
|
||||
var n = _n - 1;
|
||||
while (l[0] != 0 and r[0] != 0 and n != 0 and l[0] == r[0]) {
|
||||
l += 1;
|
||||
r += 1;
|
||||
n -= 1;
|
||||
}
|
||||
return @as(c_int, l[0]) - @as(c_int, r[0]);
|
||||
}
|
||||
|
||||
fn strerror(errnum: c_int) callconv(.C) [*:0]const u8 {
|
||||
_ = errnum;
|
||||
return "TODO strerror implementation";
|
||||
}
|
||||
|
||||
test "strncmp" {
|
||||
try std.testing.expect(strncmp("a", "b", 1) < 0);
|
||||
try std.testing.expect(strncmp("a", "c", 1) < 0);
|
||||
try std.testing.expect(strncmp("b", "a", 1) > 0);
|
||||
try std.testing.expect(strncmp("\xff", "\x02", 1) > 0);
|
||||
}
|
||||
|
||||
// TODO we should be able to put this directly in std/linux/x86_64.zig but
|
||||
// it causes a segfault in release mode. this is a workaround of calling it
|
||||
// across .o file boundaries. fix comptime @ptrCast of nakedcc functions.
|
||||
fn clone() callconv(.Naked) void {
|
||||
switch (native_arch) {
|
||||
.i386 => {
|
||||
// __clone(func, stack, flags, arg, ptid, tls, ctid)
|
||||
// +8, +12, +16, +20, +24, +28, +32
|
||||
// syscall(SYS_clone, flags, stack, ptid, tls, ctid)
|
||||
// eax, ebx, ecx, edx, esi, edi
|
||||
asm volatile (
|
||||
\\ push %%ebp
|
||||
\\ mov %%esp,%%ebp
|
||||
\\ push %%ebx
|
||||
\\ push %%esi
|
||||
\\ push %%edi
|
||||
\\ // Setup the arguments
|
||||
\\ mov 16(%%ebp),%%ebx
|
||||
\\ mov 12(%%ebp),%%ecx
|
||||
\\ and $-16,%%ecx
|
||||
\\ sub $20,%%ecx
|
||||
\\ mov 20(%%ebp),%%eax
|
||||
\\ mov %%eax,4(%%ecx)
|
||||
\\ mov 8(%%ebp),%%eax
|
||||
\\ mov %%eax,0(%%ecx)
|
||||
\\ mov 24(%%ebp),%%edx
|
||||
\\ mov 28(%%ebp),%%esi
|
||||
\\ mov 32(%%ebp),%%edi
|
||||
\\ mov $120,%%eax
|
||||
\\ int $128
|
||||
\\ test %%eax,%%eax
|
||||
\\ jnz 1f
|
||||
\\ pop %%eax
|
||||
\\ xor %%ebp,%%ebp
|
||||
\\ call *%%eax
|
||||
\\ mov %%eax,%%ebx
|
||||
\\ xor %%eax,%%eax
|
||||
\\ inc %%eax
|
||||
\\ int $128
|
||||
\\ hlt
|
||||
\\1:
|
||||
\\ pop %%edi
|
||||
\\ pop %%esi
|
||||
\\ pop %%ebx
|
||||
\\ pop %%ebp
|
||||
\\ ret
|
||||
);
|
||||
},
|
||||
.x86_64 => {
|
||||
asm volatile (
|
||||
\\ xor %%eax,%%eax
|
||||
\\ mov $56,%%al // SYS_clone
|
||||
\\ mov %%rdi,%%r11
|
||||
\\ mov %%rdx,%%rdi
|
||||
\\ mov %%r8,%%rdx
|
||||
\\ mov %%r9,%%r8
|
||||
\\ mov 8(%%rsp),%%r10
|
||||
\\ mov %%r11,%%r9
|
||||
\\ and $-16,%%rsi
|
||||
\\ sub $8,%%rsi
|
||||
\\ mov %%rcx,(%%rsi)
|
||||
\\ syscall
|
||||
\\ test %%eax,%%eax
|
||||
\\ jnz 1f
|
||||
\\ xor %%ebp,%%ebp
|
||||
\\ pop %%rdi
|
||||
\\ call *%%r9
|
||||
\\ mov %%eax,%%edi
|
||||
\\ xor %%eax,%%eax
|
||||
\\ mov $60,%%al // SYS_exit
|
||||
\\ syscall
|
||||
\\ hlt
|
||||
\\1: ret
|
||||
\\
|
||||
);
|
||||
},
|
||||
.aarch64 => {
|
||||
// __clone(func, stack, flags, arg, ptid, tls, ctid)
|
||||
// x0, x1, w2, x3, x4, x5, x6
|
||||
|
||||
// syscall(SYS_clone, flags, stack, ptid, tls, ctid)
|
||||
// x8, x0, x1, x2, x3, x4
|
||||
asm volatile (
|
||||
\\ // align stack and save func,arg
|
||||
\\ and x1,x1,#-16
|
||||
\\ stp x0,x3,[x1,#-16]!
|
||||
\\
|
||||
\\ // syscall
|
||||
\\ uxtw x0,w2
|
||||
\\ mov x2,x4
|
||||
\\ mov x3,x5
|
||||
\\ mov x4,x6
|
||||
\\ mov x8,#220 // SYS_clone
|
||||
\\ svc #0
|
||||
\\
|
||||
\\ cbz x0,1f
|
||||
\\ // parent
|
||||
\\ ret
|
||||
\\ // child
|
||||
\\1: ldp x1,x0,[sp],#16
|
||||
\\ blr x1
|
||||
\\ mov x8,#93 // SYS_exit
|
||||
\\ svc #0
|
||||
);
|
||||
},
|
||||
.arm, .thumb => {
|
||||
// __clone(func, stack, flags, arg, ptid, tls, ctid)
|
||||
// r0, r1, r2, r3, +0, +4, +8
|
||||
|
||||
// syscall(SYS_clone, flags, stack, ptid, tls, ctid)
|
||||
// r7 r0, r1, r2, r3, r4
|
||||
asm volatile (
|
||||
\\ stmfd sp!,{r4,r5,r6,r7}
|
||||
\\ mov r7,#120
|
||||
\\ mov r6,r3
|
||||
\\ mov r5,r0
|
||||
\\ mov r0,r2
|
||||
\\ and r1,r1,#-16
|
||||
\\ ldr r2,[sp,#16]
|
||||
\\ ldr r3,[sp,#20]
|
||||
\\ ldr r4,[sp,#24]
|
||||
\\ svc 0
|
||||
\\ tst r0,r0
|
||||
\\ beq 1f
|
||||
\\ ldmfd sp!,{r4,r5,r6,r7}
|
||||
\\ bx lr
|
||||
\\
|
||||
\\1: mov r0,r6
|
||||
\\ bl 3f
|
||||
\\2: mov r7,#1
|
||||
\\ svc 0
|
||||
\\ b 2b
|
||||
\\3: bx r5
|
||||
);
|
||||
},
|
||||
.riscv64 => {
|
||||
// __clone(func, stack, flags, arg, ptid, tls, ctid)
|
||||
// a0, a1, a2, a3, a4, a5, a6
|
||||
|
||||
// syscall(SYS_clone, flags, stack, ptid, tls, ctid)
|
||||
// a7 a0, a1, a2, a3, a4
|
||||
asm volatile (
|
||||
\\ # Save func and arg to stack
|
||||
\\ addi a1, a1, -16
|
||||
\\ sd a0, 0(a1)
|
||||
\\ sd a3, 8(a1)
|
||||
\\
|
||||
\\ # Call SYS_clone
|
||||
\\ mv a0, a2
|
||||
\\ mv a2, a4
|
||||
\\ mv a3, a5
|
||||
\\ mv a4, a6
|
||||
\\ li a7, 220 # SYS_clone
|
||||
\\ ecall
|
||||
\\
|
||||
\\ beqz a0, 1f
|
||||
\\ # Parent
|
||||
\\ ret
|
||||
\\
|
||||
\\ # Child
|
||||
\\1: ld a1, 0(sp)
|
||||
\\ ld a0, 8(sp)
|
||||
\\ jalr a1
|
||||
\\
|
||||
\\ # Exit
|
||||
\\ li a7, 93 # SYS_exit
|
||||
\\ ecall
|
||||
);
|
||||
},
|
||||
.mips, .mipsel => {
|
||||
// __clone(func, stack, flags, arg, ptid, tls, ctid)
|
||||
// 3, 4, 5, 6, 7, 8, 9
|
||||
|
||||
// syscall(SYS_clone, flags, stack, ptid, tls, ctid)
|
||||
// 2 4, 5, 6, 7, 8
|
||||
asm volatile (
|
||||
\\ # Save function pointer and argument pointer on new thread stack
|
||||
\\ and $5, $5, -8
|
||||
\\ subu $5, $5, 16
|
||||
\\ sw $4, 0($5)
|
||||
\\ sw $7, 4($5)
|
||||
\\ # Shuffle (fn,sp,fl,arg,ptid,tls,ctid) to (fl,sp,ptid,tls,ctid)
|
||||
\\ move $4, $6
|
||||
\\ lw $6, 16($sp)
|
||||
\\ lw $7, 20($sp)
|
||||
\\ lw $9, 24($sp)
|
||||
\\ subu $sp, $sp, 16
|
||||
\\ sw $9, 16($sp)
|
||||
\\ li $2, 4120
|
||||
\\ syscall
|
||||
\\ beq $7, $0, 1f
|
||||
\\ nop
|
||||
\\ addu $sp, $sp, 16
|
||||
\\ jr $ra
|
||||
\\ subu $2, $0, $2
|
||||
\\1:
|
||||
\\ beq $2, $0, 1f
|
||||
\\ nop
|
||||
\\ addu $sp, $sp, 16
|
||||
\\ jr $ra
|
||||
\\ nop
|
||||
\\1:
|
||||
\\ lw $25, 0($sp)
|
||||
\\ lw $4, 4($sp)
|
||||
\\ jalr $25
|
||||
\\ nop
|
||||
\\ move $4, $2
|
||||
\\ li $2, 4001
|
||||
\\ syscall
|
||||
);
|
||||
},
|
||||
.powerpc => {
|
||||
// __clone(func, stack, flags, arg, ptid, tls, ctid)
|
||||
// 3, 4, 5, 6, 7, 8, 9
|
||||
|
||||
// syscall(SYS_clone, flags, stack, ptid, tls, ctid)
|
||||
// 0 3, 4, 5, 6, 7
|
||||
asm volatile (
|
||||
\\# store non-volatile regs r30, r31 on stack in order to put our
|
||||
\\# start func and its arg there
|
||||
\\stwu 30, -16(1)
|
||||
\\stw 31, 4(1)
|
||||
\\
|
||||
\\# save r3 (func) into r30, and r6(arg) into r31
|
||||
\\mr 30, 3
|
||||
\\mr 31, 6
|
||||
\\
|
||||
\\# create initial stack frame for new thread
|
||||
\\clrrwi 4, 4, 4
|
||||
\\li 0, 0
|
||||
\\stwu 0, -16(4)
|
||||
\\
|
||||
\\#move c into first arg
|
||||
\\mr 3, 5
|
||||
\\#mr 4, 4
|
||||
\\mr 5, 7
|
||||
\\mr 6, 8
|
||||
\\mr 7, 9
|
||||
\\
|
||||
\\# move syscall number into r0
|
||||
\\li 0, 120
|
||||
\\
|
||||
\\sc
|
||||
\\
|
||||
\\# check for syscall error
|
||||
\\bns+ 1f # jump to label 1 if no summary overflow.
|
||||
\\#else
|
||||
\\neg 3, 3 #negate the result (errno)
|
||||
\\1:
|
||||
\\# compare sc result with 0
|
||||
\\cmpwi cr7, 3, 0
|
||||
\\
|
||||
\\# if not 0, jump to end
|
||||
\\bne cr7, 2f
|
||||
\\
|
||||
\\#else: we're the child
|
||||
\\#call funcptr: move arg (d) into r3
|
||||
\\mr 3, 31
|
||||
\\#move r30 (funcptr) into CTR reg
|
||||
\\mtctr 30
|
||||
\\# call CTR reg
|
||||
\\bctrl
|
||||
\\# mov SYS_exit into r0 (the exit param is already in r3)
|
||||
\\li 0, 1
|
||||
\\sc
|
||||
\\
|
||||
\\2:
|
||||
\\
|
||||
\\# restore stack
|
||||
\\lwz 30, 0(1)
|
||||
\\lwz 31, 4(1)
|
||||
\\addi 1, 1, 16
|
||||
\\
|
||||
\\blr
|
||||
);
|
||||
},
|
||||
.powerpc64, .powerpc64le => {
|
||||
// __clone(func, stack, flags, arg, ptid, tls, ctid)
|
||||
// 3, 4, 5, 6, 7, 8, 9
|
||||
|
||||
// syscall(SYS_clone, flags, stack, ptid, tls, ctid)
|
||||
// 0 3, 4, 5, 6, 7
|
||||
asm volatile (
|
||||
\\ # create initial stack frame for new thread
|
||||
\\ clrrdi 4, 4, 4
|
||||
\\ li 0, 0
|
||||
\\ stdu 0,-32(4)
|
||||
\\
|
||||
\\ # save fn and arg to child stack
|
||||
\\ std 3, 8(4)
|
||||
\\ std 6, 16(4)
|
||||
\\
|
||||
\\ # shuffle args into correct registers and call SYS_clone
|
||||
\\ mr 3, 5
|
||||
\\ #mr 4, 4
|
||||
\\ mr 5, 7
|
||||
\\ mr 6, 8
|
||||
\\ mr 7, 9
|
||||
\\ li 0, 120 # SYS_clone = 120
|
||||
\\ sc
|
||||
\\
|
||||
\\ # if error, negate return (errno)
|
||||
\\ bns+ 1f
|
||||
\\ neg 3, 3
|
||||
\\
|
||||
\\1:
|
||||
\\ # if we're the parent, return
|
||||
\\ cmpwi cr7, 3, 0
|
||||
\\ bnelr cr7
|
||||
\\
|
||||
\\ # we're the child. call fn(arg)
|
||||
\\ ld 3, 16(1)
|
||||
\\ ld 12, 8(1)
|
||||
\\ mtctr 12
|
||||
\\ bctrl
|
||||
\\
|
||||
\\ # call SYS_exit. exit code is already in r3 from fn return value
|
||||
\\ li 0, 1 # SYS_exit = 1
|
||||
\\ sc
|
||||
);
|
||||
},
|
||||
.sparc64 => {
|
||||
// __clone(func, stack, flags, arg, ptid, tls, ctid)
|
||||
// i0, i1, i2, i3, i4, i5, sp
|
||||
// syscall(SYS_clone, flags, stack, ptid, tls, ctid)
|
||||
// g1 o0, o1, o2, o3, o4
|
||||
asm volatile (
|
||||
\\ save %%sp, -192, %%sp
|
||||
\\ # Save the func pointer and the arg pointer
|
||||
\\ mov %%i0, %%g2
|
||||
\\ mov %%i3, %%g3
|
||||
\\ # Shuffle the arguments
|
||||
\\ mov 217, %%g1
|
||||
\\ mov %%i2, %%o0
|
||||
\\ # Add some extra space for the initial frame
|
||||
\\ sub %%i1, 176 + 2047, %%o1
|
||||
\\ mov %%i4, %%o2
|
||||
\\ mov %%i5, %%o3
|
||||
\\ ldx [%%fp + 0x8af], %%o4
|
||||
\\ t 0x6d
|
||||
\\ bcs,pn %%xcc, 2f
|
||||
\\ nop
|
||||
\\ # The child pid is returned in o0 while o1 tells if this
|
||||
\\ # process is # the child (=1) or the parent (=0).
|
||||
\\ brnz %%o1, 1f
|
||||
\\ nop
|
||||
\\ # Parent process, return the child pid
|
||||
\\ mov %%o0, %%i0
|
||||
\\ ret
|
||||
\\ restore
|
||||
\\1:
|
||||
\\ # Child process, call func(arg)
|
||||
\\ mov %%g0, %%fp
|
||||
\\ call %%g2
|
||||
\\ mov %%g3, %%o0
|
||||
\\ # Exit
|
||||
\\ mov 1, %%g1
|
||||
\\ t 0x6d
|
||||
\\2:
|
||||
\\ # The syscall failed
|
||||
\\ sub %%g0, %%o0, %%i0
|
||||
\\ ret
|
||||
\\ restore
|
||||
);
|
||||
},
|
||||
else => @compileError("Implement clone() for this arch."),
|
||||
}
|
||||
}
|
||||
@@ -1,224 +0,0 @@
|
||||
const builtin = @import("builtin");
|
||||
|
||||
pub const panic = @import("compiler_rt/common.zig").panic;
|
||||
|
||||
comptime {
|
||||
_ = @import("compiler_rt/atomics.zig");
|
||||
|
||||
// macOS has these functions inside libSystem.
|
||||
if (builtin.cpu.arch.isAARCH64() and !builtin.os.tag.isDarwin()) {
|
||||
_ = @import("compiler_rt/aarch64_outline_atomics.zig");
|
||||
}
|
||||
|
||||
_ = @import("compiler_rt/addf3.zig");
|
||||
_ = @import("compiler_rt/addhf3.zig");
|
||||
_ = @import("compiler_rt/addsf3.zig");
|
||||
_ = @import("compiler_rt/adddf3.zig");
|
||||
_ = @import("compiler_rt/addtf3.zig");
|
||||
_ = @import("compiler_rt/addxf3.zig");
|
||||
|
||||
_ = @import("compiler_rt/subhf3.zig");
|
||||
_ = @import("compiler_rt/subsf3.zig");
|
||||
_ = @import("compiler_rt/subdf3.zig");
|
||||
_ = @import("compiler_rt/subtf3.zig");
|
||||
_ = @import("compiler_rt/subxf3.zig");
|
||||
|
||||
_ = @import("compiler_rt/mulf3.zig");
|
||||
_ = @import("compiler_rt/mulhf3.zig");
|
||||
_ = @import("compiler_rt/mulsf3.zig");
|
||||
_ = @import("compiler_rt/muldf3.zig");
|
||||
_ = @import("compiler_rt/multf3.zig");
|
||||
_ = @import("compiler_rt/mulxf3.zig");
|
||||
|
||||
_ = @import("compiler_rt/mulc3.zig");
|
||||
_ = @import("compiler_rt/mulhc3.zig");
|
||||
_ = @import("compiler_rt/mulsc3.zig");
|
||||
_ = @import("compiler_rt/muldc3.zig");
|
||||
_ = @import("compiler_rt/mulxc3.zig");
|
||||
_ = @import("compiler_rt/multc3.zig");
|
||||
|
||||
_ = @import("compiler_rt/divc3.zig");
|
||||
_ = @import("compiler_rt/divhc3.zig");
|
||||
_ = @import("compiler_rt/divsc3.zig");
|
||||
_ = @import("compiler_rt/divdc3.zig");
|
||||
_ = @import("compiler_rt/divxc3.zig");
|
||||
_ = @import("compiler_rt/divtc3.zig");
|
||||
|
||||
_ = @import("compiler_rt/neghf2.zig");
|
||||
_ = @import("compiler_rt/negsf2.zig");
|
||||
_ = @import("compiler_rt/negdf2.zig");
|
||||
_ = @import("compiler_rt/negtf2.zig");
|
||||
_ = @import("compiler_rt/negxf2.zig");
|
||||
|
||||
_ = @import("compiler_rt/comparef.zig");
|
||||
_ = @import("compiler_rt/cmphf2.zig");
|
||||
_ = @import("compiler_rt/cmpsf2.zig");
|
||||
_ = @import("compiler_rt/cmpdf2.zig");
|
||||
_ = @import("compiler_rt/cmptf2.zig");
|
||||
_ = @import("compiler_rt/cmpxf2.zig");
|
||||
_ = @import("compiler_rt/gehf2.zig");
|
||||
_ = @import("compiler_rt/gesf2.zig");
|
||||
_ = @import("compiler_rt/gedf2.zig");
|
||||
_ = @import("compiler_rt/gexf2.zig");
|
||||
_ = @import("compiler_rt/getf2.zig");
|
||||
_ = @import("compiler_rt/unordhf2.zig");
|
||||
_ = @import("compiler_rt/unordsf2.zig");
|
||||
_ = @import("compiler_rt/unorddf2.zig");
|
||||
_ = @import("compiler_rt/unordxf2.zig");
|
||||
_ = @import("compiler_rt/unordtf2.zig");
|
||||
|
||||
_ = @import("compiler_rt/extendf.zig");
|
||||
_ = @import("compiler_rt/extendhfsf2.zig");
|
||||
_ = @import("compiler_rt/extendhfdf2.zig");
|
||||
_ = @import("compiler_rt/extendhftf2.zig");
|
||||
_ = @import("compiler_rt/extendhfxf2.zig");
|
||||
_ = @import("compiler_rt/extendsfdf2.zig");
|
||||
_ = @import("compiler_rt/extendsftf2.zig");
|
||||
_ = @import("compiler_rt/extendsfxf2.zig");
|
||||
_ = @import("compiler_rt/extenddftf2.zig");
|
||||
_ = @import("compiler_rt/extenddfxf2.zig");
|
||||
_ = @import("compiler_rt/extendxftf2.zig");
|
||||
|
||||
_ = @import("compiler_rt/truncf.zig");
|
||||
_ = @import("compiler_rt/truncsfhf2.zig");
|
||||
_ = @import("compiler_rt/truncdfhf2.zig");
|
||||
_ = @import("compiler_rt/truncdfsf2.zig");
|
||||
_ = @import("compiler_rt/truncxfhf2.zig");
|
||||
_ = @import("compiler_rt/truncxfsf2.zig");
|
||||
_ = @import("compiler_rt/truncxfdf2.zig");
|
||||
_ = @import("compiler_rt/trunctfhf2.zig");
|
||||
_ = @import("compiler_rt/trunctfsf2.zig");
|
||||
_ = @import("compiler_rt/trunctfdf2.zig");
|
||||
_ = @import("compiler_rt/trunctfxf2.zig");
|
||||
|
||||
_ = @import("compiler_rt/divhf3.zig");
|
||||
_ = @import("compiler_rt/divsf3.zig");
|
||||
_ = @import("compiler_rt/divdf3.zig");
|
||||
_ = @import("compiler_rt/divxf3.zig");
|
||||
_ = @import("compiler_rt/divtf3.zig");
|
||||
_ = @import("compiler_rt/sin.zig");
|
||||
_ = @import("compiler_rt/cos.zig");
|
||||
_ = @import("compiler_rt/sincos.zig");
|
||||
_ = @import("compiler_rt/ceil.zig");
|
||||
_ = @import("compiler_rt/exp.zig");
|
||||
_ = @import("compiler_rt/exp2.zig");
|
||||
_ = @import("compiler_rt/fabs.zig");
|
||||
_ = @import("compiler_rt/floor.zig");
|
||||
_ = @import("compiler_rt/fma.zig");
|
||||
_ = @import("compiler_rt/fmax.zig");
|
||||
_ = @import("compiler_rt/fmin.zig");
|
||||
_ = @import("compiler_rt/fmod.zig");
|
||||
_ = @import("compiler_rt/log.zig");
|
||||
_ = @import("compiler_rt/log10.zig");
|
||||
_ = @import("compiler_rt/log2.zig");
|
||||
_ = @import("compiler_rt/round.zig");
|
||||
_ = @import("compiler_rt/sqrt.zig");
|
||||
_ = @import("compiler_rt/tan.zig");
|
||||
_ = @import("compiler_rt/trunc.zig");
|
||||
_ = @import("compiler_rt/stack_probe.zig");
|
||||
_ = @import("compiler_rt/divti3.zig");
|
||||
_ = @import("compiler_rt/modti3.zig");
|
||||
_ = @import("compiler_rt/multi3.zig");
|
||||
_ = @import("compiler_rt/udivti3.zig");
|
||||
_ = @import("compiler_rt/udivmodti4.zig");
|
||||
_ = @import("compiler_rt/umodti3.zig");
|
||||
|
||||
_ = @import("compiler_rt/int_to_float.zig");
|
||||
_ = @import("compiler_rt/floatsihf.zig");
|
||||
_ = @import("compiler_rt/floatsisf.zig");
|
||||
_ = @import("compiler_rt/floatsidf.zig");
|
||||
_ = @import("compiler_rt/floatsitf.zig");
|
||||
_ = @import("compiler_rt/floatsixf.zig");
|
||||
_ = @import("compiler_rt/floatdihf.zig");
|
||||
_ = @import("compiler_rt/floatdisf.zig");
|
||||
_ = @import("compiler_rt/floatdidf.zig");
|
||||
_ = @import("compiler_rt/floatditf.zig");
|
||||
_ = @import("compiler_rt/floatdixf.zig");
|
||||
_ = @import("compiler_rt/floattihf.zig");
|
||||
_ = @import("compiler_rt/floattisf.zig");
|
||||
_ = @import("compiler_rt/floattidf.zig");
|
||||
_ = @import("compiler_rt/floattitf.zig");
|
||||
_ = @import("compiler_rt/floattixf.zig");
|
||||
_ = @import("compiler_rt/floatundihf.zig");
|
||||
_ = @import("compiler_rt/floatundisf.zig");
|
||||
_ = @import("compiler_rt/floatundidf.zig");
|
||||
_ = @import("compiler_rt/floatunditf.zig");
|
||||
_ = @import("compiler_rt/floatundixf.zig");
|
||||
_ = @import("compiler_rt/floatunsihf.zig");
|
||||
_ = @import("compiler_rt/floatunsisf.zig");
|
||||
_ = @import("compiler_rt/floatunsidf.zig");
|
||||
_ = @import("compiler_rt/floatunsitf.zig");
|
||||
_ = @import("compiler_rt/floatunsixf.zig");
|
||||
_ = @import("compiler_rt/floatuntihf.zig");
|
||||
_ = @import("compiler_rt/floatuntisf.zig");
|
||||
_ = @import("compiler_rt/floatuntidf.zig");
|
||||
_ = @import("compiler_rt/floatuntitf.zig");
|
||||
_ = @import("compiler_rt/floatuntixf.zig");
|
||||
|
||||
_ = @import("compiler_rt/float_to_int.zig");
|
||||
_ = @import("compiler_rt/fixhfsi.zig");
|
||||
_ = @import("compiler_rt/fixhfdi.zig");
|
||||
_ = @import("compiler_rt/fixhfti.zig");
|
||||
_ = @import("compiler_rt/fixsfsi.zig");
|
||||
_ = @import("compiler_rt/fixsfdi.zig");
|
||||
_ = @import("compiler_rt/fixsfti.zig");
|
||||
_ = @import("compiler_rt/fixdfsi.zig");
|
||||
_ = @import("compiler_rt/fixdfdi.zig");
|
||||
_ = @import("compiler_rt/fixdfti.zig");
|
||||
_ = @import("compiler_rt/fixtfsi.zig");
|
||||
_ = @import("compiler_rt/fixtfdi.zig");
|
||||
_ = @import("compiler_rt/fixtfti.zig");
|
||||
_ = @import("compiler_rt/fixxfsi.zig");
|
||||
_ = @import("compiler_rt/fixxfdi.zig");
|
||||
_ = @import("compiler_rt/fixxfti.zig");
|
||||
_ = @import("compiler_rt/fixunshfsi.zig");
|
||||
_ = @import("compiler_rt/fixunshfdi.zig");
|
||||
_ = @import("compiler_rt/fixunshfti.zig");
|
||||
_ = @import("compiler_rt/fixunssfsi.zig");
|
||||
_ = @import("compiler_rt/fixunssfdi.zig");
|
||||
_ = @import("compiler_rt/fixunssfti.zig");
|
||||
_ = @import("compiler_rt/fixunsdfsi.zig");
|
||||
_ = @import("compiler_rt/fixunsdfdi.zig");
|
||||
_ = @import("compiler_rt/fixunsdfti.zig");
|
||||
_ = @import("compiler_rt/fixunstfsi.zig");
|
||||
_ = @import("compiler_rt/fixunstfdi.zig");
|
||||
_ = @import("compiler_rt/fixunstfti.zig");
|
||||
_ = @import("compiler_rt/fixunsxfsi.zig");
|
||||
_ = @import("compiler_rt/fixunsxfdi.zig");
|
||||
_ = @import("compiler_rt/fixunsxfti.zig");
|
||||
|
||||
_ = @import("compiler_rt/count0bits.zig");
|
||||
_ = @import("compiler_rt/parity.zig");
|
||||
_ = @import("compiler_rt/popcount.zig");
|
||||
_ = @import("compiler_rt/bswap.zig");
|
||||
_ = @import("compiler_rt/int.zig");
|
||||
_ = @import("compiler_rt/shift.zig");
|
||||
|
||||
_ = @import("compiler_rt/negXi2.zig");
|
||||
|
||||
_ = @import("compiler_rt/muldi3.zig");
|
||||
|
||||
_ = @import("compiler_rt/absv.zig");
|
||||
_ = @import("compiler_rt/absvsi2.zig");
|
||||
_ = @import("compiler_rt/absvdi2.zig");
|
||||
_ = @import("compiler_rt/absvti2.zig");
|
||||
|
||||
_ = @import("compiler_rt/negv.zig");
|
||||
_ = @import("compiler_rt/addo.zig");
|
||||
_ = @import("compiler_rt/subo.zig");
|
||||
_ = @import("compiler_rt/mulo.zig");
|
||||
_ = @import("compiler_rt/cmp.zig");
|
||||
|
||||
_ = @import("compiler_rt/os_version_check.zig");
|
||||
_ = @import("compiler_rt/emutls.zig");
|
||||
_ = @import("compiler_rt/arm.zig");
|
||||
_ = @import("compiler_rt/aulldiv.zig");
|
||||
_ = @import("compiler_rt/aullrem.zig");
|
||||
_ = @import("compiler_rt/clear_cache.zig");
|
||||
|
||||
_ = @import("compiler_rt/memcpy.zig");
|
||||
_ = @import("compiler_rt/memset.zig");
|
||||
_ = @import("compiler_rt/memmove.zig");
|
||||
_ = @import("compiler_rt/memcmp.zig");
|
||||
_ = @import("compiler_rt/bcmp.zig");
|
||||
}
|
||||
@@ -1,508 +0,0 @@
|
||||
If hardware lacks basic or specialized functionality, compiler-rt adds such functionality
|
||||
for basic arithmetic(s).
|
||||
One such example is 64-bit integer multiplication on 32-bit x86.
|
||||
|
||||
Goals:
|
||||
1. zig as linker for object files produced by other compilers
|
||||
=> `function compatibility` to compiler-rt and libgcc for same-named functions
|
||||
* compatibility conflict between compiler-rt and libgcc: prefer compiler-rt
|
||||
2. `symbol-level compatibility` low-priority compared to emitted calls by llvm
|
||||
* symbol-level compatibility: libgcc even lower priority
|
||||
3. add zig-specific language runtime features, see #7265
|
||||
* example: arbitrary bit width integer arithmetic
|
||||
* lower to call those functions for e.g. multiplying two i12345 numbers together
|
||||
* proper naming + documention for standardizing (allow languages to follow our exmaple)
|
||||
|
||||
Current status (tracking libgcc documentation):
|
||||
- Integer library routines => almost implemented
|
||||
- Soft float library routines => finished
|
||||
- Decimal float library routines => unimplemented (~120 functions)
|
||||
- Fixed-point fractional library routines => unimplemented (~300 functions)
|
||||
- Exception handling routines => unclear, if supported (~32+x undocumented functions)
|
||||
- Miscellaneous routines => unclear, if supported (cache control and stack function)
|
||||
- No zig-specific language runtime features in compiler-rt yet
|
||||
|
||||
This library is automatically built as-needed for the compilation target and
|
||||
then statically linked and therefore is a transparent dependency for the
|
||||
programmer.
|
||||
For details see `../compiler_rt.zig`.
|
||||
|
||||
The routines in this folder are listed below.
|
||||
Routines are annotated as `type source routine // description`, with `routine`
|
||||
being the name used in aforementioned `compiler_rt.zig`.
|
||||
`dev` means deviating from compiler_rt, `port` ported, `source` is the
|
||||
information source for the implementation, `none` means unimplemented.
|
||||
Some examples for the naming convention are:
|
||||
- dev source name_routine, name_routine2 various implementations for performance, simplicity etc
|
||||
- port llvm compiler-rt library routines from [LLVM](http://compiler-rt.llvm.org/)
|
||||
* LLVM emits library calls to compiler-rt, if the hardware lacks functionality
|
||||
- port musl libc routines from [musl](https://musl.libc.org/)
|
||||
If the library or information source is uncommon, use the entry `other` for `source`.
|
||||
Please do not break the search by inserting entries in another format than `impl space source`.
|
||||
|
||||
Bugs should be solved by trying to duplicate the bug upstream, if possible.
|
||||
* If the bug exists upstream, get it fixed upstream and port the fix downstream to Zig.
|
||||
* If the bug only exists in Zig, use the corresponding C code and debug
|
||||
both implementations side by side to figure out what is wrong.
|
||||
|
||||
## Integer library routines
|
||||
|
||||
#### Integer Bit operations
|
||||
|
||||
- dev HackersDelight __clzsi2 // count leading zeros
|
||||
- dev HackersDelight __clzdi2 // count leading zeros
|
||||
- dev HackersDelight __clzti2 // count leading zeros
|
||||
- dev HackersDelight __ctzsi2 // count trailing zeros
|
||||
- dev HackersDelight __ctzdi2 // count trailing zeros
|
||||
- dev HackersDelight __ctzti2 // count trailing zeros
|
||||
- dev __ctzsi2 __ffssi2 // find least significant 1 bit
|
||||
- dev __ctzsi2 __ffsdi2 // find least significant 1 bit
|
||||
- dev __ctzsi2 __ffsti2 // find least significant 1 bit
|
||||
- dev BitTwiddlingHacks __paritysi2 // bit parity
|
||||
- dev BitTwiddlingHacks __paritydi2 // bit parity
|
||||
- dev BitTwiddlingHacks __parityti2 // bit parity
|
||||
- dev TAOCP __popcountsi2 // bit population
|
||||
- dev TAOCP __popcountdi2 // bit population
|
||||
- dev TAOCP __popcountti2 // bit population
|
||||
- dev other __bswapsi2 // a byteswapped
|
||||
- dev other __bswapdi2 // a byteswapped
|
||||
- dev other __bswapti2 // a byteswapped
|
||||
|
||||
#### Integer Comparison
|
||||
|
||||
- port llvm __cmpsi2 // a,b: i32, (a<b)-> 0, (a==b) -> 1, (a>b) -> 2
|
||||
- port llvm __cmpdi2 // a,b: i64
|
||||
- port llvm __cmpti2 // a,b: i128
|
||||
- port llvm __ucmpsi2 // a,b: u32, (a<b)-> 0, (a==b) -> 1, (a>b) -> 2
|
||||
- port llvm __ucmpdi2 // a,b: u64
|
||||
- port llvm __ucmpti2 // a,b: u128
|
||||
|
||||
#### Integer Arithmetic
|
||||
|
||||
- none none __ashlsi3 // a,b: i32, a << b unused in llvm, TODO (e.g. used by rl78)
|
||||
- port llvm __ashldi3 // a,b: u64
|
||||
- port llvm __ashlti3 // a,b: u128
|
||||
- none none __ashrsi3 // a,b: i32, a >> b arithmetic (sign fill) TODO (e.g. used by rl78)
|
||||
- port llvm __ashrdi3 // ..
|
||||
- port llvm __ashrti3 //
|
||||
- none none __lshrsi3 // a,b: i32, a >> b logical (zero fill) TODO (e.g. used by rl78)
|
||||
- port llvm __lshrdi3 //
|
||||
- port llvm __lshrti3 //
|
||||
- port llvm __negdi2 // a: i32, -a, symbol-level compatibility with libgcc
|
||||
- port llvm __negti2 // unnecessary: unused in backends
|
||||
- port llvm __mulsi3 // a,b: i32, a * b
|
||||
- port llvm __muldi3 //
|
||||
- port llvm __multi3 //
|
||||
- port llvm __divsi3 // a,b: i32, a / b
|
||||
- port llvm __divdi3 //
|
||||
- port llvm __divti3 //
|
||||
- port llvm __udivsi3 // a,b: u32, a / b
|
||||
- port llvm __udivdi3 //
|
||||
- port llvm __udivti3 //
|
||||
- port llvm __modsi3 // a,b: i32, a % b
|
||||
- port llvm __moddi3 //
|
||||
- port llvm __modti3 //
|
||||
- port llvm __umodsi3 // a,b: u32, a % b
|
||||
- port llvm __umoddi3 //
|
||||
- port llvm __umodti3 //
|
||||
- port llvm __udivmoddi4 // a,b: u32, a / b, rem.* = a % b unsigned
|
||||
- port llvm __udivmodti4 //
|
||||
- port llvm __udivmodsi4 //
|
||||
- port llvm __divmodsi4 // a,b: i32, a / b, rem.* = a % b signed, ARM
|
||||
- port llvm __divmoddi4 //
|
||||
|
||||
#### Integer Arithmetic with trapping overflow
|
||||
|
||||
- dev BitTwiddlingHacks __absvsi2 // abs(a)
|
||||
- dev BitTwiddlingHacks __absvdi2 // abs(a)
|
||||
- dev BitTwiddlingHacks __absvti2 // abs(a)
|
||||
- port llvm __negvsi2 // -a symbol-level compatibility: libgcc
|
||||
- port llvm __negvdi2 // -a unnecessary: unused in backends
|
||||
- port llvm __negvti2 // -a
|
||||
- TODO upstreaming __addvsi3..__mulvti3 after testing panics works
|
||||
- dev HackersDelight __addvsi3 // a + b
|
||||
- dev HackersDelight __addvdi3 //
|
||||
- dev HackersDelight __addvti3 //
|
||||
- dev HackersDelight __subvsi3 // a - b
|
||||
- dev HackersDelight __subvdi3 //
|
||||
- dev HackersDelight __subvti3 //
|
||||
- dev HackersDelight __mulvsi3 // a * b
|
||||
- dev HackersDelight __mulvdi3 //
|
||||
- dev HackersDelight __mulvti3 //
|
||||
|
||||
#### Integer Arithmetic which returns if overflow (would be faster without pointer)
|
||||
|
||||
- dev HackersDelight __addosi4 // a + b, overflow->ov.*=1 else 0
|
||||
- dev HackersDelight __addodi4 // (completeness + performance, llvm does not use them)
|
||||
- dev HackersDelight __addoti4 //
|
||||
- dev HackersDelight __subosi4 // a - b, overflow->ov.*=1 else 0
|
||||
- dev HackersDelight __subodi4 // (completeness + performance, llvm does not use them)
|
||||
- dev HackersDelight __suboti4 //
|
||||
- dev HackersDelight __mulosi4 // a * b, overflow->ov.*=1 else 0
|
||||
- dev HackersDelight __mulodi4 // (required by llvm)
|
||||
- dev HackersDelight __muloti4 //
|
||||
|
||||
## Float library routines
|
||||
|
||||
TODO: review source of implementation
|
||||
|
||||
#### Float Conversion
|
||||
|
||||
- dev other __extendsfdf2 // a: f32 -> f64, TODO: missing tests
|
||||
- dev other __extendsftf2 // a: f32 -> f128
|
||||
- dev llvm __extendsfxf2 // a: f32 -> f80, TODO: missing tests
|
||||
- dev other __extenddftf2 // a: f64 -> f128
|
||||
- dev llvm __extenddfxf2 // a: f64 -> f80
|
||||
- dev other __truncdfsf2 // a: f64 -> f32, rounding towards zero
|
||||
- dev other __trunctfdf2 // a: f128-> f64
|
||||
- dev other __trunctfsf2 // a: f128-> f32
|
||||
- dev llvm __truncxfsf2 // a: f80 -> f32, TODO: missing tests
|
||||
- dev llvm __truncxfdf2 // a: f80 -> f64, TODO: missing tests
|
||||
|
||||
- dev unclear __fixsfsi // a: f32 -> i32, rounding towards zero
|
||||
- dev unclear __fixdfsi // a: f64 -> i32
|
||||
- dev unclear __fixtfsi // a: f128-> i32
|
||||
- dev unclear __fixxfsi // a: f80 -> i32, TODO: missing tests
|
||||
- dev unclear __fixsfdi // a: f32 -> i64, rounding towards zero
|
||||
- dev unclear __fixdfdi // ..
|
||||
- dev unclear __fixtfdi //
|
||||
- dev unclear __fixxfdi // TODO: missing tests
|
||||
- dev unclear __fixsfti // a: f32 -> i128, rounding towards zero
|
||||
- dev unclear __fixdfti // ..
|
||||
- dev unclear __fixtfdi //
|
||||
- dev unclear __fixxfti // TODO: missing tests
|
||||
|
||||
- dev unclear __fixunssfsi // a: f32 -> u32, rounding towards zero. negative values become 0.
|
||||
- dev unclear __fixunsdfsi // ..
|
||||
- dev unclear __fixunstfsi //
|
||||
- dev unclear __fixunsxfsi // TODO: missing tests
|
||||
- dev unclear __fixunssfdi // a: f32 -> u64, rounding towards zero. negative values become 0.
|
||||
- dev unclear __fixunsdfdi //
|
||||
- dev unclear __fixunstfdi //
|
||||
- dev unclear __fixunsxfdi // TODO: missing tests
|
||||
- dev unclear __fixunssfti // a: f32 -> u128, rounding towards zero. negative values become 0.
|
||||
- dev unclear __fixunsdfti //
|
||||
- dev unclear __fixunstfdi //
|
||||
- dev unclear __fixunsxfti // TODO: some more tests needed for base coverage
|
||||
|
||||
- dev unclear __floatsisf // a: i32 -> f32
|
||||
- dev unclear __floatsidf // a: i32 -> f64, TODO: missing tests
|
||||
- dev unclear __floatsitf // ..
|
||||
- dev unclear __floatsixf // TODO: missing tests
|
||||
- dev unclear __floatdisf // a: i64 -> f32
|
||||
- dev unclear __floatdidf //
|
||||
- dev unclear __floatditf //
|
||||
- dev unclear __floatdixf // TODO: missing tests
|
||||
- dev unclear __floattisf // a: i128-> f32
|
||||
- dev unclear __floattidf //
|
||||
- dev unclear __floattitf //
|
||||
- dev unclear __floattixf // TODO: missing tests
|
||||
|
||||
- dev unclear __floatunsisf // a: u32 -> f32
|
||||
- dev unclear __floatunsidf // TODO: missing tests
|
||||
- dev unclear __floatunsitf //
|
||||
- dev unclear __floatunsixf // TODO: missing tests
|
||||
- dev unclear __floatundisf // a: u64 -> f32
|
||||
- dev unclear __floatundidf //
|
||||
- dev unclear __floatunditf //
|
||||
- dev unclear __floatundixf // TODO: missing tests
|
||||
- dev unclear __floatuntisf // a: u128-> f32
|
||||
- dev unclear __floatuntidf //
|
||||
- dev unclear __floatuntitf //
|
||||
- dev unclear __floatuntixf // TODO: missing tests
|
||||
|
||||
#### Float Comparison
|
||||
|
||||
- dev other __cmpsf2 // a,b:f32, (a<b)->-1,(a==b)->0,(a>b)->1,Nan->1
|
||||
- dev other __cmpdf2 // exported from __lesf2, __ledf2, __letf2 (below)
|
||||
- dev other __cmptf2 // But: if NaN is a possibility, use another routine.
|
||||
- dev other __unordsf2 // a,b:f32, (a==+-NaN or b==+-NaN) -> !=0, else -> 0
|
||||
- dev other __unorddf2 // __only reliable for (input!=NaN)__
|
||||
- dev other __unordtf2 // TODO: missing tests
|
||||
- dev other __eqsf2 // (a!=NaN) and (b!=Nan) and (a==b) -> output=0
|
||||
- dev other __eqdf2 //
|
||||
- dev other __eqtf2 //
|
||||
- dev other __nesf2 // (a==NaN) or (b==Nan) or (a!=b) -> output!=0
|
||||
- dev other __nedf2 //
|
||||
- dev other __netf2 // __eqtf2 and __netf2 have same return value -> tested with __eqsf2
|
||||
- dev other __gesf2 // (a!=Nan) and (b!=Nan) and (a>=b) -> output>=0
|
||||
- dev other __gedf2 //
|
||||
- dev other __getf2 // TODO: missing tests
|
||||
- dev other __ltsf2 // (a!=Nan) and (b!=Nan) and (a<b) -> output<0
|
||||
- dev other __ltdf2 //
|
||||
- dev other __lttf2 // TODO: missing tests
|
||||
- dev other __lesf2 // (a!=Nan) and (b!=Nan) and (a<=b) -> output<=0
|
||||
- dev other __ledf2 //
|
||||
- dev other __letf2 // TODO: missing tests
|
||||
- dev other __gtsf2 // (a!=Nan) and (b!=Nan) and (a>b) -> output>0
|
||||
- dev other __gtdf2 //
|
||||
- dev other __gttf2 // TODO: missing tests
|
||||
|
||||
#### Float Arithmetic
|
||||
|
||||
- dev unclear __addsf3 // a + b f32, TODO: missing tests
|
||||
- dev unclear __adddf3 // a + b f64, TODO: missing tests
|
||||
- dev unclear __addtf3 // a + b f128
|
||||
- dev unclear __addxf3 // a + b f80
|
||||
- dev unclear __aeabi_fadd // a + b f64 ARM: AAPCS
|
||||
- dev unclear __aeabi_dadd // a + b f64 ARM: AAPCS
|
||||
- dev unclear __subsf3 // a - b, TODO: missing tests
|
||||
- dev unclear __subdf3 // a - b, TODO: missing tests
|
||||
- dev unclear __subtf3 // a - b
|
||||
- dev unclear __subxf3 // a - b f80, TODO: missing tests
|
||||
- dev unclear __aeabi_fsub // a - b f64 ARM: AAPCS
|
||||
- dev unclear __aeabi_dsub // a - b f64 ARM: AAPCS
|
||||
- dev unclear __mulsf3 // a * b, TODO: missing tests
|
||||
- dev unclear __muldf3 // a * b, TODO: missing tests
|
||||
- dev unclear __multf3 // a * b
|
||||
- dev unclear __mulxf3 // a * b
|
||||
- dev unclear __divsf3 // a / b, TODO: review tests
|
||||
- dev unclear __divdf3 // a / b, TODO: review tests
|
||||
- dev unclear __divtf3 // a / b
|
||||
- dev unclear __divxf3 // a / b
|
||||
- dev unclear __negsf2 // -a symbol-level compatibility: libgcc uses this for the rl78
|
||||
- dev unclear __negdf2 // -a unnecessary: can be lowered directly to a xor
|
||||
- dev unclear __negtf2 // -a, TODO: missing tests
|
||||
- dev unclear __negxf2 // -a, TODO: missing tests
|
||||
|
||||
#### Floating point raised to integer power
|
||||
- dev unclear __powisf2 // a ^ b, TODO
|
||||
- dev unclear __powidf2 //
|
||||
- dev unclear __powitf2 //
|
||||
- dev unclear __powixf2 //
|
||||
- dev unclear __mulsc3 // (a+ib) * (c+id)
|
||||
- dev unclear __muldc3 //
|
||||
- dev unclear __multc3 //
|
||||
- dev unclear __mulxc3 //
|
||||
- dev unclear __divsc3 // (a+ib) * / (c+id)
|
||||
- dev unclear __divdc3 //
|
||||
- dev unclear __divtc3 //
|
||||
- dev unclear __divxc3 //
|
||||
|
||||
## Decimal float library routines
|
||||
|
||||
BID means Binary Integer Decimal encoding, DPD means Densely Packed Decimal encoding.
|
||||
BID should be only chosen for binary data, DPD for decimal data (ASCII, Unicode etc).
|
||||
If possible, use BCD instead of DPD to represent numbers not accurately representable
|
||||
in binary like the number 0.2.
|
||||
|
||||
All routines are TODO.
|
||||
|
||||
#### Decimal float Conversion
|
||||
|
||||
- __dpd_extendsddd2 // dec32->dec64
|
||||
- __bid_extendsddd2 // dec32->dec64
|
||||
- __dpd_extendsdtd2 // dec32->dec128
|
||||
- __bid_extendsdtd2 // dec32->dec128
|
||||
- __dpd_extendddtd2 // dec64->dec128
|
||||
- __bid_extendddtd2 // dec64->dec128
|
||||
- __dpd_truncddsd2 // dec64->dec32
|
||||
- __bid_truncddsd2 // dec64->dec32
|
||||
- __dpd_trunctdsd2 // dec128->dec32
|
||||
- __bid_trunctdsd2 // dec128->dec32
|
||||
- __dpd_trunctddd2 // dec128->dec64
|
||||
- __bid_trunctddd2 // dec128->dec64
|
||||
|
||||
- __dpd_extendsfdd // float->dec64
|
||||
- __bid_extendsfdd // float->dec64
|
||||
- __dpd_extendsftd // float->dec128
|
||||
- __bid_extendsftd // float->dec128
|
||||
- __dpd_extenddftd // double->dec128
|
||||
- __bid_extenddftd // double->dec128
|
||||
- __dpd_extendxftd // long double->dec128
|
||||
- __bid_extendxftd // long double->dec128
|
||||
- __dpd_truncdfsd // double->dec32
|
||||
- __bid_truncdfsd // double->dec32
|
||||
- __dpd_truncxfsd // long double->dec32
|
||||
- __bid_truncxfsd // long double->dec32
|
||||
- __dpd_trunctfsd // long double->dec32
|
||||
- __bid_trunctfsd // long double->dec32
|
||||
- __dpd_truncxfdd // long double->dec64
|
||||
- __bid_truncxfdd // long double->dec64
|
||||
- __dpd_trunctfdd // long double->dec64
|
||||
- __bid_trunctfdd // long double->dec64
|
||||
|
||||
- __dpd_truncddsf // dec64->float
|
||||
- __bid_truncddsf // dec64->float
|
||||
- __dpd_trunctdsf // dec128->float
|
||||
- __bid_trunctdsf // dec128->float
|
||||
- __dpd_extendsddf // dec32->double
|
||||
- __bid_extendsddf // dec32->double
|
||||
- __dpd_trunctddf // dec128->double
|
||||
- __bid_trunctddf // dec128->double
|
||||
- __dpd_extendsdxf // dec32->long double
|
||||
- __bid_extendsdxf // dec32->long double
|
||||
- __dpd_extendddxf // dec64->long double
|
||||
- __bid_extendddxf // dec64->long double
|
||||
- __dpd_trunctdxf // dec128->long double
|
||||
- __bid_trunctdxf // dec128->long double
|
||||
- __dpd_extendsdtf // dec32->long double
|
||||
- __bid_extendsdtf // dec32->long double
|
||||
- __dpd_extendddtf // dec64->long double
|
||||
- __bid_extendddtf // dec64->long double
|
||||
|
||||
Same size conversion:
|
||||
- __dpd_extendsfsd // float->dec32
|
||||
- __bid_extendsfsd // float->dec32
|
||||
- __dpd_extenddfdd // double->dec64
|
||||
- __bid_extenddfdd // double->dec64
|
||||
- __dpd_extendtftd //long double->dec128
|
||||
- __bid_extendtftd //long double->dec128
|
||||
- __dpd_truncsdsf // dec32->float
|
||||
- __bid_truncsdsf // dec32->float
|
||||
- __dpd_truncdddf // dec64->float
|
||||
- __bid_truncdddf // dec64->float
|
||||
- __dpd_trunctdtf // dec128->long double
|
||||
- __bid_trunctdtf // dec128->long double
|
||||
|
||||
- __dpd_fixsdsi // dec32->int
|
||||
- __bid_fixsdsi // dec32->int
|
||||
- __dpd_fixddsi // dec64->int
|
||||
- __bid_fixddsi // dec64->int
|
||||
- __dpd_fixtdsi // dec128->int
|
||||
- __bid_fixtdsi // dec128->int
|
||||
|
||||
- __dpd_fixsddi // dec32->long
|
||||
- __bid_fixsddi // dec32->long
|
||||
- __dpd_fixdddi // dec64->long
|
||||
- __bid_fixdddi // dec64->long
|
||||
- __dpd_fixtddi // dec128->long
|
||||
- __bid_fixtddi // dec128->long
|
||||
|
||||
- __dpd_fixunssdsi // dec32->unsigned int, All negative values become zero.
|
||||
- __bid_fixunssdsi // dec32->unsigned int
|
||||
- __dpd_fixunsddsi // dec64->unsigned int
|
||||
- __bid_fixunsddsi // dec64->unsigned int
|
||||
- __dpd_fixunstdsi // dec128->unsigned int
|
||||
- __bid_fixunstdsi // dec128->unsigned int
|
||||
|
||||
- __dpd_fixunssddi // dec32->unsigned long, All negative values become zero.
|
||||
- __bid_fixunssddi // dec32->unsigned long
|
||||
- __dpd_fixunsdddi // dec64->unsigned long
|
||||
- __bid_fixunsdddi // dec64->unsigned long
|
||||
- __dpd_fixunstddi // dec128->unsigned long
|
||||
- __bid_fixunstddi // dec128->unsigned long
|
||||
|
||||
- __dpd_floatsisd // int->dec32
|
||||
- __bid_floatsisd // int->dec32
|
||||
- __dpd_floatsidd // int->dec64
|
||||
- __bid_floatsidd // int->dec64
|
||||
- __dpd_floatsitd // int->dec128
|
||||
- __bid_floatsitd // int->dec128
|
||||
|
||||
- __dpd_floatdisd // long->dec32
|
||||
- __bid_floatdisd // long->dec32
|
||||
- __dpd_floatdidd // long->dec64
|
||||
- __bid_floatdidd // long->dec64
|
||||
- __dpd_floatditd // long->dec128
|
||||
- __bid_floatditd // long->dec128
|
||||
|
||||
- __dpd_floatunssisd // unsigned int->dec32
|
||||
- __bid_floatunssisd // unsigned int->dec32
|
||||
- __dpd_floatunssidd // unsigned int->dec64
|
||||
- __bid_floatunssidd // unsigned int->dec64
|
||||
- __dpd_floatunssitd // unsigned int->dec128
|
||||
- __bid_floatunssitd // unsigned int->dec128
|
||||
|
||||
- __dpd_floatunsdisd // unsigned long->dec32
|
||||
- __bid_floatunsdisd // unsigned long->dec32
|
||||
- __dpd_floatunsdidd // unsigned long->dec64
|
||||
- __bid_floatunsdidd // unsigned long->dec64
|
||||
- __dpd_floatunsditd // unsigned long->dec128
|
||||
- __bid_floatunsditd // unsigned long->dec128
|
||||
|
||||
#### Decimal float Comparison
|
||||
|
||||
All decimal float comparison routines return c_int.
|
||||
|
||||
- __dpd_unordsd2 // a,b: dec32, a +-NaN or a +-NaN -> 1(nonzero), else -> 0
|
||||
- __bid_unordsd2 // a,b: dec32
|
||||
- __dpd_unorddd2 // a,b: dec64
|
||||
- __bid_unorddd2 // a,b: dec64
|
||||
- __dpd_unordtd2 // a,b: dec128
|
||||
- __bid_unordtd2 // a,b: dec128
|
||||
|
||||
- __dpd_eqsd2 // a,b: dec32, a!=+-NaN and b!=+-Nan and a==b -> 0, else -> 1(nonzero)
|
||||
- __bid_eqsd2 // a,b: dec32
|
||||
- __dpd_eqdd2 // a,b: dec64
|
||||
- __bid_eqdd2 // a,b: dec64
|
||||
- __dpd_eqtd2 // a,b: dec128
|
||||
- __bid_eqtd2 // a,b: dec128
|
||||
|
||||
- __dpd_nesd2 // a,b: dec32, a==+-NaN or b==+-NaN or a!=b -> 1(nonzero), else -> 0
|
||||
- __bid_nesd2 // a,b: dec32
|
||||
- __dpd_nedd2 // a,b: dec64
|
||||
- __bid_nedd2 // a,b: dec64
|
||||
- __dpd_netd2 // a,b: dec128
|
||||
- __bid_netd2 // a,b: dec128
|
||||
|
||||
- __dpd_gesd2 // a,b: dec32, a!=+-NaN and b!=+-NaN and a>=b -> >=0, else -> <0
|
||||
- __bid_gesd2 // a,b: dec32
|
||||
- __dpd_gedd2 // a,b: dec64
|
||||
- __bid_gedd2 // a,b: dec64
|
||||
- __dpd_getd2 // a,b: dec128
|
||||
- __bid_getd2 // a,b: dec128
|
||||
|
||||
- __dpd_ltsd2 // a,b: dec32, a!=+-NaN and b!=+-NaN and a<b -> <0, else -> >=0
|
||||
- __bid_ltsd2 // a,b: dec32
|
||||
- __dpd_ltdd2 // a,b: dec64
|
||||
- __bid_ltdd2 // a,b: dec64
|
||||
- __dpd_lttd2 // a,b: dec128
|
||||
- __bid_lttd2 // a,b: dec128
|
||||
|
||||
- __dpd_lesd2 // a,b: dec32, a!=+-NaN and b!=+-NaN and a<=b -> <=0, else -> >=0
|
||||
- __bid_lesd2 // a,b: dec32
|
||||
- __dpd_ledd2 // a,b: dec64
|
||||
- __bid_ledd2 // a,b: dec64
|
||||
- __dpd_letd2 // a,b: dec128
|
||||
- __bid_letd2 // a,b: dec128
|
||||
|
||||
- __dpd_gtsd2 // a,b: dec32, a!=+-NaN and b!=+-NaN and a>b -> >0, else -> <=0
|
||||
- __bid_gtsd2 // a,b: dec32
|
||||
- __dpd_gtdd2 // a,b: dec64
|
||||
- __bid_gtdd2 // a,b: dec64
|
||||
- __dpd_gttd2 // a,b: dec128
|
||||
- __bid_gttd2 // a,b: dec128
|
||||
|
||||
#### Decimal float Arithmetic
|
||||
|
||||
These numbers include options with routines for +-0 and +-Nan.
|
||||
|
||||
- __dpd_addsd3 // a,b: dec32 -> dec32, a + b
|
||||
- __bid_addsd3 // a,b: dec32 -> dec32
|
||||
- __dpd_adddd3 // a,b: dec64 -> dec64
|
||||
- __bid_adddd3 // a,b: dec64 -> dec64
|
||||
- __dpd_addtd3 // a,b: dec128-> dec128
|
||||
- __bid_addtd3 // a,b: dec128-> dec128
|
||||
- __dpd_subsd3 // a,b: dec32, a - b
|
||||
- __bid_subsd3 // a,b: dec32 -> dec32
|
||||
- __dpd_subdd3 // a,b: dec64 ..
|
||||
- __bid_subdd3 // a,b: dec64
|
||||
- __dpd_subtd3 // a,b: dec128
|
||||
- __bid_subtd3 // a,b: dec128
|
||||
- __dpd_mulsd3 // a,b: dec32, a * b
|
||||
- __bid_mulsd3 // a,b: dec32 -> dec32
|
||||
- __dpd_muldd3 // a,b: dec64 ..
|
||||
- __bid_muldd3 // a,b: dec64
|
||||
- __dpd_multd3 // a,b: dec128
|
||||
- __bid_multd3 // a,b: dec128
|
||||
- __dpd_divsd3 // a,b: dec32, a / b
|
||||
- __bid_divsd3 // a,b: dec32 -> dec32
|
||||
- __dpd_divdd3 // a,b: dec64 ..
|
||||
- __bid_divdd3 // a,b: dec64
|
||||
- __dpd_divtd3 // a,b: dec128
|
||||
- __bid_divtd3 // a,b: dec128
|
||||
- __dpd_negsd2 // a,b: dec32, -a
|
||||
- __bid_negsd2 // a,b: dec32 -> dec32
|
||||
- __dpd_negdd2 // a,b: dec64 ..
|
||||
- __bid_negdd2 // a,b: dec64
|
||||
- __dpd_negtd2 // a,b: dec128
|
||||
- __bid_negtd2 // a,b: dec128
|
||||
|
||||
## Fixed-point fractional library routines
|
||||
|
||||
TODO
|
||||
|
||||
Too unclear for work items:
|
||||
- Miscellaneous routines => unclear, if supported (cache control and stack functions)
|
||||
- Zig-specific language runtime features, for example "Arbitrary length integer library routines"
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,26 +0,0 @@
|
||||
/// absv - absolute oVerflow
|
||||
/// * @panic if value can not be represented
|
||||
pub inline fn absv(comptime ST: type, a: ST) ST {
|
||||
const UT = switch (ST) {
|
||||
i32 => u32,
|
||||
i64 => u64,
|
||||
i128 => u128,
|
||||
else => unreachable,
|
||||
};
|
||||
// taken from Bit Twiddling Hacks
|
||||
// compute the integer absolute value (abs) without branching
|
||||
var x: ST = a;
|
||||
const N: UT = @bitSizeOf(ST);
|
||||
const sign: ST = a >> N - 1;
|
||||
x +%= sign;
|
||||
x ^= sign;
|
||||
if (x < 0)
|
||||
@panic("compiler_rt absv: overflow");
|
||||
return x;
|
||||
}
|
||||
|
||||
test {
|
||||
_ = @import("absvsi2_test.zig");
|
||||
_ = @import("absvdi2_test.zig");
|
||||
_ = @import("absvti2_test.zig");
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
const common = @import("./common.zig");
|
||||
const absv = @import("./absv.zig").absv;
|
||||
|
||||
pub const panic = common.panic;
|
||||
|
||||
comptime {
|
||||
@export(__absvdi2, .{ .name = "__absvdi2", .linkage = common.linkage });
|
||||
}
|
||||
|
||||
pub fn __absvdi2(a: i64) callconv(.C) i64 {
|
||||
return absv(i64, a);
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
const testing = @import("std").testing;
|
||||
|
||||
const __absvdi2 = @import("absvdi2.zig").__absvdi2;
|
||||
|
||||
fn test__absvdi2(a: i64, expected: i64) !void {
|
||||
var result = __absvdi2(a);
|
||||
try testing.expectEqual(expected, result);
|
||||
}
|
||||
|
||||
test "absvdi2" {
|
||||
// -2^63 <= i64 <= 2^63-1
|
||||
// 2^63 = 9223372036854775808
|
||||
// 2^63-1 = 9223372036854775807
|
||||
// TODO write panic handler for testing panics
|
||||
//try test__absvdi2(-9223372036854775808, -5); // tested with return -5; and panic
|
||||
try test__absvdi2(-9223372036854775807, 9223372036854775807);
|
||||
try test__absvdi2(-9223372036854775806, 9223372036854775806);
|
||||
try test__absvdi2(-9223372036854775805, 9223372036854775805);
|
||||
try test__absvdi2(-9223372036854775804, 9223372036854775804);
|
||||
try test__absvdi2(-42, 42);
|
||||
try test__absvdi2(-7, 7);
|
||||
try test__absvdi2(-1, 1);
|
||||
try test__absvdi2(0, 0);
|
||||
try test__absvdi2(1, 1);
|
||||
try test__absvdi2(7, 7);
|
||||
try test__absvdi2(42, 42);
|
||||
try test__absvdi2(9223372036854775804, 9223372036854775804);
|
||||
try test__absvdi2(9223372036854775805, 9223372036854775805);
|
||||
try test__absvdi2(9223372036854775806, 9223372036854775806);
|
||||
try test__absvdi2(9223372036854775807, 9223372036854775807);
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
const common = @import("./common.zig");
|
||||
const absv = @import("./absv.zig").absv;
|
||||
|
||||
pub const panic = common.panic;
|
||||
|
||||
comptime {
|
||||
@export(__absvsi2, .{ .name = "__absvsi2", .linkage = common.linkage });
|
||||
}
|
||||
|
||||
pub fn __absvsi2(a: i32) callconv(.C) i32 {
|
||||
return absv(i32, a);
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
const testing = @import("std").testing;
|
||||
|
||||
const __absvsi2 = @import("absvsi2.zig").__absvsi2;
|
||||
|
||||
fn test__absvsi2(a: i32, expected: i32) !void {
|
||||
var result = __absvsi2(a);
|
||||
try testing.expectEqual(expected, result);
|
||||
}
|
||||
|
||||
test "absvsi2" {
|
||||
// -2^31 <= i32 <= 2^31-1
|
||||
// 2^31 = 2147483648
|
||||
// 2^31-1 = 2147483647
|
||||
// TODO write panic handler for testing panics
|
||||
//try test__absvsi2(-2147483648, -5); // tested with return -5; and panic
|
||||
try test__absvsi2(-2147483647, 2147483647);
|
||||
try test__absvsi2(-2147483646, 2147483646);
|
||||
try test__absvsi2(-2147483645, 2147483645);
|
||||
try test__absvsi2(-2147483644, 2147483644);
|
||||
try test__absvsi2(-42, 42);
|
||||
try test__absvsi2(-7, 7);
|
||||
try test__absvsi2(-1, 1);
|
||||
try test__absvsi2(0, 0);
|
||||
try test__absvsi2(1, 1);
|
||||
try test__absvsi2(7, 7);
|
||||
try test__absvsi2(42, 42);
|
||||
try test__absvsi2(2147483644, 2147483644);
|
||||
try test__absvsi2(2147483645, 2147483645);
|
||||
try test__absvsi2(2147483646, 2147483646);
|
||||
try test__absvsi2(2147483647, 2147483647);
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
const common = @import("./common.zig");
|
||||
const absv = @import("./absv.zig").absv;
|
||||
|
||||
pub const panic = common.panic;
|
||||
|
||||
comptime {
|
||||
@export(__absvti2, .{ .name = "__absvti2", .linkage = common.linkage });
|
||||
}
|
||||
|
||||
pub fn __absvti2(a: i128) callconv(.C) i128 {
|
||||
return absv(i128, a);
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
const testing = @import("std").testing;
|
||||
|
||||
const __absvti2 = @import("absvti2.zig").__absvti2;
|
||||
|
||||
fn test__absvti2(a: i128, expected: i128) !void {
|
||||
var result = __absvti2(a);
|
||||
try testing.expectEqual(expected, result);
|
||||
}
|
||||
|
||||
test "absvti2" {
|
||||
// -2^127 <= i128 <= 2^127-1
|
||||
// 2^127 = 170141183460469231731687303715884105728
|
||||
// 2^127+1 = 170141183460469231731687303715884105727
|
||||
// TODO write panic handler for testing panics
|
||||
//try test__absvti2(-170141183460469231731687303715884105728, -5); // tested with return -5; and panic
|
||||
try test__absvti2(-170141183460469231731687303715884105727, 170141183460469231731687303715884105727);
|
||||
try test__absvti2(-170141183460469231731687303715884105726, 170141183460469231731687303715884105726);
|
||||
try test__absvti2(-170141183460469231731687303715884105725, 170141183460469231731687303715884105725);
|
||||
try test__absvti2(-170141183460469231731687303715884105724, 170141183460469231731687303715884105724);
|
||||
try test__absvti2(-42, 42);
|
||||
try test__absvti2(-7, 7);
|
||||
try test__absvti2(-1, 1);
|
||||
try test__absvti2(0, 0);
|
||||
try test__absvti2(1, 1);
|
||||
try test__absvti2(7, 7);
|
||||
try test__absvti2(42, 42);
|
||||
try test__absvti2(170141183460469231731687303715884105724, 170141183460469231731687303715884105724);
|
||||
try test__absvti2(170141183460469231731687303715884105725, 170141183460469231731687303715884105725);
|
||||
try test__absvti2(170141183460469231731687303715884105726, 170141183460469231731687303715884105726);
|
||||
try test__absvti2(170141183460469231731687303715884105727, 170141183460469231731687303715884105727);
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
const common = @import("./common.zig");
|
||||
const addf3 = @import("./addf3.zig").addf3;
|
||||
|
||||
pub const panic = common.panic;
|
||||
|
||||
comptime {
|
||||
if (common.want_aeabi) {
|
||||
@export(__aeabi_dadd, .{ .name = "__aeabi_dadd", .linkage = common.linkage });
|
||||
} else {
|
||||
@export(__adddf3, .{ .name = "__adddf3", .linkage = common.linkage });
|
||||
}
|
||||
}
|
||||
|
||||
fn __adddf3(a: f64, b: f64) callconv(.C) f64 {
|
||||
return addf3(f64, a, b);
|
||||
}
|
||||
|
||||
fn __aeabi_dadd(a: f64, b: f64) callconv(.AAPCS) f64 {
|
||||
return addf3(f64, a, b);
|
||||
}
|
||||
@@ -1,172 +0,0 @@
|
||||
const std = @import("std");
|
||||
const math = std.math;
|
||||
const common = @import("./common.zig");
|
||||
const normalize = common.normalize;
|
||||
|
||||
/// Ported from:
|
||||
///
|
||||
/// https://github.com/llvm/llvm-project/blob/02d85149a05cb1f6dc49f0ba7a2ceca53718ae17/compiler-rt/lib/builtins/fp_add_impl.inc
|
||||
pub inline fn addf3(comptime T: type, a: T, b: T) T {
|
||||
const bits = @typeInfo(T).Float.bits;
|
||||
const Z = std.meta.Int(.unsigned, bits);
|
||||
const S = std.meta.Int(.unsigned, bits - @clz(@as(Z, bits) - 1));
|
||||
|
||||
const typeWidth = bits;
|
||||
const significandBits = math.floatMantissaBits(T);
|
||||
const fractionalBits = math.floatFractionalBits(T);
|
||||
const exponentBits = math.floatExponentBits(T);
|
||||
|
||||
const signBit = (@as(Z, 1) << (significandBits + exponentBits));
|
||||
const maxExponent = ((1 << exponentBits) - 1);
|
||||
|
||||
const integerBit = (@as(Z, 1) << fractionalBits);
|
||||
const quietBit = integerBit >> 1;
|
||||
const significandMask = (@as(Z, 1) << significandBits) - 1;
|
||||
|
||||
const absMask = signBit - 1;
|
||||
const qnanRep = @bitCast(Z, math.nan(T)) | quietBit;
|
||||
|
||||
var aRep = @bitCast(Z, a);
|
||||
var bRep = @bitCast(Z, b);
|
||||
const aAbs = aRep & absMask;
|
||||
const bAbs = bRep & absMask;
|
||||
|
||||
const infRep = @bitCast(Z, math.inf(T));
|
||||
|
||||
// Detect if a or b is zero, infinity, or NaN.
|
||||
if (aAbs -% @as(Z, 1) >= infRep - @as(Z, 1) or
|
||||
bAbs -% @as(Z, 1) >= infRep - @as(Z, 1))
|
||||
{
|
||||
// NaN + anything = qNaN
|
||||
if (aAbs > infRep) return @bitCast(T, @bitCast(Z, a) | quietBit);
|
||||
// anything + NaN = qNaN
|
||||
if (bAbs > infRep) return @bitCast(T, @bitCast(Z, b) | quietBit);
|
||||
|
||||
if (aAbs == infRep) {
|
||||
// +/-infinity + -/+infinity = qNaN
|
||||
if ((@bitCast(Z, a) ^ @bitCast(Z, b)) == signBit) {
|
||||
return @bitCast(T, qnanRep);
|
||||
}
|
||||
// +/-infinity + anything remaining = +/- infinity
|
||||
else {
|
||||
return a;
|
||||
}
|
||||
}
|
||||
|
||||
// anything remaining + +/-infinity = +/-infinity
|
||||
if (bAbs == infRep) return b;
|
||||
|
||||
// zero + anything = anything
|
||||
if (aAbs == 0) {
|
||||
// but we need to get the sign right for zero + zero
|
||||
if (bAbs == 0) {
|
||||
return @bitCast(T, @bitCast(Z, a) & @bitCast(Z, b));
|
||||
} else {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
|
||||
// anything + zero = anything
|
||||
if (bAbs == 0) return a;
|
||||
}
|
||||
|
||||
// Swap a and b if necessary so that a has the larger absolute value.
|
||||
if (bAbs > aAbs) {
|
||||
const temp = aRep;
|
||||
aRep = bRep;
|
||||
bRep = temp;
|
||||
}
|
||||
|
||||
// Extract the exponent and significand from the (possibly swapped) a and b.
|
||||
var aExponent = @intCast(i32, (aRep >> significandBits) & maxExponent);
|
||||
var bExponent = @intCast(i32, (bRep >> significandBits) & maxExponent);
|
||||
var aSignificand = aRep & significandMask;
|
||||
var bSignificand = bRep & significandMask;
|
||||
|
||||
// Normalize any denormals, and adjust the exponent accordingly.
|
||||
if (aExponent == 0) aExponent = normalize(T, &aSignificand);
|
||||
if (bExponent == 0) bExponent = normalize(T, &bSignificand);
|
||||
|
||||
// The sign of the result is the sign of the larger operand, a. If they
|
||||
// have opposite signs, we are performing a subtraction; otherwise addition.
|
||||
const resultSign = aRep & signBit;
|
||||
const subtraction = (aRep ^ bRep) & signBit != 0;
|
||||
|
||||
// Shift the significands to give us round, guard and sticky, and or in the
|
||||
// implicit significand bit. (If we fell through from the denormal path it
|
||||
// was already set by normalize( ), but setting it twice won't hurt
|
||||
// anything.)
|
||||
aSignificand = (aSignificand | integerBit) << 3;
|
||||
bSignificand = (bSignificand | integerBit) << 3;
|
||||
|
||||
// Shift the significand of b by the difference in exponents, with a sticky
|
||||
// bottom bit to get rounding correct.
|
||||
const @"align" = @intCast(u32, aExponent - bExponent);
|
||||
if (@"align" != 0) {
|
||||
if (@"align" < typeWidth) {
|
||||
const sticky = if (bSignificand << @intCast(S, typeWidth - @"align") != 0) @as(Z, 1) else 0;
|
||||
bSignificand = (bSignificand >> @truncate(S, @"align")) | sticky;
|
||||
} else {
|
||||
bSignificand = 1; // sticky; b is known to be non-zero.
|
||||
}
|
||||
}
|
||||
if (subtraction) {
|
||||
aSignificand -= bSignificand;
|
||||
// If a == -b, return +zero.
|
||||
if (aSignificand == 0) return @bitCast(T, @as(Z, 0));
|
||||
|
||||
// If partial cancellation occured, we need to left-shift the result
|
||||
// and adjust the exponent:
|
||||
if (aSignificand < integerBit << 3) {
|
||||
const shift = @intCast(i32, @clz(aSignificand)) - @intCast(i32, @clz(integerBit << 3));
|
||||
aSignificand <<= @intCast(S, shift);
|
||||
aExponent -= shift;
|
||||
}
|
||||
} else { // addition
|
||||
aSignificand += bSignificand;
|
||||
|
||||
// If the addition carried up, we need to right-shift the result and
|
||||
// adjust the exponent:
|
||||
if (aSignificand & (integerBit << 4) != 0) {
|
||||
const sticky = aSignificand & 1;
|
||||
aSignificand = aSignificand >> 1 | sticky;
|
||||
aExponent += 1;
|
||||
}
|
||||
}
|
||||
|
||||
// If we have overflowed the type, return +/- infinity:
|
||||
if (aExponent >= maxExponent) return @bitCast(T, infRep | resultSign);
|
||||
|
||||
if (aExponent <= 0) {
|
||||
// Result is denormal; the exponent and round/sticky bits are zero.
|
||||
// All we need to do is shift the significand and apply the correct sign.
|
||||
aSignificand >>= @intCast(S, 4 - aExponent);
|
||||
return @bitCast(T, resultSign | aSignificand);
|
||||
}
|
||||
|
||||
// Low three bits are round, guard, and sticky.
|
||||
const roundGuardSticky = aSignificand & 0x7;
|
||||
|
||||
// Shift the significand into place, and mask off the integer bit, if it's implicit.
|
||||
var result = (aSignificand >> 3) & significandMask;
|
||||
|
||||
// Insert the exponent and sign.
|
||||
result |= @intCast(Z, aExponent) << significandBits;
|
||||
result |= resultSign;
|
||||
|
||||
// Final rounding. The result may overflow to infinity, but that is the
|
||||
// correct result in that case.
|
||||
if (roundGuardSticky > 0x4) result += 1;
|
||||
if (roundGuardSticky == 0x4) result += result & 1;
|
||||
|
||||
// Restore any explicit integer bit, if it was rounded off
|
||||
if (significandBits != fractionalBits) {
|
||||
if ((result >> significandBits) != 0) result |= integerBit;
|
||||
}
|
||||
|
||||
return @bitCast(T, result);
|
||||
}
|
||||
|
||||
test {
|
||||
_ = @import("addf3_test.zig");
|
||||
}
|
||||
@@ -1,156 +0,0 @@
|
||||
// Ported from:
|
||||
//
|
||||
// https://github.com/llvm/llvm-project/blob/02d85149a05cb1f6dc49f0ba7a2ceca53718ae17/compiler-rt/test/builtins/Unit/addtf3_test.c
|
||||
// https://github.com/llvm/llvm-project/blob/02d85149a05cb1f6dc49f0ba7a2ceca53718ae17/compiler-rt/test/builtins/Unit/subtf3_test.c
|
||||
|
||||
const std = @import("std");
|
||||
const math = std.math;
|
||||
const qnan128 = @bitCast(f128, @as(u128, 0x7fff800000000000) << 64);
|
||||
|
||||
const __addtf3 = @import("addtf3.zig").__addtf3;
|
||||
const __addxf3 = @import("addxf3.zig").__addxf3;
|
||||
const __subtf3 = @import("subtf3.zig").__subtf3;
|
||||
|
||||
fn test__addtf3(a: f128, b: f128, expected_hi: u64, expected_lo: u64) !void {
|
||||
const x = __addtf3(a, b);
|
||||
|
||||
const rep = @bitCast(u128, x);
|
||||
const hi = @intCast(u64, rep >> 64);
|
||||
const lo = @truncate(u64, rep);
|
||||
|
||||
if (hi == expected_hi and lo == expected_lo) {
|
||||
return;
|
||||
}
|
||||
// test other possible NaN representation (signal NaN)
|
||||
else if (expected_hi == 0x7fff800000000000 and expected_lo == 0x0) {
|
||||
if ((hi & 0x7fff000000000000) == 0x7fff000000000000 and
|
||||
((hi & 0xffffffffffff) > 0 or lo > 0))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
return error.TestFailed;
|
||||
}
|
||||
|
||||
test "addtf3" {
|
||||
try test__addtf3(qnan128, 0x1.23456789abcdefp+5, 0x7fff800000000000, 0x0);
|
||||
|
||||
// NaN + any = NaN
|
||||
try test__addtf3(@bitCast(f128, (@as(u128, 0x7fff000000000000) << 64) | @as(u128, 0x800030000000)), 0x1.23456789abcdefp+5, 0x7fff800000000000, 0x0);
|
||||
|
||||
// inf + inf = inf
|
||||
try test__addtf3(math.inf(f128), math.inf(f128), 0x7fff000000000000, 0x0);
|
||||
|
||||
// inf + any = inf
|
||||
try test__addtf3(math.inf(f128), 0x1.2335653452436234723489432abcdefp+5, 0x7fff000000000000, 0x0);
|
||||
|
||||
// any + any
|
||||
try test__addtf3(0x1.23456734245345543849abcdefp+5, 0x1.edcba52449872455634654321fp-1, 0x40042afc95c8b579, 0x61e58dd6c51eb77c);
|
||||
try test__addtf3(0x1.edcba52449872455634654321fp-1, 0x1.23456734245345543849abcdefp+5, 0x40042afc95c8b579, 0x61e58dd6c51eb77c);
|
||||
}
|
||||
|
||||
fn test__subtf3(a: f128, b: f128, expected_hi: u64, expected_lo: u64) !void {
|
||||
const x = __subtf3(a, b);
|
||||
|
||||
const rep = @bitCast(u128, x);
|
||||
const hi = @intCast(u64, rep >> 64);
|
||||
const lo = @truncate(u64, rep);
|
||||
|
||||
if (hi == expected_hi and lo == expected_lo) {
|
||||
return;
|
||||
}
|
||||
// test other possible NaN representation (signal NaN)
|
||||
else if (expected_hi == 0x7fff800000000000 and expected_lo == 0x0) {
|
||||
if ((hi & 0x7fff000000000000) == 0x7fff000000000000 and
|
||||
((hi & 0xffffffffffff) > 0 or lo > 0))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
return error.TestFailed;
|
||||
}
|
||||
|
||||
test "subtf3" {
|
||||
// qNaN - any = qNaN
|
||||
try test__subtf3(qnan128, 0x1.23456789abcdefp+5, 0x7fff800000000000, 0x0);
|
||||
|
||||
// NaN + any = NaN
|
||||
try test__subtf3(@bitCast(f128, (@as(u128, 0x7fff000000000000) << 64) | @as(u128, 0x800030000000)), 0x1.23456789abcdefp+5, 0x7fff800000000000, 0x0);
|
||||
|
||||
// inf - any = inf
|
||||
try test__subtf3(math.inf(f128), 0x1.23456789abcdefp+5, 0x7fff000000000000, 0x0);
|
||||
|
||||
// any + any
|
||||
try test__subtf3(0x1.234567829a3bcdef5678ade36734p+5, 0x1.ee9d7c52354a6936ab8d7654321fp-1, 0x40041b8af1915166, 0xa44a7bca780a166c);
|
||||
try test__subtf3(0x1.ee9d7c52354a6936ab8d7654321fp-1, 0x1.234567829a3bcdef5678ade36734p+5, 0xc0041b8af1915166, 0xa44a7bca780a166c);
|
||||
}
|
||||
|
||||
const qnan80 = @bitCast(f80, @bitCast(u80, math.nan(f80)) | (1 << (math.floatFractionalBits(f80) - 1)));
|
||||
|
||||
fn test__addxf3(a: f80, b: f80, expected: u80) !void {
|
||||
const x = __addxf3(a, b);
|
||||
const rep = @bitCast(u80, x);
|
||||
|
||||
if (rep == expected)
|
||||
return;
|
||||
|
||||
if (math.isNan(@bitCast(f80, expected)) and math.isNan(x))
|
||||
return; // We don't currently test NaN payload propagation
|
||||
|
||||
return error.TestFailed;
|
||||
}
|
||||
|
||||
test "addxf3" {
|
||||
// NaN + any = NaN
|
||||
try test__addxf3(qnan80, 0x1.23456789abcdefp+5, @bitCast(u80, qnan80));
|
||||
try test__addxf3(@bitCast(f80, @as(u80, 0x7fff_8000_8000_3000_0000)), 0x1.23456789abcdefp+5, @bitCast(u80, qnan80));
|
||||
|
||||
// any + NaN = NaN
|
||||
try test__addxf3(0x1.23456789abcdefp+5, qnan80, @bitCast(u80, qnan80));
|
||||
try test__addxf3(0x1.23456789abcdefp+5, @bitCast(f80, @as(u80, 0x7fff_8000_8000_3000_0000)), @bitCast(u80, qnan80));
|
||||
|
||||
// NaN + inf = NaN
|
||||
try test__addxf3(qnan80, math.inf(f80), @bitCast(u80, qnan80));
|
||||
|
||||
// inf + NaN = NaN
|
||||
try test__addxf3(math.inf(f80), qnan80, @bitCast(u80, qnan80));
|
||||
|
||||
// inf + inf = inf
|
||||
try test__addxf3(math.inf(f80), math.inf(f80), @bitCast(u80, math.inf(f80)));
|
||||
|
||||
// inf + -inf = NaN
|
||||
try test__addxf3(math.inf(f80), -math.inf(f80), @bitCast(u80, qnan80));
|
||||
|
||||
// -inf + inf = NaN
|
||||
try test__addxf3(-math.inf(f80), math.inf(f80), @bitCast(u80, qnan80));
|
||||
|
||||
// inf + any = inf
|
||||
try test__addxf3(math.inf(f80), 0x1.2335653452436234723489432abcdefp+5, @bitCast(u80, math.inf(f80)));
|
||||
|
||||
// any + inf = inf
|
||||
try test__addxf3(0x1.2335653452436234723489432abcdefp+5, math.inf(f80), @bitCast(u80, math.inf(f80)));
|
||||
|
||||
// any + any
|
||||
try test__addxf3(0x1.23456789abcdp+5, 0x1.dcba987654321p+5, 0x4005_BFFFFFFFFFFFC400);
|
||||
try test__addxf3(0x1.23456734245345543849abcdefp+5, 0x1.edcba52449872455634654321fp-1, 0x4004_957E_4AE4_5ABC_B0F3);
|
||||
try test__addxf3(0x1.ffff_ffff_ffff_fffcp+0, 0x1.0p-63, 0x3FFF_FFFFFFFFFFFFFFFF); // exact
|
||||
try test__addxf3(0x1.ffff_ffff_ffff_fffep+0, 0x0.0p0, 0x3FFF_FFFFFFFFFFFFFFFF); // exact
|
||||
try test__addxf3(0x1.ffff_ffff_ffff_fffcp+0, 0x1.4p-63, 0x3FFF_FFFFFFFFFFFFFFFF); // round down
|
||||
try test__addxf3(0x1.ffff_ffff_ffff_fffcp+0, 0x1.8p-63, 0x4000_8000000000000000); // round up to even
|
||||
try test__addxf3(0x1.ffff_ffff_ffff_fffcp+0, 0x1.cp-63, 0x4000_8000000000000000); // round up
|
||||
try test__addxf3(0x1.ffff_ffff_ffff_fffcp+0, 0x2.0p-63, 0x4000_8000000000000000); // exact
|
||||
try test__addxf3(0x1.ffff_ffff_ffff_fffcp+0, 0x2.1p-63, 0x4000_8000000000000000); // round down
|
||||
try test__addxf3(0x1.ffff_ffff_ffff_fffcp+0, 0x3.0p-63, 0x4000_8000000000000000); // round down to even
|
||||
try test__addxf3(0x1.ffff_ffff_ffff_fffcp+0, 0x3.1p-63, 0x4000_8000000000000001); // round up
|
||||
try test__addxf3(0x1.ffff_ffff_ffff_fffcp+0, 0x4.0p-63, 0x4000_8000000000000001); // exact
|
||||
|
||||
try test__addxf3(0x1.0fff_ffff_ffff_fffep+0, 0x1.0p-63, 0x3FFF_8800000000000000); // exact
|
||||
try test__addxf3(0x1.0fff_ffff_ffff_fffep+0, 0x1.7p-63, 0x3FFF_8800000000000000); // round down
|
||||
try test__addxf3(0x1.0fff_ffff_ffff_fffep+0, 0x1.8p-63, 0x3FFF_8800000000000000); // round down to even
|
||||
try test__addxf3(0x1.0fff_ffff_ffff_fffep+0, 0x1.9p-63, 0x3FFF_8800000000000001); // round up
|
||||
try test__addxf3(0x1.0fff_ffff_ffff_fffep+0, 0x2.0p-63, 0x3FFF_8800000000000001); // exact
|
||||
try test__addxf3(0x0.ffff_ffff_ffff_fffcp-16382, 0x0.0000_0000_0000_0002p-16382, 0x0000_7FFFFFFFFFFFFFFF); // exact
|
||||
try test__addxf3(0x0.1fff_ffff_ffff_fffcp-16382, 0x0.0000_0000_0000_0002p-16382, 0x0000_0FFFFFFFFFFFFFFF); // exact
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
const common = @import("./common.zig");
|
||||
const addf3 = @import("./addf3.zig").addf3;
|
||||
|
||||
pub const panic = common.panic;
|
||||
|
||||
comptime {
|
||||
@export(__addhf3, .{ .name = "__addhf3", .linkage = common.linkage });
|
||||
}
|
||||
|
||||
fn __addhf3(a: f16, b: f16) callconv(.C) f16 {
|
||||
return addf3(f16, a, b);
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const is_test = builtin.is_test;
|
||||
const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
|
||||
pub const panic = @import("common.zig").panic;
|
||||
|
||||
comptime {
|
||||
@export(__addosi4, .{ .name = "__addosi4", .linkage = linkage });
|
||||
@export(__addodi4, .{ .name = "__addodi4", .linkage = linkage });
|
||||
@export(__addoti4, .{ .name = "__addoti4", .linkage = linkage });
|
||||
}
|
||||
|
||||
// addo - add overflow
|
||||
// * return a+%b.
|
||||
// * return if a+b overflows => 1 else => 0
|
||||
// - addoXi4_generic as default
|
||||
|
||||
inline fn addoXi4_generic(comptime ST: type, a: ST, b: ST, overflow: *c_int) ST {
|
||||
@setRuntimeSafety(builtin.is_test);
|
||||
overflow.* = 0;
|
||||
var sum: ST = a +% b;
|
||||
// Hackers Delight: section Overflow Detection, subsection Signed Add/Subtract
|
||||
// Let sum = a +% b == a + b + carry == wraparound addition.
|
||||
// Overflow in a+b+carry occurs, iff a and b have opposite signs
|
||||
// and the sign of a+b+carry is the same as a (or equivalently b).
|
||||
// Slower routine: res = ~(a ^ b) & ((sum ^ a)
|
||||
// Faster routine: res = (sum ^ a) & (sum ^ b)
|
||||
// Overflow occured, iff (res < 0)
|
||||
if (((sum ^ a) & (sum ^ b)) < 0)
|
||||
overflow.* = 1;
|
||||
return sum;
|
||||
}
|
||||
|
||||
pub fn __addosi4(a: i32, b: i32, overflow: *c_int) callconv(.C) i32 {
|
||||
return addoXi4_generic(i32, a, b, overflow);
|
||||
}
|
||||
pub fn __addodi4(a: i64, b: i64, overflow: *c_int) callconv(.C) i64 {
|
||||
return addoXi4_generic(i64, a, b, overflow);
|
||||
}
|
||||
pub fn __addoti4(a: i128, b: i128, overflow: *c_int) callconv(.C) i128 {
|
||||
return addoXi4_generic(i128, a, b, overflow);
|
||||
}
|
||||
|
||||
test {
|
||||
_ = @import("addosi4_test.zig");
|
||||
_ = @import("addodi4_test.zig");
|
||||
_ = @import("addoti4_test.zig");
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
const addv = @import("addo.zig");
|
||||
const std = @import("std");
|
||||
const testing = std.testing;
|
||||
const math = std.math;
|
||||
|
||||
fn test__addodi4(a: i64, b: i64) !void {
|
||||
var result_ov: c_int = undefined;
|
||||
var expected_ov: c_int = undefined;
|
||||
var result = addv.__addodi4(a, b, &result_ov);
|
||||
var expected: i64 = simple_addodi4(a, b, &expected_ov);
|
||||
try testing.expectEqual(expected, result);
|
||||
try testing.expectEqual(expected_ov, result_ov);
|
||||
}
|
||||
|
||||
fn simple_addodi4(a: i64, b: i64, overflow: *c_int) i64 {
|
||||
overflow.* = 0;
|
||||
const min: i64 = math.minInt(i64);
|
||||
const max: i64 = math.maxInt(i64);
|
||||
if (((a > 0) and (b > max - a)) or
|
||||
((a < 0) and (b < min - a)))
|
||||
overflow.* = 1;
|
||||
return a +% b;
|
||||
}
|
||||
|
||||
test "addodi4" {
|
||||
const min: i64 = math.minInt(i64);
|
||||
const max: i64 = math.maxInt(i64);
|
||||
var i: i64 = 1;
|
||||
while (i < max) : (i *|= 2) {
|
||||
try test__addodi4(i, i);
|
||||
try test__addodi4(-i, -i);
|
||||
try test__addodi4(i, -i);
|
||||
try test__addodi4(-i, i);
|
||||
}
|
||||
|
||||
// edge cases
|
||||
// 0 + 0 = 0
|
||||
// MIN + MIN overflow
|
||||
// MAX + MAX overflow
|
||||
// 0 + MIN MIN
|
||||
// 0 + MAX MAX
|
||||
// MIN + 0 MIN
|
||||
// MAX + 0 MAX
|
||||
// MIN + MAX -1
|
||||
// MAX + MIN -1
|
||||
try test__addodi4(0, 0);
|
||||
try test__addodi4(min, min);
|
||||
try test__addodi4(max, max);
|
||||
try test__addodi4(0, min);
|
||||
try test__addodi4(0, max);
|
||||
try test__addodi4(min, 0);
|
||||
try test__addodi4(max, 0);
|
||||
try test__addodi4(min, max);
|
||||
try test__addodi4(max, min);
|
||||
|
||||
// derived edge cases
|
||||
// MIN+1 + MIN overflow
|
||||
// MAX-1 + MAX overflow
|
||||
// 1 + MIN = MIN+1
|
||||
// -1 + MIN overflow
|
||||
// -1 + MAX = MAX-1
|
||||
// +1 + MAX overflow
|
||||
// MIN + 1 = MIN+1
|
||||
// MIN + -1 overflow
|
||||
// MAX + 1 overflow
|
||||
// MAX + -1 = MAX-1
|
||||
try test__addodi4(min + 1, min);
|
||||
try test__addodi4(max - 1, max);
|
||||
try test__addodi4(1, min);
|
||||
try test__addodi4(-1, min);
|
||||
try test__addodi4(-1, max);
|
||||
try test__addodi4(1, max);
|
||||
try test__addodi4(min, 1);
|
||||
try test__addodi4(min, -1);
|
||||
try test__addodi4(max, -1);
|
||||
try test__addodi4(max, 1);
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
const addv = @import("addo.zig");
|
||||
const testing = @import("std").testing;
|
||||
|
||||
fn test__addosi4(a: i32, b: i32) !void {
|
||||
var result_ov: c_int = undefined;
|
||||
var expected_ov: c_int = undefined;
|
||||
var result = addv.__addosi4(a, b, &result_ov);
|
||||
var expected: i32 = simple_addosi4(a, b, &expected_ov);
|
||||
try testing.expectEqual(expected, result);
|
||||
try testing.expectEqual(expected_ov, result_ov);
|
||||
}
|
||||
|
||||
fn simple_addosi4(a: i32, b: i32, overflow: *c_int) i32 {
|
||||
overflow.* = 0;
|
||||
const min: i32 = -2147483648;
|
||||
const max: i32 = 2147483647;
|
||||
if (((a > 0) and (b > max - a)) or
|
||||
((a < 0) and (b < min - a)))
|
||||
overflow.* = 1;
|
||||
return a +% b;
|
||||
}
|
||||
|
||||
test "addosi4" {
|
||||
// -2^31 <= i32 <= 2^31-1
|
||||
// 2^31 = 2147483648
|
||||
// 2^31-1 = 2147483647
|
||||
const min: i32 = -2147483648;
|
||||
const max: i32 = 2147483647;
|
||||
var i: i32 = 1;
|
||||
while (i < max) : (i *|= 2) {
|
||||
try test__addosi4(i, i);
|
||||
try test__addosi4(-i, -i);
|
||||
try test__addosi4(i, -i);
|
||||
try test__addosi4(-i, i);
|
||||
}
|
||||
|
||||
// edge cases
|
||||
// 0 + 0 = 0
|
||||
// MIN + MIN overflow
|
||||
// MAX + MAX overflow
|
||||
// 0 + MIN MIN
|
||||
// 0 + MAX MAX
|
||||
// MIN + 0 MIN
|
||||
// MAX + 0 MAX
|
||||
// MIN + MAX -1
|
||||
// MAX + MIN -1
|
||||
try test__addosi4(0, 0);
|
||||
try test__addosi4(min, min);
|
||||
try test__addosi4(max, max);
|
||||
try test__addosi4(0, min);
|
||||
try test__addosi4(0, max);
|
||||
try test__addosi4(min, 0);
|
||||
try test__addosi4(max, 0);
|
||||
try test__addosi4(min, max);
|
||||
try test__addosi4(max, min);
|
||||
|
||||
// derived edge cases
|
||||
// MIN+1 + MIN overflow
|
||||
// MAX-1 + MAX overflow
|
||||
// 1 + MIN = MIN+1
|
||||
// -1 + MIN overflow
|
||||
// -1 + MAX = MAX-1
|
||||
// +1 + MAX overflow
|
||||
// MIN + 1 = MIN+1
|
||||
// MIN + -1 overflow
|
||||
// MAX + 1 overflow
|
||||
// MAX + -1 = MAX-1
|
||||
try test__addosi4(min + 1, min);
|
||||
try test__addosi4(max - 1, max);
|
||||
try test__addosi4(1, min);
|
||||
try test__addosi4(-1, min);
|
||||
try test__addosi4(-1, max);
|
||||
try test__addosi4(1, max);
|
||||
try test__addosi4(min, 1);
|
||||
try test__addosi4(min, -1);
|
||||
try test__addosi4(max, -1);
|
||||
try test__addosi4(max, 1);
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
const addv = @import("addo.zig");
|
||||
const std = @import("std");
|
||||
const testing = std.testing;
|
||||
const math = std.math;
|
||||
|
||||
fn test__addoti4(a: i128, b: i128) !void {
|
||||
var result_ov: c_int = undefined;
|
||||
var expected_ov: c_int = undefined;
|
||||
var result = addv.__addoti4(a, b, &result_ov);
|
||||
var expected: i128 = simple_addoti4(a, b, &expected_ov);
|
||||
try testing.expectEqual(expected, result);
|
||||
try testing.expectEqual(expected_ov, result_ov);
|
||||
}
|
||||
|
||||
fn simple_addoti4(a: i128, b: i128, overflow: *c_int) i128 {
|
||||
overflow.* = 0;
|
||||
const min: i128 = math.minInt(i128);
|
||||
const max: i128 = math.maxInt(i128);
|
||||
if (((a > 0) and (b > max - a)) or
|
||||
((a < 0) and (b < min - a)))
|
||||
overflow.* = 1;
|
||||
return a +% b;
|
||||
}
|
||||
|
||||
test "addoti4" {
|
||||
const min: i128 = math.minInt(i128);
|
||||
const max: i128 = math.maxInt(i128);
|
||||
var i: i128 = 1;
|
||||
while (i < max) : (i *|= 2) {
|
||||
try test__addoti4(i, i);
|
||||
try test__addoti4(-i, -i);
|
||||
try test__addoti4(i, -i);
|
||||
try test__addoti4(-i, i);
|
||||
}
|
||||
|
||||
// edge cases
|
||||
// 0 + 0 = 0
|
||||
// MIN + MIN overflow
|
||||
// MAX + MAX overflow
|
||||
// 0 + MIN MIN
|
||||
// 0 + MAX MAX
|
||||
// MIN + 0 MIN
|
||||
// MAX + 0 MAX
|
||||
// MIN + MAX -1
|
||||
// MAX + MIN -1
|
||||
try test__addoti4(0, 0);
|
||||
try test__addoti4(min, min);
|
||||
try test__addoti4(max, max);
|
||||
try test__addoti4(0, min);
|
||||
try test__addoti4(0, max);
|
||||
try test__addoti4(min, 0);
|
||||
try test__addoti4(max, 0);
|
||||
try test__addoti4(min, max);
|
||||
try test__addoti4(max, min);
|
||||
|
||||
// derived edge cases
|
||||
// MIN+1 + MIN overflow
|
||||
// MAX-1 + MAX overflow
|
||||
// 1 + MIN = MIN+1
|
||||
// -1 + MIN overflow
|
||||
// -1 + MAX = MAX-1
|
||||
// +1 + MAX overflow
|
||||
// MIN + 1 = MIN+1
|
||||
// MIN + -1 overflow
|
||||
// MAX + 1 overflow
|
||||
// MAX + -1 = MAX-1
|
||||
try test__addoti4(min + 1, min);
|
||||
try test__addoti4(max - 1, max);
|
||||
try test__addoti4(1, min);
|
||||
try test__addoti4(-1, min);
|
||||
try test__addoti4(-1, max);
|
||||
try test__addoti4(1, max);
|
||||
try test__addoti4(min, 1);
|
||||
try test__addoti4(min, -1);
|
||||
try test__addoti4(max, -1);
|
||||
try test__addoti4(max, 1);
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
const common = @import("./common.zig");
|
||||
const addf3 = @import("./addf3.zig").addf3;
|
||||
|
||||
pub const panic = common.panic;
|
||||
|
||||
comptime {
|
||||
if (common.want_aeabi) {
|
||||
@export(__aeabi_fadd, .{ .name = "__aeabi_fadd", .linkage = common.linkage });
|
||||
} else {
|
||||
@export(__addsf3, .{ .name = "__addsf3", .linkage = common.linkage });
|
||||
}
|
||||
}
|
||||
|
||||
fn __addsf3(a: f32, b: f32) callconv(.C) f32 {
|
||||
return addf3(f32, a, b);
|
||||
}
|
||||
|
||||
fn __aeabi_fadd(a: f32, b: f32) callconv(.AAPCS) f32 {
|
||||
return addf3(f32, a, b);
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
const common = @import("./common.zig");
|
||||
const addf3 = @import("./addf3.zig").addf3;
|
||||
|
||||
pub const panic = common.panic;
|
||||
|
||||
comptime {
|
||||
if (common.want_ppc_abi) {
|
||||
@export(__addtf3, .{ .name = "__addkf3", .linkage = common.linkage });
|
||||
} else if (common.want_sparc_abi) {
|
||||
@export(_Qp_add, .{ .name = "_Qp_add", .linkage = common.linkage });
|
||||
}
|
||||
@export(__addtf3, .{ .name = "__addtf3", .linkage = common.linkage });
|
||||
}
|
||||
|
||||
pub fn __addtf3(a: f128, b: f128) callconv(.C) f128 {
|
||||
return addf3(f128, a, b);
|
||||
}
|
||||
|
||||
fn _Qp_add(c: *f128, a: *f128, b: *f128) callconv(.C) void {
|
||||
c.* = addf3(f128, a.*, b.*);
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
const common = @import("./common.zig");
|
||||
const addf3 = @import("./addf3.zig").addf3;
|
||||
|
||||
pub const panic = common.panic;
|
||||
|
||||
comptime {
|
||||
@export(__addxf3, .{ .name = "__addxf3", .linkage = common.linkage });
|
||||
}
|
||||
|
||||
pub fn __addxf3(a: f80, b: f80) callconv(.C) f80 {
|
||||
return addf3(f80, a, b);
|
||||
}
|
||||
@@ -1,188 +0,0 @@
|
||||
// ARM specific builtins
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const arch = builtin.cpu.arch;
|
||||
const common = @import("common.zig");
|
||||
|
||||
pub const panic = common.panic;
|
||||
|
||||
comptime {
|
||||
if (!builtin.is_test) {
|
||||
if (arch.isARM() or arch.isThumb()) {
|
||||
@export(__aeabi_unwind_cpp_pr0, .{ .name = "__aeabi_unwind_cpp_pr0", .linkage = common.linkage });
|
||||
@export(__aeabi_unwind_cpp_pr1, .{ .name = "__aeabi_unwind_cpp_pr1", .linkage = common.linkage });
|
||||
@export(__aeabi_unwind_cpp_pr2, .{ .name = "__aeabi_unwind_cpp_pr2", .linkage = common.linkage });
|
||||
|
||||
@export(__aeabi_ldivmod, .{ .name = "__aeabi_ldivmod", .linkage = common.linkage });
|
||||
@export(__aeabi_uldivmod, .{ .name = "__aeabi_uldivmod", .linkage = common.linkage });
|
||||
|
||||
@export(__aeabi_idivmod, .{ .name = "__aeabi_idivmod", .linkage = common.linkage });
|
||||
@export(__aeabi_uidivmod, .{ .name = "__aeabi_uidivmod", .linkage = common.linkage });
|
||||
|
||||
@export(__aeabi_memcpy, .{ .name = "__aeabi_memcpy", .linkage = common.linkage });
|
||||
@export(__aeabi_memcpy4, .{ .name = "__aeabi_memcpy4", .linkage = common.linkage });
|
||||
@export(__aeabi_memcpy8, .{ .name = "__aeabi_memcpy8", .linkage = common.linkage });
|
||||
|
||||
@export(__aeabi_memmove, .{ .name = "__aeabi_memmove", .linkage = common.linkage });
|
||||
@export(__aeabi_memmove4, .{ .name = "__aeabi_memmove4", .linkage = common.linkage });
|
||||
@export(__aeabi_memmove8, .{ .name = "__aeabi_memmove8", .linkage = common.linkage });
|
||||
|
||||
@export(__aeabi_memset, .{ .name = "__aeabi_memset", .linkage = common.linkage });
|
||||
@export(__aeabi_memset4, .{ .name = "__aeabi_memset4", .linkage = common.linkage });
|
||||
@export(__aeabi_memset8, .{ .name = "__aeabi_memset8", .linkage = common.linkage });
|
||||
|
||||
@export(__aeabi_memclr, .{ .name = "__aeabi_memclr", .linkage = common.linkage });
|
||||
@export(__aeabi_memclr4, .{ .name = "__aeabi_memclr4", .linkage = common.linkage });
|
||||
@export(__aeabi_memclr8, .{ .name = "__aeabi_memclr8", .linkage = common.linkage });
|
||||
|
||||
if (builtin.os.tag == .linux) {
|
||||
@export(__aeabi_read_tp, .{ .name = "__aeabi_read_tp", .linkage = common.linkage });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const __divmodsi4 = @import("int.zig").__divmodsi4;
|
||||
const __udivmodsi4 = @import("int.zig").__udivmodsi4;
|
||||
const __divmoddi4 = @import("int.zig").__divmoddi4;
|
||||
const __udivmoddi4 = @import("int.zig").__udivmoddi4;
|
||||
|
||||
extern fn memset(dest: ?[*]u8, c: u8, n: usize) ?[*]u8;
|
||||
extern fn memcpy(noalias dest: ?[*]u8, noalias src: ?[*]const u8, n: usize) ?[*]u8;
|
||||
extern fn memmove(dest: ?[*]u8, src: ?[*]const u8, n: usize) ?[*]u8;
|
||||
|
||||
pub fn __aeabi_memcpy(dest: [*]u8, src: [*]u8, n: usize) callconv(.AAPCS) void {
|
||||
@setRuntimeSafety(false);
|
||||
_ = memcpy(dest, src, n);
|
||||
}
|
||||
pub fn __aeabi_memcpy4(dest: [*]u8, src: [*]u8, n: usize) callconv(.AAPCS) void {
|
||||
@setRuntimeSafety(false);
|
||||
_ = memcpy(dest, src, n);
|
||||
}
|
||||
pub fn __aeabi_memcpy8(dest: [*]u8, src: [*]u8, n: usize) callconv(.AAPCS) void {
|
||||
@setRuntimeSafety(false);
|
||||
_ = memcpy(dest, src, n);
|
||||
}
|
||||
|
||||
pub fn __aeabi_memmove(dest: [*]u8, src: [*]u8, n: usize) callconv(.AAPCS) void {
|
||||
@setRuntimeSafety(false);
|
||||
_ = memmove(dest, src, n);
|
||||
}
|
||||
pub fn __aeabi_memmove4(dest: [*]u8, src: [*]u8, n: usize) callconv(.AAPCS) void {
|
||||
@setRuntimeSafety(false);
|
||||
_ = memmove(dest, src, n);
|
||||
}
|
||||
pub fn __aeabi_memmove8(dest: [*]u8, src: [*]u8, n: usize) callconv(.AAPCS) void {
|
||||
@setRuntimeSafety(false);
|
||||
_ = memmove(dest, src, n);
|
||||
}
|
||||
|
||||
pub fn __aeabi_memset(dest: [*]u8, n: usize, c: u8) callconv(.AAPCS) void {
|
||||
@setRuntimeSafety(false);
|
||||
// This is dentical to the standard `memset` definition but with the last
|
||||
// two arguments swapped
|
||||
_ = memset(dest, c, n);
|
||||
}
|
||||
pub fn __aeabi_memset4(dest: [*]u8, n: usize, c: u8) callconv(.AAPCS) void {
|
||||
@setRuntimeSafety(false);
|
||||
_ = memset(dest, c, n);
|
||||
}
|
||||
pub fn __aeabi_memset8(dest: [*]u8, n: usize, c: u8) callconv(.AAPCS) void {
|
||||
@setRuntimeSafety(false);
|
||||
_ = memset(dest, c, n);
|
||||
}
|
||||
|
||||
pub fn __aeabi_memclr(dest: [*]u8, n: usize) callconv(.AAPCS) void {
|
||||
@setRuntimeSafety(false);
|
||||
_ = memset(dest, 0, n);
|
||||
}
|
||||
pub fn __aeabi_memclr4(dest: [*]u8, n: usize) callconv(.AAPCS) void {
|
||||
@setRuntimeSafety(false);
|
||||
_ = memset(dest, 0, n);
|
||||
}
|
||||
pub fn __aeabi_memclr8(dest: [*]u8, n: usize) callconv(.AAPCS) void {
|
||||
@setRuntimeSafety(false);
|
||||
_ = memset(dest, 0, n);
|
||||
}
|
||||
|
||||
// Dummy functions to avoid errors during the linking phase
|
||||
pub fn __aeabi_unwind_cpp_pr0() callconv(.AAPCS) void {}
|
||||
pub fn __aeabi_unwind_cpp_pr1() callconv(.AAPCS) void {}
|
||||
pub fn __aeabi_unwind_cpp_pr2() callconv(.AAPCS) void {}
|
||||
|
||||
// This function can only clobber r0 according to the ABI
|
||||
pub fn __aeabi_read_tp() callconv(.Naked) void {
|
||||
@setRuntimeSafety(false);
|
||||
asm volatile (
|
||||
\\ mrc p15, 0, r0, c13, c0, 3
|
||||
\\ bx lr
|
||||
);
|
||||
unreachable;
|
||||
}
|
||||
|
||||
// The following functions are wrapped in an asm block to ensure the required
|
||||
// calling convention is always respected
|
||||
|
||||
pub fn __aeabi_uidivmod() callconv(.Naked) void {
|
||||
@setRuntimeSafety(false);
|
||||
// Divide r0 by r1; the quotient goes in r0, the remainder in r1
|
||||
asm volatile (
|
||||
\\ push {lr}
|
||||
\\ sub sp, #4
|
||||
\\ mov r2, sp
|
||||
\\ bl __udivmodsi4
|
||||
\\ ldr r1, [sp]
|
||||
\\ add sp, #4
|
||||
\\ pop {pc}
|
||||
::: "memory");
|
||||
unreachable;
|
||||
}
|
||||
|
||||
pub fn __aeabi_uldivmod() callconv(.Naked) void {
|
||||
@setRuntimeSafety(false);
|
||||
// Divide r1:r0 by r3:r2; the quotient goes in r1:r0, the remainder in r3:r2
|
||||
asm volatile (
|
||||
\\ push {r4, lr}
|
||||
\\ sub sp, #16
|
||||
\\ add r4, sp, #8
|
||||
\\ str r4, [sp]
|
||||
\\ bl __udivmoddi4
|
||||
\\ ldr r2, [sp, #8]
|
||||
\\ ldr r3, [sp, #12]
|
||||
\\ add sp, #16
|
||||
\\ pop {r4, pc}
|
||||
::: "memory");
|
||||
unreachable;
|
||||
}
|
||||
|
||||
pub fn __aeabi_idivmod() callconv(.Naked) void {
|
||||
@setRuntimeSafety(false);
|
||||
// Divide r0 by r1; the quotient goes in r0, the remainder in r1
|
||||
asm volatile (
|
||||
\\ push {lr}
|
||||
\\ sub sp, #4
|
||||
\\ mov r2, sp
|
||||
\\ bl __divmodsi4
|
||||
\\ ldr r1, [sp]
|
||||
\\ add sp, #4
|
||||
\\ pop {pc}
|
||||
::: "memory");
|
||||
unreachable;
|
||||
}
|
||||
|
||||
pub fn __aeabi_ldivmod() callconv(.Naked) void {
|
||||
@setRuntimeSafety(false);
|
||||
// Divide r1:r0 by r3:r2; the quotient goes in r1:r0, the remainder in r3:r2
|
||||
asm volatile (
|
||||
\\ push {r4, lr}
|
||||
\\ sub sp, #16
|
||||
\\ add r4, sp, #8
|
||||
\\ str r4, [sp]
|
||||
\\ bl __divmoddi4
|
||||
\\ ldr r2, [sp, #8]
|
||||
\\ ldr r3, [sp, #12]
|
||||
\\ add sp, #16
|
||||
\\ pop {r4, pc}
|
||||
::: "memory");
|
||||
unreachable;
|
||||
}
|
||||
@@ -1,512 +0,0 @@
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const cpu = builtin.cpu;
|
||||
const arch = cpu.arch;
|
||||
const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
|
||||
pub const panic = @import("common.zig").panic;
|
||||
|
||||
// This parameter is true iff the target architecture supports the bare minimum
|
||||
// to implement the atomic load/store intrinsics.
|
||||
// Some architectures support atomic load/stores but no CAS, but we ignore this
|
||||
// detail to keep the export logic clean and because we need some kind of CAS to
|
||||
// implement the spinlocks.
|
||||
const supports_atomic_ops = switch (arch) {
|
||||
.msp430, .avr, .bpfel, .bpfeb => false,
|
||||
.arm, .armeb, .thumb, .thumbeb =>
|
||||
// The ARM v6m ISA has no ldrex/strex and so it's impossible to do CAS
|
||||
// operations (unless we're targeting Linux, the kernel provides a way to
|
||||
// perform CAS operations).
|
||||
// XXX: The Linux code path is not implemented yet.
|
||||
!std.Target.arm.featureSetHas(builtin.cpu.features, .has_v6m),
|
||||
else => true,
|
||||
};
|
||||
|
||||
// The size (in bytes) of the biggest object that the architecture can
|
||||
// load/store atomically.
|
||||
// Objects bigger than this threshold require the use of a lock.
|
||||
const largest_atomic_size = switch (arch) {
|
||||
// On SPARC systems that lacks CAS and/or swap instructions, the only
|
||||
// available atomic operation is a test-and-set (`ldstub`), so we force
|
||||
// every atomic memory access to go through the lock.
|
||||
.sparc, .sparcel => if (cpu.features.featureSetHas(.hasleoncasa)) @sizeOf(usize) else 0,
|
||||
|
||||
// XXX: On x86/x86_64 we could check the presence of cmpxchg8b/cmpxchg16b
|
||||
// and set this parameter accordingly.
|
||||
else => @sizeOf(usize),
|
||||
};
|
||||
|
||||
// The size (in bytes) of the smallest atomic object that the architecture can
|
||||
// perform fetch/exchange atomically. Note, this does not encompass load and store.
|
||||
// Objects smaller than this threshold are implemented in terms of compare-exchange
|
||||
// of a larger value.
|
||||
const smallest_atomic_fetch_exch_size = switch (arch) {
|
||||
// On AMDGPU, there are no instructions for atomic operations other than load and store
|
||||
// (as of LLVM 15), and so these need to be implemented in terms of atomic CAS.
|
||||
.amdgcn => @sizeOf(u32),
|
||||
else => @sizeOf(u8),
|
||||
};
|
||||
|
||||
const cache_line_size = 64;
|
||||
|
||||
const SpinlockTable = struct {
|
||||
// Allocate ~4096 bytes of memory for the spinlock table
|
||||
const max_spinlocks = 64;
|
||||
|
||||
const Spinlock = struct {
|
||||
// SPARC ldstub instruction will write a 255 into the memory location.
|
||||
// We'll use that as a sign that the lock is currently held.
|
||||
// See also: Section B.7 in SPARCv8 spec & A.29 in SPARCv9 spec.
|
||||
const sparc_lock: type = enum(u8) { Unlocked = 0, Locked = 255 };
|
||||
const other_lock: type = enum(usize) { Unlocked = 0, Locked };
|
||||
|
||||
// Prevent false sharing by providing enough padding between two
|
||||
// consecutive spinlock elements
|
||||
v: if (arch.isSPARC()) sparc_lock else other_lock align(cache_line_size) = .Unlocked,
|
||||
|
||||
fn acquire(self: *@This()) void {
|
||||
while (true) {
|
||||
const flag = if (comptime arch.isSPARC()) flag: {
|
||||
break :flag asm volatile ("ldstub [%[addr]], %[flag]"
|
||||
: [flag] "=r" (-> @TypeOf(self.v)),
|
||||
: [addr] "r" (&self.v),
|
||||
: "memory"
|
||||
);
|
||||
} else flag: {
|
||||
break :flag @atomicRmw(@TypeOf(self.v), &self.v, .Xchg, .Locked, .Acquire);
|
||||
};
|
||||
|
||||
switch (flag) {
|
||||
.Unlocked => break,
|
||||
.Locked => {},
|
||||
}
|
||||
}
|
||||
}
|
||||
fn release(self: *@This()) void {
|
||||
if (comptime arch.isSPARC()) {
|
||||
_ = asm volatile ("clrb [%[addr]]"
|
||||
:
|
||||
: [addr] "r" (&self.v),
|
||||
: "memory"
|
||||
);
|
||||
} else {
|
||||
@atomicStore(@TypeOf(self.v), &self.v, .Unlocked, .Release);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
list: [max_spinlocks]Spinlock = [_]Spinlock{.{}} ** max_spinlocks,
|
||||
|
||||
// The spinlock table behaves as a really simple hash table, mapping
|
||||
// addresses to spinlocks. The mapping is not unique but that's only a
|
||||
// performance problem as the lock will be contended by more than a pair of
|
||||
// threads.
|
||||
fn get(self: *@This(), address: usize) *Spinlock {
|
||||
var sl = &self.list[(address >> 3) % max_spinlocks];
|
||||
sl.acquire();
|
||||
return sl;
|
||||
}
|
||||
};
|
||||
|
||||
var spinlocks: SpinlockTable = SpinlockTable{};
|
||||
|
||||
// The following builtins do not respect the specified memory model and instead
|
||||
// uses seq_cst, the strongest one, for simplicity sake.
|
||||
|
||||
// Generic version of GCC atomic builtin functions.
|
||||
// Those work on any object no matter the pointer alignment nor its size.
|
||||
|
||||
fn __atomic_load(size: u32, src: [*]u8, dest: [*]u8, model: i32) callconv(.C) void {
|
||||
_ = model;
|
||||
var sl = spinlocks.get(@ptrToInt(src));
|
||||
defer sl.release();
|
||||
@memcpy(dest, src, size);
|
||||
}
|
||||
|
||||
fn __atomic_store(size: u32, dest: [*]u8, src: [*]u8, model: i32) callconv(.C) void {
|
||||
_ = model;
|
||||
var sl = spinlocks.get(@ptrToInt(dest));
|
||||
defer sl.release();
|
||||
@memcpy(dest, src, size);
|
||||
}
|
||||
|
||||
fn __atomic_exchange(size: u32, ptr: [*]u8, val: [*]u8, old: [*]u8, model: i32) callconv(.C) void {
|
||||
_ = model;
|
||||
var sl = spinlocks.get(@ptrToInt(ptr));
|
||||
defer sl.release();
|
||||
@memcpy(old, ptr, size);
|
||||
@memcpy(ptr, val, size);
|
||||
}
|
||||
|
||||
fn __atomic_compare_exchange(
|
||||
size: u32,
|
||||
ptr: [*]u8,
|
||||
expected: [*]u8,
|
||||
desired: [*]u8,
|
||||
success: i32,
|
||||
failure: i32,
|
||||
) callconv(.C) i32 {
|
||||
_ = success;
|
||||
_ = failure;
|
||||
var sl = spinlocks.get(@ptrToInt(ptr));
|
||||
defer sl.release();
|
||||
for (ptr[0..size]) |b, i| {
|
||||
if (expected[i] != b) break;
|
||||
} else {
|
||||
// The two objects, ptr and expected, are equal
|
||||
@memcpy(ptr, desired, size);
|
||||
return 1;
|
||||
}
|
||||
@memcpy(expected, ptr, size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Specialized versions of the GCC atomic builtin functions.
|
||||
// LLVM emits those iff the object size is known and the pointers are correctly
|
||||
// aligned.
|
||||
inline fn atomic_load_N(comptime T: type, src: *T, model: i32) T {
|
||||
_ = model;
|
||||
if (@sizeOf(T) > largest_atomic_size) {
|
||||
var sl = spinlocks.get(@ptrToInt(src));
|
||||
defer sl.release();
|
||||
return src.*;
|
||||
} else {
|
||||
return @atomicLoad(T, src, .SeqCst);
|
||||
}
|
||||
}
|
||||
|
||||
fn __atomic_load_1(src: *u8, model: i32) callconv(.C) u8 {
|
||||
return atomic_load_N(u8, src, model);
|
||||
}
|
||||
|
||||
fn __atomic_load_2(src: *u16, model: i32) callconv(.C) u16 {
|
||||
return atomic_load_N(u16, src, model);
|
||||
}
|
||||
|
||||
fn __atomic_load_4(src: *u32, model: i32) callconv(.C) u32 {
|
||||
return atomic_load_N(u32, src, model);
|
||||
}
|
||||
|
||||
fn __atomic_load_8(src: *u64, model: i32) callconv(.C) u64 {
|
||||
return atomic_load_N(u64, src, model);
|
||||
}
|
||||
|
||||
inline fn atomic_store_N(comptime T: type, dst: *T, value: T, model: i32) void {
|
||||
_ = model;
|
||||
if (@sizeOf(T) > largest_atomic_size) {
|
||||
var sl = spinlocks.get(@ptrToInt(dst));
|
||||
defer sl.release();
|
||||
dst.* = value;
|
||||
} else {
|
||||
@atomicStore(T, dst, value, .SeqCst);
|
||||
}
|
||||
}
|
||||
|
||||
fn __atomic_store_1(dst: *u8, value: u8, model: i32) callconv(.C) void {
|
||||
return atomic_store_N(u8, dst, value, model);
|
||||
}
|
||||
|
||||
fn __atomic_store_2(dst: *u16, value: u16, model: i32) callconv(.C) void {
|
||||
return atomic_store_N(u16, dst, value, model);
|
||||
}
|
||||
|
||||
fn __atomic_store_4(dst: *u32, value: u32, model: i32) callconv(.C) void {
|
||||
return atomic_store_N(u32, dst, value, model);
|
||||
}
|
||||
|
||||
fn __atomic_store_8(dst: *u64, value: u64, model: i32) callconv(.C) void {
|
||||
return atomic_store_N(u64, dst, value, model);
|
||||
}
|
||||
|
||||
fn wideUpdate(comptime T: type, ptr: *T, val: T, update: anytype) T {
|
||||
const WideAtomic = std.meta.Int(.unsigned, smallest_atomic_fetch_exch_size * 8);
|
||||
|
||||
const addr = @ptrToInt(ptr);
|
||||
const wide_addr = addr & ~(@as(T, smallest_atomic_fetch_exch_size) - 1);
|
||||
const wide_ptr = @alignCast(smallest_atomic_fetch_exch_size, @intToPtr(*WideAtomic, wide_addr));
|
||||
|
||||
const inner_offset = addr & (@as(T, smallest_atomic_fetch_exch_size) - 1);
|
||||
const inner_shift = @intCast(std.math.Log2Int(T), inner_offset * 8);
|
||||
|
||||
const mask = @as(WideAtomic, std.math.maxInt(T)) << inner_shift;
|
||||
|
||||
var wide_old = @atomicLoad(WideAtomic, wide_ptr, .SeqCst);
|
||||
while (true) {
|
||||
const old = @truncate(T, (wide_old & mask) >> inner_shift);
|
||||
const new = update(val, old);
|
||||
const wide_new = wide_old & ~mask | (@as(WideAtomic, new) << inner_shift);
|
||||
if (@cmpxchgWeak(WideAtomic, wide_ptr, wide_old, wide_new, .SeqCst, .SeqCst)) |new_wide_old| {
|
||||
wide_old = new_wide_old;
|
||||
} else {
|
||||
return old;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline fn atomic_exchange_N(comptime T: type, ptr: *T, val: T, model: i32) T {
|
||||
_ = model;
|
||||
if (@sizeOf(T) > largest_atomic_size) {
|
||||
var sl = spinlocks.get(@ptrToInt(ptr));
|
||||
defer sl.release();
|
||||
const value = ptr.*;
|
||||
ptr.* = val;
|
||||
return value;
|
||||
} else if (@sizeOf(T) < smallest_atomic_fetch_exch_size) {
|
||||
// Machine does not support this type, but it does support a larger type.
|
||||
const Updater = struct {
|
||||
fn update(new: T, old: T) T {
|
||||
_ = old;
|
||||
return new;
|
||||
}
|
||||
};
|
||||
return wideUpdate(T, ptr, val, Updater.update);
|
||||
} else {
|
||||
return @atomicRmw(T, ptr, .Xchg, val, .SeqCst);
|
||||
}
|
||||
}
|
||||
|
||||
fn __atomic_exchange_1(ptr: *u8, val: u8, model: i32) callconv(.C) u8 {
|
||||
return atomic_exchange_N(u8, ptr, val, model);
|
||||
}
|
||||
|
||||
fn __atomic_exchange_2(ptr: *u16, val: u16, model: i32) callconv(.C) u16 {
|
||||
return atomic_exchange_N(u16, ptr, val, model);
|
||||
}
|
||||
|
||||
fn __atomic_exchange_4(ptr: *u32, val: u32, model: i32) callconv(.C) u32 {
|
||||
return atomic_exchange_N(u32, ptr, val, model);
|
||||
}
|
||||
|
||||
fn __atomic_exchange_8(ptr: *u64, val: u64, model: i32) callconv(.C) u64 {
|
||||
return atomic_exchange_N(u64, ptr, val, model);
|
||||
}
|
||||
|
||||
inline fn atomic_compare_exchange_N(
|
||||
comptime T: type,
|
||||
ptr: *T,
|
||||
expected: *T,
|
||||
desired: T,
|
||||
success: i32,
|
||||
failure: i32,
|
||||
) i32 {
|
||||
_ = success;
|
||||
_ = failure;
|
||||
if (@sizeOf(T) > largest_atomic_size) {
|
||||
var sl = spinlocks.get(@ptrToInt(ptr));
|
||||
defer sl.release();
|
||||
const value = ptr.*;
|
||||
if (value == expected.*) {
|
||||
ptr.* = desired;
|
||||
return 1;
|
||||
}
|
||||
expected.* = value;
|
||||
return 0;
|
||||
} else {
|
||||
if (@cmpxchgStrong(T, ptr, expected.*, desired, .SeqCst, .SeqCst)) |old_value| {
|
||||
expected.* = old_value;
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
fn __atomic_compare_exchange_1(ptr: *u8, expected: *u8, desired: u8, success: i32, failure: i32) callconv(.C) i32 {
|
||||
return atomic_compare_exchange_N(u8, ptr, expected, desired, success, failure);
|
||||
}
|
||||
|
||||
fn __atomic_compare_exchange_2(ptr: *u16, expected: *u16, desired: u16, success: i32, failure: i32) callconv(.C) i32 {
|
||||
return atomic_compare_exchange_N(u16, ptr, expected, desired, success, failure);
|
||||
}
|
||||
|
||||
fn __atomic_compare_exchange_4(ptr: *u32, expected: *u32, desired: u32, success: i32, failure: i32) callconv(.C) i32 {
|
||||
return atomic_compare_exchange_N(u32, ptr, expected, desired, success, failure);
|
||||
}
|
||||
|
||||
fn __atomic_compare_exchange_8(ptr: *u64, expected: *u64, desired: u64, success: i32, failure: i32) callconv(.C) i32 {
|
||||
return atomic_compare_exchange_N(u64, ptr, expected, desired, success, failure);
|
||||
}
|
||||
|
||||
inline fn fetch_op_N(comptime T: type, comptime op: std.builtin.AtomicRmwOp, ptr: *T, val: T, model: i32) T {
|
||||
_ = model;
|
||||
const Updater = struct {
|
||||
fn update(new: T, old: T) T {
|
||||
return switch (op) {
|
||||
.Add => old +% new,
|
||||
.Sub => old -% new,
|
||||
.And => old & new,
|
||||
.Nand => ~(old & new),
|
||||
.Or => old | new,
|
||||
.Xor => old ^ new,
|
||||
else => @compileError("unsupported atomic op"),
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
if (@sizeOf(T) > largest_atomic_size) {
|
||||
var sl = spinlocks.get(@ptrToInt(ptr));
|
||||
defer sl.release();
|
||||
|
||||
const value = ptr.*;
|
||||
ptr.* = Updater.update(val, value);
|
||||
return value;
|
||||
} else if (@sizeOf(T) < smallest_atomic_fetch_exch_size) {
|
||||
// Machine does not support this type, but it does support a larger type.
|
||||
return wideUpdate(T, ptr, val, Updater.update);
|
||||
}
|
||||
|
||||
return @atomicRmw(T, ptr, op, val, .SeqCst);
|
||||
}
|
||||
|
||||
fn __atomic_fetch_add_1(ptr: *u8, val: u8, model: i32) callconv(.C) u8 {
|
||||
return fetch_op_N(u8, .Add, ptr, val, model);
|
||||
}
|
||||
|
||||
fn __atomic_fetch_add_2(ptr: *u16, val: u16, model: i32) callconv(.C) u16 {
|
||||
return fetch_op_N(u16, .Add, ptr, val, model);
|
||||
}
|
||||
|
||||
fn __atomic_fetch_add_4(ptr: *u32, val: u32, model: i32) callconv(.C) u32 {
|
||||
return fetch_op_N(u32, .Add, ptr, val, model);
|
||||
}
|
||||
|
||||
fn __atomic_fetch_add_8(ptr: *u64, val: u64, model: i32) callconv(.C) u64 {
|
||||
return fetch_op_N(u64, .Add, ptr, val, model);
|
||||
}
|
||||
|
||||
fn __atomic_fetch_sub_1(ptr: *u8, val: u8, model: i32) callconv(.C) u8 {
|
||||
return fetch_op_N(u8, .Sub, ptr, val, model);
|
||||
}
|
||||
|
||||
fn __atomic_fetch_sub_2(ptr: *u16, val: u16, model: i32) callconv(.C) u16 {
|
||||
return fetch_op_N(u16, .Sub, ptr, val, model);
|
||||
}
|
||||
|
||||
fn __atomic_fetch_sub_4(ptr: *u32, val: u32, model: i32) callconv(.C) u32 {
|
||||
return fetch_op_N(u32, .Sub, ptr, val, model);
|
||||
}
|
||||
|
||||
fn __atomic_fetch_sub_8(ptr: *u64, val: u64, model: i32) callconv(.C) u64 {
|
||||
return fetch_op_N(u64, .Sub, ptr, val, model);
|
||||
}
|
||||
|
||||
fn __atomic_fetch_and_1(ptr: *u8, val: u8, model: i32) callconv(.C) u8 {
|
||||
return fetch_op_N(u8, .And, ptr, val, model);
|
||||
}
|
||||
|
||||
fn __atomic_fetch_and_2(ptr: *u16, val: u16, model: i32) callconv(.C) u16 {
|
||||
return fetch_op_N(u16, .And, ptr, val, model);
|
||||
}
|
||||
|
||||
fn __atomic_fetch_and_4(ptr: *u32, val: u32, model: i32) callconv(.C) u32 {
|
||||
return fetch_op_N(u32, .And, ptr, val, model);
|
||||
}
|
||||
|
||||
fn __atomic_fetch_and_8(ptr: *u64, val: u64, model: i32) callconv(.C) u64 {
|
||||
return fetch_op_N(u64, .And, ptr, val, model);
|
||||
}
|
||||
|
||||
fn __atomic_fetch_or_1(ptr: *u8, val: u8, model: i32) callconv(.C) u8 {
|
||||
return fetch_op_N(u8, .Or, ptr, val, model);
|
||||
}
|
||||
|
||||
fn __atomic_fetch_or_2(ptr: *u16, val: u16, model: i32) callconv(.C) u16 {
|
||||
return fetch_op_N(u16, .Or, ptr, val, model);
|
||||
}
|
||||
|
||||
fn __atomic_fetch_or_4(ptr: *u32, val: u32, model: i32) callconv(.C) u32 {
|
||||
return fetch_op_N(u32, .Or, ptr, val, model);
|
||||
}
|
||||
|
||||
fn __atomic_fetch_or_8(ptr: *u64, val: u64, model: i32) callconv(.C) u64 {
|
||||
return fetch_op_N(u64, .Or, ptr, val, model);
|
||||
}
|
||||
|
||||
fn __atomic_fetch_xor_1(ptr: *u8, val: u8, model: i32) callconv(.C) u8 {
|
||||
return fetch_op_N(u8, .Xor, ptr, val, model);
|
||||
}
|
||||
|
||||
fn __atomic_fetch_xor_2(ptr: *u16, val: u16, model: i32) callconv(.C) u16 {
|
||||
return fetch_op_N(u16, .Xor, ptr, val, model);
|
||||
}
|
||||
|
||||
fn __atomic_fetch_xor_4(ptr: *u32, val: u32, model: i32) callconv(.C) u32 {
|
||||
return fetch_op_N(u32, .Xor, ptr, val, model);
|
||||
}
|
||||
|
||||
fn __atomic_fetch_xor_8(ptr: *u64, val: u64, model: i32) callconv(.C) u64 {
|
||||
return fetch_op_N(u64, .Xor, ptr, val, model);
|
||||
}
|
||||
|
||||
fn __atomic_fetch_nand_1(ptr: *u8, val: u8, model: i32) callconv(.C) u8 {
|
||||
return fetch_op_N(u8, .Nand, ptr, val, model);
|
||||
}
|
||||
|
||||
fn __atomic_fetch_nand_2(ptr: *u16, val: u16, model: i32) callconv(.C) u16 {
|
||||
return fetch_op_N(u16, .Nand, ptr, val, model);
|
||||
}
|
||||
|
||||
fn __atomic_fetch_nand_4(ptr: *u32, val: u32, model: i32) callconv(.C) u32 {
|
||||
return fetch_op_N(u32, .Nand, ptr, val, model);
|
||||
}
|
||||
|
||||
fn __atomic_fetch_nand_8(ptr: *u64, val: u64, model: i32) callconv(.C) u64 {
|
||||
return fetch_op_N(u64, .Nand, ptr, val, model);
|
||||
}
|
||||
|
||||
comptime {
|
||||
if (supports_atomic_ops) {
|
||||
@export(__atomic_load, .{ .name = "__atomic_load", .linkage = linkage });
|
||||
@export(__atomic_store, .{ .name = "__atomic_store", .linkage = linkage });
|
||||
@export(__atomic_exchange, .{ .name = "__atomic_exchange", .linkage = linkage });
|
||||
@export(__atomic_compare_exchange, .{ .name = "__atomic_compare_exchange", .linkage = linkage });
|
||||
|
||||
@export(__atomic_fetch_add_1, .{ .name = "__atomic_fetch_add_1", .linkage = linkage });
|
||||
@export(__atomic_fetch_add_2, .{ .name = "__atomic_fetch_add_2", .linkage = linkage });
|
||||
@export(__atomic_fetch_add_4, .{ .name = "__atomic_fetch_add_4", .linkage = linkage });
|
||||
@export(__atomic_fetch_add_8, .{ .name = "__atomic_fetch_add_8", .linkage = linkage });
|
||||
|
||||
@export(__atomic_fetch_sub_1, .{ .name = "__atomic_fetch_sub_1", .linkage = linkage });
|
||||
@export(__atomic_fetch_sub_2, .{ .name = "__atomic_fetch_sub_2", .linkage = linkage });
|
||||
@export(__atomic_fetch_sub_4, .{ .name = "__atomic_fetch_sub_4", .linkage = linkage });
|
||||
@export(__atomic_fetch_sub_8, .{ .name = "__atomic_fetch_sub_8", .linkage = linkage });
|
||||
|
||||
@export(__atomic_fetch_and_1, .{ .name = "__atomic_fetch_and_1", .linkage = linkage });
|
||||
@export(__atomic_fetch_and_2, .{ .name = "__atomic_fetch_and_2", .linkage = linkage });
|
||||
@export(__atomic_fetch_and_4, .{ .name = "__atomic_fetch_and_4", .linkage = linkage });
|
||||
@export(__atomic_fetch_and_8, .{ .name = "__atomic_fetch_and_8", .linkage = linkage });
|
||||
|
||||
@export(__atomic_fetch_or_1, .{ .name = "__atomic_fetch_or_1", .linkage = linkage });
|
||||
@export(__atomic_fetch_or_2, .{ .name = "__atomic_fetch_or_2", .linkage = linkage });
|
||||
@export(__atomic_fetch_or_4, .{ .name = "__atomic_fetch_or_4", .linkage = linkage });
|
||||
@export(__atomic_fetch_or_8, .{ .name = "__atomic_fetch_or_8", .linkage = linkage });
|
||||
|
||||
@export(__atomic_fetch_xor_1, .{ .name = "__atomic_fetch_xor_1", .linkage = linkage });
|
||||
@export(__atomic_fetch_xor_2, .{ .name = "__atomic_fetch_xor_2", .linkage = linkage });
|
||||
@export(__atomic_fetch_xor_4, .{ .name = "__atomic_fetch_xor_4", .linkage = linkage });
|
||||
@export(__atomic_fetch_xor_8, .{ .name = "__atomic_fetch_xor_8", .linkage = linkage });
|
||||
|
||||
@export(__atomic_fetch_nand_1, .{ .name = "__atomic_fetch_nand_1", .linkage = linkage });
|
||||
@export(__atomic_fetch_nand_2, .{ .name = "__atomic_fetch_nand_2", .linkage = linkage });
|
||||
@export(__atomic_fetch_nand_4, .{ .name = "__atomic_fetch_nand_4", .linkage = linkage });
|
||||
@export(__atomic_fetch_nand_8, .{ .name = "__atomic_fetch_nand_8", .linkage = linkage });
|
||||
|
||||
@export(__atomic_load_1, .{ .name = "__atomic_load_1", .linkage = linkage });
|
||||
@export(__atomic_load_2, .{ .name = "__atomic_load_2", .linkage = linkage });
|
||||
@export(__atomic_load_4, .{ .name = "__atomic_load_4", .linkage = linkage });
|
||||
@export(__atomic_load_8, .{ .name = "__atomic_load_8", .linkage = linkage });
|
||||
|
||||
@export(__atomic_store_1, .{ .name = "__atomic_store_1", .linkage = linkage });
|
||||
@export(__atomic_store_2, .{ .name = "__atomic_store_2", .linkage = linkage });
|
||||
@export(__atomic_store_4, .{ .name = "__atomic_store_4", .linkage = linkage });
|
||||
@export(__atomic_store_8, .{ .name = "__atomic_store_8", .linkage = linkage });
|
||||
|
||||
@export(__atomic_exchange_1, .{ .name = "__atomic_exchange_1", .linkage = linkage });
|
||||
@export(__atomic_exchange_2, .{ .name = "__atomic_exchange_2", .linkage = linkage });
|
||||
@export(__atomic_exchange_4, .{ .name = "__atomic_exchange_4", .linkage = linkage });
|
||||
@export(__atomic_exchange_8, .{ .name = "__atomic_exchange_8", .linkage = linkage });
|
||||
|
||||
@export(__atomic_compare_exchange_1, .{ .name = "__atomic_compare_exchange_1", .linkage = linkage });
|
||||
@export(__atomic_compare_exchange_2, .{ .name = "__atomic_compare_exchange_2", .linkage = linkage });
|
||||
@export(__atomic_compare_exchange_4, .{ .name = "__atomic_compare_exchange_4", .linkage = linkage });
|
||||
@export(__atomic_compare_exchange_8, .{ .name = "__atomic_compare_exchange_8", .linkage = linkage });
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
const std = @import("std");
|
||||
const common = @import("./common.zig");
|
||||
|
||||
comptime {
|
||||
@export(bcmp, .{ .name = "bcmp", .linkage = common.linkage });
|
||||
}
|
||||
|
||||
pub fn bcmp(vl: [*]allowzero const u8, vr: [*]allowzero const u8, n: usize) callconv(.C) c_int {
|
||||
@setRuntimeSafety(false);
|
||||
|
||||
var index: usize = 0;
|
||||
while (index != n) : (index += 1) {
|
||||
if (vl[index] != vr[index]) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
test "bcmp" {
|
||||
const base_arr = &[_]u8{ 1, 1, 1 };
|
||||
const arr1 = &[_]u8{ 1, 1, 1 };
|
||||
const arr2 = &[_]u8{ 1, 0, 1 };
|
||||
const arr3 = &[_]u8{ 1, 2, 1 };
|
||||
|
||||
try std.testing.expect(bcmp(base_arr[0..], arr1[0..], base_arr.len) == 0);
|
||||
try std.testing.expect(bcmp(base_arr[0..], arr2[0..], base_arr.len) != 0);
|
||||
try std.testing.expect(bcmp(base_arr[0..], arr3[0..], base_arr.len) != 0);
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const common = @import("common.zig");
|
||||
|
||||
pub const panic = common.panic;
|
||||
|
||||
comptime {
|
||||
@export(__bswapsi2, .{ .name = "__bswapsi2", .linkage = common.linkage });
|
||||
@export(__bswapdi2, .{ .name = "__bswapdi2", .linkage = common.linkage });
|
||||
@export(__bswapti2, .{ .name = "__bswapti2", .linkage = common.linkage });
|
||||
}
|
||||
|
||||
// bswap - byteswap
|
||||
// - bswapXi2 for unoptimized big and little endian
|
||||
// ie for u32
|
||||
// DE AD BE EF <- little|big endian
|
||||
// FE BE AD DE <- big|little endian
|
||||
// ff 00 00 00 >> 3*8 (leftmost byte)
|
||||
// 00 ff 00 00 >> 1*8 (2nd left byte)
|
||||
// 00 00 ff 00 << 1*8 (2n right byte)
|
||||
// 00 00 00 ff << 3*8 (rightmost byte)
|
||||
|
||||
inline fn bswapXi2(comptime T: type, a: T) T {
|
||||
switch (@bitSizeOf(T)) {
|
||||
32 => {
|
||||
// zig fmt: off
|
||||
return (((a & 0xff000000) >> 24)
|
||||
| ((a & 0x00ff0000) >> 8 )
|
||||
| ((a & 0x0000ff00) << 8 )
|
||||
| ((a & 0x000000ff) << 24));
|
||||
// zig fmt: on
|
||||
},
|
||||
64 => {
|
||||
// zig fmt: off
|
||||
return (((a & 0xff00000000000000) >> 56)
|
||||
| ((a & 0x00ff000000000000) >> 40 )
|
||||
| ((a & 0x0000ff0000000000) >> 24 )
|
||||
| ((a & 0x000000ff00000000) >> 8 )
|
||||
| ((a & 0x00000000ff000000) << 8 )
|
||||
| ((a & 0x0000000000ff0000) << 24 )
|
||||
| ((a & 0x000000000000ff00) << 40 )
|
||||
| ((a & 0x00000000000000ff) << 56));
|
||||
// zig fmt: on
|
||||
},
|
||||
128 => {
|
||||
// zig fmt: off
|
||||
return (((a & 0xff000000000000000000000000000000) >> 120)
|
||||
| ((a & 0x00ff0000000000000000000000000000) >> 104)
|
||||
| ((a & 0x0000ff00000000000000000000000000) >> 88 )
|
||||
| ((a & 0x000000ff000000000000000000000000) >> 72 )
|
||||
| ((a & 0x00000000ff0000000000000000000000) >> 56 )
|
||||
| ((a & 0x0000000000ff00000000000000000000) >> 40 )
|
||||
| ((a & 0x000000000000ff000000000000000000) >> 24 )
|
||||
| ((a & 0x00000000000000ff0000000000000000) >> 8 )
|
||||
| ((a & 0x0000000000000000ff00000000000000) << 8 )
|
||||
| ((a & 0x000000000000000000ff000000000000) << 24 )
|
||||
| ((a & 0x00000000000000000000ff0000000000) << 40 )
|
||||
| ((a & 0x0000000000000000000000ff00000000) << 56 )
|
||||
| ((a & 0x000000000000000000000000ff000000) << 72 )
|
||||
| ((a & 0x00000000000000000000000000ff0000) << 88 )
|
||||
| ((a & 0x0000000000000000000000000000ff00) << 104)
|
||||
| ((a & 0x000000000000000000000000000000ff) << 120));
|
||||
// zig fmt: on
|
||||
},
|
||||
else => unreachable,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn __bswapsi2(a: u32) callconv(.C) u32 {
|
||||
return bswapXi2(u32, a);
|
||||
}
|
||||
|
||||
pub fn __bswapdi2(a: u64) callconv(.C) u64 {
|
||||
return bswapXi2(u64, a);
|
||||
}
|
||||
|
||||
pub fn __bswapti2(a: u128) callconv(.C) u128 {
|
||||
return bswapXi2(u128, a);
|
||||
}
|
||||
|
||||
test {
|
||||
_ = @import("bswapsi2_test.zig");
|
||||
_ = @import("bswapdi2_test.zig");
|
||||
_ = @import("bswapti2_test.zig");
|
||||
}
|
||||
@@ -1,182 +0,0 @@
|
||||
//! Ported from musl, which is MIT licensed.
|
||||
//! https://git.musl-libc.org/cgit/musl/tree/COPYRIGHT
|
||||
//!
|
||||
//! https://git.musl-libc.org/cgit/musl/tree/src/math/ceilf.c
|
||||
//! https://git.musl-libc.org/cgit/musl/tree/src/math/ceil.c
|
||||
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const arch = builtin.cpu.arch;
|
||||
const math = std.math;
|
||||
const expect = std.testing.expect;
|
||||
const common = @import("common.zig");
|
||||
|
||||
pub const panic = common.panic;
|
||||
|
||||
comptime {
|
||||
@export(__ceilh, .{ .name = "__ceilh", .linkage = common.linkage });
|
||||
@export(ceilf, .{ .name = "ceilf", .linkage = common.linkage });
|
||||
@export(ceil, .{ .name = "ceil", .linkage = common.linkage });
|
||||
@export(__ceilx, .{ .name = "__ceilx", .linkage = common.linkage });
|
||||
if (common.want_ppc_abi) {
|
||||
@export(ceilq, .{ .name = "ceilf128", .linkage = common.linkage });
|
||||
}
|
||||
@export(ceilq, .{ .name = "ceilq", .linkage = common.linkage });
|
||||
@export(ceill, .{ .name = "ceill", .linkage = common.linkage });
|
||||
}
|
||||
|
||||
pub fn __ceilh(x: f16) callconv(.C) f16 {
|
||||
// TODO: more efficient implementation
|
||||
return @floatCast(f16, ceilf(x));
|
||||
}
|
||||
|
||||
pub fn ceilf(x: f32) callconv(.C) f32 {
|
||||
var u = @bitCast(u32, x);
|
||||
var e = @intCast(i32, (u >> 23) & 0xFF) - 0x7F;
|
||||
var m: u32 = undefined;
|
||||
|
||||
// TODO: Shouldn't need this explicit check.
|
||||
if (x == 0.0) {
|
||||
return x;
|
||||
}
|
||||
|
||||
if (e >= 23) {
|
||||
return x;
|
||||
} else if (e >= 0) {
|
||||
m = @as(u32, 0x007FFFFF) >> @intCast(u5, e);
|
||||
if (u & m == 0) {
|
||||
return x;
|
||||
}
|
||||
math.doNotOptimizeAway(x + 0x1.0p120);
|
||||
if (u >> 31 == 0) {
|
||||
u += m;
|
||||
}
|
||||
u &= ~m;
|
||||
return @bitCast(f32, u);
|
||||
} else {
|
||||
math.doNotOptimizeAway(x + 0x1.0p120);
|
||||
if (u >> 31 != 0) {
|
||||
return -0.0;
|
||||
} else {
|
||||
return 1.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn ceil(x: f64) callconv(.C) f64 {
|
||||
const f64_toint = 1.0 / math.floatEps(f64);
|
||||
|
||||
const u = @bitCast(u64, x);
|
||||
const e = (u >> 52) & 0x7FF;
|
||||
var y: f64 = undefined;
|
||||
|
||||
if (e >= 0x3FF + 52 or x == 0) {
|
||||
return x;
|
||||
}
|
||||
|
||||
if (u >> 63 != 0) {
|
||||
y = x - f64_toint + f64_toint - x;
|
||||
} else {
|
||||
y = x + f64_toint - f64_toint - x;
|
||||
}
|
||||
|
||||
if (e <= 0x3FF - 1) {
|
||||
math.doNotOptimizeAway(y);
|
||||
if (u >> 63 != 0) {
|
||||
return -0.0;
|
||||
} else {
|
||||
return 1.0;
|
||||
}
|
||||
} else if (y < 0) {
|
||||
return x + y + 1;
|
||||
} else {
|
||||
return x + y;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn __ceilx(x: f80) callconv(.C) f80 {
|
||||
// TODO: more efficient implementation
|
||||
return @floatCast(f80, ceilq(x));
|
||||
}
|
||||
|
||||
pub fn ceilq(x: f128) callconv(.C) f128 {
|
||||
const f128_toint = 1.0 / math.floatEps(f128);
|
||||
|
||||
const u = @bitCast(u128, x);
|
||||
const e = (u >> 112) & 0x7FFF;
|
||||
var y: f128 = undefined;
|
||||
|
||||
if (e >= 0x3FFF + 112 or x == 0) return x;
|
||||
|
||||
if (u >> 127 != 0) {
|
||||
y = x - f128_toint + f128_toint - x;
|
||||
} else {
|
||||
y = x + f128_toint - f128_toint - x;
|
||||
}
|
||||
|
||||
if (e <= 0x3FFF - 1) {
|
||||
math.doNotOptimizeAway(y);
|
||||
if (u >> 127 != 0) {
|
||||
return -0.0;
|
||||
} else {
|
||||
return 1.0;
|
||||
}
|
||||
} else if (y < 0) {
|
||||
return x + y + 1;
|
||||
} else {
|
||||
return x + y;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn ceill(x: c_longdouble) callconv(.C) c_longdouble {
|
||||
switch (@typeInfo(c_longdouble).Float.bits) {
|
||||
16 => return __ceilh(x),
|
||||
32 => return ceilf(x),
|
||||
64 => return ceil(x),
|
||||
80 => return __ceilx(x),
|
||||
128 => return ceilq(x),
|
||||
else => @compileError("unreachable"),
|
||||
}
|
||||
}
|
||||
|
||||
test "ceil32" {
|
||||
try expect(ceilf(1.3) == 2.0);
|
||||
try expect(ceilf(-1.3) == -1.0);
|
||||
try expect(ceilf(0.2) == 1.0);
|
||||
}
|
||||
|
||||
test "ceil64" {
|
||||
try expect(ceil(1.3) == 2.0);
|
||||
try expect(ceil(-1.3) == -1.0);
|
||||
try expect(ceil(0.2) == 1.0);
|
||||
}
|
||||
|
||||
test "ceil128" {
|
||||
try expect(ceilq(1.3) == 2.0);
|
||||
try expect(ceilq(-1.3) == -1.0);
|
||||
try expect(ceilq(0.2) == 1.0);
|
||||
}
|
||||
|
||||
test "ceil32.special" {
|
||||
try expect(ceilf(0.0) == 0.0);
|
||||
try expect(ceilf(-0.0) == -0.0);
|
||||
try expect(math.isPositiveInf(ceilf(math.inf(f32))));
|
||||
try expect(math.isNegativeInf(ceilf(-math.inf(f32))));
|
||||
try expect(math.isNan(ceilf(math.nan(f32))));
|
||||
}
|
||||
|
||||
test "ceil64.special" {
|
||||
try expect(ceil(0.0) == 0.0);
|
||||
try expect(ceil(-0.0) == -0.0);
|
||||
try expect(math.isPositiveInf(ceil(math.inf(f64))));
|
||||
try expect(math.isNegativeInf(ceil(-math.inf(f64))));
|
||||
try expect(math.isNan(ceil(math.nan(f64))));
|
||||
}
|
||||
|
||||
test "ceil128.special" {
|
||||
try expect(ceilq(0.0) == 0.0);
|
||||
try expect(ceilq(-0.0) == -0.0);
|
||||
try expect(math.isPositiveInf(ceilq(math.inf(f128))));
|
||||
try expect(math.isNegativeInf(ceilq(-math.inf(f128))));
|
||||
try expect(math.isNan(ceilq(math.nan(f128))));
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const is_test = builtin.is_test;
|
||||
const common = @import("common.zig");
|
||||
|
||||
pub const panic = common.panic;
|
||||
|
||||
comptime {
|
||||
@export(__cmpsi2, .{ .name = "__cmpsi2", .linkage = common.linkage });
|
||||
@export(__cmpdi2, .{ .name = "__cmpdi2", .linkage = common.linkage });
|
||||
@export(__cmpti2, .{ .name = "__cmpti2", .linkage = common.linkage });
|
||||
@export(__ucmpsi2, .{ .name = "__ucmpsi2", .linkage = common.linkage });
|
||||
@export(__ucmpdi2, .{ .name = "__ucmpdi2", .linkage = common.linkage });
|
||||
@export(__ucmpti2, .{ .name = "__ucmpti2", .linkage = common.linkage });
|
||||
}
|
||||
|
||||
// cmp - signed compare
|
||||
// - cmpXi2_generic for unoptimized little and big endian
|
||||
|
||||
// ucmp - unsigned compare
|
||||
// - ucmpXi2_generic for unoptimized little and big endian
|
||||
|
||||
// a < b => 0
|
||||
// a == b => 1
|
||||
// a > b => 2
|
||||
|
||||
inline fn XcmpXi2(comptime T: type, a: T, b: T) i32 {
|
||||
var cmp1: i32 = 0;
|
||||
var cmp2: i32 = 0;
|
||||
if (a > b)
|
||||
cmp1 = 1;
|
||||
if (a < b)
|
||||
cmp2 = 1;
|
||||
return cmp1 - cmp2 + 1;
|
||||
}
|
||||
|
||||
pub fn __cmpsi2(a: i32, b: i32) callconv(.C) i32 {
|
||||
return XcmpXi2(i32, a, b);
|
||||
}
|
||||
|
||||
pub fn __cmpdi2(a: i64, b: i64) callconv(.C) i32 {
|
||||
return XcmpXi2(i64, a, b);
|
||||
}
|
||||
|
||||
pub fn __cmpti2(a: i128, b: i128) callconv(.C) i32 {
|
||||
return XcmpXi2(i128, a, b);
|
||||
}
|
||||
|
||||
pub fn __ucmpsi2(a: u32, b: u32) callconv(.C) i32 {
|
||||
return XcmpXi2(u32, a, b);
|
||||
}
|
||||
|
||||
pub fn __ucmpdi2(a: u64, b: u64) callconv(.C) i32 {
|
||||
return XcmpXi2(u64, a, b);
|
||||
}
|
||||
|
||||
pub fn __ucmpti2(a: u128, b: u128) callconv(.C) i32 {
|
||||
return XcmpXi2(u128, a, b);
|
||||
}
|
||||
|
||||
test {
|
||||
_ = @import("cmpsi2_test.zig");
|
||||
_ = @import("cmpdi2_test.zig");
|
||||
_ = @import("cmpti2_test.zig");
|
||||
|
||||
_ = @import("ucmpsi2_test.zig");
|
||||
_ = @import("ucmpdi2_test.zig");
|
||||
_ = @import("ucmpti2_test.zig");
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
///! The quoted behavior definitions are from
|
||||
///! https://gcc.gnu.org/onlinedocs/gcc-12.1.0/gccint/Soft-float-library-routines.html#Soft-float-library-routines
|
||||
const common = @import("./common.zig");
|
||||
const comparef = @import("./comparef.zig");
|
||||
|
||||
pub const panic = common.panic;
|
||||
|
||||
comptime {
|
||||
if (common.want_aeabi) {
|
||||
@export(__aeabi_dcmpeq, .{ .name = "__aeabi_dcmpeq", .linkage = common.linkage });
|
||||
@export(__aeabi_dcmplt, .{ .name = "__aeabi_dcmplt", .linkage = common.linkage });
|
||||
@export(__aeabi_dcmple, .{ .name = "__aeabi_dcmple", .linkage = common.linkage });
|
||||
} else {
|
||||
@export(__eqdf2, .{ .name = "__eqdf2", .linkage = common.linkage });
|
||||
@export(__nedf2, .{ .name = "__nedf2", .linkage = common.linkage });
|
||||
@export(__ledf2, .{ .name = "__ledf2", .linkage = common.linkage });
|
||||
@export(__cmpdf2, .{ .name = "__cmpdf2", .linkage = common.linkage });
|
||||
@export(__ltdf2, .{ .name = "__ltdf2", .linkage = common.linkage });
|
||||
}
|
||||
}
|
||||
|
||||
/// "These functions calculate a <=> b. That is, if a is less than b, they return -1;
|
||||
/// if a is greater than b, they return 1; and if a and b are equal they return 0.
|
||||
/// If either argument is NaN they return 1..."
|
||||
///
|
||||
/// Note that this matches the definition of `__ledf2`, `__eqdf2`, `__nedf2`, `__cmpdf2`,
|
||||
/// and `__ltdf2`.
|
||||
fn __cmpdf2(a: f64, b: f64) callconv(.C) i32 {
|
||||
return @enumToInt(comparef.cmpf2(f64, comparef.LE, a, b));
|
||||
}
|
||||
|
||||
/// "These functions return a value less than or equal to zero if neither argument is NaN,
|
||||
/// and a is less than or equal to b."
|
||||
pub fn __ledf2(a: f64, b: f64) callconv(.C) i32 {
|
||||
return __cmpdf2(a, b);
|
||||
}
|
||||
|
||||
/// "These functions return zero if neither argument is NaN, and a and b are equal."
|
||||
/// Note that due to some kind of historical accident, __eqdf2 and __nedf2 are defined
|
||||
/// to have the same return value.
|
||||
pub fn __eqdf2(a: f64, b: f64) callconv(.C) i32 {
|
||||
return __cmpdf2(a, b);
|
||||
}
|
||||
|
||||
/// "These functions return a nonzero value if either argument is NaN, or if a and b are unequal."
|
||||
/// Note that due to some kind of historical accident, __eqdf2 and __nedf2 are defined
|
||||
/// to have the same return value.
|
||||
pub fn __nedf2(a: f64, b: f64) callconv(.C) i32 {
|
||||
return __cmpdf2(a, b);
|
||||
}
|
||||
|
||||
/// "These functions return a value less than zero if neither argument is NaN, and a
|
||||
/// is strictly less than b."
|
||||
pub fn __ltdf2(a: f64, b: f64) callconv(.C) i32 {
|
||||
return __cmpdf2(a, b);
|
||||
}
|
||||
|
||||
fn __aeabi_dcmpeq(a: f64, b: f64) callconv(.AAPCS) i32 {
|
||||
return @boolToInt(comparef.cmpf2(f64, comparef.LE, a, b) == .Equal);
|
||||
}
|
||||
|
||||
fn __aeabi_dcmplt(a: f64, b: f64) callconv(.AAPCS) i32 {
|
||||
return @boolToInt(comparef.cmpf2(f64, comparef.LE, a, b) == .Less);
|
||||
}
|
||||
|
||||
fn __aeabi_dcmple(a: f64, b: f64) callconv(.AAPCS) i32 {
|
||||
return @boolToInt(comparef.cmpf2(f64, comparef.LE, a, b) != .Greater);
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
///! The quoted behavior definitions are from
|
||||
///! https://gcc.gnu.org/onlinedocs/gcc-12.1.0/gccint/Soft-float-library-routines.html#Soft-float-library-routines
|
||||
const common = @import("./common.zig");
|
||||
const comparef = @import("./comparef.zig");
|
||||
|
||||
pub const panic = common.panic;
|
||||
|
||||
comptime {
|
||||
@export(__eqhf2, .{ .name = "__eqhf2", .linkage = common.linkage });
|
||||
@export(__nehf2, .{ .name = "__nehf2", .linkage = common.linkage });
|
||||
@export(__lehf2, .{ .name = "__lehf2", .linkage = common.linkage });
|
||||
@export(__cmphf2, .{ .name = "__cmphf2", .linkage = common.linkage });
|
||||
@export(__lthf2, .{ .name = "__lthf2", .linkage = common.linkage });
|
||||
}
|
||||
|
||||
/// "These functions calculate a <=> b. That is, if a is less than b, they return -1;
|
||||
/// if a is greater than b, they return 1; and if a and b are equal they return 0.
|
||||
/// If either argument is NaN they return 1..."
|
||||
///
|
||||
/// Note that this matches the definition of `__lehf2`, `__eqhf2`, `__nehf2`, `__cmphf2`,
|
||||
/// and `__lthf2`.
|
||||
fn __cmphf2(a: f16, b: f16) callconv(.C) i32 {
|
||||
return @enumToInt(comparef.cmpf2(f16, comparef.LE, a, b));
|
||||
}
|
||||
|
||||
/// "These functions return a value less than or equal to zero if neither argument is NaN,
|
||||
/// and a is less than or equal to b."
|
||||
pub fn __lehf2(a: f16, b: f16) callconv(.C) i32 {
|
||||
return __cmphf2(a, b);
|
||||
}
|
||||
|
||||
/// "These functions return zero if neither argument is NaN, and a and b are equal."
|
||||
/// Note that due to some kind of historical accident, __eqhf2 and __nehf2 are defined
|
||||
/// to have the same return value.
|
||||
pub fn __eqhf2(a: f16, b: f16) callconv(.C) i32 {
|
||||
return __cmphf2(a, b);
|
||||
}
|
||||
|
||||
/// "These functions return a nonzero value if either argument is NaN, or if a and b are unequal."
|
||||
/// Note that due to some kind of historical accident, __eqhf2 and __nehf2 are defined
|
||||
/// to have the same return value.
|
||||
pub fn __nehf2(a: f16, b: f16) callconv(.C) i32 {
|
||||
return __cmphf2(a, b);
|
||||
}
|
||||
|
||||
/// "These functions return a value less than zero if neither argument is NaN, and a
|
||||
/// is strictly less than b."
|
||||
pub fn __lthf2(a: f16, b: f16) callconv(.C) i32 {
|
||||
return __cmphf2(a, b);
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
///! The quoted behavior definitions are from
|
||||
///! https://gcc.gnu.org/onlinedocs/gcc-12.1.0/gccint/Soft-float-library-routines.html#Soft-float-library-routines
|
||||
const common = @import("./common.zig");
|
||||
const comparef = @import("./comparef.zig");
|
||||
|
||||
pub const panic = common.panic;
|
||||
|
||||
comptime {
|
||||
if (common.want_aeabi) {
|
||||
@export(__aeabi_fcmpeq, .{ .name = "__aeabi_fcmpeq", .linkage = common.linkage });
|
||||
@export(__aeabi_fcmplt, .{ .name = "__aeabi_fcmplt", .linkage = common.linkage });
|
||||
@export(__aeabi_fcmple, .{ .name = "__aeabi_fcmple", .linkage = common.linkage });
|
||||
} else {
|
||||
@export(__eqsf2, .{ .name = "__eqsf2", .linkage = common.linkage });
|
||||
@export(__nesf2, .{ .name = "__nesf2", .linkage = common.linkage });
|
||||
@export(__lesf2, .{ .name = "__lesf2", .linkage = common.linkage });
|
||||
@export(__cmpsf2, .{ .name = "__cmpsf2", .linkage = common.linkage });
|
||||
@export(__ltsf2, .{ .name = "__ltsf2", .linkage = common.linkage });
|
||||
}
|
||||
}
|
||||
|
||||
/// "These functions calculate a <=> b. That is, if a is less than b, they return -1;
|
||||
/// if a is greater than b, they return 1; and if a and b are equal they return 0.
|
||||
/// If either argument is NaN they return 1..."
|
||||
///
|
||||
/// Note that this matches the definition of `__lesf2`, `__eqsf2`, `__nesf2`, `__cmpsf2`,
|
||||
/// and `__ltsf2`.
|
||||
fn __cmpsf2(a: f32, b: f32) callconv(.C) i32 {
|
||||
return @enumToInt(comparef.cmpf2(f32, comparef.LE, a, b));
|
||||
}
|
||||
|
||||
/// "These functions return a value less than or equal to zero if neither argument is NaN,
|
||||
/// and a is less than or equal to b."
|
||||
pub fn __lesf2(a: f32, b: f32) callconv(.C) i32 {
|
||||
return __cmpsf2(a, b);
|
||||
}
|
||||
|
||||
/// "These functions return zero if neither argument is NaN, and a and b are equal."
|
||||
/// Note that due to some kind of historical accident, __eqsf2 and __nesf2 are defined
|
||||
/// to have the same return value.
|
||||
pub fn __eqsf2(a: f32, b: f32) callconv(.C) i32 {
|
||||
return __cmpsf2(a, b);
|
||||
}
|
||||
|
||||
/// "These functions return a nonzero value if either argument is NaN, or if a and b are unequal."
|
||||
/// Note that due to some kind of historical accident, __eqsf2 and __nesf2 are defined
|
||||
/// to have the same return value.
|
||||
pub fn __nesf2(a: f32, b: f32) callconv(.C) i32 {
|
||||
return __cmpsf2(a, b);
|
||||
}
|
||||
|
||||
/// "These functions return a value less than zero if neither argument is NaN, and a
|
||||
/// is strictly less than b."
|
||||
pub fn __ltsf2(a: f32, b: f32) callconv(.C) i32 {
|
||||
return __cmpsf2(a, b);
|
||||
}
|
||||
|
||||
fn __aeabi_fcmpeq(a: f32, b: f32) callconv(.AAPCS) i32 {
|
||||
return @boolToInt(comparef.cmpf2(f32, comparef.LE, a, b) == .Equal);
|
||||
}
|
||||
|
||||
fn __aeabi_fcmplt(a: f32, b: f32) callconv(.AAPCS) i32 {
|
||||
return @boolToInt(comparef.cmpf2(f32, comparef.LE, a, b) == .Less);
|
||||
}
|
||||
|
||||
fn __aeabi_fcmple(a: f32, b: f32) callconv(.AAPCS) i32 {
|
||||
return @boolToInt(comparef.cmpf2(f32, comparef.LE, a, b) != .Greater);
|
||||
}
|
||||
@@ -1,105 +0,0 @@
|
||||
///! The quoted behavior definitions are from
|
||||
///! https://gcc.gnu.org/onlinedocs/gcc-12.1.0/gccint/Soft-float-library-routines.html#Soft-float-library-routines
|
||||
const common = @import("./common.zig");
|
||||
const comparef = @import("./comparef.zig");
|
||||
|
||||
pub const panic = common.panic;
|
||||
|
||||
comptime {
|
||||
if (common.want_ppc_abi) {
|
||||
@export(__eqtf2, .{ .name = "__eqkf2", .linkage = common.linkage });
|
||||
@export(__netf2, .{ .name = "__nekf2", .linkage = common.linkage });
|
||||
@export(__lttf2, .{ .name = "__ltkf2", .linkage = common.linkage });
|
||||
@export(__letf2, .{ .name = "__lekf2", .linkage = common.linkage });
|
||||
} else if (common.want_sparc_abi) {
|
||||
@export(_Qp_cmp, .{ .name = "_Qp_cmp", .linkage = common.linkage });
|
||||
@export(_Qp_feq, .{ .name = "_Qp_feq", .linkage = common.linkage });
|
||||
@export(_Qp_fne, .{ .name = "_Qp_fne", .linkage = common.linkage });
|
||||
@export(_Qp_flt, .{ .name = "_Qp_flt", .linkage = common.linkage });
|
||||
@export(_Qp_fle, .{ .name = "_Qp_fle", .linkage = common.linkage });
|
||||
@export(_Qp_fgt, .{ .name = "_Qp_fgt", .linkage = common.linkage });
|
||||
@export(_Qp_fge, .{ .name = "_Qp_fge", .linkage = common.linkage });
|
||||
}
|
||||
@export(__eqtf2, .{ .name = "__eqtf2", .linkage = common.linkage });
|
||||
@export(__netf2, .{ .name = "__netf2", .linkage = common.linkage });
|
||||
@export(__letf2, .{ .name = "__letf2", .linkage = common.linkage });
|
||||
@export(__cmptf2, .{ .name = "__cmptf2", .linkage = common.linkage });
|
||||
@export(__lttf2, .{ .name = "__lttf2", .linkage = common.linkage });
|
||||
}
|
||||
|
||||
/// "These functions calculate a <=> b. That is, if a is less than b, they return -1;
|
||||
/// if a is greater than b, they return 1; and if a and b are equal they return 0.
|
||||
/// If either argument is NaN they return 1..."
|
||||
///
|
||||
/// Note that this matches the definition of `__letf2`, `__eqtf2`, `__netf2`, `__cmptf2`,
|
||||
/// and `__lttf2`.
|
||||
fn __cmptf2(a: f128, b: f128) callconv(.C) i32 {
|
||||
return @enumToInt(comparef.cmpf2(f128, comparef.LE, a, b));
|
||||
}
|
||||
|
||||
/// "These functions return a value less than or equal to zero if neither argument is NaN,
|
||||
/// and a is less than or equal to b."
|
||||
fn __letf2(a: f128, b: f128) callconv(.C) i32 {
|
||||
return __cmptf2(a, b);
|
||||
}
|
||||
|
||||
/// "These functions return zero if neither argument is NaN, and a and b are equal."
|
||||
/// Note that due to some kind of historical accident, __eqtf2 and __netf2 are defined
|
||||
/// to have the same return value.
|
||||
fn __eqtf2(a: f128, b: f128) callconv(.C) i32 {
|
||||
return __cmptf2(a, b);
|
||||
}
|
||||
|
||||
/// "These functions return a nonzero value if either argument is NaN, or if a and b are unequal."
|
||||
/// Note that due to some kind of historical accident, __eqtf2 and __netf2 are defined
|
||||
/// to have the same return value.
|
||||
fn __netf2(a: f128, b: f128) callconv(.C) i32 {
|
||||
return __cmptf2(a, b);
|
||||
}
|
||||
|
||||
/// "These functions return a value less than zero if neither argument is NaN, and a
|
||||
/// is strictly less than b."
|
||||
fn __lttf2(a: f128, b: f128) callconv(.C) i32 {
|
||||
return __cmptf2(a, b);
|
||||
}
|
||||
|
||||
const SparcFCMP = enum(i32) {
|
||||
Equal = 0,
|
||||
Less = 1,
|
||||
Greater = 2,
|
||||
Unordered = 3,
|
||||
};
|
||||
|
||||
fn _Qp_cmp(a: *const f128, b: *const f128) callconv(.C) i32 {
|
||||
return @enumToInt(comparef.cmpf2(f128, SparcFCMP, a.*, b.*));
|
||||
}
|
||||
|
||||
fn _Qp_feq(a: *const f128, b: *const f128) callconv(.C) bool {
|
||||
return @intToEnum(SparcFCMP, _Qp_cmp(a, b)) == .Equal;
|
||||
}
|
||||
|
||||
fn _Qp_fne(a: *const f128, b: *const f128) callconv(.C) bool {
|
||||
return @intToEnum(SparcFCMP, _Qp_cmp(a, b)) != .Equal;
|
||||
}
|
||||
|
||||
fn _Qp_flt(a: *const f128, b: *const f128) callconv(.C) bool {
|
||||
return @intToEnum(SparcFCMP, _Qp_cmp(a, b)) == .Less;
|
||||
}
|
||||
|
||||
fn _Qp_fgt(a: *const f128, b: *const f128) callconv(.C) bool {
|
||||
return @intToEnum(SparcFCMP, _Qp_cmp(a, b)) == .Greater;
|
||||
}
|
||||
|
||||
fn _Qp_fge(a: *const f128, b: *const f128) callconv(.C) bool {
|
||||
return switch (@intToEnum(SparcFCMP, _Qp_cmp(a, b))) {
|
||||
.Equal, .Greater => true,
|
||||
.Less, .Unordered => false,
|
||||
};
|
||||
}
|
||||
|
||||
fn _Qp_fle(a: *const f128, b: *const f128) callconv(.C) bool {
|
||||
return switch (@intToEnum(SparcFCMP, _Qp_cmp(a, b))) {
|
||||
.Equal, .Less => true,
|
||||
.Greater, .Unordered => false,
|
||||
};
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
///! The quoted behavior definitions are from
|
||||
///! https://gcc.gnu.org/onlinedocs/gcc-12.1.0/gccint/Soft-float-library-routines.html#Soft-float-library-routines
|
||||
const common = @import("./common.zig");
|
||||
const comparef = @import("./comparef.zig");
|
||||
|
||||
pub const panic = common.panic;
|
||||
|
||||
comptime {
|
||||
@export(__eqxf2, .{ .name = "__eqxf2", .linkage = common.linkage });
|
||||
@export(__nexf2, .{ .name = "__nexf2", .linkage = common.linkage });
|
||||
@export(__lexf2, .{ .name = "__lexf2", .linkage = common.linkage });
|
||||
@export(__cmpxf2, .{ .name = "__cmpxf2", .linkage = common.linkage });
|
||||
@export(__ltxf2, .{ .name = "__ltxf2", .linkage = common.linkage });
|
||||
}
|
||||
|
||||
/// "These functions calculate a <=> b. That is, if a is less than b, they return -1;
|
||||
/// if a is greater than b, they return 1; and if a and b are equal they return 0.
|
||||
/// If either argument is NaN they return 1..."
|
||||
///
|
||||
/// Note that this matches the definition of `__lexf2`, `__eqxf2`, `__nexf2`, `__cmpxf2`,
|
||||
/// and `__ltxf2`.
|
||||
fn __cmpxf2(a: f80, b: f80) callconv(.C) i32 {
|
||||
return @enumToInt(comparef.cmp_f80(comparef.LE, a, b));
|
||||
}
|
||||
|
||||
/// "These functions return a value less than or equal to zero if neither argument is NaN,
|
||||
/// and a is less than or equal to b."
|
||||
fn __lexf2(a: f80, b: f80) callconv(.C) i32 {
|
||||
return __cmpxf2(a, b);
|
||||
}
|
||||
|
||||
/// "These functions return zero if neither argument is NaN, and a and b are equal."
|
||||
/// Note that due to some kind of historical accident, __eqxf2 and __nexf2 are defined
|
||||
/// to have the same return value.
|
||||
fn __eqxf2(a: f80, b: f80) callconv(.C) i32 {
|
||||
return __cmpxf2(a, b);
|
||||
}
|
||||
|
||||
/// "These functions return a nonzero value if either argument is NaN, or if a and b are unequal."
|
||||
/// Note that due to some kind of historical accident, __eqxf2 and __nexf2 are defined
|
||||
/// to have the same return value.
|
||||
fn __nexf2(a: f80, b: f80) callconv(.C) i32 {
|
||||
return __cmpxf2(a, b);
|
||||
}
|
||||
|
||||
/// "These functions return a value less than zero if neither argument is NaN, and a
|
||||
/// is strictly less than b."
|
||||
fn __ltxf2(a: f80, b: f80) callconv(.C) i32 {
|
||||
return __cmpxf2(a, b);
|
||||
}
|
||||
@@ -1,219 +0,0 @@
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
|
||||
pub const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
|
||||
pub const want_aeabi = switch (builtin.abi) {
|
||||
.eabi,
|
||||
.eabihf,
|
||||
.musleabi,
|
||||
.musleabihf,
|
||||
.gnueabi,
|
||||
.gnueabihf,
|
||||
.android,
|
||||
=> switch (builtin.cpu.arch) {
|
||||
.arm, .armeb, .thumb, .thumbeb => true,
|
||||
else => false,
|
||||
},
|
||||
else => false,
|
||||
};
|
||||
pub const want_ppc_abi = builtin.cpu.arch.isPPC() or builtin.cpu.arch.isPPC64();
|
||||
|
||||
// Libcalls that involve u128 on Windows x86-64 are expected by LLVM to use the
|
||||
// calling convention of @Vector(2, u64), rather than what's standard.
|
||||
pub const want_windows_v2u64_abi = builtin.os.tag == .windows and builtin.cpu.arch == .x86_64;
|
||||
|
||||
/// This governs whether to use these symbol names for f16/f32 conversions
|
||||
/// rather than the standard names:
|
||||
/// * __gnu_f2h_ieee
|
||||
/// * __gnu_h2f_ieee
|
||||
/// Known correct configurations:
|
||||
/// x86_64-freestanding-none => true
|
||||
/// x86_64-linux-none => true
|
||||
/// x86_64-linux-gnu => true
|
||||
/// x86_64-linux-musl => true
|
||||
/// x86_64-linux-eabi => true
|
||||
/// arm-linux-musleabihf => true
|
||||
/// arm-linux-gnueabihf => true
|
||||
/// arm-linux-eabihf => false
|
||||
/// wasm32-wasi-musl => false
|
||||
/// wasm32-freestanding-none => false
|
||||
/// x86_64-windows-gnu => true
|
||||
/// x86_64-windows-msvc => true
|
||||
/// any-macos-any => false
|
||||
pub const gnu_f16_abi = switch (builtin.cpu.arch) {
|
||||
.wasm32,
|
||||
.wasm64,
|
||||
.riscv64,
|
||||
.riscv32,
|
||||
.x86_64,
|
||||
=> false,
|
||||
|
||||
.i386 => true,
|
||||
|
||||
.arm, .armeb, .thumb, .thumbeb => switch (builtin.abi) {
|
||||
.eabi, .eabihf => false,
|
||||
else => true,
|
||||
},
|
||||
|
||||
else => !builtin.os.tag.isDarwin(),
|
||||
};
|
||||
|
||||
pub const want_sparc_abi = builtin.cpu.arch.isSPARC();
|
||||
|
||||
// Avoid dragging in the runtime safety mechanisms into this .o file,
|
||||
// unless we're trying to test compiler-rt.
|
||||
pub fn panic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
|
||||
_ = error_return_trace;
|
||||
if (builtin.is_test) {
|
||||
@setCold(true);
|
||||
std.debug.panic("{s}", .{msg});
|
||||
} else {
|
||||
unreachable;
|
||||
}
|
||||
}
|
||||
|
||||
/// AArch64 is the only ABI (at the moment) to support f16 arguments without the
|
||||
/// need for extending them to wider fp types.
|
||||
/// TODO remove this; do this type selection in the language rather than
|
||||
/// here in compiler-rt.
|
||||
pub const F16T = switch (builtin.cpu.arch) {
|
||||
.aarch64, .aarch64_be, .aarch64_32 => f16,
|
||||
.riscv64 => if (builtin.zig_backend == .stage1) u16 else f16,
|
||||
.i386, .x86_64 => f16,
|
||||
else => u16,
|
||||
};
|
||||
|
||||
pub fn wideMultiply(comptime Z: type, a: Z, b: Z, hi: *Z, lo: *Z) void {
|
||||
switch (Z) {
|
||||
u16 => {
|
||||
// 16x16 --> 32 bit multiply
|
||||
const product = @as(u32, a) * @as(u32, b);
|
||||
hi.* = @intCast(u16, product >> 16);
|
||||
lo.* = @truncate(u16, product);
|
||||
},
|
||||
u32 => {
|
||||
// 32x32 --> 64 bit multiply
|
||||
const product = @as(u64, a) * @as(u64, b);
|
||||
hi.* = @truncate(u32, product >> 32);
|
||||
lo.* = @truncate(u32, product);
|
||||
},
|
||||
u64 => {
|
||||
const S = struct {
|
||||
fn loWord(x: u64) u64 {
|
||||
return @truncate(u32, x);
|
||||
}
|
||||
fn hiWord(x: u64) u64 {
|
||||
return @truncate(u32, x >> 32);
|
||||
}
|
||||
};
|
||||
// 64x64 -> 128 wide multiply for platforms that don't have such an operation;
|
||||
// many 64-bit platforms have this operation, but they tend to have hardware
|
||||
// floating-point, so we don't bother with a special case for them here.
|
||||
// Each of the component 32x32 -> 64 products
|
||||
const plolo: u64 = S.loWord(a) * S.loWord(b);
|
||||
const plohi: u64 = S.loWord(a) * S.hiWord(b);
|
||||
const philo: u64 = S.hiWord(a) * S.loWord(b);
|
||||
const phihi: u64 = S.hiWord(a) * S.hiWord(b);
|
||||
// Sum terms that contribute to lo in a way that allows us to get the carry
|
||||
const r0: u64 = S.loWord(plolo);
|
||||
const r1: u64 = S.hiWord(plolo) +% S.loWord(plohi) +% S.loWord(philo);
|
||||
lo.* = r0 +% (r1 << 32);
|
||||
// Sum terms contributing to hi with the carry from lo
|
||||
hi.* = S.hiWord(plohi) +% S.hiWord(philo) +% S.hiWord(r1) +% phihi;
|
||||
},
|
||||
u128 => {
|
||||
const Word_LoMask = @as(u64, 0x00000000ffffffff);
|
||||
const Word_HiMask = @as(u64, 0xffffffff00000000);
|
||||
const Word_FullMask = @as(u64, 0xffffffffffffffff);
|
||||
const S = struct {
|
||||
fn Word_1(x: u128) u64 {
|
||||
return @truncate(u32, x >> 96);
|
||||
}
|
||||
fn Word_2(x: u128) u64 {
|
||||
return @truncate(u32, x >> 64);
|
||||
}
|
||||
fn Word_3(x: u128) u64 {
|
||||
return @truncate(u32, x >> 32);
|
||||
}
|
||||
fn Word_4(x: u128) u64 {
|
||||
return @truncate(u32, x);
|
||||
}
|
||||
};
|
||||
// 128x128 -> 256 wide multiply for platforms that don't have such an operation;
|
||||
// many 64-bit platforms have this operation, but they tend to have hardware
|
||||
// floating-point, so we don't bother with a special case for them here.
|
||||
|
||||
const product11: u64 = S.Word_1(a) * S.Word_1(b);
|
||||
const product12: u64 = S.Word_1(a) * S.Word_2(b);
|
||||
const product13: u64 = S.Word_1(a) * S.Word_3(b);
|
||||
const product14: u64 = S.Word_1(a) * S.Word_4(b);
|
||||
const product21: u64 = S.Word_2(a) * S.Word_1(b);
|
||||
const product22: u64 = S.Word_2(a) * S.Word_2(b);
|
||||
const product23: u64 = S.Word_2(a) * S.Word_3(b);
|
||||
const product24: u64 = S.Word_2(a) * S.Word_4(b);
|
||||
const product31: u64 = S.Word_3(a) * S.Word_1(b);
|
||||
const product32: u64 = S.Word_3(a) * S.Word_2(b);
|
||||
const product33: u64 = S.Word_3(a) * S.Word_3(b);
|
||||
const product34: u64 = S.Word_3(a) * S.Word_4(b);
|
||||
const product41: u64 = S.Word_4(a) * S.Word_1(b);
|
||||
const product42: u64 = S.Word_4(a) * S.Word_2(b);
|
||||
const product43: u64 = S.Word_4(a) * S.Word_3(b);
|
||||
const product44: u64 = S.Word_4(a) * S.Word_4(b);
|
||||
|
||||
const sum0: u128 = @as(u128, product44);
|
||||
const sum1: u128 = @as(u128, product34) +%
|
||||
@as(u128, product43);
|
||||
const sum2: u128 = @as(u128, product24) +%
|
||||
@as(u128, product33) +%
|
||||
@as(u128, product42);
|
||||
const sum3: u128 = @as(u128, product14) +%
|
||||
@as(u128, product23) +%
|
||||
@as(u128, product32) +%
|
||||
@as(u128, product41);
|
||||
const sum4: u128 = @as(u128, product13) +%
|
||||
@as(u128, product22) +%
|
||||
@as(u128, product31);
|
||||
const sum5: u128 = @as(u128, product12) +%
|
||||
@as(u128, product21);
|
||||
const sum6: u128 = @as(u128, product11);
|
||||
|
||||
const r0: u128 = (sum0 & Word_FullMask) +%
|
||||
((sum1 & Word_LoMask) << 32);
|
||||
const r1: u128 = (sum0 >> 64) +%
|
||||
((sum1 >> 32) & Word_FullMask) +%
|
||||
(sum2 & Word_FullMask) +%
|
||||
((sum3 << 32) & Word_HiMask);
|
||||
|
||||
lo.* = r0 +% (r1 << 64);
|
||||
hi.* = (r1 >> 64) +%
|
||||
(sum1 >> 96) +%
|
||||
(sum2 >> 64) +%
|
||||
(sum3 >> 32) +%
|
||||
sum4 +%
|
||||
(sum5 << 32) +%
|
||||
(sum6 << 64);
|
||||
},
|
||||
else => @compileError("unsupported"),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn normalize(comptime T: type, significand: *std.meta.Int(.unsigned, @typeInfo(T).Float.bits)) i32 {
|
||||
const Z = std.meta.Int(.unsigned, @typeInfo(T).Float.bits);
|
||||
const integerBit = @as(Z, 1) << std.math.floatFractionalBits(T);
|
||||
|
||||
const shift = @clz(significand.*) - @clz(integerBit);
|
||||
significand.* <<= @intCast(std.math.Log2Int(Z), shift);
|
||||
return @as(i32, 1) - shift;
|
||||
}
|
||||
|
||||
pub inline fn fneg(a: anytype) @TypeOf(a) {
|
||||
const F = @TypeOf(a);
|
||||
const bits = @typeInfo(F).Float.bits;
|
||||
const U = @Type(.{ .Int = .{
|
||||
.signedness = .unsigned,
|
||||
.bits = bits,
|
||||
} });
|
||||
const sign_bit_mask = @as(U, 1) << (bits - 1);
|
||||
const negated = @bitCast(U, a) ^ sign_bit_mask;
|
||||
return @bitCast(F, negated);
|
||||
}
|
||||
@@ -1,109 +0,0 @@
|
||||
// Ported from:
|
||||
//
|
||||
// https://github.com/llvm/llvm-project/commit/d674d96bc56c0f377879d01c9d8dfdaaa7859cdb/compiler-rt/test/builtins/Unit/comparedf2_test.c
|
||||
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const is_test = builtin.is_test;
|
||||
|
||||
const __eqdf2 = @import("./cmpdf2.zig").__eqdf2;
|
||||
const __ledf2 = @import("./cmpdf2.zig").__ledf2;
|
||||
const __ltdf2 = @import("./cmpdf2.zig").__ltdf2;
|
||||
const __nedf2 = @import("./cmpdf2.zig").__nedf2;
|
||||
|
||||
const __gedf2 = @import("./gedf2.zig").__gedf2;
|
||||
const __gtdf2 = @import("./gedf2.zig").__gtdf2;
|
||||
|
||||
const __unorddf2 = @import("./unorddf2.zig").__unorddf2;
|
||||
|
||||
const TestVector = struct {
|
||||
a: f64,
|
||||
b: f64,
|
||||
eqReference: c_int,
|
||||
geReference: c_int,
|
||||
gtReference: c_int,
|
||||
leReference: c_int,
|
||||
ltReference: c_int,
|
||||
neReference: c_int,
|
||||
unReference: c_int,
|
||||
};
|
||||
|
||||
fn test__cmpdf2(vector: TestVector) bool {
|
||||
if (__eqdf2(vector.a, vector.b) != vector.eqReference) {
|
||||
return false;
|
||||
}
|
||||
if (__gedf2(vector.a, vector.b) != vector.geReference) {
|
||||
return false;
|
||||
}
|
||||
if (__gtdf2(vector.a, vector.b) != vector.gtReference) {
|
||||
return false;
|
||||
}
|
||||
if (__ledf2(vector.a, vector.b) != vector.leReference) {
|
||||
return false;
|
||||
}
|
||||
if (__ltdf2(vector.a, vector.b) != vector.ltReference) {
|
||||
return false;
|
||||
}
|
||||
if (__nedf2(vector.a, vector.b) != vector.neReference) {
|
||||
return false;
|
||||
}
|
||||
if (__unorddf2(vector.a, vector.b) != vector.unReference) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
const arguments = [_]f64{
|
||||
std.math.nan(f64),
|
||||
-std.math.inf(f64),
|
||||
-0x1.fffffffffffffp1023,
|
||||
-0x1.0000000000001p0 - 0x1.0000000000000p0,
|
||||
-0x1.fffffffffffffp-1,
|
||||
-0x1.0000000000000p-1022,
|
||||
-0x0.fffffffffffffp-1022,
|
||||
-0x0.0000000000001p-1022,
|
||||
-0.0,
|
||||
0.0,
|
||||
0x0.0000000000001p-1022,
|
||||
0x0.fffffffffffffp-1022,
|
||||
0x1.0000000000000p-1022,
|
||||
0x1.fffffffffffffp-1,
|
||||
0x1.0000000000000p0,
|
||||
0x1.0000000000001p0,
|
||||
0x1.fffffffffffffp1023,
|
||||
std.math.inf(f64),
|
||||
};
|
||||
|
||||
fn generateVector(comptime a: f64, comptime b: f64) TestVector {
|
||||
const leResult = if (a < b) -1 else if (a == b) 0 else 1;
|
||||
const geResult = if (a > b) 1 else if (a == b) 0 else -1;
|
||||
const unResult = if (a != a or b != b) 1 else 0;
|
||||
return TestVector{
|
||||
.a = a,
|
||||
.b = b,
|
||||
.eqReference = leResult,
|
||||
.geReference = geResult,
|
||||
.gtReference = geResult,
|
||||
.leReference = leResult,
|
||||
.ltReference = leResult,
|
||||
.neReference = leResult,
|
||||
.unReference = unResult,
|
||||
};
|
||||
}
|
||||
|
||||
const test_vectors = init: {
|
||||
@setEvalBranchQuota(10000);
|
||||
var vectors: [arguments.len * arguments.len]TestVector = undefined;
|
||||
for (arguments[0..]) |arg_i, i| {
|
||||
for (arguments[0..]) |arg_j, j| {
|
||||
vectors[(i * arguments.len) + j] = generateVector(arg_i, arg_j);
|
||||
}
|
||||
}
|
||||
break :init vectors;
|
||||
};
|
||||
|
||||
test "compare f64" {
|
||||
for (test_vectors) |vector| {
|
||||
try std.testing.expect(test__cmpdf2(vector));
|
||||
}
|
||||
}
|
||||
@@ -1,118 +0,0 @@
|
||||
const std = @import("std");
|
||||
|
||||
pub const LE = enum(i32) {
|
||||
Less = -1,
|
||||
Equal = 0,
|
||||
Greater = 1,
|
||||
|
||||
const Unordered: LE = .Greater;
|
||||
};
|
||||
|
||||
pub const GE = enum(i32) {
|
||||
Less = -1,
|
||||
Equal = 0,
|
||||
Greater = 1,
|
||||
|
||||
const Unordered: GE = .Less;
|
||||
};
|
||||
|
||||
pub inline fn cmpf2(comptime T: type, comptime RT: type, a: T, b: T) RT {
|
||||
const bits = @typeInfo(T).Float.bits;
|
||||
const srep_t = std.meta.Int(.signed, bits);
|
||||
const rep_t = std.meta.Int(.unsigned, bits);
|
||||
|
||||
const significandBits = std.math.floatMantissaBits(T);
|
||||
const exponentBits = std.math.floatExponentBits(T);
|
||||
const signBit = (@as(rep_t, 1) << (significandBits + exponentBits));
|
||||
const absMask = signBit - 1;
|
||||
const infT = comptime std.math.inf(T);
|
||||
const infRep = @bitCast(rep_t, infT);
|
||||
|
||||
const aInt = @bitCast(srep_t, a);
|
||||
const bInt = @bitCast(srep_t, b);
|
||||
const aAbs = @bitCast(rep_t, aInt) & absMask;
|
||||
const bAbs = @bitCast(rep_t, bInt) & absMask;
|
||||
|
||||
// If either a or b is NaN, they are unordered.
|
||||
if (aAbs > infRep or bAbs > infRep) return RT.Unordered;
|
||||
|
||||
// If a and b are both zeros, they are equal.
|
||||
if ((aAbs | bAbs) == 0) return .Equal;
|
||||
|
||||
// If at least one of a and b is positive, we get the same result comparing
|
||||
// a and b as signed integers as we would with a floating-point compare.
|
||||
if ((aInt & bInt) >= 0) {
|
||||
if (aInt < bInt) {
|
||||
return .Less;
|
||||
} else if (aInt == bInt) {
|
||||
return .Equal;
|
||||
} else return .Greater;
|
||||
} else {
|
||||
// Otherwise, both are negative, so we need to flip the sense of the
|
||||
// comparison to get the correct result. (This assumes a twos- or ones-
|
||||
// complement integer representation; if integers are represented in a
|
||||
// sign-magnitude representation, then this flip is incorrect).
|
||||
if (aInt > bInt) {
|
||||
return .Less;
|
||||
} else if (aInt == bInt) {
|
||||
return .Equal;
|
||||
} else return .Greater;
|
||||
}
|
||||
}
|
||||
|
||||
pub inline fn cmp_f80(comptime RT: type, a: f80, b: f80) RT {
|
||||
const a_rep = std.math.break_f80(a);
|
||||
const b_rep = std.math.break_f80(b);
|
||||
const sig_bits = std.math.floatMantissaBits(f80);
|
||||
const int_bit = 0x8000000000000000;
|
||||
const sign_bit = 0x8000;
|
||||
const special_exp = 0x7FFF;
|
||||
|
||||
// If either a or b is NaN, they are unordered.
|
||||
if ((a_rep.exp & special_exp == special_exp and a_rep.fraction ^ int_bit != 0) or
|
||||
(b_rep.exp & special_exp == special_exp and b_rep.fraction ^ int_bit != 0))
|
||||
return RT.Unordered;
|
||||
|
||||
// If a and b are both zeros, they are equal.
|
||||
if ((a_rep.fraction | b_rep.fraction) | ((a_rep.exp | b_rep.exp) & special_exp) == 0)
|
||||
return .Equal;
|
||||
|
||||
if (@boolToInt(a_rep.exp == b_rep.exp) & @boolToInt(a_rep.fraction == b_rep.fraction) != 0) {
|
||||
return .Equal;
|
||||
} else if (a_rep.exp & sign_bit != b_rep.exp & sign_bit) {
|
||||
// signs are different
|
||||
if (@bitCast(i16, a_rep.exp) < @bitCast(i16, b_rep.exp)) {
|
||||
return .Less;
|
||||
} else {
|
||||
return .Greater;
|
||||
}
|
||||
} else {
|
||||
const a_fraction = a_rep.fraction | (@as(u80, a_rep.exp) << sig_bits);
|
||||
const b_fraction = b_rep.fraction | (@as(u80, b_rep.exp) << sig_bits);
|
||||
if (a_fraction < b_fraction) {
|
||||
return .Less;
|
||||
} else {
|
||||
return .Greater;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub inline fn unordcmp(comptime T: type, a: T, b: T) i32 {
|
||||
const rep_t = std.meta.Int(.unsigned, @typeInfo(T).Float.bits);
|
||||
|
||||
const significandBits = std.math.floatMantissaBits(T);
|
||||
const exponentBits = std.math.floatExponentBits(T);
|
||||
const signBit = (@as(rep_t, 1) << (significandBits + exponentBits));
|
||||
const absMask = signBit - 1;
|
||||
const infRep = @bitCast(rep_t, std.math.inf(T));
|
||||
|
||||
const aAbs: rep_t = @bitCast(rep_t, a) & absMask;
|
||||
const bAbs: rep_t = @bitCast(rep_t, b) & absMask;
|
||||
|
||||
return @boolToInt(aAbs > infRep or bAbs > infRep);
|
||||
}
|
||||
|
||||
test {
|
||||
_ = @import("comparesf2_test.zig");
|
||||
_ = @import("comparedf2_test.zig");
|
||||
}
|
||||
@@ -1,109 +0,0 @@
|
||||
// Ported from:
|
||||
//
|
||||
// https://github.com/llvm/llvm-project/commit/d674d96bc56c0f377879d01c9d8dfdaaa7859cdb/compiler-rt/test/builtins/Unit/comparesf2_test.c
|
||||
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const is_test = builtin.is_test;
|
||||
|
||||
const __eqsf2 = @import("./cmpsf2.zig").__eqsf2;
|
||||
const __lesf2 = @import("./cmpsf2.zig").__lesf2;
|
||||
const __ltsf2 = @import("./cmpsf2.zig").__ltsf2;
|
||||
const __nesf2 = @import("./cmpsf2.zig").__nesf2;
|
||||
|
||||
const __gesf2 = @import("./gesf2.zig").__gesf2;
|
||||
const __gtsf2 = @import("./gesf2.zig").__gtsf2;
|
||||
|
||||
const __unordsf2 = @import("./unordsf2.zig").__unordsf2;
|
||||
|
||||
const TestVector = struct {
|
||||
a: f32,
|
||||
b: f32,
|
||||
eqReference: c_int,
|
||||
geReference: c_int,
|
||||
gtReference: c_int,
|
||||
leReference: c_int,
|
||||
ltReference: c_int,
|
||||
neReference: c_int,
|
||||
unReference: c_int,
|
||||
};
|
||||
|
||||
fn test__cmpsf2(vector: TestVector) bool {
|
||||
if (__eqsf2(vector.a, vector.b) != vector.eqReference) {
|
||||
return false;
|
||||
}
|
||||
if (__gesf2(vector.a, vector.b) != vector.geReference) {
|
||||
return false;
|
||||
}
|
||||
if (__gtsf2(vector.a, vector.b) != vector.gtReference) {
|
||||
return false;
|
||||
}
|
||||
if (__lesf2(vector.a, vector.b) != vector.leReference) {
|
||||
return false;
|
||||
}
|
||||
if (__ltsf2(vector.a, vector.b) != vector.ltReference) {
|
||||
return false;
|
||||
}
|
||||
if (__nesf2(vector.a, vector.b) != vector.neReference) {
|
||||
return false;
|
||||
}
|
||||
if (__unordsf2(vector.a, vector.b) != vector.unReference) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
const arguments = [_]f32{
|
||||
std.math.nan(f32),
|
||||
-std.math.inf(f32),
|
||||
-0x1.fffffep127,
|
||||
-0x1.000002p0 - 0x1.000000p0,
|
||||
-0x1.fffffep-1,
|
||||
-0x1.000000p-126,
|
||||
-0x0.fffffep-126,
|
||||
-0x0.000002p-126,
|
||||
-0.0,
|
||||
0.0,
|
||||
0x0.000002p-126,
|
||||
0x0.fffffep-126,
|
||||
0x1.000000p-126,
|
||||
0x1.fffffep-1,
|
||||
0x1.000000p0,
|
||||
0x1.000002p0,
|
||||
0x1.fffffep127,
|
||||
std.math.inf(f32),
|
||||
};
|
||||
|
||||
fn generateVector(comptime a: f32, comptime b: f32) TestVector {
|
||||
const leResult = if (a < b) -1 else if (a == b) 0 else 1;
|
||||
const geResult = if (a > b) 1 else if (a == b) 0 else -1;
|
||||
const unResult = if (a != a or b != b) 1 else 0;
|
||||
return TestVector{
|
||||
.a = a,
|
||||
.b = b,
|
||||
.eqReference = leResult,
|
||||
.geReference = geResult,
|
||||
.gtReference = geResult,
|
||||
.leReference = leResult,
|
||||
.ltReference = leResult,
|
||||
.neReference = leResult,
|
||||
.unReference = unResult,
|
||||
};
|
||||
}
|
||||
|
||||
const test_vectors = init: {
|
||||
@setEvalBranchQuota(10000);
|
||||
var vectors: [arguments.len * arguments.len]TestVector = undefined;
|
||||
for (arguments[0..]) |arg_i, i| {
|
||||
for (arguments[0..]) |arg_j, j| {
|
||||
vectors[(i * arguments.len) + j] = generateVector(arg_i, arg_j);
|
||||
}
|
||||
}
|
||||
break :init vectors;
|
||||
};
|
||||
|
||||
test "compare f32" {
|
||||
for (test_vectors) |vector| {
|
||||
try std.testing.expect(test__cmpsf2(vector));
|
||||
}
|
||||
}
|
||||
@@ -1,172 +0,0 @@
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const arch = builtin.cpu.arch;
|
||||
const math = std.math;
|
||||
const expect = std.testing.expect;
|
||||
const common = @import("common.zig");
|
||||
|
||||
pub const panic = common.panic;
|
||||
|
||||
const trig = @import("trig.zig");
|
||||
const rem_pio2 = @import("rem_pio2.zig").rem_pio2;
|
||||
const rem_pio2f = @import("rem_pio2f.zig").rem_pio2f;
|
||||
|
||||
comptime {
|
||||
@export(__cosh, .{ .name = "__cosh", .linkage = common.linkage });
|
||||
@export(cosf, .{ .name = "cosf", .linkage = common.linkage });
|
||||
@export(cos, .{ .name = "cos", .linkage = common.linkage });
|
||||
@export(__cosx, .{ .name = "__cosx", .linkage = common.linkage });
|
||||
if (common.want_ppc_abi) {
|
||||
@export(cosq, .{ .name = "cosf128", .linkage = common.linkage });
|
||||
}
|
||||
@export(cosq, .{ .name = "cosq", .linkage = common.linkage });
|
||||
@export(cosl, .{ .name = "cosl", .linkage = common.linkage });
|
||||
}
|
||||
|
||||
pub fn __cosh(a: f16) callconv(.C) f16 {
|
||||
// TODO: more efficient implementation
|
||||
return @floatCast(f16, cosf(a));
|
||||
}
|
||||
|
||||
pub fn cosf(x: f32) callconv(.C) f32 {
|
||||
// Small multiples of pi/2 rounded to double precision.
|
||||
const c1pio2: f64 = 1.0 * math.pi / 2.0; // 0x3FF921FB, 0x54442D18
|
||||
const c2pio2: f64 = 2.0 * math.pi / 2.0; // 0x400921FB, 0x54442D18
|
||||
const c3pio2: f64 = 3.0 * math.pi / 2.0; // 0x4012D97C, 0x7F3321D2
|
||||
const c4pio2: f64 = 4.0 * math.pi / 2.0; // 0x401921FB, 0x54442D18
|
||||
|
||||
var ix = @bitCast(u32, x);
|
||||
const sign = ix >> 31 != 0;
|
||||
ix &= 0x7fffffff;
|
||||
|
||||
if (ix <= 0x3f490fda) { // |x| ~<= pi/4
|
||||
if (ix < 0x39800000) { // |x| < 2**-12
|
||||
// raise inexact if x != 0
|
||||
math.doNotOptimizeAway(x + 0x1p120);
|
||||
return 1.0;
|
||||
}
|
||||
return trig.__cosdf(x);
|
||||
}
|
||||
if (ix <= 0x407b53d1) { // |x| ~<= 5*pi/4
|
||||
if (ix > 0x4016cbe3) { // |x| ~> 3*pi/4
|
||||
return -trig.__cosdf(if (sign) x + c2pio2 else x - c2pio2);
|
||||
} else {
|
||||
if (sign) {
|
||||
return trig.__sindf(x + c1pio2);
|
||||
} else {
|
||||
return trig.__sindf(c1pio2 - x);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ix <= 0x40e231d5) { // |x| ~<= 9*pi/4
|
||||
if (ix > 0x40afeddf) { // |x| ~> 7*pi/4
|
||||
return trig.__cosdf(if (sign) x + c4pio2 else x - c4pio2);
|
||||
} else {
|
||||
if (sign) {
|
||||
return trig.__sindf(-x - c3pio2);
|
||||
} else {
|
||||
return trig.__sindf(x - c3pio2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// cos(Inf or NaN) is NaN
|
||||
if (ix >= 0x7f800000) {
|
||||
return x - x;
|
||||
}
|
||||
|
||||
var y: f64 = undefined;
|
||||
const n = rem_pio2f(x, &y);
|
||||
return switch (n & 3) {
|
||||
0 => trig.__cosdf(y),
|
||||
1 => trig.__sindf(-y),
|
||||
2 => -trig.__cosdf(y),
|
||||
else => trig.__sindf(y),
|
||||
};
|
||||
}
|
||||
|
||||
pub fn cos(x: f64) callconv(.C) f64 {
|
||||
var ix = @bitCast(u64, x) >> 32;
|
||||
ix &= 0x7fffffff;
|
||||
|
||||
// |x| ~< pi/4
|
||||
if (ix <= 0x3fe921fb) {
|
||||
if (ix < 0x3e46a09e) { // |x| < 2**-27 * sqrt(2)
|
||||
// raise inexact if x!=0
|
||||
math.doNotOptimizeAway(x + 0x1p120);
|
||||
return 1.0;
|
||||
}
|
||||
return trig.__cos(x, 0);
|
||||
}
|
||||
|
||||
// cos(Inf or NaN) is NaN
|
||||
if (ix >= 0x7ff00000) {
|
||||
return x - x;
|
||||
}
|
||||
|
||||
var y: [2]f64 = undefined;
|
||||
const n = rem_pio2(x, &y);
|
||||
return switch (n & 3) {
|
||||
0 => trig.__cos(y[0], y[1]),
|
||||
1 => -trig.__sin(y[0], y[1], 1),
|
||||
2 => -trig.__cos(y[0], y[1]),
|
||||
else => trig.__sin(y[0], y[1], 1),
|
||||
};
|
||||
}
|
||||
|
||||
pub fn __cosx(a: f80) callconv(.C) f80 {
|
||||
// TODO: more efficient implementation
|
||||
return @floatCast(f80, cosq(a));
|
||||
}
|
||||
|
||||
pub fn cosq(a: f128) callconv(.C) f128 {
|
||||
// TODO: more correct implementation
|
||||
return cos(@floatCast(f64, a));
|
||||
}
|
||||
|
||||
pub fn cosl(x: c_longdouble) callconv(.C) c_longdouble {
|
||||
switch (@typeInfo(c_longdouble).Float.bits) {
|
||||
16 => return __cosh(x),
|
||||
32 => return cosf(x),
|
||||
64 => return cos(x),
|
||||
80 => return __cosx(x),
|
||||
128 => return cosq(x),
|
||||
else => @compileError("unreachable"),
|
||||
}
|
||||
}
|
||||
|
||||
test "cos32" {
|
||||
const epsilon = 0.00001;
|
||||
|
||||
try expect(math.approxEqAbs(f32, cosf(0.0), 1.0, epsilon));
|
||||
try expect(math.approxEqAbs(f32, cosf(0.2), 0.980067, epsilon));
|
||||
try expect(math.approxEqAbs(f32, cosf(0.8923), 0.627623, epsilon));
|
||||
try expect(math.approxEqAbs(f32, cosf(1.5), 0.070737, epsilon));
|
||||
try expect(math.approxEqAbs(f32, cosf(-1.5), 0.070737, epsilon));
|
||||
try expect(math.approxEqAbs(f32, cosf(37.45), 0.969132, epsilon));
|
||||
try expect(math.approxEqAbs(f32, cosf(89.123), 0.400798, epsilon));
|
||||
}
|
||||
|
||||
test "cos64" {
|
||||
const epsilon = 0.000001;
|
||||
|
||||
try expect(math.approxEqAbs(f64, cos(0.0), 1.0, epsilon));
|
||||
try expect(math.approxEqAbs(f64, cos(0.2), 0.980067, epsilon));
|
||||
try expect(math.approxEqAbs(f64, cos(0.8923), 0.627623, epsilon));
|
||||
try expect(math.approxEqAbs(f64, cos(1.5), 0.070737, epsilon));
|
||||
try expect(math.approxEqAbs(f64, cos(-1.5), 0.070737, epsilon));
|
||||
try expect(math.approxEqAbs(f64, cos(37.45), 0.969132, epsilon));
|
||||
try expect(math.approxEqAbs(f64, cos(89.123), 0.40080, epsilon));
|
||||
}
|
||||
|
||||
test "cos32.special" {
|
||||
try expect(math.isNan(cosf(math.inf(f32))));
|
||||
try expect(math.isNan(cosf(-math.inf(f32))));
|
||||
try expect(math.isNan(cosf(math.nan(f32))));
|
||||
}
|
||||
|
||||
test "cos64.special" {
|
||||
try expect(math.isNan(cos(math.inf(f64))));
|
||||
try expect(math.isNan(cos(-math.inf(f64))));
|
||||
try expect(math.isNan(cos(math.nan(f64))));
|
||||
}
|
||||
@@ -1,254 +0,0 @@
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const is_test = builtin.is_test;
|
||||
const common = @import("common.zig");
|
||||
|
||||
pub const panic = common.panic;
|
||||
|
||||
comptime {
|
||||
@export(__clzsi2, .{ .name = "__clzsi2", .linkage = common.linkage });
|
||||
@export(__clzdi2, .{ .name = "__clzdi2", .linkage = common.linkage });
|
||||
@export(__clzti2, .{ .name = "__clzti2", .linkage = common.linkage });
|
||||
@export(__ctzsi2, .{ .name = "__ctzsi2", .linkage = common.linkage });
|
||||
@export(__ctzdi2, .{ .name = "__ctzdi2", .linkage = common.linkage });
|
||||
@export(__ctzti2, .{ .name = "__ctzti2", .linkage = common.linkage });
|
||||
@export(__ffssi2, .{ .name = "__ffssi2", .linkage = common.linkage });
|
||||
@export(__ffsdi2, .{ .name = "__ffsdi2", .linkage = common.linkage });
|
||||
@export(__ffsti2, .{ .name = "__ffsti2", .linkage = common.linkage });
|
||||
}
|
||||
|
||||
// clz - count leading zeroes
|
||||
// - clzXi2 for unoptimized little and big endian
|
||||
// - __clzsi2_thumb1: assume a != 0
|
||||
// - __clzsi2_arm32: assume a != 0
|
||||
|
||||
// ctz - count trailing zeroes
|
||||
// - ctzXi2 for unoptimized little and big endian
|
||||
|
||||
// ffs - find first set
|
||||
// * ffs = (a == 0) => 0, (a != 0) => ctz + 1
|
||||
// * dont pay for `if (x == 0) return shift;` inside ctz
|
||||
// - ffsXi2 for unoptimized little and big endian
|
||||
|
||||
inline fn clzXi2(comptime T: type, a: T) i32 {
|
||||
var x = switch (@bitSizeOf(T)) {
|
||||
32 => @bitCast(u32, a),
|
||||
64 => @bitCast(u64, a),
|
||||
128 => @bitCast(u128, a),
|
||||
else => unreachable,
|
||||
};
|
||||
var n: T = @bitSizeOf(T);
|
||||
// Count first bit set using binary search, from Hacker's Delight
|
||||
var y: @TypeOf(x) = 0;
|
||||
comptime var shift: u8 = @bitSizeOf(T);
|
||||
inline while (shift > 0) {
|
||||
shift = shift >> 1;
|
||||
y = x >> shift;
|
||||
if (y != 0) {
|
||||
n = n - shift;
|
||||
x = y;
|
||||
}
|
||||
}
|
||||
return @intCast(i32, n - @bitCast(T, x));
|
||||
}
|
||||
|
||||
fn __clzsi2_thumb1() callconv(.Naked) void {
|
||||
@setRuntimeSafety(false);
|
||||
|
||||
// Similar to the generic version with the last two rounds replaced by a LUT
|
||||
asm volatile (
|
||||
\\ movs r1, #32
|
||||
\\ lsrs r2, r0, #16
|
||||
\\ beq 1f
|
||||
\\ subs r1, #16
|
||||
\\ movs r0, r2
|
||||
\\ 1:
|
||||
\\ lsrs r2, r0, #8
|
||||
\\ beq 1f
|
||||
\\ subs r1, #8
|
||||
\\ movs r0, r2
|
||||
\\ 1:
|
||||
\\ lsrs r2, r0, #4
|
||||
\\ beq 1f
|
||||
\\ subs r1, #4
|
||||
\\ movs r0, r2
|
||||
\\ 1:
|
||||
\\ ldr r3, =LUT
|
||||
\\ ldrb r0, [r3, r0]
|
||||
\\ subs r0, r1, r0
|
||||
\\ bx lr
|
||||
\\ .p2align 2
|
||||
\\ // Number of bits set in the 0-15 range
|
||||
\\ LUT:
|
||||
\\ .byte 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4
|
||||
);
|
||||
|
||||
unreachable;
|
||||
}
|
||||
|
||||
fn __clzsi2_arm32() callconv(.Naked) void {
|
||||
@setRuntimeSafety(false);
|
||||
|
||||
asm volatile (
|
||||
\\ // Assumption: n != 0
|
||||
\\ // r0: n
|
||||
\\ // r1: count of leading zeros in n + 1
|
||||
\\ // r2: scratch register for shifted r0
|
||||
\\ mov r1, #1
|
||||
\\
|
||||
\\ // Basic block:
|
||||
\\ // if ((r0 >> SHIFT) == 0)
|
||||
\\ // r1 += SHIFT;
|
||||
\\ // else
|
||||
\\ // r0 >>= SHIFT;
|
||||
\\ // for descending powers of two as SHIFT.
|
||||
\\ lsrs r2, r0, #16
|
||||
\\ movne r0, r2
|
||||
\\ addeq r1, #16
|
||||
\\
|
||||
\\ lsrs r2, r0, #8
|
||||
\\ movne r0, r2
|
||||
\\ addeq r1, #8
|
||||
\\
|
||||
\\ lsrs r2, r0, #4
|
||||
\\ movne r0, r2
|
||||
\\ addeq r1, #4
|
||||
\\
|
||||
\\ lsrs r2, r0, #2
|
||||
\\ movne r0, r2
|
||||
\\ addeq r1, #2
|
||||
\\
|
||||
\\ // The basic block invariants at this point are (r0 >> 2) == 0 and
|
||||
\\ // r0 != 0. This means 1 <= r0 <= 3 and 0 <= (r0 >> 1) <= 1.
|
||||
\\ //
|
||||
\\ // r0 | (r0 >> 1) == 0 | (r0 >> 1) == 1 | -(r0 >> 1) | 1 - (r0 >> 1)f
|
||||
\\ // ---+----------------+----------------+------------+--------------
|
||||
\\ // 1 | 1 | 0 | 0 | 1
|
||||
\\ // 2 | 0 | 1 | -1 | 0
|
||||
\\ // 3 | 0 | 1 | -1 | 0
|
||||
\\ //
|
||||
\\ // The r1's initial value of 1 compensates for the 1 here.
|
||||
\\ sub r0, r1, r0, lsr #1
|
||||
\\ bx lr
|
||||
);
|
||||
|
||||
unreachable;
|
||||
}
|
||||
|
||||
fn clzsi2_generic(a: i32) callconv(.C) i32 {
|
||||
return clzXi2(i32, a);
|
||||
}
|
||||
|
||||
pub const __clzsi2 = switch (builtin.cpu.arch) {
|
||||
.arm, .armeb, .thumb, .thumbeb => impl: {
|
||||
const use_thumb1 =
|
||||
(builtin.cpu.arch.isThumb() or
|
||||
std.Target.arm.featureSetHas(builtin.cpu.features, .noarm)) and
|
||||
!std.Target.arm.featureSetHas(builtin.cpu.features, .thumb2);
|
||||
|
||||
if (use_thumb1) {
|
||||
break :impl __clzsi2_thumb1;
|
||||
}
|
||||
// From here on we're either targeting Thumb2 or ARM.
|
||||
else if (!builtin.cpu.arch.isThumb()) {
|
||||
break :impl __clzsi2_arm32;
|
||||
}
|
||||
// Use the generic implementation otherwise.
|
||||
else break :impl clzsi2_generic;
|
||||
},
|
||||
else => clzsi2_generic,
|
||||
};
|
||||
|
||||
pub fn __clzdi2(a: i64) callconv(.C) i32 {
|
||||
return clzXi2(i64, a);
|
||||
}
|
||||
|
||||
pub fn __clzti2(a: i128) callconv(.C) i32 {
|
||||
return clzXi2(i128, a);
|
||||
}
|
||||
|
||||
inline fn ctzXi2(comptime T: type, a: T) i32 {
|
||||
var x = switch (@bitSizeOf(T)) {
|
||||
32 => @bitCast(u32, a),
|
||||
64 => @bitCast(u64, a),
|
||||
128 => @bitCast(u128, a),
|
||||
else => unreachable,
|
||||
};
|
||||
var n: T = 1;
|
||||
// Number of trailing zeroes as binary search, from Hacker's Delight
|
||||
var mask: @TypeOf(x) = std.math.maxInt(@TypeOf(x));
|
||||
comptime var shift = @bitSizeOf(T);
|
||||
if (x == 0) return shift;
|
||||
inline while (shift > 1) {
|
||||
shift = shift >> 1;
|
||||
mask = mask >> shift;
|
||||
if ((x & mask) == 0) {
|
||||
n = n + shift;
|
||||
x = x >> shift;
|
||||
}
|
||||
}
|
||||
return @intCast(i32, n - @bitCast(T, (x & 1)));
|
||||
}
|
||||
|
||||
pub fn __ctzsi2(a: i32) callconv(.C) i32 {
|
||||
return ctzXi2(i32, a);
|
||||
}
|
||||
|
||||
pub fn __ctzdi2(a: i64) callconv(.C) i32 {
|
||||
return ctzXi2(i64, a);
|
||||
}
|
||||
|
||||
pub fn __ctzti2(a: i128) callconv(.C) i32 {
|
||||
return ctzXi2(i128, a);
|
||||
}
|
||||
|
||||
inline fn ffsXi2(comptime T: type, a: T) i32 {
|
||||
var x = switch (@bitSizeOf(T)) {
|
||||
32 => @bitCast(u32, a),
|
||||
64 => @bitCast(u64, a),
|
||||
128 => @bitCast(u128, a),
|
||||
else => unreachable,
|
||||
};
|
||||
var n: T = 1;
|
||||
// adapted from Number of trailing zeroes (see ctzXi2)
|
||||
var mask: @TypeOf(x) = std.math.maxInt(@TypeOf(x));
|
||||
comptime var shift = @bitSizeOf(T);
|
||||
// In contrast to ctz return 0
|
||||
if (x == 0) return 0;
|
||||
inline while (shift > 1) {
|
||||
shift = shift >> 1;
|
||||
mask = mask >> shift;
|
||||
if ((x & mask) == 0) {
|
||||
n = n + shift;
|
||||
x = x >> shift;
|
||||
}
|
||||
}
|
||||
// return ctz + 1
|
||||
return @intCast(i32, n - @bitCast(T, (x & 1))) + @as(i32, 1);
|
||||
}
|
||||
|
||||
pub fn __ffssi2(a: i32) callconv(.C) i32 {
|
||||
return ffsXi2(i32, a);
|
||||
}
|
||||
|
||||
pub fn __ffsdi2(a: i64) callconv(.C) i32 {
|
||||
return ffsXi2(i64, a);
|
||||
}
|
||||
|
||||
pub fn __ffsti2(a: i128) callconv(.C) i32 {
|
||||
return ffsXi2(i128, a);
|
||||
}
|
||||
|
||||
test {
|
||||
_ = @import("clzsi2_test.zig");
|
||||
_ = @import("clzdi2_test.zig");
|
||||
_ = @import("clzti2_test.zig");
|
||||
|
||||
_ = @import("ctzsi2_test.zig");
|
||||
_ = @import("ctzdi2_test.zig");
|
||||
_ = @import("ctzti2_test.zig");
|
||||
|
||||
_ = @import("ffssi2_test.zig");
|
||||
_ = @import("ffsdi2_test.zig");
|
||||
_ = @import("ffsti2_test.zig");
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
const std = @import("std");
|
||||
const isNan = std.math.isNan;
|
||||
const isInf = std.math.isInf;
|
||||
const scalbn = std.math.scalbn;
|
||||
const ilogb = std.math.ilogb;
|
||||
const max = std.math.max;
|
||||
const fabs = std.math.fabs;
|
||||
const maxInt = std.math.maxInt;
|
||||
const minInt = std.math.minInt;
|
||||
const isFinite = std.math.isFinite;
|
||||
const copysign = std.math.copysign;
|
||||
const Complex = @import("mulc3.zig").Complex;
|
||||
|
||||
/// Implementation based on Annex G of C17 Standard (N2176)
|
||||
pub inline fn divc3(comptime T: type, a: T, b: T, c_in: T, d_in: T) Complex(T) {
|
||||
var c = c_in;
|
||||
var d = d_in;
|
||||
|
||||
// logbw used to prevent under/over-flow
|
||||
const logbw = ilogb(max(fabs(c), fabs(d)));
|
||||
const logbw_finite = logbw != maxInt(i32) and logbw != minInt(i32);
|
||||
const ilogbw = if (logbw_finite) b: {
|
||||
c = scalbn(c, -logbw);
|
||||
d = scalbn(d, -logbw);
|
||||
break :b logbw;
|
||||
} else 0;
|
||||
const denom = c * c + d * d;
|
||||
const result = Complex(T){
|
||||
.real = scalbn((a * c + b * d) / denom, -ilogbw),
|
||||
.imag = scalbn((b * c - a * d) / denom, -ilogbw),
|
||||
};
|
||||
|
||||
// Recover infinities and zeros that computed as NaN+iNaN;
|
||||
// the only cases are non-zero/zero, infinite/finite, and finite/infinite, ...
|
||||
if (isNan(result.real) and isNan(result.imag)) {
|
||||
const zero: T = 0.0;
|
||||
const one: T = 1.0;
|
||||
|
||||
if ((denom == 0.0) and (!isNan(a) or !isNan(b))) {
|
||||
return .{
|
||||
.real = copysign(std.math.inf(T), c) * a,
|
||||
.imag = copysign(std.math.inf(T), c) * b,
|
||||
};
|
||||
} else if ((isInf(a) or isInf(b)) and isFinite(c) and isFinite(d)) {
|
||||
const boxed_a = copysign(if (isInf(a)) one else zero, a);
|
||||
const boxed_b = copysign(if (isInf(b)) one else zero, b);
|
||||
return .{
|
||||
.real = std.math.inf(T) * (boxed_a * c - boxed_b * d),
|
||||
.imag = std.math.inf(T) * (boxed_b * c - boxed_a * d),
|
||||
};
|
||||
} else if (logbw == maxInt(i32) and isFinite(a) and isFinite(b)) {
|
||||
const boxed_c = copysign(if (isInf(c)) one else zero, c);
|
||||
const boxed_d = copysign(if (isInf(d)) one else zero, d);
|
||||
return .{
|
||||
.real = 0.0 * (a * boxed_c + b * boxed_d),
|
||||
.imag = 0.0 * (b * boxed_c - a * boxed_d),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
const std = @import("std");
|
||||
const math = std.math;
|
||||
const expect = std.testing.expect;
|
||||
|
||||
const Complex = @import("./mulc3.zig").Complex;
|
||||
const __divhc3 = @import("./divhc3.zig").__divhc3;
|
||||
const __divsc3 = @import("./divsc3.zig").__divsc3;
|
||||
const __divdc3 = @import("./divdc3.zig").__divdc3;
|
||||
const __divxc3 = @import("./divxc3.zig").__divxc3;
|
||||
const __divtc3 = @import("./divtc3.zig").__divtc3;
|
||||
|
||||
test {
|
||||
try testDiv(f16, __divhc3);
|
||||
try testDiv(f32, __divsc3);
|
||||
try testDiv(f64, __divdc3);
|
||||
try testDiv(f80, __divxc3);
|
||||
try testDiv(f128, __divtc3);
|
||||
}
|
||||
|
||||
fn testDiv(comptime T: type, comptime f: fn (T, T, T, T) callconv(.C) Complex(T)) !void {
|
||||
{
|
||||
var a: T = 1.0;
|
||||
var b: T = 0.0;
|
||||
var c: T = -1.0;
|
||||
var d: T = 0.0;
|
||||
|
||||
const result = f(a, b, c, d);
|
||||
try expect(result.real == -1.0);
|
||||
try expect(result.imag == 0.0);
|
||||
}
|
||||
{
|
||||
var a: T = 1.0;
|
||||
var b: T = 0.0;
|
||||
var c: T = -4.0;
|
||||
var d: T = 0.0;
|
||||
|
||||
const result = f(a, b, c, d);
|
||||
try expect(result.real == -0.25);
|
||||
try expect(result.imag == 0.0);
|
||||
}
|
||||
{
|
||||
// if the first operand is an infinity and the second operand is a finite number, then the
|
||||
// result of the / operator is an infinity;
|
||||
var a: T = -math.inf(T);
|
||||
var b: T = 0.0;
|
||||
var c: T = -4.0;
|
||||
var d: T = 1.0;
|
||||
|
||||
const result = f(a, b, c, d);
|
||||
try expect(result.real == math.inf(T));
|
||||
try expect(result.imag == math.inf(T));
|
||||
}
|
||||
{
|
||||
// if the first operand is a finite number and the second operand is an infinity, then the
|
||||
// result of the / operator is a zero;
|
||||
var a: T = 17.2;
|
||||
var b: T = 0.0;
|
||||
var c: T = -math.inf(T);
|
||||
var d: T = 0.0;
|
||||
|
||||
const result = f(a, b, c, d);
|
||||
try expect(result.real == -0.0);
|
||||
try expect(result.imag == 0.0);
|
||||
}
|
||||
{
|
||||
// if the first operand is a nonzero finite number or an infinity and the second operand is
|
||||
// a zero, then the result of the / operator is an infinity
|
||||
var a: T = 1.1;
|
||||
var b: T = 0.1;
|
||||
var c: T = 0.0;
|
||||
var d: T = 0.0;
|
||||
|
||||
const result = f(a, b, c, d);
|
||||
try expect(result.real == math.inf(T));
|
||||
try expect(result.imag == math.inf(T));
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
const common = @import("./common.zig");
|
||||
const divc3 = @import("./divc3.zig");
|
||||
const Complex = @import("./mulc3.zig").Complex;
|
||||
|
||||
comptime {
|
||||
@export(__divdc3, .{ .name = "__divdc3", .linkage = common.linkage });
|
||||
}
|
||||
|
||||
pub fn __divdc3(a: f64, b: f64, c: f64, d: f64) callconv(.C) Complex(f64) {
|
||||
return divc3.divc3(f64, a, b, c, d);
|
||||
}
|
||||
@@ -1,230 +0,0 @@
|
||||
//! Ported from:
|
||||
//!
|
||||
//! https://github.com/llvm/llvm-project/commit/d674d96bc56c0f377879d01c9d8dfdaaa7859cdb/compiler-rt/lib/builtins/divdf3.c
|
||||
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const arch = builtin.cpu.arch;
|
||||
const is_test = builtin.is_test;
|
||||
const common = @import("common.zig");
|
||||
|
||||
const normalize = common.normalize;
|
||||
const wideMultiply = common.wideMultiply;
|
||||
|
||||
pub const panic = common.panic;
|
||||
|
||||
comptime {
|
||||
if (common.want_aeabi) {
|
||||
@export(__aeabi_ddiv, .{ .name = "__aeabi_ddiv", .linkage = common.linkage });
|
||||
} else {
|
||||
@export(__divdf3, .{ .name = "__divdf3", .linkage = common.linkage });
|
||||
}
|
||||
}
|
||||
|
||||
pub fn __divdf3(a: f64, b: f64) callconv(.C) f64 {
|
||||
return div(a, b);
|
||||
}
|
||||
|
||||
fn __aeabi_ddiv(a: f64, b: f64) callconv(.AAPCS) f64 {
|
||||
return div(a, b);
|
||||
}
|
||||
|
||||
inline fn div(a: f64, b: f64) f64 {
|
||||
const Z = std.meta.Int(.unsigned, 64);
|
||||
const SignedZ = std.meta.Int(.signed, 64);
|
||||
|
||||
const significandBits = std.math.floatMantissaBits(f64);
|
||||
const exponentBits = std.math.floatExponentBits(f64);
|
||||
|
||||
const signBit = (@as(Z, 1) << (significandBits + exponentBits));
|
||||
const maxExponent = ((1 << exponentBits) - 1);
|
||||
const exponentBias = (maxExponent >> 1);
|
||||
|
||||
const implicitBit = (@as(Z, 1) << significandBits);
|
||||
const quietBit = implicitBit >> 1;
|
||||
const significandMask = implicitBit - 1;
|
||||
|
||||
const absMask = signBit - 1;
|
||||
const exponentMask = absMask ^ significandMask;
|
||||
const qnanRep = exponentMask | quietBit;
|
||||
const infRep = @bitCast(Z, std.math.inf(f64));
|
||||
|
||||
const aExponent = @truncate(u32, (@bitCast(Z, a) >> significandBits) & maxExponent);
|
||||
const bExponent = @truncate(u32, (@bitCast(Z, b) >> significandBits) & maxExponent);
|
||||
const quotientSign: Z = (@bitCast(Z, a) ^ @bitCast(Z, b)) & signBit;
|
||||
|
||||
var aSignificand: Z = @bitCast(Z, a) & significandMask;
|
||||
var bSignificand: Z = @bitCast(Z, b) & significandMask;
|
||||
var scale: i32 = 0;
|
||||
|
||||
// Detect if a or b is zero, denormal, infinity, or NaN.
|
||||
if (aExponent -% 1 >= maxExponent - 1 or bExponent -% 1 >= maxExponent - 1) {
|
||||
const aAbs: Z = @bitCast(Z, a) & absMask;
|
||||
const bAbs: Z = @bitCast(Z, b) & absMask;
|
||||
|
||||
// NaN / anything = qNaN
|
||||
if (aAbs > infRep) return @bitCast(f64, @bitCast(Z, a) | quietBit);
|
||||
// anything / NaN = qNaN
|
||||
if (bAbs > infRep) return @bitCast(f64, @bitCast(Z, b) | quietBit);
|
||||
|
||||
if (aAbs == infRep) {
|
||||
// infinity / infinity = NaN
|
||||
if (bAbs == infRep) {
|
||||
return @bitCast(f64, qnanRep);
|
||||
}
|
||||
// infinity / anything else = +/- infinity
|
||||
else {
|
||||
return @bitCast(f64, aAbs | quotientSign);
|
||||
}
|
||||
}
|
||||
|
||||
// anything else / infinity = +/- 0
|
||||
if (bAbs == infRep) return @bitCast(f64, quotientSign);
|
||||
|
||||
if (aAbs == 0) {
|
||||
// zero / zero = NaN
|
||||
if (bAbs == 0) {
|
||||
return @bitCast(f64, qnanRep);
|
||||
}
|
||||
// zero / anything else = +/- zero
|
||||
else {
|
||||
return @bitCast(f64, quotientSign);
|
||||
}
|
||||
}
|
||||
// anything else / zero = +/- infinity
|
||||
if (bAbs == 0) return @bitCast(f64, infRep | quotientSign);
|
||||
|
||||
// one or both of a or b is denormal, the other (if applicable) is a
|
||||
// normal number. Renormalize one or both of a and b, and set scale to
|
||||
// include the necessary exponent adjustment.
|
||||
if (aAbs < implicitBit) scale +%= normalize(f64, &aSignificand);
|
||||
if (bAbs < implicitBit) scale -%= normalize(f64, &bSignificand);
|
||||
}
|
||||
|
||||
// Or in the implicit significand bit. (If we fell through from the
|
||||
// denormal path it was already set by normalize( ), but setting it twice
|
||||
// won't hurt anything.)
|
||||
aSignificand |= implicitBit;
|
||||
bSignificand |= implicitBit;
|
||||
var quotientExponent: i32 = @bitCast(i32, aExponent -% bExponent) +% scale;
|
||||
|
||||
// Align the significand of b as a Q31 fixed-point number in the range
|
||||
// [1, 2.0) and get a Q32 approximate reciprocal using a small minimax
|
||||
// polynomial approximation: reciprocal = 3/4 + 1/sqrt(2) - b/2. This
|
||||
// is accurate to about 3.5 binary digits.
|
||||
const q31b: u32 = @truncate(u32, bSignificand >> 21);
|
||||
var recip32 = @as(u32, 0x7504f333) -% q31b;
|
||||
|
||||
// Now refine the reciprocal estimate using a Newton-Raphson iteration:
|
||||
//
|
||||
// x1 = x0 * (2 - x0 * b)
|
||||
//
|
||||
// This doubles the number of correct binary digits in the approximation
|
||||
// with each iteration, so after three iterations, we have about 28 binary
|
||||
// digits of accuracy.
|
||||
var correction32: u32 = undefined;
|
||||
correction32 = @truncate(u32, ~(@as(u64, recip32) *% q31b >> 32) +% 1);
|
||||
recip32 = @truncate(u32, @as(u64, recip32) *% correction32 >> 31);
|
||||
correction32 = @truncate(u32, ~(@as(u64, recip32) *% q31b >> 32) +% 1);
|
||||
recip32 = @truncate(u32, @as(u64, recip32) *% correction32 >> 31);
|
||||
correction32 = @truncate(u32, ~(@as(u64, recip32) *% q31b >> 32) +% 1);
|
||||
recip32 = @truncate(u32, @as(u64, recip32) *% correction32 >> 31);
|
||||
|
||||
// recip32 might have overflowed to exactly zero in the preceding
|
||||
// computation if the high word of b is exactly 1.0. This would sabotage
|
||||
// the full-width final stage of the computation that follows, so we adjust
|
||||
// recip32 downward by one bit.
|
||||
recip32 -%= 1;
|
||||
|
||||
// We need to perform one more iteration to get us to 56 binary digits;
|
||||
// The last iteration needs to happen with extra precision.
|
||||
const q63blo: u32 = @truncate(u32, bSignificand << 11);
|
||||
var correction: u64 = undefined;
|
||||
var reciprocal: u64 = undefined;
|
||||
correction = ~(@as(u64, recip32) *% q31b +% (@as(u64, recip32) *% q63blo >> 32)) +% 1;
|
||||
const cHi = @truncate(u32, correction >> 32);
|
||||
const cLo = @truncate(u32, correction);
|
||||
reciprocal = @as(u64, recip32) *% cHi +% (@as(u64, recip32) *% cLo >> 32);
|
||||
|
||||
// We already adjusted the 32-bit estimate, now we need to adjust the final
|
||||
// 64-bit reciprocal estimate downward to ensure that it is strictly smaller
|
||||
// than the infinitely precise exact reciprocal. Because the computation
|
||||
// of the Newton-Raphson step is truncating at every step, this adjustment
|
||||
// is small; most of the work is already done.
|
||||
reciprocal -%= 2;
|
||||
|
||||
// The numerical reciprocal is accurate to within 2^-56, lies in the
|
||||
// interval [0.5, 1.0), and is strictly smaller than the true reciprocal
|
||||
// of b. Multiplying a by this reciprocal thus gives a numerical q = a/b
|
||||
// in Q53 with the following properties:
|
||||
//
|
||||
// 1. q < a/b
|
||||
// 2. q is in the interval [0.5, 2.0)
|
||||
// 3. the error in q is bounded away from 2^-53 (actually, we have a
|
||||
// couple of bits to spare, but this is all we need).
|
||||
|
||||
// We need a 64 x 64 multiply high to compute q, which isn't a basic
|
||||
// operation in C, so we need to be a little bit fussy.
|
||||
var quotient: Z = undefined;
|
||||
var quotientLo: Z = undefined;
|
||||
wideMultiply(Z, aSignificand << 2, reciprocal, "ient, "ientLo);
|
||||
|
||||
// Two cases: quotient is in [0.5, 1.0) or quotient is in [1.0, 2.0).
|
||||
// In either case, we are going to compute a residual of the form
|
||||
//
|
||||
// r = a - q*b
|
||||
//
|
||||
// We know from the construction of q that r satisfies:
|
||||
//
|
||||
// 0 <= r < ulp(q)*b
|
||||
//
|
||||
// if r is greater than 1/2 ulp(q)*b, then q rounds up. Otherwise, we
|
||||
// already have the correct result. The exact halfway case cannot occur.
|
||||
// We also take this time to right shift quotient if it falls in the [1,2)
|
||||
// range and adjust the exponent accordingly.
|
||||
var residual: Z = undefined;
|
||||
if (quotient < (implicitBit << 1)) {
|
||||
residual = (aSignificand << 53) -% quotient *% bSignificand;
|
||||
quotientExponent -%= 1;
|
||||
} else {
|
||||
quotient >>= 1;
|
||||
residual = (aSignificand << 52) -% quotient *% bSignificand;
|
||||
}
|
||||
|
||||
const writtenExponent = quotientExponent +% exponentBias;
|
||||
|
||||
if (writtenExponent >= maxExponent) {
|
||||
// If we have overflowed the exponent, return infinity.
|
||||
return @bitCast(f64, infRep | quotientSign);
|
||||
} else if (writtenExponent < 1) {
|
||||
if (writtenExponent == 0) {
|
||||
// Check whether the rounded result is normal.
|
||||
const round = @boolToInt((residual << 1) > bSignificand);
|
||||
// Clear the implicit bit.
|
||||
var absResult = quotient & significandMask;
|
||||
// Round.
|
||||
absResult += round;
|
||||
if ((absResult & ~significandMask) != 0) {
|
||||
// The rounded result is normal; return it.
|
||||
return @bitCast(f64, absResult | quotientSign);
|
||||
}
|
||||
}
|
||||
// Flush denormals to zero. In the future, it would be nice to add
|
||||
// code to round them correctly.
|
||||
return @bitCast(f64, quotientSign);
|
||||
} else {
|
||||
const round = @boolToInt((residual << 1) > bSignificand);
|
||||
// Clear the implicit bit
|
||||
var absResult = quotient & significandMask;
|
||||
// Insert the exponent
|
||||
absResult |= @bitCast(Z, @as(SignedZ, writtenExponent)) << significandBits;
|
||||
// Round
|
||||
absResult +%= round;
|
||||
// Insert the sign and return
|
||||
return @bitCast(f64, absResult | quotientSign);
|
||||
}
|
||||
}
|
||||
|
||||
test {
|
||||
_ = @import("divdf3_test.zig");
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
const common = @import("./common.zig");
|
||||
const divc3 = @import("./divc3.zig");
|
||||
const Complex = @import("./mulc3.zig").Complex;
|
||||
|
||||
comptime {
|
||||
@export(__divhc3, .{ .name = "__divhc3", .linkage = common.linkage });
|
||||
}
|
||||
|
||||
pub fn __divhc3(a: f16, b: f16, c: f16, d: f16) callconv(.C) Complex(f16) {
|
||||
return divc3.divc3(f16, a, b, c, d);
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
const common = @import("common.zig");
|
||||
const divsf3 = @import("./divsf3.zig");
|
||||
|
||||
comptime {
|
||||
@export(__divhf3, .{ .name = "__divhf3", .linkage = common.linkage });
|
||||
}
|
||||
|
||||
pub fn __divhf3(a: f16, b: f16) callconv(.C) f16 {
|
||||
// TODO: more efficient implementation
|
||||
return @floatCast(f16, divsf3.__divsf3(a, b));
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
const common = @import("./common.zig");
|
||||
const divc3 = @import("./divc3.zig");
|
||||
const Complex = @import("./mulc3.zig").Complex;
|
||||
|
||||
comptime {
|
||||
@export(__divsc3, .{ .name = "__divsc3", .linkage = common.linkage });
|
||||
}
|
||||
|
||||
pub fn __divsc3(a: f32, b: f32, c: f32, d: f32) callconv(.C) Complex(f32) {
|
||||
return divc3.divc3(f32, a, b, c, d);
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
const common = @import("./common.zig");
|
||||
const divc3 = @import("./divc3.zig");
|
||||
const Complex = @import("./mulc3.zig").Complex;
|
||||
|
||||
comptime {
|
||||
@export(__divtc3, .{ .name = "__divtc3", .linkage = common.linkage });
|
||||
}
|
||||
|
||||
pub fn __divtc3(a: f128, b: f128, c: f128, d: f128) callconv(.C) Complex(f128) {
|
||||
return divc3.divc3(f128, a, b, c, d);
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user