Pact with the devil: LLVM
This commit is contained in:
parent
f7c1077706
commit
3bdc01ab0a
32
.github/workflows/ci.yml
vendored
32
.github/workflows/ci.yml
vendored
@ -16,7 +16,7 @@ jobs:
|
|||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: sudo apt install -y ninja-build
|
run: sudo apt install -y ninja-build mold
|
||||||
- name: System information
|
- name: System information
|
||||||
run: |
|
run: |
|
||||||
uname -a
|
uname -a
|
||||||
@ -32,7 +32,7 @@ jobs:
|
|||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: sudo apt install -y ninja-build
|
run: sudo apt install -y ninja-build mold
|
||||||
- name: System information
|
- name: System information
|
||||||
run: |
|
run: |
|
||||||
uname -a
|
uname -a
|
||||||
@ -48,7 +48,7 @@ jobs:
|
|||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: sudo apt install -y ninja-build
|
run: sudo apt install -y ninja-build mold
|
||||||
- name: System information
|
- name: System information
|
||||||
run: |
|
run: |
|
||||||
uname -a
|
uname -a
|
||||||
@ -64,7 +64,7 @@ jobs:
|
|||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: sudo apt install -y ninja-build
|
run: sudo apt install -y ninja-build mold
|
||||||
- name: System information
|
- name: System information
|
||||||
run: |
|
run: |
|
||||||
uname -a
|
uname -a
|
||||||
@ -144,13 +144,15 @@ jobs:
|
|||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: choco install ninja
|
run: |
|
||||||
|
choco install ninja
|
||||||
|
pwsh ./fetch-llvm.ps1
|
||||||
# - name: System information
|
# - name: System information
|
||||||
# run: |
|
# run: |
|
||||||
# systeminfo
|
# systeminfo
|
||||||
# clang -v
|
# clang -v
|
||||||
- name: Build and test
|
- name: Build and test
|
||||||
run: pwsh ./project.ps1 "build_type=Debug" test all
|
run: pwsh ./project.ps1 "-DCMAKE_PREFIX_PATH=clang+llvm-19.1.2-x86_64-pc-windows-msvc" "build_type=Debug" test all
|
||||||
env:
|
env:
|
||||||
LANG: en_US.UTF-8 # Ensure UTF-8 encoding
|
LANG: en_US.UTF-8 # Ensure UTF-8 encoding
|
||||||
windows_MinSizeRel:
|
windows_MinSizeRel:
|
||||||
@ -160,13 +162,15 @@ jobs:
|
|||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: choco install ninja
|
run: |
|
||||||
|
choco install ninja
|
||||||
|
pwsh ./fetch-llvm.ps1
|
||||||
# - name: System information
|
# - name: System information
|
||||||
# run: |
|
# run: |
|
||||||
# systeminfo
|
# systeminfo
|
||||||
# clang -v
|
# clang -v
|
||||||
- name: Build and test
|
- name: Build and test
|
||||||
run: pwsh ./project.ps1 "build_type=MinSizeRel" test all
|
run: pwsh ./project.ps1 "-DCMAKE_PREFIX_PATH=clang+llvm-19.1.2-x86_64-pc-windows-msvc" "build_type=MinSizeRel" test all
|
||||||
env:
|
env:
|
||||||
LANG: en_US.UTF-8 # Ensure UTF-8 encoding
|
LANG: en_US.UTF-8 # Ensure UTF-8 encoding
|
||||||
windows_RelWithDebInfo:
|
windows_RelWithDebInfo:
|
||||||
@ -176,13 +180,15 @@ jobs:
|
|||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: choco install ninja
|
run: |
|
||||||
|
choco install ninja
|
||||||
|
pwsh ./fetch-llvm.ps1
|
||||||
# - name: System information
|
# - name: System information
|
||||||
# run: |
|
# run: |
|
||||||
# systeminfo
|
# systeminfo
|
||||||
# clang -v
|
# clang -v
|
||||||
- name: Build and test
|
- name: Build and test
|
||||||
run: pwsh ./project.ps1 "build_type=RelWithDebInfo" test all
|
run: pwsh ./project.ps1 "-DCMAKE_PREFIX_PATH=clang+llvm-19.1.2-x86_64-pc-windows-msvc" "build_type=RelWithDebInfo" test all
|
||||||
env:
|
env:
|
||||||
LANG: en_US.UTF-8 # Ensure UTF-8 encoding
|
LANG: en_US.UTF-8 # Ensure UTF-8 encoding
|
||||||
windows_Release:
|
windows_Release:
|
||||||
@ -192,12 +198,14 @@ jobs:
|
|||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: choco install ninja
|
run: |
|
||||||
|
choco install ninja
|
||||||
|
pwsh ./fetch-llvm.ps1
|
||||||
# - name: System information
|
# - name: System information
|
||||||
# run: |
|
# run: |
|
||||||
# systeminfo
|
# systeminfo
|
||||||
# clang -v
|
# clang -v
|
||||||
- name: Build and test
|
- name: Build and test
|
||||||
run: pwsh ./project.ps1 "build_type=Release" test all
|
run: pwsh ./project.ps1 "-DCMAKE_PREFIX_PATH=clang+llvm-19.1.2-x86_64-pc-windows-msvc" "build_type=Release" test all
|
||||||
env:
|
env:
|
||||||
LANG: en_US.UTF-8 # Ensure UTF-8 encoding
|
LANG: en_US.UTF-8 # Ensure UTF-8 encoding
|
||||||
|
@ -14,9 +14,12 @@ add_compile_options(
|
|||||||
)
|
)
|
||||||
include_directories("bootstrap/include")
|
include_directories("bootstrap/include")
|
||||||
|
|
||||||
|
find_package(LLVM REQUIRED CONFIG)
|
||||||
|
|
||||||
set(LIBRARY_NAME "std")
|
set(LIBRARY_NAME "std")
|
||||||
set(RUNNER_NAME "runner")
|
set(RUNNER_NAME "runner")
|
||||||
set(COMPILER_NAME "nest")
|
set(COMPILER_NAME "nest")
|
||||||
|
|
||||||
add_library("${LIBRARY_NAME}"
|
add_library("${LIBRARY_NAME}"
|
||||||
"bootstrap/std/base.c"
|
"bootstrap/std/base.c"
|
||||||
"bootstrap/std/string.c"
|
"bootstrap/std/string.c"
|
||||||
@ -27,10 +30,15 @@ add_library("${LIBRARY_NAME}"
|
|||||||
"bootstrap/std/sha1.c"
|
"bootstrap/std/sha1.c"
|
||||||
)
|
)
|
||||||
add_executable("${RUNNER_NAME}" "bootstrap/runner/runner.c")
|
add_executable("${RUNNER_NAME}" "bootstrap/runner/runner.c")
|
||||||
target_link_libraries(${RUNNER_NAME} ${LIBRARY_NAME})
|
target_link_libraries(${RUNNER_NAME} PRIVATE ${LIBRARY_NAME})
|
||||||
|
|
||||||
add_executable("${COMPILER_NAME}"
|
add_executable("${COMPILER_NAME}"
|
||||||
"bootstrap/src/main.c"
|
"bootstrap/src/main.c"
|
||||||
"bootstrap/src/pdb_image.c"
|
"bootstrap/src/pdb_image.c"
|
||||||
)
|
)
|
||||||
target_link_libraries(${COMPILER_NAME} ${LIBRARY_NAME})
|
|
||||||
|
target_compile_definitions(${COMPILER_NAME} PRIVATE ${LLVM_DEFINITIONS})
|
||||||
|
target_include_directories(${COMPILER_NAME} PRIVATE ${LLVM_INCLUDE_DIRS})
|
||||||
|
target_link_directories(${COMPILER_NAME} PRIVATE ${LLVM_LIBRARY_DIRS})
|
||||||
|
target_link_libraries(${COMPILER_NAME} PRIVATE ${LIBRARY_NAME} ${LLVM_LIBRARIES})
|
||||||
|
|
||||||
|
14
fetch-llvm.ps1
Normal file
14
fetch-llvm.ps1
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
Set-StrictMode -Version Latest
|
||||||
|
Set-PSDebug -Trace 2
|
||||||
|
|
||||||
|
$LLVM_VERSION="19.1.2"
|
||||||
|
$BASE_DOWNLOAD_URL="https://github.com/llvm/llvm-project/releases/download/llvmorg-$LLVM_VERSION"
|
||||||
|
|
||||||
|
$LLVM_DOWNLOAD_FILE_BASENAME="clang+llvm-$LLVM_VERSION-x86_64-pc-windows-msvc"
|
||||||
|
$LLVM_DOWNLOAD_FILE="$LLVM_DOWNLOAD_FILE_BASENAME.tar.xz"
|
||||||
|
$LLVM_DOWNLOAD_URL="$BASE_DOWNLOAD_URL/$LLVM_DOWNLOAD_FILE"
|
||||||
|
|
||||||
|
Invoke-WebRequest -Uri "$LLVM_DOWNLOAD_URL" -OutFile "$LLVM_DOWNLOAD_FILE"
|
||||||
|
7z x $LLVM_DOWNLOAD_FILE
|
||||||
|
7z x "$LLVM_DOWNLOAD_FILE_BASENAME.tar"
|
||||||
|
dir
|
18
project.ps1
18
project.ps1
@ -1,25 +1,33 @@
|
|||||||
Set-StrictMode -Version Latest
|
Set-StrictMode -Version Latest
|
||||||
Set-PSDebug -Trace 2
|
Set-PSDebug -Trace 2
|
||||||
$previous_error_action_preference = $global:ErrorActionPreference
|
$previous_error_action_preference = $global:ErrorActionPreference
|
||||||
|
$global:ErrorActionPreference = 'Stop'
|
||||||
$myargs=$args
|
$myargs=$args
|
||||||
$build_dir="build"
|
$build_dir="build"
|
||||||
$release_mode="Debug"
|
$release_mode="Debug"
|
||||||
$build_type_prefix="build_type="
|
$build_type_prefix="build_type="
|
||||||
|
$cmake_prefix_path_prefix="-DCMAKE_PREFIX_PATH="
|
||||||
|
$cmake_prefix_path=""
|
||||||
|
|
||||||
& {
|
& {
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$global:ErrorActionPreference = 'Stop'
|
foreach ($arg in $myargs)
|
||||||
|
|
||||||
if ($($myargs.Length) -ne 0 -and $myargs[0].StartsWith($build_type_prefix))
|
|
||||||
{
|
{
|
||||||
$release_mode = $myargs[0].Substring($build_type_prefix.Length)
|
if ($arg.StartsWith($build_type_prefix))
|
||||||
|
{
|
||||||
|
$release_mode = $arg.Substring($build_type_prefix.Length)
|
||||||
|
}
|
||||||
|
if ($arg.StartsWith($cmake_prefix_path_prefix))
|
||||||
|
{
|
||||||
|
$cmake_prefix_path = $arg.Substring($cmake_prefix_path_prefix.Length);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-Output "Build type: $release_mode"
|
Write-Output "Build type: $release_mode"
|
||||||
|
|
||||||
New-Item -Path $build_dir -ItemType Directory -Force
|
New-Item -Path $build_dir -ItemType Directory -Force
|
||||||
cmake . "-B$build_dir" -G Ninja "-DCMAKE_BUILD_TYPE=$release_mode" -DCMAKE_C_COMPILER="clang" -DCMAKE_CXX_COMPILER="clang++"
|
cmake . "-B$build_dir" -G Ninja "-DCMAKE_BUILD_TYPE=$release_mode" -DCMAKE_C_COMPILER="clang" -DCMAKE_CXX_COMPILER="clang++" "-DCMAKE_PREFIX_PATH=$cmake_prefix_path"
|
||||||
pushd $build_dir
|
pushd $build_dir
|
||||||
ninja
|
ninja
|
||||||
popd
|
popd
|
||||||
|
14
project.sh
14
project.sh
@ -7,7 +7,19 @@ fi
|
|||||||
echo "Build type: $release_mode"
|
echo "Build type: $release_mode"
|
||||||
build_dir=build
|
build_dir=build
|
||||||
mkdir -p $build_dir
|
mkdir -p $build_dir
|
||||||
cmake . -B$build_dir -G Ninja -DCMAKE_BUILD_TYPE="$release_mode" -DCMAKE_C_COMPILER="clang" -DCMAKE_CXX_COMPILER="clang++"
|
|
||||||
|
case "$OSTYPE" in
|
||||||
|
linux*) CLANG_PREFIX="/usr/bin" ;;
|
||||||
|
darwin*) CLANG_PREFIX="/opt/homebrew/opt/llvm/bin" ;;
|
||||||
|
*) exit 1 ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
case "$OSTYPE" in
|
||||||
|
linux*) cmake . -B$build_dir -G Ninja -DCMAKE_BUILD_TYPE="$release_mode" -DCMAKE_C_COMPILER="$CLANG_PREFIX/clang" -DCMAKE_CXX_COMPILER="$CLANG_PREFIX/clang++" -DCMAKE_EXE_LINKER_FLAGS="-fuse-ld=mold" -DCMAKE_SHARED_LINKER_FLAGS="-fuse-ld=mold" ;;
|
||||||
|
darwin*) cmake . -B$build_dir -G Ninja -DCMAKE_BUILD_TYPE="$release_mode" -DCMAKE_C_COMPILER="$CLANG_PREFIX/clang" -DCMAKE_CXX_COMPILER="$CLANG_PREFIX/clang++" -DCMAKE_PREFIX_PATH=$(brew --prefix llvm) ;;
|
||||||
|
*) exit 1 ;;
|
||||||
|
esac
|
||||||
|
|
||||||
original_dir=$PWD
|
original_dir=$PWD
|
||||||
cd $build_dir
|
cd $build_dir
|
||||||
ninja
|
ninja
|
||||||
|
Loading…
x
Reference in New Issue
Block a user