Build process for cflow & cadvisor Linux open source projects

I chose the cflow and cadvisor Linux open source projects for documenting the package build & installation process and listed some of the things I encountered along the way.  Both package installations were done on a Fedora 25 virtual machine.

cflow

An open source project licensed by GNU that charts control flow within source code.

Build & install steps:

  1. Download cflow-1.4.tar.bz2 from http://directory.fsf.org/wiki/Cflow ‘Download’ link
  2. Unpack tar file:
    tar xvf cflow-1.4.tar.bz2
  3. Change to install directory: cd cflow-1.4
  4. Create make files:
    ./configure
  5. Compile package:
    make
  6. Switch user to root:
    su root
  7. Install programs/data files/documentation:
    make install
  8. Verify that installation completed correctly: make installcheck

All 21 tests were successful.

Testing newly installed cflow software:

I tested cflow with the whoami.c sample file from the cflow manual: https://www.gnu.org/software/cflow/manual/cflow.html#Quick-Start

Run:
cflow whoami.c

Output:

main() :
    fprintf()
    who_am_i() :
        getpwuid()
        geteuid()
        getenv()
        fprintf()
        printf()

cflow package installation was successful.  No extra dependencies were required during the installation process.  I tried this software with C++ code and it also works very well.

cadvisor

This project is licensed under the Apache License Version 2.0 and provides resource usage and performance characteristics for running containers.  It also has native support for Docker, an open source project for containerization.  Here is a previous blog of mine on Docker.

Github open source code link: https://github.com/google/cadvisor

Installing required dependencies:

GO language – open-source programming language initially developed by Google.  Installation instructions on Linux can be found here: http://ask.xmodulo.com/install-go-language-linux.html (instructions for both Ubuntu and Fedora are included).  Total download size is approximately 49M.

Once GO language is installed (cAdvisor requires Go 1.6+ to build), I followed the build & testing instructions here: https://github.com/google/cadvisor/blob/master/docs/development/build.md

At this time, I have installed go version 1.7.4 linux/amd64.

Issues I encountered:

After running ‘make build’ from the $GOPATH/src/github.com/google/cadvisor path, the cadvisor build failed:

building assets
building binaries
building cadvisor
/usr/lib/golang/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/usr/bin/ld: cannot find -lpthread
/usr/bin/ld: cannot find -ldl
/usr/bin/ld: cannot find -lc
collect2: error: ld returned 1 exit status
Makefile:38: recipe for target 'build' failed
make: *** [build] Error 2

I tried running ‘make test’ for only unit tests – all existing test files passed ok.  I’ve tested gcc with another c program using the -lpthread argument and it works fine.  So I investigated further to figure out what the issue was.

Steps I took to resolve the issue:

The Linux version I’m running is 4.8.6-300.fc25.x86_64 GNU/Linux (‘uname -or‘), running on a Fedora release 25 (‘cat /etc/fedora-release‘).

After searching online for ‘/usr/lib/golang/pkg/tool/linux_amd64/link: running gcc failed’, I came across this github issue https://github.com/golang/go/issues/13114.  It mentions here that the GOROOT environment variable being set can cause issues on any system other than Windows.

So I checked if GOROOT was set:

echo $GOROOT

/usr/lib/golang

And unset it:

unset GOROOT

Running ‘make build’ again still fails, so it did not fix the issue.

From the Makefile at line 38:

build: assets
@echo ">> building binaries"
@./build/build.sh

It seems that the issue has to do with the c compiler linking, which is why I thought unsetting GOROOT might fix it.  After more digging, I found the fix for this issue here https://github.com/kubernetes/minikube/issues/585

The fix for this was installing glibc-static on my system:

dnf install @development-tools
dnf install glibc-static

Build is now successful.
make build

building assets
building binaries
building cadvisor

Also worth noting, after installing glibc-static, I set GOROOT back to the original /usr/lib/golang location set GOROOT=/usr/lib/golang and the ‘make build’ still worked.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s