linux-x86: Add toolchain file and install libc6 and stdc++6 32-bit libraries

This commit is contained in:
Jean-Christophe Fillion-Robin 2016-04-13 19:24:04 -04:00
parent d47a208afa
commit f57b97b06b
3 changed files with 38 additions and 3 deletions

View File

@ -4,18 +4,31 @@ MAINTAINER Matt McCormick "matt.mccormick@kitware.com"
RUN dpkg --add-architecture i386 && \ RUN dpkg --add-architecture i386 && \
apt-get update && apt-get -y install \ apt-get update && apt-get -y install \
gcc-multilib \ gcc-multilib \
g++-multilib g++-multilib \
libc6:i386 \
libstdc++6:i386
ENV CROSS_TRIPLE i686-linux-gnu ENV CROSS_TRIPLE i686-linux-gnu
ENV CROSS_ROOT /usr/${CROSS_TRIPLE} ENV CROSS_ROOT /usr/${CROSS_TRIPLE}
ENV PATH ${PATH}:${CROSS_ROOT}/bin ENV PATH ${PATH}:${CROSS_ROOT}/bin
RUN mkdir -p ${CROSS_ROOT}/bin RUN mkdir -p ${CROSS_ROOT}/bin
COPY ${CROSS_TRIPLE}.sh ${CROSS_ROOT}/bin/${CROSS_TRIPLE}.sh COPY ${CROSS_TRIPLE}.sh ${CROSS_ROOT}/bin/${CROSS_TRIPLE}.sh
COPY ${CROSS_TRIPLE}-as.sh ${CROSS_ROOT}/bin/${CROSS_TRIPLE}-as.sh
RUN cd ${CROSS_ROOT}/bin && \ RUN cd ${CROSS_ROOT}/bin && \
chmod +x ${CROSS_TRIPLE}.sh && \ chmod +x ${CROSS_TRIPLE}.sh && \
ln -s /usr/bin/x86_64-linux-gnu-gcc && \ ln -s /usr/bin/x86_64-linux-gnu-gcc && \
ln -s /usr/bin/x86_64-linux-gnu-g++ && \ ln -s /usr/bin/x86_64-linux-gnu-g++ && \
ln -s /usr/bin/x86_64-linux-gnu-as && \
ln -s ${CROSS_TRIPLE}.sh ${CROSS_TRIPLE}-gcc && \ ln -s ${CROSS_TRIPLE}.sh ${CROSS_TRIPLE}-gcc && \
ln -s ${CROSS_TRIPLE}.sh ${CROSS_TRIPLE}-g++ ln -s ${CROSS_TRIPLE}.sh ${CROSS_TRIPLE}-g++ && \
ENV CC=${CROSS_ROOT}/bin/${CROSS_TRIPLE}-gcc \ ln -s ${CROSS_TRIPLE}-as.sh ${CROSS_TRIPLE}-as && \
ln -s /usr/bin/x86_64-linux-gnu-ar ${CROSS_TRIPLE}-ar
ENV AS=${CROSS_ROOT}/bin/${CROSS_TRIPLE}-as \
AR=${CROSS_ROOT}/bin/${CROSS_TRIPLE}-ar \
CC=${CROSS_ROOT}/bin/${CROSS_TRIPLE}-gcc \
CXX=${CROSS_ROOT}/bin/${CROSS_TRIPLE}-g++ CXX=${CROSS_ROOT}/bin/${CROSS_TRIPLE}-g++
# Note: Toolchain file support is currently in debian Experimental:
# https://wiki.debian.org/CrossToolchains#In_jessie_.28Debian_8.29
COPY Toolchain.cmake /usr/lib/${CROSS_TRIPLE}/
ENV CMAKE_TOOLCHAIN_FILE /usr/lib/${CROSS_TRIPLE}/Toolchain.cmake

20
linux-x86/Toolchain.cmake Normal file
View File

@ -0,0 +1,20 @@
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_VERSION 1)
set(CMAKE_SYSTEM_PROCESSOR i686)
# Setting these is not needed because the -m32 flag is already
# associated with the ${cross_triple}-gcc wrapper script.
#set(CMAKE_CXX_COMPILER_ARG1 "-m32")
#set(CMAKE_C_COMPILER_ARG1 "-m32")
set(cross_triple "i686-linux-gnu")
set(CMAKE_C_COMPILER /usr/${cross_triple}/bin/${cross_triple}-gcc)
set(CMAKE_CXX_COMPILER /usr/${cross_triple}/bin/${cross_triple}-g++)
set(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER})
set(CMAKE_AR /usr/${cross_triple}/bin/${cross_triple}-ar)
# Prevent 64-bit libraries from being discovered
set(CMAKE_IGNORE_PATH /usr/lib/x86_64-linux-gnu/ /usr/lib/x86_64-linux-gnu/lib/)
set(CMAKE_CROSSCOMPILING_EMULATOR sh -c)

View File

@ -0,0 +1,2 @@
#!/bin/bash
exec ${0/${CROSS_TRIPLE}-/x86_64-linux-gnu-} --32 "$@"