Skip to content

How to build Open64

Yvan edited this page Aug 2, 2023 · 10 revisions

Obtaining the Source Code

To compile Open64 you need to obtain the source code first.

There are two ways:

  • Obtain the Source Code as Archive
    You can download the source code from github.com. You can download different versions from github.com. The develop zip file is available at:

https://github.com/open64-compiler/open64/archive/refs/heads/develop.zip

Extract the source code:

unzip develop.zip
  • Obtain the Source Code from our Subversion Repository
    You can also obtain the latest version of our source code from the sub-version repository. To get the latest version issue the following command:
git clone https://github.com/open64-compiler/open64.git open64
cd open64
git checkout develop

This will copy the latest code to the directory open64. You can also surf through the git repository online on github.com.

Prerequisites

In order to compile Open64 successfully, you should meet the following requirements:

  • Linux based OS
    Currently, Open64 is intensively tested on Linux on IA64/X86_64/IA32. The recommended OS is Ubuntu 16.04/18.04/20.04/22.04 LTS.

  • IA32/x86_64/IA64 based machine
    In this release, Open64 is supported and tested for the Itanium 2 and IA32/x86_64 architectures. Itanium 1 and generic IA32 are also supported, but not tested carefully.

  • GNU Make
    You should use an up to date version of Make. The system default versions on most recent Linux distributions have been tested and work with our Makefile.

  • GCC (GNU Compiler Collection)
    In order to compile the Open64 source code, you need GCC 5.x - 11.x.

  • Several standard packages

sudo apt install build-essential bison flex python3 python3-pip openjdk-8-jre openjdk-8-jdk gradle
  • LLVM and Clang To compile the Clang front-end and RISC-V back-end for Open64, you have two options. You can either install LLVM(11.x to 16.x) and Clang, or you can build them from the source code. The recommended LLVM version is LLVM-14.x

    • Install the pre-build package
    sudo apt install llvm-dev libclang-dev
    • Build LLVM/CLANG from the source code Follow the guide here.

Setup the ENV variables

  • Setup the path to LLVM/Clang
    Open64 uses llvm-config to obtain the path of the LLVM library. Therefore, you need to make sure llvm-config is contained in the $PATH. $CLANG_HOME specifies the path to the clang library. Usually, libclang is located in the same path of LLVM(for example: /usr/lib/llvm-14).
# set $CLANG_HOME to be the path to the LLVM library
# for example: export CLANG_HOME="/usr/lib/llvm-15/"
export CLANG_HOME=/PATH/TO/YOUR/LLVM/DIRECTORY

# make sure that "llvm-config" is contained in the $PATH
export PATH=$CLANG_HOME/bin/:$PATH
llvm-config --version
  • Setup the path to Java8.
export JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64/"

Compiling

The open64 build process has been changed to use the autoconf tool that many other open-source products use. In the old build process, it was necessary to set variables on the make command to control the build; MACHINE_TYPE, BUILD_OPTIMIZE, and TOOLROOT arguments were passed to the make a command to control what type of open64 compiler to build.

To build open64 with CLANG front end, please check and follow the instructions available in osprey/clang2whirl/README.md.

In the new build process, these arguments are passed to the configure script (using a different syntax) and then the 'make all' and 'make install' commands are run without any arguments.

Here is a mapping for some of the old make options to configure options:

Makefile setting configure option
MACHINE_TYPE=i386 --target=i386-unknown-linux-gnu(1)
MACHINE_TYPE=ia64 --target=ia64-unknown-linux-gnu
BUILD_OPTIMIZE=DEBUG --with-build-optimize=DEBUG
BUILD_COMPILER=GNU --with-build-compiler=GNU
TOOLROOT=/opt/open64 --prefix=/opt/open64

(1) If you are building on an 386/x86_64 system, the target will default to building a 32 bit compiler with 32 and 64 bit libraries and you do not have to use this option

Other differences between the old and new build are that 'make' or 'make all' now builds both the compiler and the libraries. It is no longer neccessary to run 'make all' to build the compiler and then 'make lib' to build the libraries.

Additionally, the libraries that need to be compiled with the open64 compiler will be built using the compiler that was just created during the make process. A seperate open64 compiler is not needed to build these libraries.

Building the compiler on x86_64

By default, on x86_64 machines, the compiler will be built in 32 bit mode and libraries will be built in 32 and 64 bit modes to support compilation in either mode. You can build 64 bit executables by specifying --build=x86_64-unknown-linux-gnu on the configure command. By default, you can run the following configuration.

mkdir build && cd build

<path-to-open64-dir>/open64/configure --prefix=<path-install-open64> --host=x86_64-linux-gnu --target=x86_64-linux-gnu --disable-fortran --with-build-product=OPEN64 --with-build-optimize=DEBUG --disable-multilib

make -j $(nproc)

Some tips on Ubuntu machines

If you are building the compiler on Ubuntu machine, you need to install the following tools first:

awk, csh, bash, gmake, flex and bison,

On some Ubuntu distributions, you need to change the symbol link '/bin/sh' to '/bin/bash' to make the scripts work. If you met the following error:

##./table INTERNAL ERROR: Unexpected line: Abort
##sh: line 1: 27052 Segmentation fault      ./table <OPTIONS.P

You need to make sure the awk is linked to mawk on your Ubuntu machine

libraries

Libraries used to be built separately from the compiler, but now the libraries as well as the compiler are built as part of the default make target. The libraries are built using the newly built compiler

Installation

Once you have done make all to make the compiler, make install will copy it to the location specified by the --prefix argument to configure. If --prefix was not used the default install location is in /usr/local.

Congratulations. You have successfully installed Open64. Have fun.

Your Open64 Team