Skip to content

Commit 2cc9bfc

Browse files
committed
Merge cheriot with llvm-18
2 parents 3b5b5c1 + 6d22636 commit 2cc9bfc

File tree

2,501 files changed

+178629
-10026
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,501 files changed

+178629
-10026
lines changed

.cirrus.yml

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
gcp_credentials: ENCRYPTED[cf2b73ff299c7afb7adf7a219c948781a360b3c629b4a5583133d855a5563c7e55514c86f995b41967f3f8cb9fa49673]
2+
pr_task:
3+
name: Build and test PR
4+
skip: $CIRRUS_PR == ""
5+
timeout_in: 240m
6+
gce_instance: &arm_vm
7+
image_project: ubuntu-os-cloud
8+
image_family: ubuntu-2404-lts-arm64
9+
architecture: arm64
10+
zone: us-central1-a
11+
type: c4a-standard-8
12+
disk: 60
13+
preemptible: true
14+
env:
15+
NINJA_STATUS: '%p [%f:%s/%t] %o/s, %es: '
16+
CIRRUS_CLONE_DEPTH: 1
17+
dependencies_script:
18+
- set -eo pipefail
19+
- apt-get update
20+
- apt-get install -y clang ninja-build lld cmake ccache perl
21+
configure_script:
22+
- mkdir Build
23+
- cd Build
24+
- cmake ../llvm -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=ON -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;lld" -DLLVM_ENABLE_UNWIND_TABLES=NO -DLLVM_ENABLE_LLD=ON -DLLVM_PARALLEL_LINK_JOBS=1 -DLLVM_APPEND_VC_REV=ON -DLLVM_VC_REPOSITORY=${CIRRUS_REPO_FULL_NAME} -DLLVM_VC_REVISION=${CIRRUS_CHANGE_IN_REPO} -DLLVM_CCACHE_BUILD=ON -G Ninja
25+
build_script:
26+
- cd Build
27+
- export CCACHE_REMOTE_STORAGE="http://${CIRRUS_HTTP_CACHE_HOST}/${CIRRUS_OS}/"
28+
- export CCACHE_REMOTE_ONLY=1
29+
- ninja test-depends
30+
test_script:
31+
- cd Build
32+
- ./bin/llvm-lit -v ../llvm/test/Unit ../clang/test/Unit
33+
- ./bin/llvm-lit -v ../llvm/test/ ../clang/test/
34+
35+
x86_release_task:
36+
name: Build and upload artefact x86_64
37+
only_if: ($CIRRUS_PR == "") && ($CIRRUS_BRANCH == "cheriot")
38+
timeout_in: 120m
39+
gce_instance:
40+
<<: *arm_vm
41+
image_family: ubuntu-2404-lts-amd64
42+
architecture: amd64
43+
zone: us-central1-a
44+
type: t2d-standard-8
45+
env:
46+
NINJA_STATUS: '%p [%f:%s/%t] %o/s, %es: '
47+
CIRRUS_CLONE_DEPTH: 1
48+
dependencies_script:
49+
- set -eo pipefail
50+
- apt-get update
51+
- apt-get install -y clang ninja-build lld cmake ccache
52+
configure_script:
53+
- mkdir Build
54+
- cd Build
55+
- cmake ../llvm -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;lld" -DLLVM_ENABLE_UNWIND_TABLES=NO -DLLVM_ENABLE_LLD=ON -DLLVM_TARGETS_TO_BUILD=RISCV -DLLVM_DISTRIBUTION_COMPONENTS="clang;clangd;lld;llvm-objdump;llvm-objcopy;llvm-strip;clang-tidy;clang-format" -DCMAKE_INSTALL_PREFIX=install -DLLVM_PARALLEL_LINK_JOBS=1 -DLLVM_APPEND_VC_REV=ON -DLLVM_VC_REPOSITORY=${CIRRUS_REPO_FULL_NAME} -DLLVM_VC_REVISION=${CIRRUS_CHANGE_IN_REPO} -DLLVM_CCACHE_BUILD=ON -G Ninja
56+
build_script:
57+
- cd Build
58+
- export CCACHE_REMOTE_STORAGE="http://${CIRRUS_HTTP_CACHE_HOST}/release-amd64/${CIRRUS_OS}/"
59+
- export CCACHE_REMOTE_ONLY=1
60+
- ninja install-distribution
61+
- cp ../llvm/LICENSE.TXT install/LLVM-LICENSE.TXT
62+
# Artefact upload uploads symlinks as copies, so delete all of the clang symlinks
63+
- rm install/bin/clang
64+
- rm install/bin/clang++
65+
- rm install/bin/clang-cl
66+
- rm install/bin/clang-cpp
67+
- rm install/bin/ld.lld
68+
- rm install/bin/ld64*
69+
- rm install/bin/lld-link
70+
- rm install/bin/wasm-ld
71+
binaries_artifacts:
72+
path: "Build/install/**"
73+
74+
arm_release_task:
75+
name: Build and upload artefact aarch64
76+
only_if: ($CIRRUS_PR == "") && ($CIRRUS_BRANCH == "cheriot")
77+
timeout_in: 120m
78+
gce_instance: *arm_vm
79+
env:
80+
NINJA_STATUS: '%p [%f:%s/%t] %o/s, %es: '
81+
CIRRUS_CLONE_DEPTH: 1
82+
dependencies_script:
83+
- set -eo pipefail
84+
- apt-get update
85+
- apt-get install -y clang ninja-build lld cmake ccache
86+
configure_script:
87+
- mkdir Build
88+
- cd Build
89+
- cmake ../llvm -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;lld" -DLLVM_ENABLE_UNWIND_TABLES=NO -DLLVM_ENABLE_LLD=ON -DLLVM_TARGETS_TO_BUILD=RISCV -DLLVM_DISTRIBUTION_COMPONENTS="clang;clangd;lld;llvm-objdump;llvm-objcopy;llvm-strip;clang-tidy;clang-format" -DCMAKE_INSTALL_PREFIX=install -DLLVM_PARALLEL_LINK_JOBS=1 -DLLVM_APPEND_VC_REV=ON -DLLVM_VC_REPOSITORY=${CIRRUS_REPO_FULL_NAME} -DLLVM_VC_REVISION=${CIRRUS_CHANGE_IN_REPO} -DLLVM_CCACHE_BUILD=ON -G Ninja
90+
build_script:
91+
- cd Build
92+
- export CCACHE_REMOTE_STORAGE="http://${CIRRUS_HTTP_CACHE_HOST}/release/${CIRRUS_OS}/arm64/"
93+
- export CCACHE_REMOTE_ONLY=1
94+
- ninja install-distribution
95+
- cp ../llvm/LICENSE.TXT install/LLVM-LICENSE.TXT
96+
# Artefact upload uploads symlinks as copies, so delete all of the clang symlinks
97+
- rm install/bin/clang
98+
- rm install/bin/clang++
99+
- rm install/bin/clang-cl
100+
- rm install/bin/clang-cpp
101+
- rm install/bin/ld.lld
102+
- rm install/bin/ld64*
103+
- rm install/bin/lld-link
104+
- rm install/bin/wasm-ld
105+
binaries_artifacts:
106+
path: "Build/install/**"

.git-blame-ignore-revs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
# r280751: [Coding style change][lldb] Moved LLDB code base to use LLVM style
1818
b9c1b51e45b845debb76d8658edabca70ca56079
19+
# Same change for CHERI:
20+
ffe13ea92c3bd526a4fdd458d48357affd8fe8a7
1921

2022
# r302421: That change incorrectly changed line endings in some libc++ files
2123
9669df28d4fd3c52d09f451186bd217cdc3322c0

.github/workflows/clang-format.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Check coding style
2+
on: [pull_request]
3+
defaults:
4+
run:
5+
shell: bash
6+
jobs:
7+
check-format:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout
11+
uses: actions/checkout@v2
12+
- name: Try to fetch required commits
13+
run: |
14+
set -xe
15+
echo "base_ref=${{ github.base_ref }}"
16+
echo "github.event.pull_request.head.sha=${{ github.event.pull_request.head.sha }}"
17+
# Based on https://stackoverflow.com/questions/54181901/fetching-only-the-range-of-commits-not-present-in-base-branch
18+
for ((depth = 8; depth <= 65536; depth *= 2)); do
19+
echo "trying depth $depth ..."
20+
git fetch "--depth=$depth" origin "${{ github.base_ref }}:${{ github.base_ref }}"
21+
git fetch "--depth=$depth" origin "+${{ github.event.pull_request.head.sha }}"
22+
if git merge-base "${{ github.base_ref }}" "${{ github.event.pull_request.head.sha }}"; then
23+
echo "found with depth=$depth"
24+
break
25+
fi
26+
done
27+
- name: List commits
28+
run: git log --oneline "${{ github.base_ref }}..${{ github.event.pull_request.head.sha }}"
29+
- name: Run clang-format
30+
uses: wolletd/clang-format-checker@v1
31+
with:
32+
source-ref: "${{ github.event.pull_request.head.sha }}"
33+
target-ref: "${{ github.base_ref }}" # required, merge target

Jenkinsfile

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
@Library('ctsrd-jenkins-scripts') _
2+
3+
cheribuildArgs = ['--llvm/build-type=Release', // DEBUG builds are too slow, we use release + assertions
4+
'--install-prefix=/', // This path is expected by downstream jobs
5+
'--without-sdk', // Use host compilers
6+
'--llvm/build-everything', // build all targets
7+
'--llvm/install-toolchain-only', // but only install compiler+binutils
8+
]
9+
// Set job properties:
10+
// Only archive artifacts for the default master and dev builds
11+
def archiveArtifacts = false
12+
def jobProperties = [rateLimitBuilds(throttle: [count: 1, durationName: 'hour', userBoost: true]),
13+
copyArtifactPermission('*'), // Downstream jobs need the compiler tarball
14+
[$class: 'GithubProjectProperty', displayName: '', projectUrlStr: 'https://github.com/CTSRD-CHERI/llvm-project/'],
15+
]
16+
if (env.JOB_NAME.startsWith('CLANG-LLVM-linux/') || env.JOB_NAME.startsWith('CLANG-LLVM-freebsd/')) {
17+
// Skip pull requests and non-default branches:
18+
def archiveBranches = ['master', 'dev', 'upstream-llvm-merge']
19+
if (!env.CHANGE_ID && (archiveBranches.contains(env.BRANCH_NAME))) {
20+
archiveArtifacts = true
21+
cheribuildArgs.add("--use-all-cores")
22+
// For branches other than the master branch, only keep the last two artifacts to save disk space
23+
if (env.BRANCH_NAME != 'master') {
24+
jobProperties.add(buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '2')))
25+
}
26+
}
27+
}
28+
// Set the default job properties (work around properties() not being additive but replacing)
29+
setDefaultJobProperties(jobProperties)
30+
31+
def nodeLabel = null
32+
echo("JOB_NAME='${env.JOB_NAME}', JOB_BASE_NAME='${env.JOB_BASE_NAME}'")
33+
if (env.JOB_NAME.toLowerCase().contains("linux")) {
34+
// Ensure that we can run the resulting binaries on all Linux slaves:
35+
nodeLabel = "linux-baseline"
36+
} else if (env.JOB_NAME.toLowerCase().contains("freebsd")) {
37+
nodeLabel = "freebsd"
38+
} else {
39+
error("Invalid job name: ${env.JOB_NAME}")
40+
}
41+
42+
def TEST_RELEASE_BUILD = false
43+
if (env.JOB_NAME.toLowerCase().contains("nodebug")) {
44+
TEST_RELEASE_BUILD = true
45+
}
46+
def TEST_WITH_SANITIZERS = false
47+
if (env.JOB_NAME.toLowerCase().contains("sanitizer")) {
48+
TEST_WITH_SANITIZERS = true
49+
}
50+
51+
cmakeArgs = [
52+
// Shared library builds are significantly slower
53+
'-DBUILD_SHARED_LIBS=OFF',
54+
// Avoid expensive checks (but keep assertions by default)
55+
'-DLLVM_ENABLE_EXPENSIVE_CHECKS=OFF',
56+
// link the C++ standard library statically (if possible)
57+
// This should make it easier to run binaries on other systems
58+
'-DLLVM_STATIC_LINK_CXX_STDLIB=ON',]
59+
if (TEST_RELEASE_BUILD) {
60+
cheribuildArgs.add('--llvm/no-assertions')
61+
} else {
62+
// Release build with assertions is a bit faster than a debug build and A LOT smaller
63+
cheribuildArgs.add('--llvm/assertions')
64+
}
65+
def individualTestTimeout = 300
66+
if (TEST_WITH_SANITIZERS) {
67+
individualTestTimeout = 600 // Sanitizer builds are slow
68+
cheribuildArgs.add('--llvm/use-asan')
69+
}
70+
// By default max 1 hour total and max 2 minutes per test
71+
cmakeArgs.add("-DLLVM_LIT_ARGS=--xunit-xml-output llvm-test-output.xml --max-time 3600 --timeout ${individualTestTimeout}")
72+
// Quote and join the cmake args
73+
cheribuildCmakeOption = '\'--llvm/cmake-options=\"' + cmakeArgs.join('\" \"') + '\"\''
74+
echo("CMake options = ${cheribuildCmakeOption}")
75+
cheribuildArgs.add(cheribuildCmakeOption)
76+
77+
Map defaultArgs = [target : 'llvm-native', architecture: 'native',
78+
customGitCheckoutDir: 'llvm-project',
79+
nodeLabel : nodeLabel,
80+
fetchCheriCompiler : false, // We are building the CHERI compiler, don't fetch it...
81+
extraArgs : cheribuildArgs.join(" "),
82+
skipArchiving : true,
83+
skipTarball : true,
84+
tarballName : "cheri-clang-llvm.tar.xz",
85+
runTests : true,
86+
uniqueId : env.JOB_NAME,
87+
afterTests : {
88+
// Delete all files generated by the tests.
89+
// The FreeBSD builders are currently configured with an ASCII locale.
90+
// This causes recordIssues() step to fail due to the non-ASCII file
91+
// names produced by some tests.
92+
// FIXME: We should fix the FreeBSD build servers, but deleting the
93+
// files first so that they aren't scanned for warnings probably
94+
// helps speed up recordIssues() anyway.
95+
sh "find llvm-project-build -type d -name Output -prune -exec rm -rf {} +"
96+
},
97+
junitXmlFiles : "llvm-project-build/llvm-test-output.xml",
98+
]
99+
100+
if (archiveArtifacts) {
101+
parallel "Build+Test": {
102+
node (nodeLabel) {
103+
// Run the full test suite
104+
def result = cheribuildProject(defaultArgs + [nodeLabel: null]) // already have a node
105+
// Run the libunwind+libcxxabi+libcxx tests to check we didn't regress native builds
106+
cheribuildProject(target: 'llvm-libs', architecture: 'native',
107+
skipTarball: true, skipInitialSetup: true, // No need to checkout git
108+
nodeLabel: null, buildStage: "Run libunwind+libcxxabi+libcxx tests",
109+
// Ensure we test failures don't prevent creation of the junit file
110+
extraArgs: '--keep-install-dir --install-prefix=/ --without-sdk',
111+
// Set the status message on the current commit of the LLVM repo
112+
gitHubStatusArgs: result.gitInfo,
113+
uniqueId: "llvm-libraries/${env.JOB_BASE_NAME}/${nodeLabel}/",
114+
// Libc++ tests are currently broken on FreeBSD. Skip them until we have added the required XFAIL annotations.
115+
runTests: nodeLabel != "freebsd", junitXmlFiles: "llvm-libs-native-build/test-results.xml")
116+
}
117+
}, "Build LTO": {
118+
// Build for archiving (with LTO, only toolchain binaries)
119+
String ltoCheribuildArgs = cheribuildArgs.join(" ")
120+
ltoCheribuildArgs = ltoCheribuildArgs.replace('--llvm/build-everything', '')
121+
ltoCheribuildArgs = ltoCheribuildArgs.replace('--llvm/install-toolchain-only', '')
122+
ltoCheribuildArgs += ' --llvm/use-lto --llvm/build-minimal-toolchain --llvm/build-all-targets'
123+
cheribuildProject(defaultArgs + [runTests : false,
124+
skipArchiving: false, skipTarball: false,
125+
uniqueId: env.JOB_NAME + "-LTO",
126+
extraArgs: ltoCheribuildArgs])
127+
}
128+
} else {
129+
cheribuildProject(defaultArgs)
130+
}

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# The LLVM Compiler Infrastructure
1+
# The CHERI LLVM Compiler Infrastructure
22

33
[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/llvm/llvm-project/badge)](https://securityscorecards.dev/viewer/?uri=github.com/llvm/llvm-project)
44
[![OpenSSF Best Practices](https://www.bestpractices.dev/projects/8273/badge)](https://www.bestpractices.dev/projects/8273)
@@ -8,7 +8,7 @@ Welcome to the LLVM project!
88

99
This repository contains the source code for LLVM, a toolkit for the
1010
construction of highly optimized compilers, optimizers, and run-time
11-
environments.
11+
environments, extended to support [CHERI](http://cheri-cpu.org).
1212

1313
The LLVM project has multiple components. The core of the project is
1414
itself called "LLVM". This contains all of the tools, libraries, and header

azure-pipelines.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
trigger:
2+
- cheriot
3+
4+
variables:
5+
isMain: $[eq(variables['Build.SourceBranch'], 'refs/heads/cheriot')]
6+
7+
jobs:
8+
############################################## Linux Builds
9+
- job:
10+
displayName: LLVM Linux Build
11+
pool:
12+
vmImage: ubuntu-20.04
13+
name: Portmeirion
14+
timeoutInMinutes: 300
15+
strategy:
16+
matrix:
17+
Clang Release:
18+
CC: clang
19+
CXX: clang++
20+
CXXFLAGS: -stdlib=libstdc++
21+
BuildType: Release
22+
BuildName: release
23+
Sanitizer:
24+
variables:
25+
- name: PKG_NAME
26+
value: cheriot-llvm-install-x86_64-linux-$(BuildName)
27+
steps:
28+
- checkout: self
29+
submodules: true
30+
31+
- script: |
32+
set -eo pipefail
33+
sudo apt-get update
34+
sudo apt-get install -y clang ninja-build lld
35+
sudo snap install cmake --classic
36+
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
37+
displayName: 'Install Build Dependencies'
38+
- task: CMake@1
39+
displayName: 'CMake'
40+
inputs:
41+
cmakeArgs: |
42+
../llvm -DCMAKE_BUILD_TYPE=$(BuildType) -DCMAKE_C_COMPILER=$(CC) -DCMAKE_CXX_COMPILER=$(CXX) -DCMAKE_CXX_FLAGS=$(CXXFLAGS) -DLLVM_USE_SANITIZER=$(Sanitizer) -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;lld" -DCMAKE_INSTALL_PREFIX=install -DLLVM_ENABLE_UNWIND_TABLES=NO -DLLVM_ENABLE_LLD=ON -DLLVM_TARGETS_TO_BUILD=RISCV -DLLVM_DISTRIBUTION_COMPONENTS="clang;clangd;lld;llvm-objdump;clang-tidy;clang-format" -G Ninja
43+
- script: |
44+
set -eo pipefail
45+
export NINJA_STATUS='%p [%f:%s/%t] %o/s, %es'
46+
ninja install-distribution
47+
workingDirectory: build
48+
displayName: 'Compile clang, clangd and lld'
49+
- script: |
50+
cp llvm/LICENSE.TXT build/install/LLVM-LICENSE.TXT
51+
- publish: build/install
52+
condition: and(succeeded(), eq(variables.isMain, 'true'))
53+
artifact: LLVM
54+
displayName: 'Uploading LLVM toolchain'

clang-tools-extra/clangd/unittests/SourceCodeTests.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -803,6 +803,9 @@ TEST(SourceCodeTests, isHeaderFile) {
803803
TEST(SourceCodeTests, isKeywords) {
804804
LangOptions LangOpts;
805805
LangOpts.CPlusPlus20 = true;
806+
// XXX CHERI FIXME: We require coroutines to be enabled separately from C++20
807+
// because we don't support them yet.
808+
LangOpts.Coroutines = true;
806809
EXPECT_TRUE(isKeyword("int", LangOpts));
807810
EXPECT_TRUE(isKeyword("return", LangOpts));
808811
EXPECT_TRUE(isKeyword("co_await", LangOpts));

clang/CMakeLists.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,10 @@ if(CLANG_ENABLE_ARCMT)
445445
set(CLANG_ENABLE_OBJC_REWRITER ON)
446446
endif()
447447

448+
# Make sure we don't accidentaly generate AS0 pointers for CHERI pure ABI
449+
add_definitions(-DLLVM_NO_DEFAULT_ADDRESS_SPACE)
450+
# TODO: add_definitions(-DLLVM_NO_DEFAULT_ADDRESS_SPACE_FOR_GLOBAL_VARS)
451+
448452
# This option is a stop-gap, we should commit to removing this as
449453
# soon as possible. See discussion:
450454
# https://discourse.llvm.org/t/rationale-for-removing-versioned-libclang-middle-ground-to-keep-it-behind-option/
@@ -470,6 +474,13 @@ mark_as_advanced(CLANG_ENABLE_HLSL)
470474

471475
add_subdirectory(utils/TableGen)
472476

477+
set(CREDUCE_CRASH_TESTCASE_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/utils/creduce_crash_testcase.py)
478+
configure_file(
479+
utils/creduce_crash_testcase.py.in
480+
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/creduce_crash_testcase.py
481+
@ONLY
482+
)
483+
473484
# Export CLANG_TABLEGEN_EXE for use by flang docs.
474485
set(CLANG_TABLEGEN_EXE "${CLANG_TABLEGEN_EXE}" CACHE INTERNAL "")
475486

clang/bindings/python/tests/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ endif()
2727
if(NOT LLVM_USE_SANITIZER STREQUAL "")
2828
set(RUN_PYTHON_TESTS FALSE)
2929
endif()
30+
list(FIND LLVM_USE_SANITIZER "Undefined" LLVM_USE_UBSAN_INDEX)
31+
if(NOT LLVM_USE_UBSAN_INDEX EQUAL -1)
32+
set(RUN_PYTHON_TESTS FALSE)
33+
endif()
3034

3135
# Tests fail on Windows, and need someone knowledgeable to fix.
3236
# It's not clear whether it's a test or a valid binding problem.

0 commit comments

Comments
 (0)