Saturday, May 13, 2017

Installing Gitlab Server

Let me walk through the steps.
  1. sudo apt-get install curl openssh-server ca-certificates
  2. curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash 
  3. sudo apt-get install gitlab-ce
  4. In file /etc/gitlab/gitlab.rb
    1. nginx['listen_port'] = 8081
    2. external_url 'http://mithun.cse.iitm.ac.in' 
  5. sudo gitlab-ctl reconfigure
  6. Go to localhost or mithun.cse.iitm.ac.in to set to root's password.
  • Note: We tried setting up as gitlab.mithun.cse.iitm.ac.in but wasn't able to as mithun.cse.iitm.ac.in was already running an apache2 webserver from 80 port.
  • Note: We decided to run on 8081 instead
  • Note: We could have setup as "http://mithun.cse.iitm.ac.in/gitlab" --  I was not in favour of it.
If someone knows how to setup gitlab it as subdomain without affecting the existing webserver. Do let us know. Thank you.

Install custom vimrc file

There are basically only two step. Download and copy it in your home dir and save it as .vimrc. But let me walk thorough.

  1. cd ~
  2. wget https://raw.githubusercontent.com/pallavagarwal07/_vim/master/_vimrc
  3. mv _vimrc .vimrc
  4. vim
  5. :PlugInstall
If there is error in the 4th step. Check that you have git as well as curl installed already. Do you get error still?, then.

curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
    https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
 
 
And repeat the steps 4 and 5.

Thanks to Pallav


Saturday, April 1, 2017

Resolve Linux screen freeze due to external monitor

My Laptop has  Linux mint 18 installed. Here is the thing I wanted to do. There is an extra monitor I wanted use it as a secondary screen (or dual display) and set the monitor's display as my primary screen.

However, the max resolution of the laptop(1366x768 16:9 ) and max resolution of the the monitor(1366x768 16:9 ) are different. So, whenever I connect the VGA cable of the monitor to my laptop(through an HDMI converter), it was just mirroring the screen with a low resolution 1024x768. And when is change the resolution to 1366x768 16:9 (or any other) the screen freezes. And you can not do anything. Either you can hard shutdown or reboot from here. Only the mouse pointer movement is seen but the clicks are not recognized . Keyboad's cap/num lights works but keys don't work. Only thing I can do is long press the power button till it is shutdown. Other option is to go to tty(Ctrl + Alt + F1 ) and login to reboot it. This seems like a bug. But whose OS/Kernal /Cinnamon - don't know the root cause.

These are my atttempts / understanding:
  • Updating Linux mint - did NOT work.
  • Updating Kernal - did NOT work.
  • The secondary monitor is not hot pluggable in Linux mint(or in general Linux or due to HDMI - VGA convertion -- I don't understand it yet). 
  • Finally the below steps did work.
Steps to solve the issue.
  • Set the secondary monitor to primary in display option.
  • Shutdown the machine.
  • Make the VGA-HDMI connected to the machine.
  • Start the machine.
  • Go to the display option, changed the external monitor to max resolution [1366x768 16:9]. 
  • Cool. All done and Enjoy the large screen ;-)  

Monday, January 23, 2017

Installing and Using LLVM Clang on Linux

Here are the specs (Hardware and software) of my machine
RAM: 8GB
Proc : Intel Core i7-4510U @ 2.00GHz
Linux mint 18 Cinnamon
word size - 64 bit
Kernel - 4.4.0-21-generic
swap Size - 10GB
HDD :  150GB

There are two ways of installing
1. Install from apt-get
2. Building from src files using tar.gz
Make sure to check this requirements.
GNU Make3.79, 3.79.1 Makefile/build processor
GCC >=4.8.0 C/C++ compiler
python >=2.7 Automated test suite
zlib >=1.2.3.4 Compression library //it worked without this

1. Install from apt-get

 $ sudo apt-get clang-3.9 llvm-3.9

Reference:  http://apt.llvm.org

2.  Building LLVM 3.9.1 from Source

  1. Download two tar file for llvm & clang from here
  2. Extract both the files inside some folder // say llvm
  3. Rename llvm-3.9.1.src folder as llvm-3.9 //LLVM_SRC
  4. Rename cfe-3.9.1.src folder as clang and move inside folder llvm-3.9/tools
  5. Create a folder llvm/llvm-build and cd llvm-build // LLVM_OBJ
  6. cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE="Release" -DLLVM_ENABLE_ASSERTIONS=On /home/rajz/install/llvm/llvm-3.9
  7. // after some time
  8. make -j2
  9. //after some more time
  10. sudo make install
  11. opt --version 
  12. clang --version 
  13. //Done
References: 
1. http://llvm.org/docs/GettingStarted.html
2. https://www.youtube.com/watch?v=4iVc204omI0
3. http://llvm.org/docs/CMake.html

Writing a Sample Pass using LLVM
1. Source folder for LLVM:
    ~/install/llvm/llvm-3.9
2. Build folder for LLVM:
    ~/install/llvm/llvm-build
3. Create a CMakeLists.txt file as below
   add_llvm_loadable_module( LLVMSample
        Sample.cpp
        PLUGIN_TOOL
        opt
        )
4. Create the Sample.cpp as below
#include "llvm/IR/Function.h"
#include "llvm/Pass.h"
#include "llvm/Support/raw_ostream.h"
using namespace llvm;
namespace {
struct Sample : public FunctionPass {
  static char ID;
  Sample() : FunctionPass(ID) {}

  bool runOnFunction(Function &F) override {
    errs() << "Sample: ";
    errs().write_escaped(F.getName()) << '\n';
    return false;
  }
}; // end of struct Sample
} // end of anonymous namespace

char Sample::ID = 0;
static RegisterPass X("sample", "Sample Hello World Pass ",
                              false /* Only looks at CFG */,
                              false /* Analysis Pass */);
5. Sample pass folders at:
    ~/install/llvm/llvm-3.9/lib/Analysis/Sample (contains Sample.cpp and CMakeLists.txt)
    ~/install/llvm/llvm-build/lib/Analysis/Sample (contains only the CMakeLists.txt)
6. Append a line in ~/install/llvm/llvm-3.9/lib/Analysis/CMakeLists.txt

       add_subdirectory(Sample)

7. Created shared library at ~/install/llvm/llvm-build/lib/LLVMSample.so

       $ cd ~/install/llvm/llvm-build
       $ make

8. To run analysis on a test1.c program:
    $ clang -S -O0 -emit-llvm test1.c -o test1.ll
    $ opt -load ~/install/llvm/llvm-build/lib/LLVMSample.so -disable-output -sample test1.ll

Reference
1. http://llvm.org/docs/WritingAnLLVMPass.html
2. AMR, PA TAs

Installing Gitlab Server

Let me walk through the steps. sudo apt-get install curl openssh-server ca-certificates curl -sS https://packages.gitlab.com/install/...