Skip to content

Commit

Permalink
compiler-families/llvm-compilers: use distro gcc (#623)
Browse files Browse the repository at this point in the history
Signed-off-by: Reese Baird <reese.baird@intel.com>
  • Loading branch information
crbaird committed Feb 6, 2018
1 parent d782529 commit 87812ee
Showing 1 changed file with 13 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,8 @@
#
#----------------------------------------------------------------------------eh-

%define compiler_family gnu7
%include %{_sourcedir}/OHPC_macros

# Remember to drop this gnu-compilers dependency in the future,
# when gcc-5.3+ appear in all the targeted Linux distros.
%global gnuver 7.3.0

%global clang_sha b11539abc46cbd19189c5719d1e30539de3a93b9
%global flang_sha 37e86e06f74d9bd91ef6bb511c026753b9124006

Expand All @@ -38,27 +33,27 @@ Source6: http://releases.llvm.org/%{version}/libunwind-%{version}.src.tar.xz
Source7: http://releases.llvm.org/%{version}/lld-%{version}.src.tar.xz
Source8: http://releases.llvm.org/%{version}/openmp-%{version}.src.tar.xz
Source9: OHPC_macros
BuildRequires: gnu7-compilers%{PROJ_DELIM}
BuildRequires: cmake%{PROJ_DELIM}
BuildRequires: make
BuildRequires: perl
BuildRequires: python
BuildRequires: pkgconfig
BuildRequires: binutils-devel
%if 0%{?sles_version} || 0%{?suse_version}
BuildRequires: gcc-fortran
BuildRequires: libstdc++48-devel
%else
BuildRequires: gcc-gfortran
BuildRequires: libstdc++-devel
%endif
Requires: binutils
BuildRequires: gcc-c++
Requires: gcc-c++
Requires: gnu7-compilers%{PROJ_DELIM}
%if 0%{?rhel_version} || 0%{?centos_version} || 0%{?rhel}
BuildRequires: perl-Data-Dumper
%endif

%define install_path %{OHPC_COMPILERS}/llvm/%{version}
%define gnu_path %{OHPC_COMPILERS}/gcc/%{gnuver}
%if 0%{?sles_version} || 0%{?suse_version}
%define compiler_path `%{OHPC_COMPILERS}/gcc/%{gnuver}/bin/g++ -v --version 2>&1|grep COMPILER_PATH|cut -f 2- -d '='`
%define library_path `%{OHPC_COMPILERS}/gcc/%{gnuver}/bin/g++ -v --version 2>&1|grep LIBRARY_PATH|cut -f 2- -d '='`
%endif

%description

Expand All @@ -79,7 +74,6 @@ cd llvm-%{version}.src/projects
ln -s ../../compiler-rt-%{version}.src compiler-rt
cd ../..

%ifnarch ppc64le
cd llvm-%{version}.src/projects
ln -s ../../libcxx-%{version}.src libcxx
cd ../..
Expand All @@ -91,7 +85,6 @@ cd ../..
cd llvm-%{version}.src/projects
ln -s ../../libunwind-%{version}.src libunwind
cd ../..
%endif

cd llvm-%{version}.src/projects
ln -s ../../openmp-%{version}.src openmp
Expand All @@ -104,7 +97,6 @@ ln -s flang-%{flang_sha} flang
%{__sed} -i -e 's/-Werror/-Wall/g' flang/CMakeLists.txt

%install
%ohpc_setup_compiler
module load cmake

mkdir build-clang
Expand All @@ -125,32 +117,16 @@ cmake \
%{__make} DESTDIR=$RPM_BUILD_ROOT INSTALL="%{__install} -p" install
cd ..

%if 0%{?sles_version} || 0%{?suse_version}
SUSE_CXXFLAGS="-I%{gnu_path}/include/c++/%{gnuver}"
%ifarch aarch64
SUSE_CXXFLAGS="$SUSE_CXXFLAGS -I%{gnu_path}/include/c++/%{gnuver}/aarch64-unknown-linux-gnu"
%endif
%ifarch x86_64
SUSE_CXXFLAGS="$SUSE_CXXFLAGS -I%{gnu_path}/include/c++/%{gnuver}/x86_64-pc-linux-gnu"
%endif
%endif

mkdir build-flang
cd build-flang
CC=$RPM_BUILD_ROOT/%{install_path}/bin/clang \
CXX=$RPM_BUILD_ROOT/%{install_path}/bin/clang++ \
CFLAGS="-fPIC -DPIC" \
%if 0%{?sles_version} || 0%{?suse_version}
CXXFLAGS="-fPIC -DPIC $SUSE_CXXFLAGS" \
%else
CXXFLAGS="-fPIC -DPIC" \
%endif
FFLAGS="-fPIC -DPIC" \
FCFLAGS="-fPIC -DPIC" \
%if 0%{?sles_version} || 0%{?suse_version}
COMPILER_PATH=%{compiler_path} \
LIBRARY_PATH=%{library_path} \
%endif

cmake \
../flang \
-DCMAKE_SKIP_RPATH=YES \
Expand All @@ -166,10 +142,7 @@ cmake \
-DFLANG_LIBOMP=$RPM_BUILD_ROOT/%{install_path}/lib/libomp.so \
-DCMAKE_INSTALL_PREFIX=%{install_path}

%if 0%{?sles_version} || 0%{?suse_version}
COMPILER_PATH=%{compiler_path} \
LIBRARY_PATH=%{library_path} \
%endif

%{__make} VERBOSE=1
%{__make} VERBOSE=1 DESTDIR=$RPM_BUILD_ROOT INSTALL="%{__install} -p" install
cd ..
Expand All @@ -183,10 +156,7 @@ F90=$RPM_BUILD_ROOT/%{install_path}/bin/flang \
F95=$RPM_BUILD_ROOT/%{install_path}/bin/flang \
F03=$RPM_BUILD_ROOT/%{install_path}/bin/flang \
LD_LIBRARY_PATH=$RPM_BUILD_ROOT/%{install_path}/lib:$LD_LIBRARY_PATH \
%if 0%{?sles_version} || 0%{?suse_version}
COMPILER_PATH=%{compiler_path} \
LIBRARY_PATH=%{library_path} \
%endif

cmake \
../llvm/projects/openmp \
-DBUILD_SHARED_LIBS=True \
Expand Down Expand Up @@ -225,19 +195,10 @@ set version %{version}

prepend-path PATH %{install_path}/bin
prepend-path MANPATH %{install_path}/share/man
prepend-path LD_LIBRARY_PATH %{gnu_path}/lib64:%{install_path}/lib
prepend-path LD_LIBRARY_PATH %{install_path}/lib
prepend-path CMAKE_MODULE_PATH %{install_path}/lib/cmake/clang:%{install_path}/lib/cmake/llvm
prepend-path MODULEPATH %{OHPC_MODULEDEPS}/llvm
%if 0%{?sles_version} || 0%{?suse_version}
prepend-path COMPILER_PATH %{compiler_path}
prepend-path LIBRARY_PATH %{library_path}
%ifarch aarch64
prepend-path CPLUS_INCLUDE_PATH %{gnu_path}/include/c++/%{gnuver}:%{gnu_path}/include/c++/%{gnuver}/aarch64-unknown-linux-gnu
%endif
%ifarch x86_64
prepend-path CPLUS_INCLUDE_PATH %{gnu_path}/include/c++/%{gnuver}:%{gnu_path}/include/c++/%{gnuver}/x86_64-pc-linux-gnu
%endif
%endif


family "compiler"
EOF
Expand Down Expand Up @@ -266,3 +227,4 @@ EOF
%changelog
* Thu May 25 2017 Paul Osmialowski <pawel.osmialowski@foss.arm.com> - 4.0.0-1
- add Fortran language frontend and runtime libraries (Flang)

0 comments on commit 87812ee

Please sign in to comment.