Needs help to build LoopTools using BinaryBuilder

Hello,

There is a package called LoopTools, for which I succeeded in building a .so shared lib locally that I can call in julia.

Now I am trying to build it using BinaryBuilder.jl with the following code that was modified from the documentation

using BinaryBuilder, Pkg

name = "LoopTools"
version = v"2.15"

# Collection of sources required to complete build
sources = [
    ArchiveSource("http://www.feynarts.de/looptools/LoopTools-2.15.tar.gz", "a065ffdc4fe6882aa3bb926134ba8ec875d6c0a633c3d4aa5f70db26542713f2"),
]

# Bash recipe for building across all platforms
script = raw"""
cd ${WORKSPACE}/srcdir/LoopTools-*

./configure
make -j${nproc}
make install
"""

# These are the platforms we will build for by default, unless further
# platforms are passed in on the command line
# platforms = expand_gfortran_versions(supported_platforms())
#
platforms = [
    Linux(:x86_64, libc=:glibc)
]

# The products that we will ensure are always built
products = [
    LibraryProduct("liblooptools", :liblooptools)
]

# Dependencies that must be installed before this package can be built
dependencies = Dependency[
]

# Build the tarballs, and possibly a `build.jl` as well.
build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies)

but did not have luck to succeed…

The configure step already failed with the message:

[21:37:20]  ---> ./configure
[21:37:20] looking for gcc... /opt/bin/cc
[21:37:20] looking for g++... /opt/bin/c++
[21:37:20] looking for fortran... /opt/bin/gfortran
[21:37:20] extracting the Fortran libraries... ok
[21:37:20] does gfortran append underscores... error linking Fortran and C
[21:37:20]  ---> ./configure
[21:37:20] Previous command exited with 1
[21:37:21] Child Process exited, exit code 1

A successful ./configure would give a message like the following:

looking for gcc... /usr/bin/clang
looking for g++... /usr/bin/clang++
looking for fortran... /user/bin/gfortran
extracting the Fortran libraries... ok
does gfortran append underscores... yes
does gfortran support REAL*16... yes
does gfortran need 'external' for U77 routines... no
are we big-endian... no
do we have MathLink... yes
creating makefile

now you must run make

In the debug mode of binarybuilder, by LOGFILE=log.txt, export log.txt and then ./configure, I got the following log:

+ shopt -s nullglob
+ export LC_ALL=C
+ LC_ALL=C
+ CONF_DIR=.
++ uname -s
+ CONF_OS=Linux
++ uname -m
+ CONF_MACH=x86_64
+ CONF_DEFPREFIX=x86_64-Linux
+ CONF_PREFIX=x86_64-Linux
+ CONF_TARGET=
+ CONF_STATIC=
+ CONF_STATIC_EXT=
+ CONF_STATIC_GFORTRAN=
+ CONF_QUAD=
+ CONF_QUADSIZE=16
+ CONF_REAL10=
+ CONF_DEBUG=
+ CONF_BITS=
+ CONF_MCLIBS=
+ CONF_ARCH=
+ CONF_AS=
+ CONF_EXE=
+ CONF_LDFLAGS=
+ case "$CONF_OS" in
+ CONF_MCLIBS=' -lpthread -lrt'
+ test=test19
+ trap 'rm -fr test19* =.' 0 1 2 3 15
+ findprog gcc CC clang gcc
+ echo -n 'looking for gcc... '
+ var=CC
+ set -- cc clang gcc
+ test -n ''
+ for prog in "$@"
++ type -P cc
+ full=/opt/bin/cc
+ echo /opt/bin/cc
+ printf -v CONF_CC %q cc
+ return 0
+ findprog g++ CXX clang++ g++
+ echo -n 'looking for g++... '
+ var=CXX
+ set -- c++ clang++ g++
+ test -n ''
+ for prog in "$@"
++ type -P c++
+ full=/opt/bin/c++
+ echo /opt/bin/c++
+ printf -v CONF_CXX %q c++
+ return 0
+ findprog fortran FC ifort pgf90 xlf gfortran g95 f90
+ echo -n 'looking for fortran... '
+ var=FC
+ set -- gfortran ifort pgf90 xlf gfortran g95 f90
+ test -n ''
+ for prog in "$@"
++ type -P gfortran
+ full=/opt/bin/gfortran
+ echo /opt/bin/gfortran
+ printf -v CONF_FC %q gfortran
+ return 0
+ CONF_DEF=-D
++ ++ sed eval gfortran '/^$/d;s/(.*)//;q'
--version -c
+++ gfortran --version -c
+ set -- GNU Fortran 4.8.5
+ case "$1,$2,$3" in
+ eval setflags FFLAGS '-O3     -ffixed-line-length-none -fno-range-check   '
++ setflags FFLAGS -O3 -ffixed-line-length-none -fno-range-check
++ rhs=
++ printf -v rhs ' %q' -O3 -ffixed-line-length-none -fno-range-check
++ eval 'CONF_FFLAGS="${rhs//\\,/,}"'
+++ CONF_FFLAGS=' -O3 -ffixed-line-length-none -fno-range-check'
+ echo -n 'extracting the Fortran libraries... '
+ rm -fr
+ tee test19.f
        program test
        integer i
        common /uscore/ i
        call exit(i)
        end
++ eval gfortran ./configure: line 226: /dev/fd/62: No such file or directory++ eval -O3 -ffixed-line-length-none
gfortran -O3 -fno-range-check -v -ffixed-line-length-none -fno-range-check + eval -o test19 -v -o setflags LDFLAGS test19.f
test19 test19.f'  '

++ setflags LDFLAGS
++ rhs=
++ eval 'CONF_LDFLAGS="${rhs//\\,/,}"'
+++ CONF_LDFLAGS=
+ echo ok
++ eval cc --version -c
+ [[ +++ cc --version -c
x86_64-linux-gnu-gcc (GCC) 4.8.5
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. =~ gcc ]]
+ CONF_STATIC_GCC=
+ eval setflags CFLAGS '-O3 -g -fomit-frame-pointer -ffast-math -fPIC -Wall  '
++ setflags CFLAGS -O3 -g -fomit-frame-pointer -ffast-math -fPIC -Wall
++ rhs=
++ printf -v rhs ' %q' -O3 -g -fomit-frame-pointer -ffast-math -fPIC -Wall
++ eval 'CONF_CFLAGS="${rhs//\\,/,}"'
+++ CONF_CFLAGS=' -O3 -g -fomit-frame-pointer -ffast-math -fPIC -Wall'
+ eval setflags CXXFLAGS '-O3 -g -fomit-frame-pointer -ffast-math -Wall  '
++ setflags CXXFLAGS -O3 -g -fomit-frame-pointer -ffast-math -Wall
++ rhs=
++ printf -v rhs ' %q' -O3 -g -fomit-frame-pointer -ffast-math -Wall
++ eval 'CONF_CXXFLAGS="${rhs//\\,/,}"'
+++ CONF_CXXFLAGS=' -O3 -g -fomit-frame-pointer -ffast-math -Wall'
+ echo -n 'does gfortran append underscores... '
+ tee test19-c.c
int uscore_ = 95;
int uscore = 59;
+ for CONF_BITS in ${CONF_BITS:--m64 -m32} ""
+ eval cc -O3 -g -fomit-frame-pointer -ffast-math -fPIC -Wall -m64 -c test19-c.c
++ cc -O3 -g -fomit-frame-pointer -ffast-math -fPIC -Wall -m64 -c test19-c.c
You used one or more of the unsafe flags: -Ofast, -ffast-math, -funsafe-math-optimizations
Please repent.
+ continue
+ for CONF_BITS in ${CONF_BITS:--m64 -m32} ""
+ eval cc -O3 -g -fomit-frame-pointer -ffast-math -fPIC -Wall -m32 -c test19-c.c
++ cc -O3 -g -fomit-frame-pointer -ffast-math -fPIC -Wall -m32 -c test19-c.c
You used one or more of the unsafe flags: -Ofast, -ffast-math, -funsafe-math-optimizations
Please repent.
+ continue
+ for CONF_BITS in ${CONF_BITS:--m64 -m32} ""
+ eval cc -O3 -g -fomit-frame-pointer -ffast-math -fPIC -Wall -c test19-c.c
++ cc -O3 -g -fomit-frame-pointer -ffast-math -fPIC -Wall -c test19-c.c
You used one or more of the unsafe flags: -Ofast, -ffast-math, -funsafe-math-optimizations
Please repent.
+ continue
+ ./test19
./configure: line 258: ./test19: No such file or directory
+ case $? in
+ echo 'error linking Fortran and C'
+ exit 1
+ rm -fr test19-c.c test19.f =.

It is far beyond my knowledge to make it work, and I would like to ask for your kind help here. Thank you in advance.

Read the documentation of BinaryBuilder, in particular Build Tips · BinaryBuilder.jl. You must pass the flags --prefix=$prefix --build=${MACHTYPE} --host=${target} to configure.

Anyway, I recommend you opening a pull request to Yggdrasil with your build recipe so far and we’ll be able to have a look at it more easily. We also already have a recipe for Cuba, a library by the same author as LoopTools

Thanks for your quick reply. I tried ./configure --prefix=$prefix --build=${MACHTYPE} --host=${target}, but no success. I also just tried the recipe for Cuba, no success either…

I’ll open a PR later. Thanks.

What do you mean exactly? What’s the problem? You can’t build Cuba using that recipe? I’d be worried if it didn’t work with the latest stable version of BinaryBuilder. In fact, I tried right now and it worked flawless. Please, provide more context (operating system, version of BinaryBuilder, etc…)

Well, I opened the configure script, it starts with a comment

# configure script for LoopTools
# note: has nothing to do with GNU autoconf
# last modified 1 Jan 20 th

So it’ll be more complicated than expected…

1 Like

Ok, I found the culprit: remove -ffast-math from line 240 of the configure script. You’ll also need to set the following environment variables:

export AR=ar
export RANLIB=ranlib
1 Like

Very sorry for the confusion. I meant that I copied the recipe from Cuba for LoopTools… I’ll try your suggestions below.

Thanks. I tried these modifications in the debug mode, and ./configure still gives the same error…

BTW, I’m using WSL2, BinaryBuilder.jl v0.2.5 with julia 1.5.0.

Let’s continue in https://github.com/JuliaPackaging/Yggdrasil/pull/1411, it’s wasteful to have two places where to discuss

For the record, I ended up heavily patching the custom configure script and now we can build for all supported platforms.

Thank you!