Friday, November 29, 2013

How to build and setup LLVM Scan Analyzer for Linaro Toolchain

Downloading and Installing Clang-Analyzer

Download LLVM, Clang, Clang-tools-extra and Compiler-RT from - http://llvm.org/releases/download.html.

  1. Extract the LLVM tarball. I'm going to use the variable LLVM to point to this directory going forward.
  2. Go to $LLVM/tools/src. Extract the clang release tarball. Rename the extracted directory as clang
  3. Go to $LLVM/tools/src/clang/tools/. Extract the clang-tools-extra and rename it as extra.
  4. Go to $LLVM/projects/. Extract the compiler-rt tarball and rename it as compiler-rt.
Note! - If you don't extract the clang, clang-tools-extra and compiler-rt in the respectively directories, it will not build them by default.

For more information look at http://clang.llvm.org/get_started.html. The instructions are for svn but they apply for the release tarballs as well.

Building and Installing Clang

Go to $LLVM directory and then you can configure, build and install clang.
 $ ./configure $ make $ make install
If you want to install clang in a specific directory then pass --prefix= to configure. Usually, I use /proj/staging/ to stage my builds and so, I usually build as ./configure --prefix=/proj/staging/llvm

Note! make install will not install scan-build and scan-view. They remain in $LLVM/tools/clang/tools/scan-build and $LLVM/tools/clang/tools/scan-view. So you will need to add these directories into your path.

Downloading and Installing Linaro Toolchain

Download Linaro Toolchain from - https://launchpad.net/linaro-toolchain-binaries/. Extract it to a directory of choice. I usually place it in /proj/staging/linaro-gcc. Next add the /proj/staging/linaro-gcc/bin directory to your PATH variable.

Running clang-analyzer with linaro toolchain

Now follow usual steps to cross compile your program. To enable scan-build make sure you run make via scan-build as shown in my previous post on running clang-analyzer.

Monday, November 18, 2013

Running a custom PHP application on the Bitnami Wordpress stack

Being an embedded software engineer, I usually go a bit spaced out when reading about things like wordpress, bitnami stacks etc.. I have dabbled on making small intranet sites with Ruby on Rails but have never looked at PHP.

Today, I downloaded a wordpress installer from bitnami and 10 minutes later I had a small site running on my laptop. I had a look at the various plugins and installed a couple as well.

Intrigued, I wanted to spend a little time learning PHP. So, I created a custom app by following the instructions from Bitnami's Wiki topic and started reading the tutorial from w3cschools. So far PHP doesn't seem very complex and I'm being to understand why it's so popular.

Steps to create a custom app


  1. Create a new folder in the apps directory, say 'test'.
  2. Copy over the conf folder from the wordpress directory into the apps/test folder. We will need to edit the configurations inside them
  3. Search and replace 'wordpress' with 'test'. Typically, these are directory paths
  4. Create a htdocs folder in apps/test. This will hold our application. For now create an index.php and echo a 'Hello World'.
  5. Now, we need to edit the apache server configuration files so that they can find the app. Bitnami makes it quite simple by keeping a configuration file in apache2/conf/bitnami with the name bitnami-apps-prefix.conf. Edit this file and copy the line pointing to wordpress directory to a new line and change from 'wordpress' to 'test'.
  6. Restart Apache and that's it!