Skip to content

Commit

Permalink
LLVM/Clang 11 support.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-penev authored and vgvassilev committed Nov 18, 2020
1 parent ab20167 commit 213bfbd
Show file tree
Hide file tree
Showing 7 changed files with 278 additions and 38 deletions.
195 changes: 185 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ addons: &common-addons
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
- sourceline: 'deb https://apt.llvm.org/bionic/ llvm-toolchain-bionic-10 main'
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
- sourceline: 'deb https://apt.llvm.org/bionic/ llvm-toolchain-bionic-11 main'
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
- sourceline: 'deb https://apt.llvm.org/xenial/ llvm-toolchain-xenial-7 main'
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
- sourceline: 'deb https://apt.llvm.org/xenial/ llvm-toolchain-xenial-8 main'
Expand All @@ -26,6 +28,8 @@ addons: &common-addons
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
- sourceline: 'deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-10 main'
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
- sourceline: 'deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-11 main'
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
homebrew: &common-brew
packages: &common-brew-packages
- ccache
Expand Down Expand Up @@ -114,8 +118,8 @@ addons-6: &addons-6
]
homebrew: &brew-6
<<: *common-brew
packages: &brew-packages-6 [*common-brew-packages,
'llvm@6'
packages: &brew-packages-6 [*common-brew-packages
# 'llvm@6'
]
update: true

Expand Down Expand Up @@ -187,6 +191,23 @@ addons-10: &addons-10
]
update: true

addons-11: &addons-11
<<: *common-addons
apt: &apt-11
<<: *common-apt
packages: &apt-packages-11 [*common-apt-packages,
'clang-11',
'libclang-11-dev',
'llvm-11-tools',
'llvm-11-dev'
]
homebrew: &brew-11
<<: *common-brew
packages: &brew-packages-11 [*common-brew-packages,
'llvm' #llvm@11
]
update: true


before_cache:
- brew cleanup
Expand Down Expand Up @@ -229,7 +250,7 @@ jobs:
<<: *addons-5
homebrew:
<<: *brew-5
packages: [*common-brew, llvm@6]
packages: [*common-brew, llvm]
update: true

# Ubuntu, GCC 5
Expand Down Expand Up @@ -324,6 +345,10 @@ jobs:
compiler: clang
addons:
<<: *addons-6
homebrew:
<<: *brew-6
packages: [*common-brew, llvm]
update: true

# Ubuntu, GCC 5
- env: CLANG_RUNTIME=6.0 CXX=g++-5 CC=gcc
Expand Down Expand Up @@ -691,6 +716,105 @@ jobs:
<<: *apt-10
packages: [*apt-packages-10, 'clang-10', 'llvm-10-tools', 'g++-multilib', 'libc6-dbg']

##################### Clad for clang 11 #####################
# OSX 10.13, Clang and XCode 12
- os: osx
env: CLANG_RUNTIME=11 CXX=clang++ CC=clang
osx_image: xcode12
compiler: clang
addons:
<<: *addons-11

# Ubuntu, GCC 5
- env: CLANG_RUNTIME=11 CXX=g++-5 CC=gcc
compiler: gcc
dist: bionic
addons:
<<: *addons-11
apt:
<<: *apt-11
packages: [*apt-packages-11, 'g++-5', 'g++-5-multilib', 'libc6-dbg']

# GCC 6 Code Coverage
- env: CLANG_RUNTIME=11 CODE_COVERAGE=1 CXX=g++-6 CC=gcc BUILD_TYPE=Debug
compiler: gcc
dist: bionic
addons:
<<: *addons-11
apt:
<<: *apt-11
packages: [*apt-packages-11, 'g++-6', 'g++-6-multilib', 'libc6-dbg']

# GCC 8
- env: CLANG_RUNTIME=11 CXX=g++-8 CC=gcc
compiler: gcc
dist: bionic
addons:
<<: *addons-11
apt:
<<: *apt-11
packages: [*apt-packages-11, 'g++-8', 'g++-8-multilib', 'libc6-dbg']

# GCC 9
- env: CLANG_RUNTIME=11 CXX=g++-9 CC=gcc
compiler: gcc
dist: bionic
addons:
<<: *addons-11
apt:
<<: *apt-11
packages: [*apt-packages-11, 'g++-9', 'g++-9-multilib', 'libc6-dbg']

# Clang 4
- env: CLANG_RUNTIME=11 CXX=clang++-4.0 CC=clang-4.0
compiler: clang
dist: bionic
addons:
<<: *addons-11
apt:
<<: *apt-11
packages: [*apt-packages-11, 'clang-4.0', 'llvm-4.0-tools', 'g++-multilib', 'libc6-dbg']

# Clang 8
- env: CLANG_RUNTIME=11 CXX=clang++-8 CC=clang-8
dist: bionic
compiler: clang
addons:
<<: *addons-11
apt:
<<: *apt-11
packages: [*apt-packages-11, 'clang-8', 'g++-multilib', 'libc6-dbg']

# Clang 9
- env: CLANG_RUNTIME=11 CXX=clang++-9 CC=clang-9
dist: bionic
compiler: clang
addons:
<<: *addons-11
apt:
<<: *apt-11
packages: [*apt-packages-11, 'clang-9', 'llvm-9-tools', 'g++-multilib', 'libc6-dbg']

# Clang 10
- env: CLANG_RUNTIME=11 CXX=clang++-10 CC=clang-10
dist: bionic
compiler: clang
addons:
<<: *addons-11
apt:
<<: *apt-11
packages: [*apt-packages-11, 'clang-10', 'llvm-10-tools', 'g++-multilib', 'libc6-dbg']

# Clang 11
- env: CLANG_RUNTIME=11 CXX=clang++-11 CC=clang-11
dist: bionic
compiler: clang
addons:
<<: *addons-11
apt:
<<: *apt-11
packages: [*apt-packages-11, 'clang-11', 'llvm-11-tools', 'g++-multilib', 'libc6-dbg']


before_install:
- export
Expand All @@ -709,25 +833,74 @@ install:
- |
if [ $TRAVIS_OS_NAME == 'osx' ]; then
# Update openssl on osx because the current one is deprecated by python.
curl https://bootstrap.pypa.io/get-pip.py | sudo python
curl -L https://bootstrap.pypa.io/get-pip.py | sudo python
PATH="/usr/local/opt/ccache/libexec:$PATH"
export TRAVIS_PATH_TO_LLVM_BUILD=/usr/local/opt/llvm@${CLANG_RUNTIME}/
# Package llvm@5 is not supported on brew. We must install it from binary build.
if [ $CLANG_RUNTIME == '5.0' ]; then
export TRAVIS_PATH_TO_LLVM_BUILD=/usr/local/opt/llvm@5/
pushd /usr/local/opt
sudo curl https://releases.llvm.org/5.0.2/clang+llvm-5.0.2-x86_64-apple-darwin.tar.xz | sudo xz -d -c | sudo tar -x
sudo curl -L https://releases.llvm.org/5.0.2/clang+llvm-5.0.2-x86_64-apple-darwin.tar.xz | sudo xz -d -c | sudo tar -x
sudo rm -fr /usr/local/clang*
sudo mv clang+llvm-5.0.2-x86_64-apple-darwin/ llvm@5/
if [ ! -f $TRAVIS_PATH_TO_LLVM_BUILD/bin/FileCheck ]; then
# Use llvm@6 Filecheck
sudo ln -s /usr/local/opt/llvm\@6/bin/FileCheck ${TRAVIS_PATH_TO_LLVM_BUILD}bin/FileCheck
# Use llvm/llvm@10/llvm@6 Filecheck
if [ ! -f ${TRAVIS_PATH_TO_LLVM_BUILD}bin/FileCheck ]; then
if [ -f /usr/local/opt/llvm/bin/FileCheck ]; then
sudo ln -s /usr/local/opt/llvm/bin/FileCheck ${TRAVIS_PATH_TO_LLVM_BUILD}bin/FileCheck
elif [ -f /usr/local/opt/llvm\@10/bin/FileCheck ]; then
sudo ln -s /usr/local/opt/llvm\@10/bin/FileCheck ${TRAVIS_PATH_TO_LLVM_BUILD}bin/FileCheck
elif [ -f /usr/local/opt/llvm\@6/bin/FileCheck ]; then
sudo ln -s /usr/local/opt/llvm\@6/bin/FileCheck ${TRAVIS_PATH_TO_LLVM_BUILD}bin/FileCheck
fi
fi
popd
fi
# Package llvm@6
if [ $CLANG_RUNTIME == '6.0' ]; then
export TRAVIS_PATH_TO_LLVM_BUILD=/usr/local/opt/llvm@6/
pushd /usr/local/opt
sudo curl -L https://releases.llvm.org/6.0.0/clang+llvm-6.0.0-x86_64-apple-darwin.tar.xz | sudo xz -d -c | sudo tar -x
sudo rm -fr /usr/local/clang*
sudo mv clang+llvm-6.0.0-x86_64-apple-darwin/ llvm@6/
# Use llvm/llvm@10/llvm@6 Filecheck
if [ ! -f ${TRAVIS_PATH_TO_LLVM_BUILD}bin/FileCheck ]; then
if [ -f /usr/local/opt/llvm/bin/FileCheck ]; then
sudo ln -s /usr/local/opt/llvm/bin/FileCheck ${TRAVIS_PATH_TO_LLVM_BUILD}bin/FileCheck
elif [ -f /usr/local/opt/llvm\@10/bin/FileCheck ]; then
sudo ln -s /usr/local/opt/llvm\@10/bin/FileCheck ${TRAVIS_PATH_TO_LLVM_BUILD}bin/FileCheck
elif [ -f /usr/local/opt/llvm\@6/bin/FileCheck ]; then
sudo ln -s /usr/local/opt/llvm\@6/bin/FileCheck ${TRAVIS_PATH_TO_LLVM_BUILD}bin/FileCheck
fi
fi
popd
fi
# Package llvm@10 == llvm. FIXME: Remove when official brew package llvm@10 is released.
if [ $CLANG_RUNTIME == '10' ]; then
echo $CLANG_RUNTIME
export TRAVIS_PATH_TO_LLVM_BUILD=/usr/local/opt/llvm@10/
sudo ln -s /usr/local/opt/llvm /usr/local/opt/llvm@10
fi
# Package llvm@11 is not supported (yet) on brew. FIXME: Remove when official brew package is released.
if [ $CLANG_RUNTIME == '11' ]; then
export TRAVIS_PATH_TO_LLVM_BUILD=/usr/local/opt/llvm@11/
pushd /usr/local/opt
sudo curl -L https://github.com/llvm/llvm-project/releases/download/llvmorg-11.0.0-rc2/clang+llvm-11.0.0-rc2-x86_64-apple-darwin.tar.xz | sudo xz -d -c | sudo tar -x
sudo rm -fr /usr/local/clang*
sudo mv clang+llvm-11.0.0-rc2-x86_64-apple-darwin/ llvm@11/
sudo xcode-select --install
ls /Library/Developer/CommandLineTools/Packages/
sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_`sw_vers -productVersion | sed 's/\([0-9]*\.[0-9]*\).*/\1/'`.pkg -target /
# Use llvm/llvm@10/llvm@6 Filecheck
if [ ! -f ${TRAVIS_PATH_TO_LLVM_BUILD}bin/FileCheck ]; then
if [ -f /usr/local/opt/llvm/bin/FileCheck ]; then
sudo ln -s /usr/local/opt/llvm/bin/FileCheck ${TRAVIS_PATH_TO_LLVM_BUILD}bin/FileCheck
elif [ -f /usr/local/opt/llvm\@10/bin/FileCheck ]; then
sudo ln -s /usr/local/opt/llvm\@10/bin/FileCheck ${TRAVIS_PATH_TO_LLVM_BUILD}bin/FileCheck
elif [ -f /usr/local/opt/llvm\@6/bin/FileCheck ]; then
sudo ln -s /usr/local/opt/llvm\@6/bin/FileCheck ${TRAVIS_PATH_TO_LLVM_BUILD}bin/FileCheck
fi
fi
popd
fi
fi
if [ $TRAVIS_OS_NAME == 'linux' ]; then
Expand All @@ -739,7 +912,7 @@ install:
export TRAVIS_PATH_TO_LLVM_BUILD=/usr/lib/opt/llvm-${CLANG_RUNTIME}/
sudo mkdir -p /usr/lib/opt
pushd /usr/lib/opt
sudo curl https://releases.llvm.org/5.0.2/clang+llvm-5.0.2-x86_64-linux-gnu-ubuntu-${UNIX_DISTRO}.tar.xz | sudo xz -d -c | sudo tar -x
sudo curl -L https://releases.llvm.org/5.0.2/clang+llvm-5.0.2-x86_64-linux-gnu-ubuntu-${UNIX_DISTRO}.tar.xz | sudo xz -d -c | sudo tar -x
sudo rm -fr /usr/lib/clang*
sudo mv clang+llvm-5.0.2-x86_64-linux-gnu-ubuntu-${UNIX_DISTRO}/ llvm-5.0/
if [ ! -f $TRAVIS_PATH_TO_LLVM_BUILD/bin/FileCheck ]; then
Expand All @@ -753,7 +926,7 @@ install:
export TRAVIS_PATH_TO_LLVM_BUILD=/usr/lib/opt/llvm-${CLANG_RUNTIME}/
sudo mkdir -p /usr/lib/opt
pushd /usr/lib/opt
sudo curl https://releases.llvm.org/6.0.1/clang+llvm-6.0.1-x86_64-linux-gnu-ubuntu-${UNIX_DISTRO}.tar.xz | sudo xz -d -c | sudo tar -x
sudo curl -L https://releases.llvm.org/6.0.1/clang+llvm-6.0.1-x86_64-linux-gnu-ubuntu-${UNIX_DISTRO}.tar.xz | sudo xz -d -c | sudo tar -x
sudo rm -fr /usr/lib/clang*
sudo mv clang+llvm-6.0.1-x86_64-linux-gnu-ubuntu-${UNIX_DISTRO}/ llvm-6.0/
if [ ! -f $TRAVIS_PATH_TO_LLVM_BUILD/bin/FileCheck ]; then
Expand All @@ -776,6 +949,8 @@ before_script:
- cmake --version
- $CC --version
- $CXX --version
- xz --version
- tar --version
- mkdir obj && cd obj
- echo "Use Clang/LLVM in $TRAVIS_PATH_TO_LLVM_BUILD"
- echo "Building clad in `[[ -z "$BUILD_TYPE" ]] && echo RelWithDebInfo || echo $BUILD_TYPE`"
Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
## Define clad supported version of clang and llvm

set(CLANG_MIN_SUPPORTED 5.0)
set(CLANG_MAX_SUPPORTED 10.0.1)
set(CLANG_MAX_SUPPORTED 11.0.1)
set(LLVM_MIN_SUPPORTED 5.0)
set(LLVM_MAX_SUPPORTED 10.0.1)
set(LLVM_MAX_SUPPORTED 11.0.1)

if (NOT DEFINED Clang_DIR)
set(Clang_DIR ${LLVM_DIR})
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ Clad is a plugin for the Clang compiler. It relies on the Clang to build the AST
* Finally, derivative's AST is [passed](https://github.com/vgvassilev/clad/blob/a264195f00792feeebe63ac7a8ab815c02d20eee/tools/ClangPlugin.cpp#L145) for further processing by Clang compiler (LLVM IR generation, optimizations, machine code generation, etc.).
## How to install
At the moment, only LLVM/Clang 5.0.x - 10.0.x are supported.
At the moment, LLVM/Clang 5.0.x - 11.0.x are supported.
### Building from source (example was tested on Ubuntu 18.04 LTS)
```
Expand Down
2 changes: 1 addition & 1 deletion docs/ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ described first.

External Dependencies
---------------------
* Clad now works with clang-5.0 to clang-10
* Clad now works with clang-5.0 to clang-11

Forward Mode & Reverse Mode
---------------------------
Expand Down
Loading

0 comments on commit 213bfbd

Please sign in to comment.