Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
Update build clang/llvm/lldb 3.9 (#14096)
Browse files Browse the repository at this point in the history
Update build scripts, docs and build pipeline docker images to clang/llvm/lldb 3.9
  • Loading branch information
mikem8361 committed Sep 29, 2017
1 parent 1ed2739 commit 32c4673
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 97 deletions.
8 changes: 4 additions & 4 deletions Documentation/building/buildinglldb.md
Expand Up @@ -19,15 +19,15 @@ Building LLDB
git clone http://llvm.org/git/lldb.git
```

2. Checkout the "release_38" branches in llvm/clang/lldb:
2. Checkout the "release_39" branches in llvm/clang/lldb:

```
cd $HOME/llvm
git checkout release_38
git checkout release_39
cd $HOME/llvm/tools/clang
git checkout release_38
git checkout release_39
cd $HOME/llvm/tools/lldb
git checkout release_38
git checkout release_39
```

3. Install the prerequisites:
Expand Down
88 changes: 16 additions & 72 deletions Documentation/building/linux-instructions.md
Expand Up @@ -18,10 +18,10 @@ Toolchain Setup
Install the following packages for the toolchain:

- cmake
- llvm-3.5 (llvm-3.9 for ARM cross build)
- clang-3.5 (clang-3.9 for ARM cross build)
- lldb-3.6
- lldb-3.6-dev
- llvm-3.9
- clang-3.9
- lldb-3.9
- liblldb-3.9-dev
- libunwind8
- libunwind8-dev
- gettext
Expand All @@ -33,33 +33,28 @@ Install the following packages for the toolchain:
- libkrb5-dev
- libnuma-dev (optional, enables numa support)

In order to get lldb-3.6 on Ubuntu 14.04, we need to add an additional package source:
In order to get clang-3.9, llvm-3.9 and lldb-3.9 on Ubuntu 14.04, we need to add an additional package source:

```
ellismg@linux:~$ echo "deb http://llvm.org/apt/trusty/ llvm-toolchain-trusty-3.6 main" | sudo tee /etc/apt/sources.list.d/llvm.list
ellismg@linux:~$ wget -O - http://llvm.org/apt/llvm-snapshot.gpg.key | sudo apt-key add -
ellismg@linux:~$ sudo apt-get update
```

If you are going to cross build for ARM, you need llvm-3.9 and clang-3.9 and please add below package source instead for Ubuntu 14.04.
```
hqueue@linux:~$ echo "deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-3.9 main" | sudo tee /etc/apt/sources.list.d/llvm.list
hqueue@linux:~$ wget -O - http://llvm.org/apt/llvm-snapshot.gpg.key | sudo apt-key add -
hqueue@linux:~$ sudo apt-get update
```
~$ echo "deb http://llvm.org/apt/trusty/ llvm-toolchain-trusty-3.9 main" | sudo tee /etc/apt/sources.list.d/llvm.list
~$ wget -O - http://llvm.org/apt/llvm-snapshot.gpg.key | sudo apt-key add -
~$ sudo apt-get update

For other version of Debian/Ubuntu, please visit http://apt.llvm.org/.

Then install the packages you need:

```
ellismg@linux:~$ sudo apt-get install cmake llvm-3.5 clang-3.5 lldb-3.6 lldb-3.6-dev libunwind8 libunwind8-dev gettext libicu-dev liblttng-ust-dev libcurl4-openssl-dev libssl-dev uuid-dev libnuma-dev libkrb5-dev
```
~$ sudo apt-get install cmake llvm-3.9 clang-3.9 lldb-3.9 liblldb-3.9-dev libunwind8 libunwind8-dev gettext libicu-dev liblttng-ust-dev libcurl4-openssl-dev libssl-dev uuid-dev libnuma-dev libkrb5-dev

The lldb 3.9 package needs a lib file symbolic link fixed:

cd /usr/lib/llvm-3.9/lib
sudo ln -s ../../x86_64-linux-gnu/liblldb-3.9.so.1 liblldb-3.9.so.1

You now have all the required components.

If you are using Fedora, then you will need to install the following packages:

`$ sudo dnf install llvm cmake clang lldb-devel libunwind-devel lttng-ust-devel libuuid-devel libicu-devel numactl-devel`
~$ sudo dnf install llvm cmake clang lldb-devel libunwind-devel lttng-ust-devel libuuid-devel libicu-devel numactl-devel

Git Setup
---------
Expand Down Expand Up @@ -127,57 +122,6 @@ index 1ed3dbf..c643032 100644
}
```

How to enable -O3 optimization level for ARM/Linux
==================================================

If you are using clang-3.9, -O3 optimization is enabled as default and you can skip this section.
If you are using older version of clang, please follow instructions in this section to enable -O3 optimization.
Currently, we can build coreclr with -O1 flag of clang in release build mode for Linux/ARM without any bugfix of llvm-3.6. This instruction is to enable -O3 optimization level of clang on Linux/ARM by fixing the bug of llvm.

First, download latest version from the clang-3.6/llvm-3.6 upstream:
```
lgs@ubuntu cd /work/dotnet/
lgs@ubuntu wget http://llvm.org/releases/3.6.2/llvm-3.6.2.src.tar.xz
lgs@ubuntu tar xJf llvm-3.6.2.src.tar.xz
lgs@ubuntu cd ./llvm-3.6.2.src/tools/
lgs@ubuntu wget http://llvm.org/releases/3.6.2/cfe-3.6.2.src.tar.xz
lgs@ubuntu tar xJf cfe-3.6.2.src.tar.xz
lgs@ubuntu mv cfe-3.6.2.src clang
```

Second, expand the coverage of the upstream patch by:
https://bugs.launchpad.net/ubuntu/+source/llvm-defaults/+bug/1584089

Third, build clang-3.6/llvm-3.6 source as following:
```
lgs@ubuntu cmake -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD="all" -DCMAKE_INSTALL_PREFIX=~/llvm-3.6.2 \
-DLLVM_BUILD_LLVM_DYLIB=1 -DLLDB_DISABLE_LIBEDIT=1 -DLLDB_DISABLE_CURSES=1 -DLLDB_DISABLE_PYTHON=1 \
-DLLVM_ENABLE_DOXYGEN=0 -DLLVM_ENABLE_TERMINFO=0 -DLLVM_INCLUDE_EXAMPLES=0 -DLLVM_BUILD_RUNTIME=0 \
-DLLVM_INCLUDE_TESTS=0 -DPYTHON_INCLUDE_DIR=/usr/include/python2.7 /work/dotnet/llvm-3.6.2.src
lgs@ubuntu
lgs@ubuntu sudo ln -sf /usr/bin/ld /usr/bin/ld.gold
lgs@ubuntu time make -j8
lgs@ubuntu time make -j8 install
lgs@ubuntu
lgs@ubuntu sudo apt-get remove clang-3.6 llvm-3.6
lgs@ubuntu vi ~/.bashrc (or /etc/profile)
# Setting new clang/llvm version
export PATH=$HOME/llvm-3.6.2/bin/:$PATH
export LD_LIBRARY_PATH=$HOME/llvm-3.6.2/lib:$LD_LIBRARY_PATH
```

For Ubuntu 14.04 X64 users, they can easily install the fixed clang/llvm3.6 package with "apt-get" command from the "ppa:leemgs/dotnet" Ubuntu repository, without the need to execute the above 1st, 2nd, and 3rd step.
```
lgs@ubuntu sudo add-apt-repository ppa:leemgs/dotnet
lgs@ubuntu sudo apt-get update
lgs@ubuntu sudo apt-get install clang-3.6 llvm-3.6 lldb-3.6
```

Finally, let's build coreclr with updated clang/llvm. If you meet a lldb related error message at build-time, try to build coreclr with "skipgenerateversion" option.
```
lgs@ubuntu time ROOTFS_DIR=/work/dotnet/rootfs-coreclr/arm ./build.sh arm release clean cross
```

Additional optimization levels for ARM/Linux: -Oz and -Ofast
============================================================

Expand Down
15 changes: 2 additions & 13 deletions build.sh
Expand Up @@ -878,19 +878,8 @@ fi

# Set default clang version
if [[ $__ClangMajorVersion == 0 && $__ClangMinorVersion == 0 ]]; then
if [ $__CrossBuild == 1 ]; then
if [[ "$__BuildArch" == "arm" || "$__BuildArch" == "armel" ]]; then
__ClangMajorVersion=3
__ClangMinorVersion=9
else
__ClangMajorVersion=3
__ClangMinorVersion=6
fi

else
__ClangMajorVersion=3
__ClangMinorVersion=5
fi
__ClangMajorVersion=3
__ClangMinorVersion=9
fi

if [[ "$__BuildArch" == "armel" ]]; then
Expand Down
2 changes: 1 addition & 1 deletion buildpipeline/DotNet-CoreClr-Trusted-Linux-Crossbuild.json
Expand Up @@ -360,7 +360,7 @@
"value": "microsoft/dotnet-buildtools-prereqs"
},
"DockerTag": {
"value": "ubuntu1404_cross_prereqs_v1",
"value": "ubuntu-14.04-cross-0cd4667-20170319080304",
"allowOverride": true
},
"CloudDropAccountName": {
Expand Down
4 changes: 2 additions & 2 deletions buildpipeline/DotNet-CoreClr-Trusted-Linux.json
Expand Up @@ -324,7 +324,7 @@
"value": "microsoft/dotnet-buildtools-prereqs"
},
"DockerTag": {
"value": "debian82_prereqs_2",
"value": "centos-7-34f1db9-20171620021620",
"allowOverride": true
},
"CloudDropAccountName": {
Expand Down Expand Up @@ -449,4 +449,4 @@
"state": "wellFormed",
"revision": 418097633
}
}
}
4 changes: 2 additions & 2 deletions buildpipeline/pipelines.json
Expand Up @@ -13,7 +13,7 @@
{
"Name": "DotNet-CoreClr-Trusted-Linux",
"Parameters": {
"DockerTag": "rhel-7-dd8aa64-20170320090348",
"DockerTag": "centos-7-34f1db9-20171620021620",
"Rid": "linux"
},
"ReportingParameters": {
Expand Down Expand Up @@ -110,7 +110,7 @@
{
"Name": "DotNet-CoreClr-Trusted-Linux-Crossbuild",
"Parameters": {
"DockerTag": "ubuntu-14.04-cross-0cd4667-20172211042239",
"DockerTag": "ubuntu-14.04-cross-0cd4667-20170319080304",
"Architecture": "arm",
"Rid": "linux"
},
Expand Down
6 changes: 3 additions & 3 deletions src/ToolBox/SOS/lldbplugin/CMakeLists.txt
Expand Up @@ -63,7 +63,7 @@ if (CLR_CMAKE_PLATFORM_DARWIN)
else()
set(MESSAGE_MODE WARNING)
endif()
message(${MESSAGE_MODE} "Cannot find lldb-3.5, lldb-3.6, lldb-3.8, lldb-3.9 or lldb-4.0. Try installing lldb-3.6-dev (or the appropriate package for your platform)")
message(${MESSAGE_MODE} "Cannot find lldb-3.5, lldb-3.6, lldb-3.8, lldb-3.9 or lldb-4.0. Try installing liblldb-3.9-dev (or the appropriate package for your platform)")
return()
endif()

Expand All @@ -84,9 +84,9 @@ find_path(LLDB_H "lldb/API/LLDB.h" PATHS "/usr/lib/llvm-3.5/include")

if(LLDB_H STREQUAL LLDB_H-NOTFOUND)
if(REQUIRE_LLDBPLUGIN)
message(FATAL_ERROR "Cannot find LLDB.h. Try installing lldb-3.6-dev (or the appropriate package for your platform)")
message(FATAL_ERROR "Cannot find LLDB.h. Try installing liblldb-3.9-dev (or the appropriate package for your platform)")
else()
message(WARNING "Cannot find LLDB.h Try installing lldb-3.6-dev (or the appropriate package for your platform)")
message(WARNING "Cannot find LLDB.h Try installing liblldb-3.9-dev (or the appropriate package for your platform)")
endif()
return()
endif()
Expand Down

0 comments on commit 32c4673

Please sign in to comment.