Skip to content

Compilation of Composite 32Bit on Ubuntu 18.04 64Bit

Phani Gadepalli edited this page Apr 5, 2019 · 2 revisions

Prerequisites

Here's all the packages you need to install to be able to build Composite 32Bit on Ubuntu 18.04 64Bit! (use sudo, obviously!)

$ dpkg --add-architecture i386
$ apt-get update
$ apt-get install gcc g++
$ apt-get install gcc-multilib g++-multilib
$ apt-get install binutils-multiarch-dev
$ apt-get install zlib1g:i386
$ apt-get install libbinutils:i386

BFD (additional)

In addition to the above packages, you need to download and copy some lib archives and softlinks which are part of binutils-dev:i386 but apt-get install that will ask you to remove 64bit dev packages, which we don't want to. So this is how I did it:

$ mkdir tmp
$ cd tmp
$ apt-get download binutils-dev:i386
$ ar x binutils-dev_2.30-21ubuntu1~18.04_i386.deb
$ tar -xvf data.tar.gz
$ cp -d usr/lib/i386-linux-gnu/lib* /usr/lib/i386-linux-gnu/
$ cd ../
$ rm -rf tmp

Standard Packages

The packages above enable Composite 32bit build on 64Bit Ubuntu. Please check the docs directory in Composite source to install other standard development libraries you'd prior to recompiling Composite. E.g.,

$ apt-get install build-essential git qemu 

Recompile

After completing the above steps, recompile Composite:

$ make distclean; make init; make

Caveats

  • Just so you know, you're going to see warnings in a few places in C and C++ compilation.

  • There is a strange undefined symbol problem in unitcxx compilation and I'm not attempting to resolve that in this wiki!

|     [CXX]  cxx.cc: Compiling
|     [LD]   tests.unit_cxx (cxx_test.o): Linking  cxx.o /home/phani/research/mygit/composite/src//components//lib/posix/posix.o
Error: component tests.unit_cxx does not have stated dependencies to provide ['_ZdlPvj']
	Suggested Fix: add the proper interface dependency in the DEPENDENCIES list in components/implementation/tests/unit_cxx/Makefile.
Less likely fixes: a) you should specify a FN_PREPEND in the Makefile for a component that wishes to invoke another component with the same interface.
b) you should reorder dependencies within the Makefile (see FAQ).
  • I've not installed or tested rust compilation.

Makefile changes

I'll delete this section after the required changes are in the mainline.

PS library

I've a PR #8 to add -m32 to the CFLAGS, without which ps compilation will fail!

In Makefile.inc, add:

ifeq ($(ARCHNAME), x86)
CFLAGS   += -m32
endif

Composite

I'll make a PR after ps is approved, as I'd need to update the submodule link in Composite!

If you don't want to wait, in src/components/Makefile.comp, after line#49

GCC_PIE=$(shell gcc -v 2>&1 | grep -c "\--enable-default-pie")
ifeq ($(GCC_PIE),1)
MUSLCFLAGS+=-no-pie
LDFLAGS+=-no-pie
CFLAGS+=-fno-pie
CXXFLAGS+=-fno-pie
endif

In src/components/lib/Makefile, add quiescence option to configure at line #63 only if you're up-to-date with ps repository. I've used real_time, I don't know the details as to how this affects any current composite code, I'd think it won't:

cd ps; ./configure cos x86 real_time; cd ..; make -C ps config ; make -C ps all

In src/platform/linker/Makefile, add -m32 at line #5:

CFLAGS=-m32 -D__x86__ -D_GNU_SOURCE -lpthread -Wall -Wextra -Wno-unused-parameter -Wno-unused-function -Wno-pointer-to-int-cast -Wno-int-to-pointer-cast -Wno-format -g    gdb3 -I$(SHAREDINC)