[hdf5] 02/02: WIP: Test making bounce libs
Alastair McKinstry
mckinstry at moszumanska.debian.org
Mon Jul 21 08:46:21 UTC 2014
This is an automated email from the git hooks/post-receive script.
mckinstry pushed a commit to branch dev-alternatives
in repository hdf5.
commit 15c1c80b1520dc297f0d492bf5be2e00ba2fbc42
Author: Alastair McKinstry <mckinstry at debian.org>
Date: Mon Jul 21 09:40:35 2014 +0100
WIP: Test making bounce libs
---
debian/libhdf5-flavor-dev.install.in | 1 +
debian/libhdf5-flavor-soname.install.in | 1 +
debian/make_bounce_libs.py | 197 ++++++++++++++++++++++++++++++++
debian/rules | 7 +-
4 files changed, 204 insertions(+), 2 deletions(-)
diff --git a/debian/libhdf5-flavor-dev.install.in b/debian/libhdf5-flavor-dev.install.in
index 5b64666..9d694fb 100644
--- a/debian/libhdf5-flavor-dev.install.in
+++ b/debian/libhdf5-flavor-dev.install.in
@@ -2,5 +2,6 @@ usr/include
usr/lib/*/libhdf5 at FLAVORLIB@*.so
usr/lib/*/libhdf5 at FLAVORLIB@*.settings
usr/lib/*/libhdf5 at FLAVORLIB@*.a
+usr/lib/*/@FLAVOR@/*.so
@IFMPI at usr/bin/h5pcc
@IFMPI at usr/bin/h5pfc
diff --git a/debian/libhdf5-flavor-soname.install.in b/debian/libhdf5-flavor-soname.install.in
index 4138d0e..f2d9ac7 100644
--- a/debian/libhdf5-flavor-soname.install.in
+++ b/debian/libhdf5-flavor-soname.install.in
@@ -2,3 +2,4 @@ usr/lib/*/libhdf5 at FLAVORLIB@.so.*
usr/lib/*/libhdf5 at FLAVORLIB@_hl.so.*
usr/lib/*/libhdf5 at FLAVORLIB@_fortran.so.*
usr/lib/*/libhdf5 at FLAVORLIB@hl_fortran.so.*
+usr/lib/*/@FLAVOR@/*.so.*
diff --git a/debian/make_bounce_libs.py b/debian/make_bounce_libs.py
new file mode 100755
index 0000000..ad3a1c6
--- /dev/null
+++ b/debian/make_bounce_libs.py
@@ -0,0 +1,197 @@
+#!/usr/bin/python3
+"""
+Create bounce libraries for HDF5
+
+Alastair McKinstry, <mckinstry at debian.org>
+ 2014-07-17
+
+TODO: Split ver files into per-library versions (e.g. separate out
+ fortran, hl bits)
+"""
+from os.path import join, getsize
+import sys
+
+###
+### First we need to parse the version scripts and create
+### linker script from them ...
+###
+
+def sh(cmd, debug=True):
+ """Helper. Do a shell command."""
+ import subprocess, sys
+ (st, out) = subprocess.getstatusoutput(cmd)
+ if debug: print("[doing %s]" % cmd)
+ if st != 0:
+ print("Error: %s " % out)
+ sys.exit(1)
+ return out
+
+def cleaned_line(line, in_comment=False):
+ """ Clean a comment line. Either the line contains /* or we're already
+ in a multiline comment. We don't handle nested comments."""
+ if in_comment:
+ start = 0
+ else:
+ start = line.find('/*')
+ in_comment = True
+ if '*/' in line:
+ end = line.find('*/')+2
+ in_comment = False
+ else:
+ end = len(line)
+ newl = line[:start] + line[end:]
+ if '/*' in newl: # Clean further comments.
+ return cleaned_line(newl, in_comment)
+ else:
+ return newl, in_comment
+
+def version_file_tokens(lines):
+ """Break a file into tokens; returns a generator"""
+ in_comment = False
+ for line in lines:
+ if ('/*' in line) or in_comment:
+ newl, in_comment = cleaned_line(line, in_comment)
+ for token in newl.split():
+ yield token
+ else:
+ for token in line.split():
+ yield token
+
+class SymbolSet:
+ def __init__(self, version):
+ self.version = version
+ self.inherits = None
+ self.global_list = []
+ self.local_list = []
+
+ def parse_syms(self, syms, inherits = None):
+ """Parse a tokenized description of symset into SymbolSet object.
+ """
+ self.inherits = inherits
+ in_global = True
+ # Assume two sections. Local and global.
+ for t in syms:
+ if t=='global:':
+ in_global = True
+ elif t == 'local':
+ in_global = False
+ else:
+ if t == '{' or t == '*;':
+ continue
+ if in_global:
+ self.global_list += [t[:-1]]
+ else:
+ self.local_list += [t[:-1]]
+
+ def __str__(self):
+ """Print out a symbol set."""
+ s = "%s { \n" % self.version
+ if self.global_list:
+ s += "\tglobal:\n"
+ for sym in self.global_list:
+ s += '\t\t%s;\n' % sym
+ if self.local_list:
+ s += "\tlocal:\n"
+ for sym in self.local_list:
+ s += '\t\t%s;\n' % sym
+ s += '\t};\n'
+ if self.inherits:
+ s += '} %s;\n' % self.inherits
+ else:
+ s += '};\n'
+ return s
+ def new_generic_version(self):
+ """Return a new SymbolSet with generic version name"""
+ # HDF5_XXX_1.2 -> HDF5_1.2
+ s, e = self.version.find('_'), self.version.rfind('_')
+ newv = self.version[:s] + self.version[e:]
+ cp = SymbolSet(newv)
+ cp.global_list = self.global_list
+ cp.local_list = self.local_list
+ if self.inherits:
+ s = self.inherits.find('_')
+ e = self.inherits.rfind('_')
+ cp.inherits = self.inherits[:s] + self.inherits[e:]
+ return cp
+
+def parse_version_file(filename):
+ """Parse a version file into symbolsets"""
+ with open(filename) as f:
+ lines = open(filename).readlines()
+ tokens = version_file_tokens(lines)
+ sets = []
+ for t in tokens:
+ # Assume well formed. Ie. first token has ';'
+ if t.endswith(';'):
+ raise Exception("Buggy token : %s " % t)
+ n = SymbolSet(t)
+ syms = []
+ t = next(tokens)
+ while t != '}' and t != '};':
+ syms += [t]
+ t = next(tokens)
+ if t=='};':
+ n.parse_syms(syms)
+ sets.append(n)
+ else:
+ t = next(tokens)
+ inherits = t[:-1]
+ n.parse_syms(syms, inherits)
+ sets.append(n)
+ return sets
+
+def write_linker_script(filename, symbols_sets):
+ """Write the linker script."""
+ with open(filename,'w') as f:
+ print("/* linker script */", file=f)
+ for ss in symbols_sets:
+ for s in ss.global_list:
+ print("%s = __dummy_h5;" % s,file=f)
+ print("VERSION { \n", file=f);
+ for ss in symbols_sets:
+ print(ss, file=f)
+ print("};",file=f);
+
+def create_bounce_libs(dirname, scriptname, filtername, libname, soname ):
+ """Create a bounce library that the alternative will point to.
+ """
+ f=open('%s/dummy.c' % tmpdir,'w')
+ print(""" void __dummy_h5(void) { int a; } """, file=f)
+ f.close()
+ sh("cd %s && gcc -c dummy.c " % tmpdir)
+ sh("""ld -shared -o %s/%s --script=%s -f %s/lib%s.so -L%s -l%s \
+ --soname=%s %s/dummy.o""" % \
+ (dirname, libname, scriptname, dirname, filtername, \
+ dirname,filtername, soname, tmpdir))
+
+
+###
+### Main program
+###
+
+# pass in from Makefile
+# e.g . ver_filename = 'debian/mpich_mpi.ver,
+# libsuffix= '_hl', sover='8', flavor='mpich'
+
+# TODO: Spit ver_filename into per-library components
+
+ver_filename, sover, flavor = sys.argv[1:4]
+
+if flavor != 'serial':
+ flavorlib = '-%s' % flavor
+else:
+ flavorlib = ''
+multiarch = sh("dpkg-architecture -qDEB_HOST_MULTIARCH")
+dirname = 'debian/build%s/tmpinst/usr/lib/%s' % (flavorlib, multiarch)
+tmpdir = 'debian/tmp/%s' % flavor
+sh('mkdir -p %s' % tmpdir)
+sh('mkdir -p %s/%s' % (dirname,flavor))
+
+for libsuffix in ['','_hl','_fortran','hl_fortran']:
+ filtername = 'libhdf5%s_%s' % (libsuffix, flavor)
+ soname = 'libhdf5%s.so.%s' % (libsuffix, sover)
+ bouncename ='libhdf5%s_b.so.%s' % (libsuffix, sover)
+ scriptname = '%s/link-libhdf5%s-%s.scr' % (tmpdir,libsuffix,flavor)
+ symbol_sets = parse_version_file(ver_filename)
+ write_linker_script(scriptname, symbol_sets)
+ create_bounce_libs(dirname, scriptname,filtername, bouncename, soname)
diff --git a/debian/rules b/debian/rules
index 0ecabf0..89364d1 100755
--- a/debian/rules
+++ b/debian/rules
@@ -221,8 +221,9 @@ install: build prep install-serial $(install_openmpi) install-mpich install-doc
install-serial: build-stamp
dh_testdir
dh_testroot
- -mkdir debian/build/tmpinst
+ -mkdir debian/build/tmpinst
$(MAKE) -C debian/build/ install prefix=$(CURDIR)/debian/build/tmpinst/usr
+ ./debian/make_bounce_libs.py debian/map_serial.ver 8 serial
chrpath -d $(CURDIR)/debian/build/tmpinst/usr/lib/*/libhdf5*so*
dh_install -p$(serpack) -p$(package)-dev -phdf5-helpers -phdf5-tools -p$(sercpppack) \
--sourcedir=debian/build/tmpinst
@@ -234,6 +235,7 @@ install-openmpi: build-stamp-openmpi
dh_testroot
-mkdir debian/build-openmpi/tmpinst
$(MAKE) -C debian/build-openmpi/ install prefix=$(CURDIR)/debian/build-openmpi/tmpinst/usr
+ ./debian/make_bounce_libs.py debian/map_mpi.ver 8 openmpi
chrpath -d $(CURDIR)/debian/build-openmpi/tmpinst/usr/lib/*/libhdf5*so*
dh_install -p$(openmpipack) -p$(package)-openmpi-dev \
--sourcedir=debian/build-openmpi/tmpinst
@@ -247,7 +249,8 @@ install-mpich: build-stamp-mpich
dh_testroot
-mkdir debian/build-mpich/tmpinst
$(MAKE) -C debian/build-mpich/ install prefix=$(CURDIR)/debian/build-mpich/tmpinst/usr
- chrpath -d $(CURDIR)/debian/build-mpich/tmpinst/usr/lib/*/libhdf5*so*
+ ./debian/make_bounce_libs.py debian/map_mpi.ver 8 mpich
+ chrpath -d $(CURDIR)/debian/build-mpich/tmpinst/usr/lib/*/libshdf5*so*
dh_install -p$(mpichpack) -p$(package)-mpich-dev \
--sourcedir=debian/build-mpich/tmpinst
install -m644 -D debian/hdf5-mpich.pc debian/$(package)-mpich-dev/usr/lib/$(DEB_HOST_MULTIARCH)/pkgconfig/hdf5-mpich.pc
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/hdf5.git
More information about the Pkg-grass-devel
mailing list