File: linux.sh

package info (click to toggle)
ospray 3.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 10,048 kB
  • sloc: cpp: 80,569; ansic: 951; sh: 805; makefile: 170; python: 69
file content (161 lines) | stat: -rwxr-xr-x 3,813 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#!/bin/bash
## Copyright 2014 Intel Corporation
## SPDX-License-Identifier: Apache-2.0

#### Helper functions ####

function check_symbols
{
  for sym in `nm $1 | grep $2_`
  do
    version=(`echo $sym | sed 's/.*@@\(.*\)$/\1/g' | grep -E -o "[0-9]+"`)
    if [ ${#version[@]} -ne 0 ]; then
      if [ ${#version[@]} -eq 1 ]; then version[1]=0; fi
      if [ ${#version[@]} -eq 2 ]; then version[2]=0; fi
      if [ ${version[0]} -gt $3 ]; then
        echo "Error: problematic $2 symbol " $sym
        exit 1
      fi
      if [ ${version[0]} -lt $3 ]; then continue; fi

      if [ ${version[1]} -gt $4 ]; then
        echo "Error: problematic $2 symbol " $sym
        exit 1
      fi
      if [ ${version[1]} -lt $4 ]; then continue; fi

      if [ ${version[2]} -gt $5 ]; then
        echo "Error: problematic $2 symbol " $sym
        exit 1
      fi
    fi
  done
}

function check_lib_dependency_error
{
for lib in "$1"
do
  if [ -n "`ldd $lib | fgrep $2`" ]; then
    echo "Error: dependency to '$2' found"
    exit 3
  fi
done
}

function get_so_version
{
  local version=`ldd $1 | fgrep $2 | sed "s/.*\.so\.\([0-9\.]\+\).*/\1/"`
  echo "$version"
}

#### Set variables for script ####

ROOT_DIR=$PWD
DEP_DIR=$ROOT_DIR/deps
DEP_BUILD_DIR=$ROOT_DIR/build_deps
THREADS=`nproc`

if [ `uname -m` == aarch64 ]; then
  GPU=OFF
else
  GPU=ON
  SYM_TEST=true # FIXME: currently building ARM on Ubuntu
fi


#### Build dependencies ####

mkdir $DEP_BUILD_DIR
cd $DEP_BUILD_DIR

# NOTE(jda) - Some Linux OSs need to have lib/ on LD_LIBRARY_PATH at build time
export LD_LIBRARY_PATH=$DEP_DIR/lib:${LD_LIBRARY_PATH}

cmake --version

cmake \
  "$@" \
  -D BUILD_JOBS=$THREADS \
  -D BUILD_DEPENDENCIES_ONLY=ON \
  -D CMAKE_INSTALL_PREFIX=$DEP_DIR \
  -D CMAKE_INSTALL_LIBDIR=lib \
  -D BUILD_OSPRAY_MODULE_MPI=ON \
  -D BUILD_GPU_SUPPORT=$GPU \
  -D INSTALL_IN_SEPARATE_DIRECTORIES=OFF \
  ../scripts/superbuild

cmake --build .

cd $ROOT_DIR

#### Build OSPRay ####

mkdir -p build_release
cd build_release

# Clean out build directory to be sure we are doing a fresh build
rm -rf *

# Setup environment for dependencies
export CMAKE_PREFIX_PATH=$DEP_DIR

# set release settings
cmake -L \
  "$@" \
  -D TBB_ROOT=$DEP_DIR \
  -D OSPRAY_ZIP_MODE=ON \
  -D OSPRAY_BUILD_ISA=ALL \
  -D OSPRAY_INSTALL_DEPENDENCIES=ON \
  -D OSPRAY_MODULE_DENOISER=ON \
  -D OSPRAY_MODULE_MPI=ON \
  -D OSPRAY_MODULE_GPU=$GPU \
  -D CMAKE_INSTALL_INCLUDEDIR=include \
  -D CMAKE_INSTALL_LIBDIR=lib \
  -D CMAKE_INSTALL_DOCDIR=doc \
  -D CMAKE_INSTALL_BINDIR=bin \
  -D CMAKE_BUILD_WITH_INSTALL_RPATH=ON \
  ..


# create tar.gz
make -j $THREADS preinstall

if [ $SYM_TEST ] ; then

# verify libs
for lib in libospray.so libospray_module_cpu.so libospray_module_mpi_offload.so libospray_module_mpi_distributed_cpu.so ; do
  echo "checking $lib..."
  check_symbols $lib GLIBC   2 28 0
  check_symbols $lib GLIBCXX 3 4 22
  check_symbols $lib CXXABI  1 3 11
  check_lib_dependency_error $lib libimf.so
  check_lib_dependency_error $lib libsvml.so
done

for lib in libospray_module_mpi_offload.so libospray_module_mpi_distributed_cpu.so ; do
  echo "checking $lib..."
  check_lib_dependency_error $lib libmpifort.so
  
  MPICH_ABI_VER=12
  mpi_so_ver=$(get_so_version $lib libmpi.so)
  mpicxx_so_ver=$(get_so_version $lib libmpicxx.so)
  
  if [ -z "$mpi_so_ver" ] || [ -z "$mpicxx_so_ver" ]; then
    echo "MPI module is not linked against libmpi.so or libmpicxx.so"
    exit 3
  fi
  
  if [ "$mpi_so_ver" != "$MPICH_ABI_VER" ]; then
    echo "MPI module is linked against the wrong MPICH ABI: libmpi.so.$mpi_so_ver"
    exit 3
  fi
  if [ "$mpicxx_so_ver" != "$MPICH_ABI_VER" ]; then
    echo "MPI module is linked against the wrong MPICH ABI: libmpicxx.so.$mpi_so_ver"
    exit 3
  fi
done

fi

cmake --build . --target package || exit 2