-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: build script and github pipeline
- Loading branch information
1 parent
09a6094
commit 0e89248
Showing
5 changed files
with
142 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
name: "Build LLVM" | ||
|
||
on: [push] | ||
|
||
jobs: | ||
build_llvm: | ||
name: Build LLVM | ||
strategy: | ||
matrix: | ||
# os: [ubuntu-20.04, macos-11, windows-2019] | ||
os: [ubuntu-20.04] | ||
runs-on: ${{ matrix.os }} | ||
permissions: | ||
contents: write # for creating releases | ||
container: | ||
# Intentionally old ubuntu version with old glibc. | ||
image: ubuntu:18.04 | ||
steps: | ||
- name: checkout | ||
uses: actions/checkout@v3 | ||
- run: "apt update && apt install -y clang git wget build-essential python3" | ||
- run: "wget https://github.com/Kitware/CMake/releases/download/v3.30.0-rc2/cmake-3.30.0-rc2-linux-x86_64.sh" | ||
- run: "chmod +x cmake-*.sh" | ||
- run: "./cmake-*.sh --skip-license --prefix=/usr" | ||
- run: "cmake --version" | ||
- run: "python3 --version" | ||
- run: "./build-llvm-libs.sh" | ||
- uses: actions/upload-artifact@v3 | ||
with: | ||
name: llvm-static-libs | ||
path: llvm-static-libs.tar.gz | ||
- name: read version | ||
id: read-version | ||
run: | | ||
echo ::set-output name=version::$(cat VERSION) | ||
shell: bash | ||
- name: create release | ||
id: create-release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ steps.read-version.outputs.version }} | ||
release_name: ${{ steps.read-version.outputs.version }} | ||
draft: false | ||
prerelease: true | ||
- name: upload linux artifact | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ github.token }} | ||
with: | ||
upload_url: ${{ steps.create-release.outputs.upload_url }} | ||
asset_path: ./llvm-static-libs.tar.gz | ||
asset_name: llvm-static-linux-amd64.tar.gz | ||
asset_content_type: application/gzip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
cmake_minimum_required(VERSION 3.5) | ||
project(llvm-static) | ||
|
||
if(POLICY CMP0114) | ||
cmake_policy(SET CMP0114 NEW) | ||
endif() | ||
|
||
# Avoid warning about DOWNLOAD_EXTRACT_TIMESTAMP in CMake 3.24: | ||
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0") | ||
cmake_policy(SET CMP0135 NEW) | ||
endif() | ||
|
||
set(CMAKE_CXX_STANDARD 17) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
# set(CMAKE_POSITION_INDEPENDENT_CODE ON) | ||
set(CMAKE_BUILD_TYPE Release) | ||
|
||
set(LLVM_LIBRARIES | ||
clangTooling clangFormat clangToolingInclusions clangFrontend clangDriver clangParse clangSerialization clangSema clangAPINotes clangEdit clangAnalysis clangASTMatchers clangAST clangSupport clangToolingCore clangRewrite clangLex clangBasic | ||
# Order as reported by llvm-config --libs --link-static | ||
LLVMWindowsDriver LLVMOption LLVMFrontendOpenMP LLVMFrontendOffloading LLVMScalarOpts LLVMTransformUtils LLVMAnalysis LLVMProfileData LLVMDebugInfoDWARF LLVMObject LLVMTextAPI LLVMMCParser LLVMIRReader LLVMAsmParser LLVMMC LLVMBitReader LLVMCore LLVMRemarks LLVMBitstreamReader LLVMBinaryFormat LLVMTargetParser LLVMSupport LLVMDemangle) | ||
|
||
set(LLVM_PROJECT_TARGET external.llvm-project) | ||
set(LLVM_PROJECT_INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/${LLVM_PROJECT_TARGET}) | ||
foreach(lib ${LLVM_LIBRARIES}) | ||
set(LIB_PATH ${LLVM_PROJECT_INSTALL_DIR}/lib/lib${lib}) | ||
list(APPEND LLVM_PROJECT_BUILD_BYPRODUCTS ${LIB_PATH}) | ||
|
||
add_library(${lib} STATIC IMPORTED) | ||
set_property(TARGET ${lib} PROPERTY IMPORTED_LOCATION ${LIB_PATH}) | ||
add_dependencies(${lib} ${LLVM_PROJECT_TARGET}) | ||
endforeach(lib) | ||
|
||
include(ExternalProject) | ||
ExternalProject_Add(${LLVM_PROJECT_TARGET} | ||
PREFIX ${LLVM_PROJECT_TARGET} | ||
GIT_REPOSITORY https://github.com/llvm/llvm-project.git | ||
GIT_TAG llvmorg-18.1.5 | ||
GIT_SHALLOW ON | ||
SOURCE_SUBDIR llvm | ||
CMAKE_ARGS | ||
-G${CMAKE_GENERATOR} | ||
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} | ||
-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR> | ||
-DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER} | ||
-DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER} | ||
-DCMAKE_C_COMPILER_LAUNCHER:FILEPATH=${CMAKE_C_COMPILER_LAUNCHER} | ||
-DCMAKE_CXX_COMPILER_LAUNCHER:FILEPATH=${CMAKE_CXX_COMPILER_LAUNCHER} | ||
-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD} | ||
-DCMAKE_POSITION_INDEPENDENT_CODE=${CMAKE_POSITION_INDEPENDENT_CODE} | ||
-DLLVM_ENABLE_PROJECTS=clang | ||
-DLLVM_ENABLE_RTTI=ON | ||
-DLLVM_ENABLE_PIC=ON | ||
-DLLVM_TARGETS_TO_BUILD=X86 | ||
-DLLVM_BUILD_TOOLS=OFF | ||
-DLLVM_BUILD_TESTS=OFF | ||
-DLLVM_ENABLE_TERMINFO=OFF | ||
-DLLVM_ENABLE_ZLIB=OFF | ||
-DLLVM_ENABLE_ZSTD=OFF | ||
-DLLVM_ENABLE_LIBXML2=OFF | ||
BUILD_COMMAND ${CMAKE_COMMAND} --build <BINARY_DIR> --target clangTooling -j16 | ||
BUILD_BYPRODUCTS ${LLVM_PROJECT_BUILD_BYPRODUCTS} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
18.1.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/usr/bin/env bash | ||
|
||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) | ||
BUILD_DIR="$SCRIPT_DIR/build" | ||
LLVM_BUILD_DIR="$BUILD_DIR/external.llvm-project" | ||
|
||
cd "$SCRIPT_DIR" | ||
mkdir -p build | ||
# cmake -B build . | ||
# cmake --build build | ||
|
||
|
||
echo "Mocked LLVM build" | ||
mkdir -p build/external.llvm-project/lib | ||
touch build/external.llvm-project/lib/libclangTooling.a | ||
mkdir -p build/external.llvm-project/include | ||
touch build/external.llvm-project/include/clang.h | ||
|
||
# Pack everything we need into a tar archive. | ||
# We only need the header files and all produced static libraries. | ||
cd $LLVM_BUILD_DIR | ||
tar -czvf "$SCRIPT_DIR/llvm-static-libs.tar.gz" include/ lib/*.a |