File llvm.spec of Package llvm

#
# spec file for package llvm
#
# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#


%define _revision     198681
%define _release_version 3.4

Name:           llvm
Version:        3.4
Release:        0
Summary:        Low Level Virtual Machine
License:        NCSA
Group:          Development/Languages/Other
Url:            http://www.llvm.org
Source0:        %{name}-%{version}.tar.bz2
Source100:      %{name}-rpmlintrc
# PATCH-FIX-OPENSUSE set-revision.patch idoenmez@suse.de -- Allow us to set revision
Patch1:         set-revision.patch
# PATCH-FIX-OPENSUSE assume-opensuse.patch idoenmez@suse.de -- Always enable openSUSE/SUSE features
Patch2:         assume-opensuse.patch
# PATCH-FIX-OPENSUSE clang-disable-ada-extension.patch idoenmez@suse.de -- Don't run gcc for ada files
Patch3:         clang-disable-ada-extension.patch
# PATCH-FIX-OPENSUSE default-to-i586.patch -- Use i586 as default target for 32bit
Patch4:         default-to-i586.patch
Patch5:         llvm-config-lib64.patch
# PATCH-FIX-OPENSUSE arm_suse_support.diff --Enable ARM suse toolchain support
Patch6:         arm_suse_support.diff
Patch7:         cmake-host-triple.patch
# PATCH-FIX-OPENSUSE aarch64-suse-support.patch -- Enable AArch64 suse toolchain support
Patch8:         aarch64-suse-support.patch
Patch9:         arm-remove-xfails.diff
# PATCH-FIX-OPENSUSE asan-disable-hugemalloctest.patch -- Disable ASAN HugeMallocTest
Patch10:        asan-disable-hugemalloctest.patch
Patch11:        clang-resourcedirs.patch
Patch12:        llvm-34branch-backports.patch
Patch13:        llvm-mainline-backports.patch
Patch14:        clang-mainline-backports.patch
Patch15:        aarch64-workaround.patch
# IBM's s390 patches
Patch1000:      backport-llvm-r195471
Patch1001:      backport-llvm-r197908
Patch1002:      backport-llvm-r197909
Patch1003:      backport-llvm-r197030
Patch1004:      backport-llvm-r215409
Patch1005:      backport-llvm-r221336
Patch1006:      backport-llvm-r204049
Patch1007:      backport-llvm-r204200
Patch1008:      backport-llvm-r205625
Patch1009:      backport-llvm-r205626
Patch1010:      backport-llvm-r212242
Patch1011:      backport-llvm-r220945
Patch1012:      backport-llvm-r212610
Patch1013:      backport-llvm-r212612
Patch1014:      backport-llvm-r212614
Patch1015:      backport-llvm-r212661
Patch1016:      backport-llvm-r212714
Patch1017:      backport-llvm-r218560
Patch1018:      backport-llvm-r196578
Patch1019:      backport-llvm-r196579
Patch1020:      backport-llvm-r196580
Patch1021:      backport-llvm-r196905
Patch1022:      backport-llvm-r196906
Patch1023:      backport-llvm-r197032
Patch1024:      backport-llvm-r197170
Patch1025:      backport-llvm-r197234
Patch1026:      backport-llvm-r197235
Patch1027:      backport-llvm-r197236
Patch1028:      backport-llvm-r197238
Patch1029:      backport-llvm-r197239
Patch1030:      backport-llvm-r197802
Patch1031:      backport-llvm-r197804
Patch1032:      backport-llvm-r197984
Patch1033:      backport-llvm-r197985
Patch1034:      backport-llvm-r197986
Patch1035:      backport-llvm-r198862
Patch1036:      backport-llvm-r199114
Patch1037:      backport-llvm-r199115
Patch1038:      backport-llvm-r199116
Patch1039:      backport-llvm-r199117
Patch1040:      backport-llvm-r203103
Patch1041:      backport-llvm-r203234
Patch1042:      backport-llvm-r204451
Patch1043:      backport-llvm-r204452
Patch1044:      backport-llvm-r210263
Patch1045:      backport-llvm-r212701
Patch1046:      backport-llvm-r212702
Patch1047:      backport-llvm-r212703
Patch1048:      backport-llvm-r212707
Patch1049:      backport-llvm-r212711
Patch1050:      backport-llvm-r216131
Patch1051:      backport-llvm-r219069
Patch1052:      backport-llvm-r229652
Patch1053:      backport-llvm-r229654
Patch1054:      backport-llvm-r229658
Patch1055:      backport-llvm-r233541
Patch1056:      backport-llvm-r233688
Patch1057:      backport-llvm-r233689
Patch1058:      backport-llvm-r233690
Patch1059:      backport-llvm-r233700
Patch1060:      backport-llvm-r233736
Patch1061:      backport-llvm-r233803
Patch1062:      backport-llvm-r236430
Patch1063:      backport-llvm-r236432
Patch1064:      backport-llvm-r236433
Patch1065:      backport-llvm-r236520
Patch1066:      backport-llvm-r236521
Patch1067:      backport-llvm-r236522
Patch1068:      backport-llvm-r236523
Patch1069:      backport-llvm-r236524
Patch1070:      backport-llvm-r236525
Patch1071:      backport-llvm-r236526
Patch1072:      backport-llvm-r236527
Patch1073:      backport-llvm-r236528
Patch1074:      backport-llvm-r236529
Patch1075:      backport-llvm-r236530
Patch1076:      backport-clang-r206364
Patch1077:      backport-clang-r233543
Patch1078:      backport-clang-r233544
Patch1079:      backport-clang-r233574
Patch1080:      backport-clang-r233804
Patch1081:      backport-clang-r233807
Patch1082:      backport-clang-r236531
Patch1083:      backport-clang-r236532
Patch1084:      backport-llvm-r247694
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildRequires:  autoconf
BuildRequires:  automake
BuildRequires:  cmake
%if 0%{?suse_version} >= 1220
BuildRequires:  binutils-devel >= 2.21.90
%endif
BuildRequires:  bison
BuildRequires:  fdupes
BuildRequires:  flex
BuildRequires:  gcc
BuildRequires:  gcc-c++
BuildRequires:  groff
BuildRequires:  libffi-devel
BuildRequires:  libtool
BuildRequires:  ncurses-devel
BuildRequires:  python-base
Requires:       libLLVM = %{version}-%{release}
# LLVM does not support 32bit PPC/s390
ExcludeArch:    ppc s390

%description
LLVM is a compiler infrastructure designed for compile-time,
link-time, runtime, and idle-time optimization of programs from
arbitrary programming languages.

The compiler infrastructure includes mirror sets of programming
tools as well as libraries with equivalent functionality.

%package -n libLLVM
Summary:        Libraries for LLVM
Group:          Development/Libraries/C and C++

%description -n libLLVM
This package contains the shared libraries needed for LLVM.

%package devel
Summary:        Header Files for LLVM
Group:          Development/Languages/Other
Requires:       %{name} = %{version}
Requires:       libffi-devel
Requires:       libstdc++-devel >= 3.4
Requires:       ncurses-devel

%description devel
This package contains library and header files needed to develop
new native programs that use the LLVM infrastructure.

%package clang
Summary:        CLANG frontend for LLVM
Group:          Development/Languages/Other
Requires:       %{name} = %{version}
Requires:       binutils
Requires:       libclang = %{version}-%{release}
Requires:       libstdc++-devel
Provides:       clang

%description clang
This package contains the clang (C language) frontend for LLVM.

%package -n libclang
Summary:        Library files needed for clang
Group:          Development/Libraries/C and C++

%description -n libclang
This package contains the shared libraries needed for clang.

%package clang-devel
Summary:        CLANG frontend for LLVM (devel package)
Group:          Development/Languages/Other
Requires:       clang = %{version}
Requires:       llvm-devel = %{version}

%description clang-devel
This package contains the clang (C language) frontend for LLVM.
(development files)

%package        vim-plugins
Summary:        Vim plugins for LLVM
Group:          Productivity/Text/Editors
Requires:       vim

%description    vim-plugins
This package contains vim plugins for LLVM like syntax highlighting.

%package -n python-clang
Summary:        Python bindings for libclang
Group:          Development/Languages/Python
Requires:       libclang = %{version}
Requires:       python

%description -n python-clang
This package contains the Python bindings to clang (C language) frontend for LLVM.

%prep
%setup -q -n %{name}
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%if "%{_lib}" == "lib64"
%patch5 -p1
%endif
%patch6 -p1
%patch7 -p1
%patch8 -p1
%patch9
%patch10 -p1
%patch11 -p1
%patch12 -p1
%patch13 -p1
%patch14 -p1
%ifarch aarch64
%patch15 -p1
%endif
%patch1000
%patch1001
%patch1002
%patch1003
%patch1004
%patch1005
%patch1006
%patch1007
%patch1008
%patch1009
%patch1010
%patch1011
%patch1012
%patch1013
%patch1014
%patch1015
%patch1016
%patch1017
%patch1018
%patch1019
%patch1020
%patch1021
%patch1022
%patch1023
%patch1024
%patch1025
%patch1026
%patch1027
%patch1028
%patch1029
%patch1030
%patch1031
%patch1032
%patch1033
%patch1034
%patch1035
%patch1036
%patch1037
%patch1038
%patch1039
%patch1040
%patch1041
%patch1042
%patch1043
%patch1044
%patch1045
%patch1046
%patch1047
%patch1048
%patch1049
%patch1050
%patch1051
%patch1052
%patch1053
%patch1054
%patch1055
%patch1056
%patch1057
%patch1058
%patch1059
%patch1060
%patch1061
%patch1062
%patch1063
%patch1064
%patch1065
%patch1066
%patch1067
%patch1068
%patch1069
%patch1070
%patch1071
%patch1072
%patch1073
%patch1074
%patch1075
%patch1076
%patch1077
%patch1078
%patch1079
%patch1080
%patch1081
%patch1082
%patch1083
%patch1084

# We hardcode i586
rm tools/clang/test/Driver/x86_features.c

sed -i s,SVN_REVISION,\"%{_revision}\",g tools/clang/lib/Basic/Version.cpp
sed -i s,LLVM_REVISION,\"%{_revision}\",g tools/clang/lib/Basic/Version.cpp

%if "%{_lib}" == "lib64"
# Nasty hardcoded path
sed -i s,"/lib/LLVMgold","/lib64/LLVMgold",g tools/clang/lib/Driver/Tools.cpp
sed -i s,"}lib{","}lib64{",g tools/clang/test/Preprocessor/iwithprefix.c
%endif

sed -i s,LLVM_LIBDIR,%{_lib}, tools/clang/lib/Driver/Driver.cpp

# Only enable target archs otherwise llvm-config is messed up
%ifarch %{ix86} x86_64
sed -i s,"subdirectories = .*","subdirectories = R600 X86", lib/Target/LLVMBuild.txt
%endif

%ifarch %arm
sed -i s,"subdirectories = .*","subdirectories = ARM", lib/Target/LLVMBuild.txt
%endif

%ifarch ppc64 ppc64le
sed -i s,"subdirectories = .*","subdirectories = PowerPC", lib/Target/LLVMBuild.txt
%endif

%ifarch s390x
sed -i s,"subdirectories = .*","subdirectories = SystemZ", lib/Target/LLVMBuild.txt
%endif

sed -i s,"IntelJITEvents OProfileJIT","", lib/ExecutionEngine/LLVMBuild.txt
echo > utils/unittest/LLVMBuild.txt

%build
TOPLEVEL=$PWD
mkdir stage1 stage2
pushd stage1
ln -sf lib lib64

# Define host-triple
%ifarch %{ix86}
%define host_triple i586-suse-linux
%endif
%ifarch x86_64
%define host_triple x86_64-suse-linux
%endif
%ifarch armv6hl
%define host_triple armv6hl-suse-linux-gnueabi
%endif
%ifarch armv7hl
%define host_triple armv7hl-suse-linux-gnueabi
%endif
%ifarch aarch64
%define host_triple aarch64-suse-linux
%endif
%ifarch ppc64
%define host_triple powerpc64-suse-linux
sed -i s,'${CMAKE_SYSTEM_PROCESSOR}','"PowerPC"',g ../cmake/modules/AddLLVM.cmake
rm -rf ../projects/compiler-rt
%endif
%ifarch ppc64le
%define host_triple powerpc64le-suse-linux
sed -i s,'${CMAKE_SYSTEM_PROCESSOR}','"PowerPC"',g ../cmake/modules/AddLLVM.cmake
%endif
%ifarch s390x
%define host_triple s390x-suse-linux
sed -i s,'${CMAKE_SYSTEM_PROCESSOR}','"SystemZ"',g ../cmake/modules/AddLLVM.cmake
rm -rf ../projects/compiler-rt
%endif

cmake -G "Unix Makefiles" \
      -DBUILD_SHARED_LIBS=OFF \
      -DCMAKE_BUILD_TYPE=Release \
      -DLLVM_ENABLE_ASSERTIONS=OFF \
      -DLLVM_TARGETS_TO_BUILD=host \
      -DLLVM_HOST_TRIPLE=%{host_triple} \
      ..

make %{?_smp_mflags} VERBOSE=1 clang

popd
pushd stage2

export CC=$TOPLEVEL/stage1/bin/clang
export CXX=$TOPLEVEL/stage1/bin/clang++

cmake -G "Unix Makefiles" \
%ifnarch ppc64 ppc64le
      -DBUILD_SHARED_LIBS=ON \
%endif
%ifarch %arm ppc64 ppc64le
      -DCMAKE_BUILD_TYPE=Release \
%else
      -DCMAKE_BUILD_TYPE=RelWithDebInfo \
      -DLLVM_HOST_TRIPLE=%{host_triple} \
%endif
      -DCMAKE_INSTALL_PREFIX=%{_prefix} \
%ifarch armv6hl
      -DCMAKE_C_FLAGS="-mfloat-abi=hard -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp" \
      -DCMAKE_CXX_FLAGS="-mfloat-abi=hard -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp" \
%endif
%ifarch armv7hl
      -DCMAKE_C_FLAGS="-mfloat-abi=hard -march=armv7-a -mtune=cortex-a9 -mfpu=vfpv3-d16" \
      -DCMAKE_CXX_FLAGS="-mfloat-abi=hard -march=armv7-a -mtune=cortex-a9 -mfpu=vfpv3-d16" \
%endif
%if "%{_lib}" == "lib64"
      -DLLVM_LIBDIR_SUFFIX=64 \
%endif
      -DLLVM_REQUIRES_RTTI=ON \
      -DLLVM_ENABLE_TIMESTAMPS=OFF \
      -DLLVM_ENABLE_ASSERTIONS=OFF \
      -DLLVM_ENABLE_PIC=ON \
%if 0%{?suse_version} >= 1220
      -DLLVM_BINUTILS_INCDIR=/usr/include \
%endif
%ifarch %{ix86} x86_64
      -DLLVM_TARGETS_TO_BUILD="host;R600" \
%else
      -DLLVM_TARGETS_TO_BUILD=host \
%endif
      -DLLVM_BUILD_TESTS=ON \
      ..

make %{?_smp_mflags} VERBOSE=1

%check
cd stage2
%ifnarch aarch64 armv7hl armv7l
%if 0%{!?qemu_user_space_build:1}
# we just do not have enough memory with qemu emulation

%if "%{_lib}" == "lib64"
ln -s lib lib64
%endif

make check
make clang-test
%endif
%endif

%install
cd stage2
make install DESTDIR=%{buildroot}
cd ..

# Build man/html pages
cd docs
# Docs are prebuilt due to sphinx dependency -- cartman
#make -f Makefile.sphinx html man
rm -rf %{buildroot}/usr/docs

mkdir -p %{buildroot}%{_docdir}/llvm/html
mkdir -p %{buildroot}/usr/share/man/man1
cp -r _build/man/* %{buildroot}/usr/share/man/man1
cp -r _build/html/* %{buildroot}%{_docdir}/llvm/html

cd ../tools/clang/docs
mkdir -p %{buildroot}%{_docdir}/llvm-clang/html
cp -r _build/man/* %{buildroot}/usr/share/man/man1
cp -r _build/html/* %{buildroot}%{_docdir}/llvm-clang/html
cd ../../..

# install scan-build et al
install -d %{buildroot}%{_datadir}/clang
install -d %{buildroot}%{py_sitedir}

pushd tools/clang/tools
for file in scan-build/ccc-analyzer scan-build/scan-build \
		scan-view/scan-view; do
	install $file %{buildroot}%{_bindir}
done
for file in scan-build/scanview.css scan-build/sorttable.js; do
	install -m 644 $file %{buildroot}%{_datadir}/clang/
done
for file in scan-view/Reporter.py scan-view/ScanView.py \
		scan-view/startfile.py; do
	install -m 644 $file %{buildroot}%{py_sitedir}
done
install -d %{buildroot}%{py_sitedir}/Resources/
for file in scan-view/Resources/*; do
	install -m 644 $file %{buildroot}%{py_sitedir}/Resources/
done
popd

# install python bindings
install -d %{buildroot}%{py_sitedir}/clang
pushd tools/clang/bindings/python
cp clang/*.py %{buildroot}%{py_sitedir}/clang
install -d %{buildroot}%{_docdir}/python-clang/examples/cindex
cp -r examples %{buildroot}%{_docdir}/python-clang
install -d %{buildroot}%{_docdir}/python-clang/tests/cindex/INPUTS
cp -r tests %{buildroot}%{_docdir}/python-clang
popd
pushd %{buildroot}%{_bindir}
ln -s ccc-analyzer c++-analyzer
popd

%if 0%{?suse_version} >= 1220
mkdir -p %{buildroot}%{_libdir}/bfd-plugins
ln -s %{_libdir}/LLVMgold.so %{buildroot}%{_libdir}/bfd-plugins/
%endif

sed -i 's,RealBin/bin/clang,RealBin/clang,' \
  %{buildroot}%{_bindir}/scan-build

sed -i 's,RealBin/bin/ccc-analyzer,RealBin/ccc-analyzer,' \
  %{buildroot}%{_bindir}/scan-build

sed -i 's,RealBin/bin/ccc-analyzer,RealBin/ccc-analyzer,' \
  %{buildroot}%{_bindir}/scan-build

sed -i 's,$RealBin/sorttable.js,%{_datadir}/clang/sorttable.js,' \
  %{buildroot}%{_bindir}/scan-build

sed -i 's,$RealBin/scanview.css,%{_datadir}/clang/scanview.css,' \
  %{buildroot}%{_bindir}/scan-build

sed -i 's,RealBin/bin,RealBin,' \
  %{buildroot}%{_bindir}/scan-build

install -m 755 -d %{buildroot}%{_datadir}/vim/site/syntax/
install -m 644 utils/vim/*.vim %{buildroot}%{_datadir}/vim/site/syntax/
mv utils/vim/README utils/vim/README.vim

# Stuff we don't want to include
rm %{buildroot}%{_libdir}/BugpointPasses.*
rm %{buildroot}%{_libdir}/LLVMHello.*
rm %{buildroot}%{_libdir}/libgtest*
rm %{buildroot}%{_mandir}/man1/lit.1

%fdupes -s %{buildroot}%{_docdir}/%{name}
%fdupes -s %{buildroot}%{_docdir}/%{name}-doc

%post -n libLLVM -p /sbin/ldconfig
%postun -n libLLVM -p /sbin/ldconfig

%post -n libclang -p /sbin/ldconfig
%postun -n libclang -p /sbin/ldconfig

%post clang-devel -p /sbin/ldconfig
%postun clang-devel -p /sbin/ldconfig

%files
%defattr(-,root,root)
%{_bindir}/bugpoint
%{_bindir}/llc
%{_bindir}/lli
%{_bindir}/lli-child-target
%{_bindir}/macho-dump
%exclude %{_bindir}/%{name}-config
%{_bindir}/%{name}*
%{_bindir}/opt
%exclude %{_mandir}/man1/%{name}-config.1%{ext_man}
%{_mandir}/man1/bugpoint.1%{ext_man}
%{_mandir}/man1/tblgen.1%{ext_man}
%{_mandir}/man1/llc.1%{ext_man}
%{_mandir}/man1/lli.1%{ext_man}
%{_mandir}/man1/llvm*.1%{ext_man}
%{_mandir}/man1/FileCheck.1%{ext_man}
%{_mandir}/man1/opt.1%{ext_man}

%files -n libLLVM
%defattr(-,root,root,-)
%{_libdir}/libLLVM*

%files clang
%defattr(-,root,root)
%{_bindir}/clang
%{_bindir}/clang-*
%{_bindir}/clang++
%{_bindir}/clang-format
%{_bindir}/ccc-analyzer
%{_bindir}/c++-analyzer
%{_bindir}/git-clang-format
%{_bindir}/scan-build
%{_bindir}/scan-view
%{py_sitedir}/ScanView.py
%{py_sitedir}/Reporter.py
%{py_sitedir}/startfile.py
%{py_sitedir}/Resources
%{_datadir}/clang
%{_mandir}/man1/clang.1%{ext_man}
%{_libdir}/libLTO.*
%if 0%{?suse_version} >= 1220
%{_libdir}/LLVMgold.so
%{_libdir}/bfd-plugins/
%endif
%{_libdir}/clang
%ifnarch %arm aarch64 ppc64 ppc64le s390x
%{_libdir}/clang/%{_release_version}/lib/linux/
%endif

%files -n libclang
%defattr(-,root,root,-)
%exclude %{_libdir}/libclang.so
%{_libdir}/libclang*.so
%{_libdir}/libclang.so.*
%ifarch ppc64 ppc64le
%{_libdir}/libclang*.a
%endif

%files clang-devel
%defattr(-,root,root)
%{_libdir}/libclang.so
%{_includedir}/clang
%{_includedir}/clang-c
%doc %{_docdir}/llvm-clang

%files devel
%defattr(-,root,root,-)
%{_bindir}/%{name}-config
%doc %{_mandir}/man1/%{name}-config.1%{ext_man}
%{_includedir}/%{name}/
%{_includedir}/%{name}-c/
%dir %{_datadir}/%{name}
%{_datadir}/%{name}/cmake/
%doc %{_docdir}/%{name}

%files vim-plugins
%defattr(-,root,root,-)
%doc utils/vim/README.vim
%{_datadir}/vim/

%files -n python-clang
%defattr(-,root,root)
%{py_sitedir}/clang
%{py_sitedir}/clang/__init__.py
%{py_sitedir}/clang/cindex.py
%{py_sitedir}/clang/enumerations.py

%doc %{_docdir}/python-clang

%changelog
openSUSE Build Service is sponsored by