I'm trying to cross-compile boost library for ppc64le and I need it to run on RH9.
I'm doing the cross-compilation inside a container and using the at15.0
toolchain.
The compilation works, but when compiling my code I get this error:
libboost_system.a(error_code.o): in function `_GLOBAL__sub_I__ZN5boost6system6throwsE':
error_code.cpp:(.text.startup+0x20): call to `boost::system::generic_category()' lacks nop, can't restore toc; (plt call stub)
error_code.cpp:(.text.startup+0x24): call to `boost::system::generic_category()' lacks nop, can't restore toc; (plt call stub)
error_code.cpp:(.text.startup+0x28): call to `boost::system::system_category()' lacks nop, can't restore toc; (plt call stub)
error_code.cpp:(.text.startup+0x38): call to `boost::system::system_category()' lacks nop, can't restore toc; (plt call stub)
/opt/at15.0/bin/powerpc64le-linux-gnu-ld: final link failed: bad value
This is the section of the dockerfile I use to cross compile (multi-stage build)
FROM registry.access.redhat.com/ubi8/ubi:8.1 AS CrossCompileBase
# Install required packages
RUN yum -y update \
# && yum install epel-release \
# && yum update -y \
&& yum -y install \
xz-5.2.4 \
gcc-8.5.0 \
gcc-c++-8.5.0 \
make-4.2.1 \
wget-1.19.5 \
tar-1.30 \
cmake-3.20.2 \
autoconf-2.69 \
automake-1.16.1 \
libtool-2.4.6 \
pkgconfig \
bzip2-1.0.6 \
zlib-devel-1.2.11 \
rpm-build-4.14.3 \
diffutils-3.6 \
sudo \
curl-7.61.1 \
python36-3.6.8 \
python36-devel-3.6.8 \
python3-pip-9.0.3 \
&& yum -y clean all;
# Download and install the advance-toolchain-at15.0
RUN mkdir -p /tmp/at15 \
&& wget \
-qO /tmp/at15/advance-toolchain-at15.0-cross-common-15.0-0.x86_64.rpm \
"https://public.dhe.ibm.com/software/server/POWER/Linux/toolchain/at/redhat/RHEL8/at15.0/advance-toolchain-at15.0-cross-common-15.0-0.x86_64.rpm" \
--no-check-certificate \
&& wget \
-qO /tmp/at15/advance-toolchain-at15.0-cross-ppc64le-15.0-0.x86_64.rpm \
"https://public.dhe.ibm.com/software/server/POWER/Linux/toolchain/at/redhat/RHEL8/at15.0/advance-toolchain-at15.0-cross-ppc64le-15.0-0.x86_64.rpm" \
--no-check-certificate \
&& yum install -y /tmp/at15//*.rpm \
&& rm -rf /tmp/at15
# Set cross compile environment variables:
ENV CC=/opt/at15.0/bin/powerpc64le-linux-gnu-gcc
ENV CXX=/opt/at15.0/bin/powerpc64le-linux-gnu-g++
ENV CMAKE_C_COMPILER=/opt/at15.0/bin/powerpc64le-linux-gnu-gcc
ENV CMAKE_CXX_COMPILER=/opt/at15.0/bin/powerpc64le-linux-gnu-g++
ENV PATH=$PATH:/opt/at15.0/bin:/opt/cmake/bin/
# install boost
FROM CrossCompileBase AS LibBoostBuilder
RUN mkdir -p /tmp/install/boost \
&& wget -qO /tmp/boost_1_64_0.tar.gz "https://boostorg.jfrog.io/artifactory/main/release/1.64.0/source/boost_1_64_0.tar.gz" --no-check-certificate \
&& cd /tmp \
&& tar xvf boost_1_64_0.tar.gz
ENV CC=/opt/at15.0/bin/powerpc64le-linux-gnu-gcc
ENV CXX=/opt/at15.0/bin/powerpc64le-linux-gnu-g++
COPY user-config.jam /tmp/boost_1_64_0/user-config.jam
RUN cd /tmp/boost_1_64_0 \
&& ./bootstrap.sh \
--with-toolset=gcc \
--prefix=/usr/local/boost \
--without-libraries=python \
&& ./b2 \
--user-config=/tmp/boost_1_64_0/user-config.jam \
toolset=gcc \
target-os=linux \
link=static \
variant=release \
install \
--with-filesystem \
--with-system \
--with-regex
user-config.jam contents:
import toolset ;
using gcc : : /opt/at15.0/bin/powerpc64le-linux-gnu-gcc ;
Tried to look at what ChatGPT has to say about this:
This error message indicates that there is an issue with the code that calls the boost::system::generic_category() function. The error message specifically mentions a missing "nop" instruction, which is a special instruction that is used to pad instructions in the code so that they align with a specific memory boundary.
The error message also mentions a problem with the "toc", which stands for "table of contents". The TOC is a data structure used by the PowerPC architecture to manage function calls and data accesses. The error message suggests that the boost::system::generic_category() function is being called using a "plt call stub", which is a mechanism used by the linker to enable dynamic linking of shared libraries.
Not sure what I'm doing wrong.