Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add LLVM distributions [BUILD-538] #13

Draft
wants to merge 47 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
9b1168d
Add LLVM hermetic toolchains [BUILD-538]
krisukox Feb 15, 2023
2ef24cd
Test
krisukox Feb 15, 2023
b7ad638
Test
krisukox Feb 15, 2023
027eb3e
Test
krisukox Feb 15, 2023
3ea536f
Test
krisukox Feb 15, 2023
343c080
Test
krisukox Feb 15, 2023
e55056b
Test
krisukox Feb 15, 2023
8a080bd
Test
krisukox Feb 15, 2023
64b12a9
Build both stages
krisukox Feb 15, 2023
8950832
Fix
krisukox Feb 15, 2023
9578824
Fix
krisukox Feb 15, 2023
d86eb12
Fix
krisukox Feb 15, 2023
f0a2a9e
Test
krisukox Feb 15, 2023
a5a5671
Test
krisukox Feb 15, 2023
bef716d
Try apple stage 2
krisukox Feb 16, 2023
037adb8
Linux x86
krisukox Feb 16, 2023
47cff61
Fix
krisukox Feb 16, 2023
a70c478
Test
krisukox Feb 16, 2023
bd5375b
Test
krisukox Feb 16, 2023
e31d977
Test
krisukox Feb 16, 2023
7e4ff97
Test
krisukox Feb 16, 2023
c71160d
Test
krisukox Feb 16, 2023
c893601
Build x86
krisukox Feb 16, 2023
92b606b
Fix
krisukox Feb 16, 2023
20a3129
Fix
krisukox Feb 16, 2023
18cae1b
Fix
krisukox Feb 16, 2023
a790251
Try default
krisukox Feb 16, 2023
7fafd71
Test
krisukox Feb 16, 2023
1340f86
Test
krisukox Feb 17, 2023
92f7797
Single branch
krisukox Feb 17, 2023
52f45ee
Fix
krisukox Feb 17, 2023
2073e78
Build only necessary
krisukox Feb 17, 2023
0fe0809
Test tar
krisukox Feb 17, 2023
4b33fca
Final tar
krisukox Feb 17, 2023
9a71657
Try only lld
krisukox Feb 20, 2023
e2849c1
Revert "Try only lld"
krisukox Feb 21, 2023
f4c833d
Add m1 mac
krisukox Feb 21, 2023
fcc8e73
Test release
krisukox Feb 21, 2023
fbf7c7c
Fix
krisukox Feb 21, 2023
1e2d722
Fix
krisukox Feb 21, 2023
c669b66
Fix
krisukox Feb 21, 2023
1e0b0a8
Test
krisukox Feb 21, 2023
25ae18d
Add x86 mac
krisukox Feb 21, 2023
3ff6ed1
Archive toolchains on jenkins
krisukox Feb 23, 2023
d86f9f2
Enable more components
krisukox Feb 24, 2023
6d2bc1a
Fix
krisukox Feb 24, 2023
7bddbc5
Fix: enable clang-tools-extra project
krisukox Feb 24, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Dockerfile.llvm
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM ubuntu:jammy

RUN apt-get update
RUN apt-get install -y \
build-essential \
clang-14 \
clang++-14 \
cmake \
libc6-dev-i386 \
python3-pip \
python3-distutils \
vim \
ninja-build \
git
121 changes: 121 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
#!groovy

/**
* This Jenkinsfile will only work in a Swift Navigation build/CI environment, as it uses
* non-public docker images and pipeline libraries.
*/

// Use 'ci-jenkins@somebranch' to pull shared lib from a different branch than the default.
// Default is configured in Jenkins and should be from "stable" tag.
@Library("ci-jenkins") import com.swiftnav.ci.*

def context = new Context(context: this)
context.setRepo("swift-toolchains")

/**
* - Mount the refrepo to keep git operations functional on a repo that uses ref-repo during clone
**/
String dockerMountArgs = "-v /mnt/efs/refrepo:/mnt/efs/refrepo"

pipeline {
// Override agent in each stage to make sure we don't share containers among stages.
agent any
options {
// Make sure job aborts after 2 hours if hanging.
timeout(time: 4, unit: 'HOURS')
timestamps()
// Keep builds for 7 days.
buildDiscarder(logRotator(daysToKeepStr: '7'))
}

stages {
stage('Build') {
parallel {
stage('llvm x86_64 linux') {
agent {
dockerfile {
filename "Dockerfile.llvm"
}
}
steps {
sh('''
git clone https://github.com/llvm/llvm-project --branch=llvmorg-14.0.6 --single-branch
cd llvm-project

mkdir build
cd build

cmake -GNinja ../llvm \
-DCMAKE_INSTALL_PREFIX=../out/ \
-C ../../llvm/Distribution.cmake
ninja stage2-install-distribution
''')
uploadDistribution("clang+llvm-14.0.6-x86_64-linux", context)
}
}
stage('llvm aarch64 darwin') {
agent {
node('macos-arm64')
}
steps {
sh('''
git clone https://github.com/llvm/llvm-project --branch=llvmorg-14.0.6 --single-branch
cd llvm-project

mkdir build
cd build

cmake -GNinja ../llvm \
-DCMAKE_INSTALL_PREFIX=../out/ \
-DCMAKE_OSX_ARCHITECTURES='arm64' \
-DCMAKE_C_COMPILER=`which clang` \
-DCMAKE_CXX_COMPILER=`which clang++` \
-DCMAKE_BUILD_TYPE=Release \
-C ../../llvm/Distribution.cmake
ninja stage2-install-distribution
''')
uploadDistribution("clang+llvm-14.0.6-arm64-apple-darwin", context)
}
}
stage('llvm x86_64 darwin') {
agent {
node('macos')
}
steps {
sh('''
git clone https://github.com/llvm/llvm-project --branch=llvmorg-14.0.6 --single-branch
cd llvm-project
mkdir build
cd build
cmake -GNinja ../llvm \
-DCMAKE_INSTALL_PREFIX=../out/ \
-DCMAKE_OSX_ARCHITECTURES='x86_64' \
-DLLVM_ENABLE_RUNTIMES='compiler-rt;libcxx;libcxxabi' \
-DCMAKE_C_COMPILER=`which clang` \
-DCMAKE_CXX_COMPILER=`which clang++` \
-DCMAKE_BUILD_TYPE=Release \
-C ../../llvm/Distribution.cmake
ninja stage2-install-distribution
''')
uploadDistribution("clang+llvm-14.0.6-x86_64-apple-darwin", context)
}
}
}
}
}
}

def uploadDistribution(name, context) {
sh("""
mkdir -p tar/${name}/
cp -rH llvm-project/out/* tar/${name}/
""")
tar(file: "${name}.tar.gz", dir: 'tar', archive: true)
script{
context.archivePatterns(
patterns: ["${name}.tar.gz"],
path: "swift-toolchains/${context.gitDescribe()}/${name}.tar.gz",
jenkins: false
)
}
}
37 changes: 37 additions & 0 deletions llvm/Distribution-stage2.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# This file sets up a CMakeCache for the second stage of a simple distribution
# bootstrap build.

set(LLVM_ENABLE_PROJECTS "clang;clang-tools-extra;lld" CACHE STRING "")
set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "")

set(COMPILER_RT_BUILD_BUILTINS ON CACHE BOOL "")

set(LLVM_TARGETS_TO_BUILD Native CACHE STRING "")

set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 -gline-tables-only -DNDEBUG" CACHE STRING "")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -gline-tables-only -DNDEBUG" CACHE STRING "")

# setup toolchain
set(LLVM_INSTALL_TOOLCHAIN_ONLY ON CACHE BOOL "")
set(LLVM_TOOLCHAIN_TOOLS
llvm-ar
llvm-cov
llvm-dwp
llvm-nm
llvm-objcopy
llvm-objdump
llvm-profdata
llvm-strip
llvm-symbolizer
CACHE STRING "")

set(LLVM_DISTRIBUTION_COMPONENTS
clang
lld
builtins
runtimes
clang-resource-headers
clang-tidy
${LLVM_TOOLCHAIN_TOOLS}
CACHE STRING "")
36 changes: 36 additions & 0 deletions llvm/Distribution.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# This file sets up a CMakeCache for a simple distribution bootstrap build.

#Enable LLVM projects and runtimes
set(LLVM_ENABLE_PROJECTS "clang;clang-tools-extra;lld" CACHE STRING "")

# Only build the native target in stage1 since it is a throwaway build.
set(LLVM_TARGETS_TO_BUILD Native CACHE STRING "")

# Optimize the stage1 compiler, but don't LTO it because that wastes time.
set(CMAKE_BUILD_TYPE Release CACHE STRING "")

# Setup vendor-specific settings.
set(PACKAGE_VENDOR LLVM.org CACHE STRING "")

# Setting up the stage2 LTO option needs to be done on the stage1 build so that
# the proper LTO library dependencies can be connected.
set(BOOTSTRAP_LLVM_ENABLE_LTO ON CACHE BOOL "")

if (NOT APPLE)
# Since LLVM_ENABLE_LTO is ON we need a LTO capable linker
set(BOOTSTRAP_LLVM_ENABLE_LLD ON CACHE BOOL "")
endif()

# Expose stage2 targets through the stage1 build configuration.
set(CLANG_BOOTSTRAP_TARGETS
distribution
install-distribution
clang CACHE STRING "")

# Setup the bootstrap build.
set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "")

set(CLANG_BOOTSTRAP_CMAKE_ARGS
-C ${CMAKE_CURRENT_LIST_DIR}/Distribution-stage2.cmake
CACHE STRING "")