ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CMSDIST/llvm-gcc-toolfile.spec
Revision: 1.3
Committed: Tue Jan 25 13:04:30 2011 UTC (14 years, 3 months ago) by eulisse
Branch: MAIN
Changes since 1.2: +1 -1 lines
Log Message:
Fix relocation issue.

* This was actually already affecting (and then it was fixed) in gcc-toolfile,
  but I started from a bad revision. Should be fixed now.

File Contents

# User Rev Content
1 eulisse 1.1 ### RPM cms llvm-gcc-toolfile 11.0
2    
3     Requires: llvm
4     %if "%(echo %cmsos | grep osx >/dev/null && echo true)" == "true"
5     Requires: gfortran-macosx
6     %endif
7     Source: none
8    
9     %if "%(echo %cmsos | grep osx >/dev/null && echo true)" == "true"
10     Requires: gfortran-macosx
11     %else
12     Requires: gcc
13     %endif
14    
15     %prep
16     %build
17     %install
18     mkdir -p %i/etc/scram.d
19    
20     export LLVM_PATH
21     export LLVM_ROOT
22     export LLVM_VERSION
23    
24     # Determine the GCC_ROOT if "use system compiler is used. We still need this
25     # because we need to pick up libstdc++ from the gcc installation since clang
26     # does not ship its own and because clang does not provide a fortran compiler.
27     if [ "X$GCC_ROOT" = X ]
28     then
29     export GCC_PATH=`which gcc` || exit 1
30     export GCC_ROOT=`echo $GCC_PATH | sed -e 's|/bin/gcc||'`
31     export GCC_VERSION=`gcc -v 2>&1 | grep "gcc version" | sed 's|[^0-9]*\([0-9].[0-9].[0-9]\).*|\1|'` || exit 1
32     export G77_ROOT=$GFORTRAN_MACOSX_ROOT
33     else
34     export GCC_PATH
35     export GCC_ROOT
36     export GCC_VERSION
37     export G77_ROOT=$GCC_ROOT
38     fi
39    
40     export GCC_REALVERSION=`echo $GCC_VERSION | sed -e's|-.*||'`
41     export COMPILER_VERSION=`echo $LLVM_VERSION`
42     export COMPILER_VERSION_MAJOR=`echo $LLVM_VERSION | sed -e 's|\([0-9]\).*|\1|'`
43     export COMPILER_VERSION_MINOR=`echo $LLVM_VERSION | sed -e 's|[0-9].\([0-9]\).*|\1|'`
44    
45 eulisse 1.2 export GCC_ARCH=$(basename $(dirname `find $GCC_ROOT/include -mindepth 4 -maxdepth 4 -name bits`))
46    
47 eulisse 1.1 # Generic template for the toolfiles.
48     # *** USE @VARIABLE@ plus associated environment variable to customize. ***
49     # DO NOT DUPLICATE the toolfile template.
50    
51     cat << \EOF_TOOLFILE >%i/etc/scram.d/cxxcompiler.xml
52     <tool name="cxxcompiler" version="@LLVM_VERSION@" type="compiler">
53     <client>
54     <environment name="CXXCOMPILER_BASE" default="@LLVM_ROOT@"/>
55     <environment name="GCCBINDIR" default="$CXXCOMPILER_BASE/bin"/>
56     <environment name="CXX" value="$GCCBINDIR/clang++@COMPILER_NAME_SUFFIX@"/>
57     </client>
58     <flags SCRAM_COMPILER_NAME="clang@COMPILER_VERSION@"/>
59     <flags CCCOMPILER="clang@COMPILER_VERSION_MAJOR@"/>
60     <flags MODULEFLAGS="@OS_SHAREDFLAGS@ @ARCH_SHAREDFLAGS@"/>
61     <flags CXXDEBUGFLAG="-g"/>
62     <flags CPPDEFINES="GNU_GCC"/>
63     <flags CPPDEFINES="_GNU_SOURCE"/>
64     <flags CXXSHAREDOBJECTFLAGS="-fPIC"/>
65     <flags CPPFLAGS="-I@GCC_ROOT@/include/c++/@GCC_REALVERSION@"/>
66 eulisse 1.2 <flags CPPFLAGS="-I@GCC_ROOT@/include/c++/@GCC_REALVERSION@/@GCC_ARCH@"/>
67 eulisse 1.1 <flags CPPFLAGS="-I@GCC_ROOT@/include/c++/@GCC_REALVERSION@/backward"/>
68     <flags CXXFLAGS="-O2 -pedantic -ansi -pthread -pipe"/>
69     <flags CXXFLAGS="@ARCH_CXXFLAGS@ @COMPILER_CXXFLAGS@"/>
70     <flags CXXFLAGS="-felide-constructors -fmessage-length=0 -ftemplate-depth-300"/>
71     <flags CXXFLAGS="-Wunknown-warning-option -Wall -Wno-non-template-friend -Wno-long-long -Wimplicit -Wreturn-type -Wunused -Wparentheses -Wsign-compare -Wno-deprecated -Werror=return-type -Werror=missing-braces -Werror=unused-value -Werror=address -Werror=format -Werror=write-strings -Werror=strict-overflow -fdiagnostics-show-option"/>
72     <flags LDFLAGS="@OS_LDFLAGS@"/>
73     <flags CXXSHAREDFLAGS="@OS_SHAREDFLAGS@ @ARCH_SHAREDFLAGS@"/>
74     <flags SHAREDSUFFIX="@OS_SHAREDSUFFIX@"/>
75     <flags LD_UNIT="@OS_LD_UNIT@ @ARCH_LD_UNIT@"/>
76     <flags SCRAM_LANGUAGE_TYPE="C++"/>
77     <runtime name="@OS_RUNTIME_LDPATH_NAME@" value="$CXXCOMPILER_BASE/lib" type="path"/>
78     <runtime name="PATH" value="$CXXCOMPILER_BASE/bin" type="path"/>
79     <runtime name="@OS_RUNTIME_LDPATH_NAME@" value="@GCC_ROOT@/@ARCH_LIB64DIR@" type="path"/>
80     <runtime name="@OS_RUNTIME_LDPATH_NAME@" value="@GCC_ROOT@/lib" type="path"/>
81     <runtime name="PATH" value="@GCC_ROOT@/bin" type="path"/>
82     </tool>
83     EOF_TOOLFILE
84    
85     cat << \EOF_TOOLFILE >%i/etc/scram.d/ccompiler.xml
86     <tool name="ccompiler" version="@LLVM_VERSION@" type="compiler">
87     <client>
88     <environment name="CCOMPILER_BASE" default="@LLVM_ROOT@"/>
89     <environment name="GCCBINDIR" value="$CCOMPILER_BASE/bin"/>
90     <environment name="CC" value="$GCCBINDIR/clang@COMPILER_NAME_SUFFIX@"/>
91     </client>
92     <flags CDEBUGFLAG="-g"/>
93     <flags CSHAREDOBJECTFLAGS="-fPIC"/>
94     <flags CFLAGS="-pthread"/>
95     <flags CFLAGS="-O2"/>
96     <flags LDFLAGS="@OS_LDFLAGS@"/>
97     <flags CSHAREDFLAGS="@OS_SHAREDFLAGS@ @ARCH_SHAREDFLAGS@"/>
98     <flags SCRAM_COMPILER_NAME="clangc@COMPILER_VERSION@"/>
99     <flags SCRAM_LANGUAGE_TYPE="C"/>
100     </tool>
101     EOF_TOOLFILE
102    
103     # Notice that on OSX we have a LIBDIR defined for f77compiler because gcc C++
104     # compiler (which comes from the system) does not know about where to find
105     # libgfortran.
106     cat << \EOF_TOOLFILE >%i/etc/scram.d/f77compiler.xml
107     <tool name="f77compiler" version="@GCC_VERSION@" type="compiler">
108     <lib name="gfortran"/>
109     <lib name="m"/>
110     <client>
111     <environment name="F77COMPILER_BASE" default="@G77_ROOT@"/>
112     <environment name="FC" default="$F77COMPILER_BASE/bin/gfortran"/>
113     @ARCH_FORTRAN_LIBDIR@
114     </client>
115     <flags SCRAM_COMPILER_NAME="clang@COMPILER_VERSION@"/>
116     <flags FFLAGS="-fno-second-underscore -Wunused -Wuninitialized -O2"/>
117     <flags FCO2FLAG="-O2"/>
118     <flags FCOPTIMISED="-O2"/>
119     <flags FCDEBUGFLAG="-g"/>
120     <flags FCSHAREDOBJECTFLAGS="-fPIC"/>
121     <flags SCRAM_LANGUAGE_TYPE="FORTRAN"/>
122     </tool>
123     EOF_TOOLFILE
124    
125     # NON-empty defaults
126     export COMPILER_EXEC_NAME="clang++"
127    
128     # First of all handle OS specific options.
129     case %cmsplatf in
130     slc* )
131     export OS_SHAREDFLAGS="-shared -Wl,-E"
132     export OS_SHAREDSUFFIX="so"
133     export OS_LDFLAGS="-Wl,-E -Wl,--hash-style=gnu"
134     export OS_RUNTIME_LDPATH_NAME="LD_LIBRARY_PATH"
135     ;;
136     osx* )
137     export OS_SHAREDFLAGS="-shared -dynamic -single_module"
138     export OS_SHAREDSUFFIX="dylib"
139     export OS_LDFLAGS="-Wl,-commons -Wl,use_dylibs"
140     export OS_RUNTIME_LDPATH_NAME="DYLD_LIBRARY_PATH"
141     ;;
142     esac
143    
144     # Then handle OS + architecture specific options (maybe we should enable more
145     # aggressive optimizations for amd64 as well??)
146     case %cmsplatf in
147     osx*_ia32_* )
148     export ARCH_CXXFLAGS="-arch i386"
149     export ARCH_SHAREDFLAGS="-arch i386"
150     export ARCH_LIB64DIR="lib"
151     export ARCH_FORTRAN_LIBDIR='<environment name="LIBDIR" default="$F77COMPILER_BASE/lib/gcc/i686-apple-darwin10/4.2.1"/>'
152     ;;
153     osx*_amd64_* )
154     export ARCH_CXXFLAGS="-arch x86_64"
155     export ARCH_SHAREDFLAGS="-arch x86_64"
156     export ARCH_LIB64DIR="lib"
157     export ARCH_FORTRAN_LIBDIR='<environment name="LIBDIR" default="$F77COMPILER_BASE/lib/gcc/i686-apple-darwin10/4.2.1/x86_64"/>'
158     ;;
159     osx*_ppc32_* )
160     export ARCH_CXXFLAGS="-arch ppc"
161     export ARCH_SHAREDFLAGS="-arch ppc"
162     export ARCH_LIB64DIR="lib"
163     ;;
164     slc*_amd64_* )
165     # For some reason on mac, some of the header do not compile if this is
166     # defined. Ignore for now.
167     export ARCH_CXXFLAGS="-Werror=overflow"
168     export ARCH_LIB64DIR="lib64"
169     export ARCH_LD_UNIT="-r -m elf_x86_64"
170     ;;
171     slc*_ia32_* )
172     # For some reason on mac, some of the header do not compile if this is
173     # defined. Ignore for now.
174     export ARCH_CXXFLAGS="-Werror=overflow"
175     export ARCH_LIB64DIR="lib"
176     export ARCH_LD_UNIT="-r -m elf_i386"
177     ;;
178     *)
179     echo "Unsupported."
180     exit 1
181     ;;
182     esac
183    
184     # Then handle compiler specific options. E.g. enable
185     # optimizations as they become available in gcc.
186     COMPILER_CXXFLAGS=
187     case %cmsplatf in
188     *_gcc4[56789]* )
189     COMPILER_CXXFLAGS="$COMPILER_CXXFLAGS -std=c++0x -ftree-vectorize"
190     F77_MMD="-cpp -MMD"
191     ;;
192     esac
193    
194     case %cmsplatf in
195     *_gcc4[3456789]* )
196     COMPILER_CXXFLAGS="$COMPILER_CXXFLAGS -Werror=type-limits"
197     ;;
198     esac
199    
200     # Enable visibility inlines hidden. Should drastically remove
201     # the amount of symbols due to templates.
202     # FIXME: not enabled on linux, yet, change the case statement
203     # to *_gcc4[23456789]* when stable.
204     case %cmsplatf in
205     osx* )
206     COMPILER_CXXFLAGS="$COMPILER_CXXFLAGS -fvisibility-inlines-hidden"
207     ;;
208     esac
209    
210     export COMPILER_CXXFLAGS
211    
212     # Handle here platform specific overrides. In case we
213     # want to tune something for a specific architecture.
214     case %cmsplatf in
215     osx10[56]*)
216     # On macosx we explicitly pick up a compiler version so that there is
217     # actually matching between the platform specified to cmsBuild and the
218     # compiler.
219     export COMPILER_NAME_SUFFIX="-$COMPILER_VERSION_MAJOR.$COMPILER_VERSION_MINOR"
220     ;;
221     esac
222    
223     # General substitutions
224     perl -p -i -e 's|\@([^@]*)\@|$ENV{$1}|g' %i/etc/scram.d/*.xml
225    
226     %post
227 eulisse 1.3 %{relocateConfig}etc/scram.d/*.xml
228 eulisse 1.1 echo "LLVM_GCC_TOOLFILE_ROOT='$CMS_INSTALL_PREFIX/%{pkgrel}'; export GCC_TOOLFILE_ROOT" > $RPM_INSTALL_PREFIX/%{pkgrel}/etc/profile.d/init.sh
229     echo "setenv LLVM_GCC_TOOLFILE_ROOT '$CMS_INSTALL_PREFIX/%{pkgrel}'" > $RPM_INSTALL_PREFIX/%{pkgrel}/etc/profile.d/init.csh