JuliaLang / julia

The Julia Programming Language
https://julialang.org/
MIT License
45.82k stars 5.49k forks source link

Error building Julia on Raspberry Pi zero (both Docker and locally) >= 1.2.0 #33929

Closed terasakisatoshi closed 4 years ago

terasakisatoshi commented 4 years ago
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/pi/work/build/usr/tools /home/pi/work/build/contrib/fixup-libgfortran.sh --verbose /home/pi/work/build/usr/lib
Discovered traces of libgfortran within . 
Got SONAMES of 

Thank you.

ViralBShah commented 4 years ago

Have you seen: https://github.com/JuliaLang/julia/blob/master/doc/build/arm.md ?

terasakisatoshi commented 4 years ago

I should have added link how to reproduce our issue

@ViralBShah Yes. This doc says:

Julia requires at least the armv6

So there is a chance to build Julia.

We discussed the issue several months ago. At this moment (1.1.x was the latest version of Julia )we could build Julia from source for all Raspberry Pi series.

ViralBShah commented 4 years ago

I wonder if disabling the use of binary builder helps? That way you will build llvm on the pi zero.

terasakisatoshi commented 4 years ago

I wonder if disabling the use of binary builder helps? That way you will build llvm on the pi zero.

This means add USE_BINARYBUILDER = 0 to Make.user via

$ echo "USE_BINARYBUILDER = 0" >> Make.user

?

I will try it.

ViralBShah commented 4 years ago

Yes, that's right. I am not sure how effective that will be, but it is worth a try.

terasakisatoshi commented 4 years ago

Sorry my delay of reply. Adding USE_BINARYBUILDER = 0 doesn't solve our problem 😭

Here is my dockerfile I used for reproducing error

# Build Julia binary for arm32-bit devices e.g. RaspberryPi Zero(W/WH)
FROM balenalib/raspberry-pi:buster-20191030

MAINTAINER SATOSHI TERASAKI

# install dependencies
RUN apt-get update && \
    apt-get install -y build-essential libatomic1 python gfortran perl wget m4 cmake pkg-config \
    libopenblas-base libopenblas-dev \
    libatlas3-base libatlas-base-dev \
    liblapack-dev \
    libmpfr-dev libgmp3-dev \
    libgfortran3 \
    git

# build julia from source
ARG JL_VERSION="v1.2.0"
ARG WDIR=/home/pi/work
ARG JL_BUILD_DIR=$WDIR/build
WORKDIR $WDIR
RUN echo "\
JULIA_CPU_TARGET=arm1176jzf-s\n\
prefix=$WDIR/julia-$JL_VERSION\n\
LDFLAGS=-latomic\n\
USE_BINARYBUILDER = 0\n\
override USE_SYSTEM_BLAS=1\n\
override USE_SYSTEM_LAPACK=1\n\
override USE_SYSTEM_LIBM=1\n\
override USE_SYSTEM_GMP=1\n\
override USE_SYSTEM_MPFR=1\n\
" > Make.user && \
    cat Make.user && \
    git clone --depth=1 -b $JL_VERSION https://github.com/JuliaLang/julia.git $JL_BUILD_DIR &&\
    cp Make.user $JL_BUILD_DIR && \
    cd $JL_BUILD_DIR && make -j $(nproc) OPENBLAS_USE_THREAD=0 && make install

# add path of Julia
ENV PATH=$WDIR/julia-$JL_VERSION/bin:$PATH

# clean up
RUN rm -r $JL_BUILD_DIR $WDIR/Make.user
RUN apt-get clean && rm -rf /var/cache/apt/archives/* /var/lib/apt/lists/*

Edit

I've added how to reproduce our issue

$ ls 
Dockerfile # see above
$ docker build -t rpizero .
terasakisatoshi commented 4 years ago

https://gist.github.com/terasakisatoshi/8771a7f846aea2f0f40db60a4802f329

# Build Julia binary for arm32-bit devices e.g. RaspberryPi Zero(W/WH)
FROM balenalib/raspberry-pi:buster-20191030

MAINTAINER SATOSHI TERASAKI

# install dependencies
RUN apt-get update && \
    apt-get install -y build-essential gcc-8 libatomic1 python gfortran-8 perl wget m4 cmake pkg-config git

# build julia from source
ARG JL_VERSION="v1.2.0"
ARG WDIR=/home/pi/work
ARG JL_BUILD_DIR=$WDIR/build
WORKDIR $WDIR
RUN echo "\
MARCH=armv6\n\
JULIA_CPU_TARGET=arm1176jzf-s\n\
USE_BINARYBUILDER = 0\n\
prefix=$WDIR/julia-$JL_VERSION\n\
LDFLAGS=-latomic\n\
override FC=gfortran-8\n\
override CC=gcc-8\n\
override CXX=g++-8\n\
" > Make.user && \
    cat Make.user && \
    git clone --depth=1 -b $JL_VERSION https://github.com/JuliaLang/julia.git $JL_BUILD_DIR &&\
    cp Make.user $JL_BUILD_DIR && \
    cd $JL_BUILD_DIR && make -j $(nproc) OPENBLAS_USE_THREAD=0 && make install

# add path of Julia
ENV PATH=$WDIR/julia-$JL_VERSION/bin:$PATH

# clean up
RUN rm -r $JL_BUILD_DIR $WDIR/Make.user
RUN apt-get clean && rm -rf /var/cache/apt/archives/* /var/lib/apt/lists/*
ViralBShah commented 4 years ago

Someone familiar with llvm would need to dive in and figure out what is breaking.

terasakisatoshi commented 4 years ago
# Build Julia binary for arm32-bit devices e.g. RaspberryPi Zero(W/WH)
FROM balenalib/raspberry-pi:buster-20191030

MAINTAINER SATOSHI TERASAKI

# install dependencies
RUN apt-get update && \
    apt-get install -y build-essential libatomic1 python gfortran perl wget m4 cmake pkg-config \
    libopenblas-dev \
    liblapack-dev \
    libgmp3-dev \
    libmpfr-dev \
    git

# build julia from source
ARG JL_VERSION="v1.3.0"
ARG WDIR=/home/pi/work
ARG JL_BUILD_DIR=$WDIR/build
WORKDIR $WDIR
RUN echo "\
prefix=$WDIR/julia-$JL_VERSION\n\
JULIA_CPU_TARGET=arm1176jzf-s\n\
LDFLAGS=-latomic\n\
USE_BINARYBUILDER=0\n\
override USE_SYSTEM_BLAS=1\n\
override USE_SYSTEM_LAPACK=1\n\
override USE_SYSTEM_LIBM=1\n\
override USE_SYSTEM_GMP=1\n\
override USE_SYSTEM_MPFR=1\n\
" > Make.user && \
    cat Make.user && \
    git clone --depth=1 -b $JL_VERSION https://github.com/JuliaLang/julia.git $JL_BUILD_DIR &&\
    cp Make.user $JL_BUILD_DIR && \
    cd $JL_BUILD_DIR && make -j $(nproc) OPENBLAS_USE_THREAD=0 && make install

# add path of Julia
ENV PATH=$WDIR/julia-$JL_VERSION/bin:$PATH

# clean up
RUN rm -r $JL_BUILD_DIR $WDIR/Make.user
RUN apt-get clean && rm -rf /var/cache/apt/archives/* /var/lib/apt/lists/*
terasakisatoshi commented 4 years ago
# Open terminal your work station
$ docker build -t julia4pi -f Dockerfile-v1.3.0 .
$ docker run --name jltmp julia4pi /bin/bash
$ docker cp jltmp:/home/pi/work/julia-v.1.3.0 /home/pi
$ ls
julia-v.1.3.0
$ scp -r julia-v1.3.0 pi@raspberrypi.local # this is your Raspberry Pi Zero
# Open terminal of your Raspberry Pi Zero e.g. ssh pi@raspberrypi.local
$ sudo apt-get update && \
    apt-get install -y build-essential libatomic1 python gfortran perl wget m4 cmake pkg-config \
    libopenblas-dev \
    liblapack-dev \
    libgmp3-dev \
    libmpfr-dev
$ echo 'PATH=/home/pi/julia-v1.3.0:$PATH' >> /home/pi/.bashrc
$ source /home/pi/.bashrc
$ julia
terasakisatoshi commented 4 years ago