-
Notifications
You must be signed in to change notification settings - Fork 1
Building Debian with Clang: tests
nonas edited this page May 4, 2014
·
32 revisions
sudo apt-get install sbuild
sudo sbuild-update --keygen
sudo sbuild-adduser $LOGNAME
Log out and back in
sudo sbuild-createchroot --make-sbuild-tarball=/var/lib/sbuild/sid-amd64.tar.gz sid /mnt/ito/chroot http://http.debian.net/debian
Update: (apt-get update, dist-upgrade, clean, autoclean, and autoremove)
sudo sbuild-update -udcar sid-amd64-sbuild
Get a shell in sbuild source:
sudo sbuild-shell source:sid-amd64-sbuild
We now are root in the chroot. Install Clang:
apt-get install --no-install-recommends clang-3.4
Let's see what we have about gcc in /usr/bin
:
# ls -l /usr/bin | grep -e gcc -e g++ -e cpp
-rwxr-xr-x 1 root root 428 Jun 12 2013 c89-gcc
-rwxr-xr-x 1 root root 454 Jun 12 2013 c99-gcc
lrwxrwxrwx 1 root root 5 Feb 13 16:26 clang++ -> clang
lrwxrwxrwx 1 root root 7 Jan 17 09:19 cpp -> cpp-4.8
-rwxr-xr-x 1 root root 772208 Feb 17 23:22 cpp-4.8
lrwxrwxrwx 1 root root 7 Jan 17 09:19 g++ -> g++-4.8
-rwxr-xr-x 1 root root 772880 Feb 17 23:26 g++-4.8
lrwxrwxrwx 1 root root 7 Jan 17 09:19 gcc -> gcc-4.8
-rwxr-xr-x 1 root root 772208 Feb 17 23:28 gcc-4.8
-rwxr-xr-x 1 root root 24736 Feb 17 23:28 gcc-ar-4.8
-rwxr-xr-x 1 root root 24704 Feb 17 23:28 gcc-nm-4.8
-rwxr-xr-x 1 root root 24704 Feb 17 23:28 gcc-ranlib-4.8
lrwxrwxrwx 1 root root 7 Jan 17 09:19 x86_64-linux-gnu-cpp -> cpp-4.8
lrwxrwxrwx 1 root root 7 Feb 17 23:22 x86_64-linux-gnu-cpp-4.8 -> cpp-4.8
lrwxrwxrwx 1 root root 7 Jan 17 09:19 x86_64-linux-gnu-g++ -> g++-4.8
lrwxrwxrwx 1 root root 7 Feb 17 23:26 x86_64-linux-gnu-g++-4.8 -> g++-4.8
lrwxrwxrwx 1 root root 7 Jan 17 09:19 x86_64-linux-gnu-gcc -> gcc-4.8
lrwxrwxrwx 1 root root 7 Feb 17 23:28 x86_64-linux-gnu-gcc-4.8 -> gcc-4.8
lrwxrwxrwx 1 root root 10 Feb 17 23:28 x86_64-linux-gnu-gcc-ar-4.8 -> gcc-ar-4.8
lrwxrwxrwx 1 root root 10 Feb 17 23:28 x86_64-linux-gnu-gcc-nm-4.8 -> gcc-nm-4.8
lrwxrwxrwx 1 root root 14 Feb 17 23:28 x86_64-linux-gnu-gcc-ranlib-4.8 -> gcc-ranlib-4.8
We need to put gcc stuff on hold:
# dpkg --get-selections | grep -e gcc -e cpp -e g++
cpp install
cpp-4.8 install
g++ install
g++-4.8 install
gcc install
gcc-4.8 install
gcc-4.8-base:amd64 install
libgcc-4.8-dev:amd64 install
libgcc1:amd64 install
libjsoncpp0 install
Let's get rid of gcc (script adapted from clang.debian.net), put the following inside a file:
echo "Replace gcc, g++ & cpp by clang"
cd /usr/bin
VERSIONS="4.8"
for VERSION in $VERSIONS; do
rm g++-$VERSION gcc-$VERSION cpp-$VERSION
ln -s clang++ g++-$VERSION
ln -s clang gcc-$VERSION
ln -s clang cpp-$VERSION
done
rm g++ gcc cpp
ln -s clang++ g++
ln -s clang gcc
ln -s clang cpp
echo "Block the installation of new gcc version"
echo "cpp hold"|dpkg --set-selections
echo "cpp-4.8 hold"|dpkg --set-selections
echo "g++ hold"|dpkg --set-selections
echo "g++-4.8 hold"|dpkg --set-selections
echo "gcc hold"|dpkg --set-selections
echo "gcc-4.8 hold"|dpkg --set-selections
echo "gcc-4.8-base:amd64 hold"|dpkg --set-selections
echo "Check if gcc, g++ & cpp are actually clang"
echo "* gcc:"
gcc --version|grep clang
echo "* g++:"
g++ --version|grep clang
echo "* cpp:"
cpp --version|grep clang
Change the file attributes and run it:
chmod u+x grog.sh
./grog.sh
Output should look like:
Replace gcc, g++ & cpp by clang
Block the installation of new gcc version
Check if gcc, g++ & cpp are actually clang
* gcc:
Debian clang version 3.4-2 (tags/RELEASE_34/final) (based on LLVM 3.4)
* g++:
Debian clang version 3.4-2 (tags/RELEASE_34/final) (based on LLVM 3.4)
* cpp:
Debian clang version 3.4-2 (tags/RELEASE_34/final) (based on LLVM 3.4)
end session: schroot -e -c session:sid-amd64-sbuild- [tab]