WikiStart: make-xlsmp-nonconflicting.sh

File make-xlsmp-nonconflicting.sh, 484 bytes (added by hfinkel, 3 years ago)
Line 
1#!/bin/sh
2
3TF=$(mktemp)
4echo '#include <omp.h>' >> $TF.c
5echo 'int main() { return omp_get_num_threads(); }' > $TF.c
6XLSMP=$(bgxlc -qsmp=omp -O3 -Wl,--verbose -o $TF $TF.c 2>&1 | grep 'attempt to open .*libxlsmp.a succeeded' | head -n1 | awk '{ print $4 }')
7rm -f $TF
8
9echo "Renaming symbols in $XLSMP"
10for s in $(nm $XLSMP | grep 'D omp_' | awk '{ print $3 }' | sort | uniq); do
11        echo "$s __xl_$s" >> $TF.syms
12done
13
14objcopy --redefine-syms=$TF.syms $XLSMP libxlsmp.a
15rm -f $TF.syms
16