Strange errors when compiling Erlang R1304 on NetBSD

Posted by marian on June 03, 2010

Well I dindn’t expect this. If you are trying to compiler Erlang on this OS, this might save you some time.

If you get the the following error sequence:


make: "/home/acces/otp_src_R13B04/Makefile" line 88: Missing dependency operator
make: "/home/acces/otp_src_R13B04/Makefile" line 89: Missing dependency operator
make: "/home/acces/otp_src_R13B04/Makefile" line 91: Need an operator
make: "/home/acces/otp_src_R13B04/Makefile" line 92: Need an operator
make: "/home/acces/otp_src_R13B04/Makefile" line 93: Missing dependency operator
make: "/home/acces/otp_src_R13B04/Makefile" line 94: Missing dependency operator
make: "/home/acces/otp_src_R13B04/Makefile" line 95: Need an operator
make: "/home/acces/otp_src_R13B04/Makefile" line 96: Need an operator
make: "/home/acces/otp_src_R13B04/Makefile" line 97: Need an operator
make: "/home/acces/otp_src_R13B04/Makefile" line 98: Need an operator
make: "/home/acces/otp_src_R13B04/Makefile" line 159: Need an operator
make: "/home/acces/otp_src_R13B04/Makefile" line 164: Missing dependency operator
make: "/home/acces/otp_src_R13B04/Makefile" line 166: Need an operator
make: "/home/acces/otp_src_R13B04/Makefile" line 167: Missing dependency operator
make: "/home/acces/otp_src_R13B04/Makefile" line 169: Need an operator
make: "/home/acces/otp_src_R13B04/Makefile" line 171: Need an operator
make: "/home/acces/otp_src_R13B04/Makefile" line 172: Need an operator
make: "/home/acces/otp_src_R13B04/Makefile" line 202: Need an operator
make: "/home/acces/otp_src_R13B04/Makefile" line 217: Missing dependency operator
make: "/home/acces/otp_src_R13B04/Makefile" line 220: Need an operator
make: "/home/acces/otp_src_R13B04/Makefile" line 222: Need an operator
make: "/home/acces/otp_src_R13B04/Makefile" line 228: Cannot open /home/acces/otp_src_R13B04/make//otp_ded.mk
make: "/home/acces/otp_src_R13B04/Makefile" line 250: Missing dependency operator
make: "/home/acces/otp_src_R13B04/Makefile" line 254: Missing dependency operator
make: "/home/acces/otp_src_R13B04/Makefile" line 256: Need an operator
make: "/home/acces/otp_src_R13B04/Makefile" line 258: Need an operator
make: "/home/acces/otp_src_R13B04/Makefile" line 268: Missing dependency operator
make: "/home/acces/otp_src_R13B04/Makefile" line 270: Need an operator
make: "/home/acces/otp_src_R13B04/Makefile" line 272: Need an operator
make: "/home/acces/otp_src_R13B04/Makefile" line 276: Missing dependency operator
make: "/home/acces/otp_src_R13B04/Makefile" line 277: Missing dependency operator
make: "/home/acces/otp_src_R13B04/Makefile" line 279: Need an operator
make: "/home/acces/otp_src_R13B04/Makefile" line 280: Need an operator
make: "/home/acces/otp_src_R13B04/Makefile" line 287: Missing dependency operator
make: "/home/acces/otp_src_R13B04/Makefile" line 288: Missing dependency operator
make: "/home/acces/otp_src_R13B04/Makefile" line 290: Need an operator
make: "/home/acces/otp_src_R13B04/Makefile" line 292: Need an operator
make: "/home/acces/otp_src_R13B04/Makefile" line 293: Need an operator
make: "/home/acces/otp_src_R13B04/Makefile" line 305: Missing dependency operator
make: "/home/acces/otp_src_R13B04/Makefile" line 308: Missing dependency operator
make: "/home/acces/otp_src_R13B04/Makefile" line 310: Need an operator
make: "/home/acces/otp_src_R13B04/Makefile" line 313: Need an operator
make: "/home/acces/otp_src_R13B04/Makefile" line 315: Need an operator
make: "/home/acces/otp_src_R13B04/Makefile" line 320: Need an operator
make: "/home/acces/otp_src_R13B04/Makefile" line 337: Missing dependency operator
make: "/home/acces/otp_src_R13B04/Makefile" line 344: Need an operator
make: "/home/acces/otp_src_R13B04/Makefile" line 360: Missing dependency operator
make: "/home/acces/otp_src_R13B04/Makefile" line 363: Need an operator
make: "/home/acces/otp_src_R13B04/Makefile" line 365: warning: duplicate script for target "noboot" ignored
make: "/home/acces/otp_src_R13B04/Makefile" line 362: warning: using previous script for "noboot" defined here
make: "/home/acces/otp_src_R13B04/Makefile" line 366: Need an operator
make: "/home/acces/otp_src_R13B04/Makefile" line 373: Missing dependency operator
make: "/home/acces/otp_src_R13B04/Makefile" line 377: Need an operator
make: "/home/acces/otp_src_R13B04/Makefile" line 381: Missing dependency operator
make: "/home/acces/otp_src_R13B04/Makefile" line 391: Need an operator
make: "/home/acces/otp_src_R13B04/Makefile" line 392: Need an operator
make: "/home/acces/otp_src_R13B04/Makefile" line 401: Missing dependency operator
make: "/home/acces/otp_src_R13B04/Makefile" line 403: warning: duplicate script for target "ifeq" ignored
make: "/home/acces/otp_src_R13B04/Makefile" line 376: warning: using previous script for "ifeq" defined here
make: "/home/acces/otp_src_R13B04/Makefile" line 403: warning: duplicate script for target "(,true)" ignored
make: "/home/acces/otp_src_R13B04/Makefile" line 376: warning: using previous script for "(,true)" defined here
make: "/home/acces/otp_src_R13B04/Makefile" line 404: Need an operator
make: "/home/acces/otp_src_R13B04/Makefile" line 409: Need an operator
make: "/home/acces/otp_src_R13B04/Makefile" line 441: Missing dependency operator
make: "/home/acces/otp_src_R13B04/Makefile" line 442: warning: duplicate script for target "ifneq" ignored
make: "/home/acces/otp_src_R13B04/Makefile" line 390: warning: using previous script for "ifneq" defined here
make: "/home/acces/otp_src_R13B04/Makefile" line 443: Need an operator
make: "/home/acces/otp_src_R13B04/Makefile" line 447: Need an operator
make: "/home/acces/otp_src_R13B04/Makefile" line 463: Missing dependency operator
make: "/home/acces/otp_src_R13B04/Makefile" line 466: warning: duplicate script for target "ifeq" ignored
make: "/home/acces/otp_src_R13B04/Makefile" line 376: warning: using previous script for "ifeq" defined here
make: "/home/acces/otp_src_R13B04/Makefile" line 466: warning: duplicate script for target "(,true)" ignored
make: "/home/acces/otp_src_R13B04/Makefile" line 376: warning: using previous script for "(,true)" defined here
make: "/home/acces/otp_src_R13B04/Makefile" line 467: Need an operator
make: "/home/acces/otp_src_R13B04/Makefile" line 471: Need an operator
make: "/home/acces/otp_src_R13B04/Makefile" line 493: Missing dependency operator
make: "/home/acces/otp_src_R13B04/Makefile" line 502: warning: duplicate script for target "ifneq" ignored
make: "/home/acces/otp_src_R13B04/Makefile" line 390: warning: using previous script for "ifneq" defined here
make: "/home/acces/otp_src_R13B04/Makefile" line 502: warning: duplicate script for target "(,true)" ignored
make: "/home/acces/otp_src_R13B04/Makefile" line 376: warning: using previous script for "(,true)" defined here
make: "/home/acces/otp_src_R13B04/Makefile" line 503: Need an operator
make: "/home/acces/otp_src_R13B04/Makefile" line 530: Missing dependency operator
make: "/home/acces/otp_src_R13B04/Makefile" line 542: Need an operator
make: "/home/acces/otp_src_R13B04/Makefile" line 558: Need an operator
make: "/home/acces/otp_src_R13B04/Makefile" line 972: Missing dependency operator
make: "/home/acces/otp_src_R13B04/Makefile" line 975: warning: duplicate script for target "ifeq" ignored
make: "/home/acces/otp_src_R13B04/Makefile" line 376: warning: using previous script for "ifeq" defined here
make: "/home/acces/otp_src_R13B04/Makefile" line 975: warning: duplicate script for target "(,true)" ignored
make: "/home/acces/otp_src_R13B04/Makefile" line 376: warning: using previous script for "(,true)" defined here
make: "/home/acces/otp_src_R13B04/Makefile" line 976: Need an operator
make: "/home/acces/otp_src_R13B04/Makefile" line 989: Need an operator
make: Fatal errors encountered -- cannot continue

make: stopped in /home/acces/otp_src_R13B04

then the easy solution to overcome it is to build Erlang with :

Another issue:

The only solution that I found was at http://mail-index.netbsd.org/pkgsrc-bugs/2007/11/11/msg025712.htm.

Basically you have to run config & gmake.

Starting Erlang at NetBSD boot up

Posted by marian on April 16, 2010

This would do the job:

vi /etc/rc.d/erlang.sh

  1. #!/bin/sh
  2. case $1 in
  3. start)
  4.         /usr/pkg/bin/erl -Pa /home/user/path_to_your_applications +A 5 -remsh -name e1@192.168.1.5 -heart -detached  -setcookie "mycookie" &
  5.         ;;
  6. stop)
  7.         killall erl
  8.         ;;
  9. esac

Compiling Erlang with Intel® C++ Compiler Professional Edition for Linux

Posted by marian on October 26, 2009

First of all, a big plus to Intel for providing the compiler free on Linux, for non-comercial use. Compiling Erlang with the Intel Compiler has greatly increased the speed of the Erlang VM (in my case, with the trade-off of increasing slightly the memory requirements). You should expect something about 20% to 30% overall speedup.

But compilling it, took me some time. A succesful compilation envolves the followin steps:

  1. Prepare the source code, install the necessary libraries that Erlang needs to be compiled (see the previous post).
  2. Install Intel® C++ Compiler Professional Edition for Linux.
  3. Open a Bash console and go to your Erlang source directory.
  4. Set the paths to Intel’s compiler and libraries:
    1. LD_LIBRARY_PATH=/opt/intel/Compiler/11.1/056/lib/intel64:$LD_LIBRARY_PATH
    2. PATH=/opt/intel/Compiler/11.1/056/mkl/lib/em64t:/opt/intel/Compiler/11.1/056/lib/intel64:/opt/intel/Compiler/11.1/056/bin/intel64/:$PATH
  5. Run ./configure with the following options:
    1. ./configure CC=icc CFLAGS="-gcc-version=420 -xssse3 -mssse3 -ip -par-threshold=50 -fp-model strict -prec-div -prec-sqrt -pc80 -opt-streaming-stores always -par-threshold=50 -par-runtime-control -par-schedule-static-balanced -static-libgcc -static-intel" –enable-smp-support –enable-threads –enable-kernel-poll –enable-hipe  –with-ssl

    This optimizes:

  • floating point operations they are more exact, and less fast (internal representation on 80 bit -pc80)
  • memory operations

But to get this we need:

  • we compile for Intel 64 bit processors
  • we use the SSSE3 instructions that my processor is capable of
  • we assume that threads are memory bounded so we use -opt-streaming-stores, and a static threading model
  • we statically link any needed Intel libraries -static-intel
  • we statically link libgcc, but I don’t think this is necessary (and increases the size of the executable)

Compiling Erlang

Posted by marian on October 26, 2009

There comes a day when you need to squize every bit of performance from Erlang or you need it for some exotic platform (or you are just a Slackware user). For doing this you either improve your program or use Erlang Virtual Machine optimization. This tutorial comprises the steps needed to compile Erlang.

  1. First get the tools needed for compilation: sudo apt-get install build-essential libncurses5-dev m4 openssl libssl-dev unixodbc-dev libstdc++5 libc6 .Please note that you need to install libstdc++5 R(compatibility) inspite the fact that you may have a newer version (they can co-exist). Regarding wx, well I had some issues with it. By some way you should have on your system:
    libpthread-stubs0
    libxcb1-dev
    libx11-dev
    mesa-common-dev
    libgl1-mesa-dev
    libglu1-mesa-dev
    libice-dev
    libsm-dev
    x11proto-xext-dev
    libxt-dev
    freeglut3-dev
    libglut3-dev
    wx2.8-headers
    libwxgtk2.8-dev
    wx-common
    wx2.8-i18n
  2. First go to you build directory (were you usually to the builds of you programs).
  3. Get the Erlang source. What a pity… there is no cvs or svn repository. Get Erlang source code
      1. wget http://www.erlang.org/download/otp_src_R13B02.tar.gz
      1. tar -xzf otp_src_R13B02.tar.gz
  4. In the Erlang source directory run the configuration script: ./configure. You can pass arguments to configure (see the docs), I use: ./configure  –enable-smp-support –enable-threads –enable-kernel-poll –enable-hipe  –with-ssl
  5. Compile the source code: make
  6. Install it using: sudo make install, but I do not  recommend it. I generally have on my system multiple Erlang builds. Some of them use precise floating for backpropagation in neural network learning, others use fast floating point for instance in genetic algorithm testing, and last but not least some or compiled so that the node data throughtput is enhanced (crypto package, memory stores -> streaming).

About Java and Distributed Systems

Posted by marian on October 24, 2009

It is rely weird when people refuse to learn anything new or reuse something old.

Late this day I have received an email about a workshop in Distributed Computing. Lets establish the context first. In my hometown the is a project undergoing which has as objective the creation of a local computer cluster. And, in this context it just happens that a company wants to promote a product in Distributed Computing .

The company is called Actieeon, and its website is http://proactive.inria.fr/. They say that they are Open Source, but of course they have an Enterprise Solution that you can license.

I am eager to see what will they say at the workshop, and if I could mange to stop laughing. I must admit that they have a beautiful source code, well documented, but to build a Distributed System in Java seems to be a rather stupid thing to do.

Let me explain miself. In my faculty, at the Distributed Systems course we of course study Java as a language for Distributed programming. This is not because it is very good, but because nobody wants to try something new or use something old. Probably our parents heard about C, Fortran or Ada, languages  that were used succesfully for parallel and distributed computing. But we do not know anything about them, we must know the all mighty Java, an universal panaceea for our computing problems. Ohh, and there is also Erlang which “is a language designed concurrency in mind”.

The basic question is: why would you need an Object Oriented Language when you need raw power ? Probably there is nobody to do distributed computing with something other that OOP concepts. I would prefer a functional languag like Haskel or Erlang:  they provide a clear demarcation between what should be executed sequentially and what should be executed in parallel. The Java solution is to provide some function calls, to some “objects”, to perform “something” in parallel. The resulting code cannot be something else than ugly. But, we use OOP principles, and “some” say that this is good practice.

Some say that Java is very portable, and it is,realy it is, but only when you print on the console “Hello world”.

But when you want to do input/output and run computationally intensive programs, well you would have to write a chron scripts for killing the Java Virtual machine. Of course, some may say that for example JRockit Java VM can be used for powering highly demanding websites; and it is true, it is well suited for the MVC pattern, but it isn’t a language to use in a distributed system.

First of all a Distributed System is a heterogeneous one. Clusters have a large variaty of Operating System, ranging from AIX, Solaris, RedHat, Ubuntu server. Cheap solutions also use NetBsd; try running Sun’s Java VM on that one; the whole system needs around 90 MB to run, but when you start Java, hmm arround 300 MB.

So we’ve covered Java’s ugly code, large memory consumption, portability; now lets see about how others deal with these issues. Which componany has as main bussines distributed computing ? Answer: Google, job searching. Some say that they use a combination of C, Python and Java. I would say that they generally use Python, and do all the dirty things at the C level. Python has low memory consumtion, it is a glue language and can work along with other languages relatively well. Of course, there is Jython the Java version of Python, but, realy, I don’t think they are using it.

Next we have Erricson and the telecommunication world. Do they use Java ? It seems that there are some niche companies that are testing the field, but Erricson uses Erlang. Their purpose is the creation of a fault tolerant environment for providing services such emargency call. How are exceptions treated by those at Erricson ?

Is there a fault on the system ? If yes, automatically kill the process or if it is something extremly serious kill the Virtual Machine on the corresponding node and then restart it, while relying on the existing redundancy. In Java you must catch tens of expetions and handle them. Wouldn’t it be simpler to just kill the process that makes the computation ? Well, you can’t since it is an OOP language:  it doesn’t have fault tollerance, there is no mechanism for killing and restaring the VM, it does not have lightweight processes you could kill if they do something nasty, but it has a hightly complex garbage collector that has the job of making some room in the excesivelly large memory that it is needed.

Scalar product computation

Posted by marian on October 24, 2009

Lets say we have to compute the scalar product of two vectors of arbitrary (but equal) lengths. This can be accomplished easily in Erlang using:

  1. -module(product).
  2. -export([scalar_product/2,test/0]).
  3.  
  4. scalar_product(Vector1,Vector2)->
  5.  {Result,_} = mais_lists:foldl(fun(X,{Acc,[Hd|Tail]})->{Hd*X+Acc,Tail} end, {0,Vector1}, Vector2),
  6.  Result.
  7. test()->
  8.  scalar_product([1,2,3],[4,5,6]).

Developing in Erlang

Posted by marian on October 18, 2009

1) Installing Erlang is very easy, but compiling it is rather difficult. Depending on the underlying Operating System one could use:
Ubuntu

  1. apt get install erlang

Fedora

  1. yum install erlang

Windows

  1. http://www.erlang.org/download.html

2) For writing the Erlang programs (modules) one could use :
vim
Ubuntu

  1. apt get install vim

Fedora

  1. yum install vim

For other OSs:

  1. http://www.vim.org/download.php

emacs
SciTE
3) For a build machine (compiling + Eunit testing + deployment) I use Sinan.
a) First you have to install Faxien. This can be easily done with the following script (choose according to your OS):

  1. http://code.google.com/p/faxien/downloads/list

b) To install Sinan use:

  1. faxien install-release sinan

4) As an example lets build our code:

  1. sinan build

and let us test it using Eunit (the corresponding of JUnit in the Erlang world):

  1. sinan test