Skip to content

Cross Compiling and Building Lind Binaries

Çağlar Doğan edited this page Nov 26, 2020 · 14 revisions

Building binaries for Lind:

The scripts for cross-compilation and building of programs in lind_project/tests/applications/ are in the executable bootstrap_nacl files in their respective folders.

Running Lind binaries:

After running the bootstrap_nacl file, the resulting binaries can be run like the .nexe files after being copied into the Lind file system.

Information about specific programs:

Python

The source code needed to build Python and the bootstrap_nacl file is located at lind_project/tests/applications/python/

The binary is built into the root folder of the source code (lind_project/tests/applications/python/).

The build process will give an error message at some point as it requires the running of some built intermediary binaries to generate certain required files. At that point, the bootstrap_nacl script will build a native version of Python into the python-native folder, copy the required files to the main folder and carry on the build process.

In the end, there will be another error as the make process will try to run the cross-compiled code on the native machine. However, Python will already have been built at this point, and the resulting executable can be deemed valid.

The details about the building process can be found under Issue 65 in GitHub.

Nginx

The source code needed to build Nginx and the bootstrap_nacl file is located at lind_project/tests/applications/nginx/

The executable binary is built into objs after the completion of bootstrap_nacl.

The details about the building process can be found under Issue 63 in GitHub.

PostgreSQL

The source code needed to build PostgreSQL and the bootstrap_nacl file are located at lind_project/tests/applications/postgres/

The binary is built into the root folder of the source code (lind_project/tests/applications/postgres/).

The details about the building process can be found under Issue 64 in GitHub.

Development Cycle:

The introduction of a new binary to Lind is a multi-step process. This process is largely dependent on a bootstrap file's debugging for each program, and therefore has unique steps for each application. Still, a good number of the unique problems faced are variations of a small subset of problems. The information below can serve as a guide in planning a roadmap for this process by detailing out the most common problems and their solutions.

1) Initialization of General Variables in bootstrap_nacl:

This is the most fundamental part of the process as it is how we denote that the binary should be cross-compiled. Here, the relevant variables denoting compilers and the linker to be used should be updated to their x86_64-nacl counterparts with the given lines of code:

export CC=x86_64-nacl-gcc

export CXX=x86_64-nacl-g++

export LD=x86_64-nacl-ld

The flags for each of these should also be updated. The generic code used for this is:

export CFLAGS='-g -fno-pie'

export CXXFLAGS='-g -fno-pie'

export LDFLAGS='-g -fno-pie'

Please note that the flag values are flexible, an can be changed. Some programs will fail to build with certain flags, so this process should be undertaken alongside the debugging process. For example, the build process of nginx coul only be completed after the removal of the -fno-pie flag from CFLAGS.

Lastly, the path variable should be set with:

export PATH="/usr/bin:/usr/sbin:/bin:/sbin:$PATH"

2) Configuration Process:

After the relevant variables are set, the configuration process should be handled with the given command in bootstrap_nacl:

./<relative_path_of_the_configure_file>/configure <configuration_specific_vartiable_exports> <configuration_flags> --host=x86_64-nacl "$@"

Here, the <configuration_specific_vartiable_exports> and <configuration_flags> parts are to be determined according to the functionality wanted and should be improved with the debugging of the bootstrap_nacl file.

<configuration_flags> are especially important for the errors denoting the unavailability of certain libraries in the lin system. These are frequent types of errors and can be solved by either denoting the omitting of the library with the --without_library flag or the introduction of the ai library to the lind system.