We’ve been using IOAPI 3.2 and are now compiling IOAPI 3.2 large. One of the problems we ran into was there is no top-level Makefile, so I use the top-level Makefile from the original tarball of IOAPI 3.2.
However, m3tools then fails to compile with:
m3combo.f90:(.text+0x5c2): relocation truncated to fit: R_X86_64_PC32 against `.bss'
The full trace is:
cd /tmp/spack-stage/yul18051/ioapi-3.2-large-z6yl2gueys6xxhwcpwpkreupbtu7cswq/spack-src/Linux2_x86_64; gfortran -fPIC m3combo.o -L/tmp/spack-stage/yul18051/ioapi-3.2-large-z6yl2gueys6xxhwcpwpkreupbtu7cswq/spack-src/Linux2_x86_64 -lioapi -lnetcdff -lnetcdf -fopenmp -dynamic -L/usr/lib64 -lm -lpthread -lc -o m3combo
m3combo.o: In function `MAIN__':
m3combo.f90:(.text+0x5c2): relocation truncated to fit: R_X86_64_PC32 against `.bss'
m3combo.f90:(.text+0x620): relocation truncated to fit: R_X86_64_PC32 against `.bss'
m3combo.f90:(.text+0x668): relocation truncated to fit: R_X86_64_PC32 against `.bss'
m3combo.f90:(.text+0x874): relocation truncated to fit: R_X86_64_PC32 against `.bss'
m3combo.f90:(.text+0xa31): relocation truncated to fit: R_X86_64_PC32 against `.bss'
m3combo.f90:(.text+0xb04): relocation truncated to fit: R_X86_64_PC32 against `.bss'
m3combo.f90:(.text+0xbd7): relocation truncated to fit: R_X86_64_PC32 against `.bss'
m3combo.f90:(.text+0xca5): relocation truncated to fit: R_X86_64_PC32 against `.bss'
m3combo.f90:(.text+0xcf1): relocation truncated to fit: R_X86_64_PC32 against `.bss'
m3combo.f90:(.text+0xd12): relocation truncated to fit: R_X86_64_PC32 against `.bss'
m3combo.f90:(.text+0xdf7): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
make[1]: *** [m3combo] Error 1
make[1]: Leaving directory `/tmp/spack-stage/yul18051/ioapi-3.2-large-z6yl2gueys6xxhwcpwpkreupbtu7cswq/spack-src/m3tools'
make: *** [all] Error 2
==> Error: ProcessError: Command exited with status 2:
'make' '-j12'
3 errors found in build log:
587 m3combo.f90:(.text+0xb04): relocation truncated to fit: R_X86_64_PC
32 against `.bss'
588 m3combo.f90:(.text+0xbd7): relocation truncated to fit: R_X86_64_PC
32 against `.bss'
589 m3combo.f90:(.text+0xca5): relocation truncated to fit: R_X86_64_PC
32 against `.bss'
590 m3combo.f90:(.text+0xcf1): relocation truncated to fit: R_X86_64_PC
32 against `.bss'
591 m3combo.f90:(.text+0xd12): relocation truncated to fit: R_X86_64_PC
32 against `.bss'
592 m3combo.f90:(.text+0xdf7): additional relocation overflows omitted
from the output
>> 593 collect2: error: ld returned 1 exit status
>> 594 make[1]: *** [m3combo] Error 1
595 make[1]: Leaving directory `/tmp/spack-stage/yul18051/ioapi-3.2-lar
ge-z6yl2gueys6xxhwcpwpkreupbtu7cswq/spack-src/m3tools'
>> 596 make: *** [all] Error 2
See build log for details:
/tmp/spack-stage/yul18051/ioapi-3.2-large-z6yl2gueys6xxhwcpwpkreupbtu7cswq/spack-build-out.txt
My past experience with similar errors is that the offending files need to be compiled with position independent code enabled using the -fPIC flag, but compiling both IOAPI (by adding -fPIC
to COPTFLAGS
and FOPTFLAGS
) and m3tools (by adding -fPIC
to LFLAGS
) does not help.
The full output files are here -
Environment log: spack-build-env.txt (18.4 KB)
Build log: spack-build-out.txt (147.0 KB)
Input file used to compile ioapi@3-2large
# Copyright 2013-2019 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import glob
import os
from spack import *
class Ioapi(MakefilePackage):
"""Models-3/EDSS Input/Output Applications Programming Interface."""
homepage = "https://www.cmascenter.org/ioapi/"
url = "https://www.cmascenter.org/ioapi/download/ioapi-3.2.tar.gz"
version('3.2', sha256='4858415e265d017b45d8b2d661286d8db8f6e70a5736f7a0d06ca275fab84c47')
version('3.2-large', sha256='1a92a8399261b4a500b0dd5c546ce6ec21c3310054fe17e15bcfeb9b77872c59')
resource(
# IOAPI 3.2-large is missing the root Makefile.template file.
when='@3.2-large',
name='root_makefile',
extension='template',
placement='patches',
expand=False,
url='https://raw.githubusercontent.com/cjcoats/ioapi-3.2/d01616e33ddc82be46ddf70cd4d7d381946b1e9b/Makefile.template',
sha256='6aff255459e2e7ff1d9b9aeb6df7438e38f9ee6975d1531a6f1e300d41bfc575',
)
depends_on('mpi')
depends_on('netcdf@4:')
depends_on('netcdf-fortran@4:')
depends_on('sed', type='build')
def edit(self, spec, prefix):
# Workaround not being able to copy resource files into the root directory.
if os.path.exists('patches'):
os.symlink(os.path.join('patches', 'Makefile.template'),
'Makefile.template')
# No default Makefile bundled; edit the template.
os.symlink('Makefile.template', 'Makefile')
# The makefile uses stubborn assignments of = instead of ?= so
# edit the makefile instead of using environmental variables.
makefile = FileFilter('Makefile')
makefile.filter('^BASEDIR.*', 'BASEDIR = ' + self.build_directory)
makefile.filter('^INSTALL.*', 'INSTALL = ' + prefix)
makefile.filter('^BININST.*', 'BININST = ' + prefix.bin)
makefile.filter('^LIBINST.*', 'LIBINST = ' + prefix.lib)
# Compile m3tools with PIC, otherwise linking airs2m3 fails.
env['LFLAGS'] = self.compiler.pic_flag
# Compile ioapi with PIC, otherwise linking airs2m3 fails.
#
# Find the name of the appropriate Makeinclude.* file from the
# top-directory Makefile.
bin = None
with open('Makefile') as f:
for line in f:
if line.startswith('BIN'):
bin = line.split()[-1]
break
if bin is None:
raise IOError('Could not find BIN file to patch with -fPIC!')
makeinclude = FileFilter(os.path.join('ioapi', 'Makeinclude.' + bin))
makeinclude.filter('^(COPTFLAGS.*)', r'\1 ' + self.compiler.pic_flag)
makeinclude.filter('^(FOPTFLAGS.*)', r'\1 ' + self.compiler.pic_flag)
def install(self, spec, prefix):
make('install')
# Install the header files.
mkdirp(prefix.include.fixed132)
headers = glob.glob('ioapi/*.EXT')
for header in headers:
install(header, prefix.include)
# Install the header files for CMAQ and SMOKE in the
# non-standard -ffixed-line-length-132 format.
headers_fixed132 = glob.glob('ioapi/fixed_src/*.EXT')
for header in headers_fixed132:
install(header, prefix.include.fixed132)