Blob Blame History Raw
# Components enabled if supported by target architecture:
%ifarch %ix86 x86_64
	%bcond_without gold
%else
	%bcond_with gold
%endif

%global major_version 3.9

Name:		llvm%{major_version}
Version:	%{major_version}.1
Release:	4%{?dist}
Summary:	The Low Level Virtual Machine Version %{major_version}

License:	NCSA
URL:		http://llvm.org
Source0:	http://llvm.org/releases/%{version}/llvm-%{version}.src.tar.xz

Source100:	llvm-config.h

# recognize s390 as SystemZ when configuring build
Patch0:		llvm-3.7.1-cmake-s390.patch

Patch1:		0001-This-code-block-breaks-the-docs-build-http-lab.llvm..patch
Patch2:		0001-fix-docs-2.patch
Patch3:		0001-fix-docs-3.patch
Patch4:		0001-docs-fix-cmake-code-block-warning.patch
# backport from upstream to fix lldb out of tree
Patch5:		0001-cmake-Install-CheckAtomic.cmake-needed-by-lldb.patch

Patch6:		install_dirs.patch

# Add SOVERSION (modified to add . between version numbers)
# https://reviews.llvm.org/rL283189
Patch7:		llvm-soversion.patch

Patch71:	llvm-arm-fix-prel31.patch
Patch72:	llvm-D23597_sdag_names.patch
Patch73:	llvm-D24300_ptx_intrinsics.patch
Patch74:	llvm-D25865-cmakeshlib.patch
Patch75:	llvm-D27609-AArch64-UABS_G3.patch
Patch76:	llvm-D27629-AArch64-large_model.patch
Patch77:	llvm-D9168_argument_alignment.patch
Patch78:	llvm-PR22923.patch
Patch80:	llvm-D27389.patch
Patch81:	llvm-D27397.patch
Patch82:	llvm-D28009.patch

BuildRequires:	cmake3
BuildRequires:	zlib-devel
BuildRequires:	libedit-devel
BuildRequires:	libffi-devel
BuildRequires:	ncurses-devel
BuildRequires:	python-sphinx
BuildRequires:	valgrind-devel
%if %{with gold}
BuildRequires:	binutils-devel
%endif
BuildRequires:	libstdc++-static

Requires:	%{name}-libs%{?_isa} = %{version}-%{release}

%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.

This package contains LLVM %{major_version} and can be installed
in parallel with other LLVM versions.


%package devel
Summary:	Libraries and header files for LLVM %{major_version}
Requires:	%{name}%{?_isa} = %{version}-%{release}

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

This package contains LLVM %{major_version} and can be installed
in parallel with other LLVM versions.

%package doc
Summary:	Documentation for LLVM %{major_version}
BuildArch:	noarch
Requires:	%{name} = %{version}-%{release}

%description doc
Documentation for the LLVM compiler infrastructure.

This package contains LLVM %{major_version} and can be installed
in parallel with other LLVM versions.

%package libs
Summary:	LLVM %{major_version} shared libraries

%description libs
Shared libraries for the LLVM compiler infrastructure.

This package contains LLVM %{major_version} and can be installed
in parallel with other LLVM versions.

%package static
Summary:	LLVM %{major_version} static libraries
Requires:	%{name}-devel%{?_isa} = %{version}-%{release}
Requires:	ncurses-devel%{?_isa}

%description static
Static libraries for the LLVM compiler infrastructure.

This package contains LLVM %{major_version} and can be installed
in parallel with other LLVM versions.


%prep
%setup -q -n llvm-%{version}.src
%patch0 -p1 -b .s390
%patch1 -p1 -b .sphinx
%patch2 -p1 -b .docs2
%patch3 -p1 -b .docs3
%patch4 -p1 -b .docs4
%patch5 -p1 -b .lldbfix
%patch6 -p1 -b .instdirs
%patch7 -p0 -b .soversion
%patch71 -p1 -b .julia1
%patch72 -p1 -b .julia2
%patch73 -p1 -b .julia3
%patch74 -p1 -b .julia4
%patch75 -p1 -b .julia5
%patch76 -p1 -b .julia6
%patch77 -p1 -b .julia7
%patch78 -p1 -b .julia8
%patch80 -p1 -b .julia9
%patch81 -p1 -b .julia10
%patch82 -p1 -b .julia11

%build
mkdir -p _build
cd _build

%ifarch s390
# Decrease debuginfo verbosity to reduce memory consumption during final library linking
%global optflags %(echo %{optflags} | sed 's/-g /-g1 /')
%endif

# force off shared libs as cmake macros turns it on.
%cmake3 .. \
	-DBUILD_SHARED_LIBS:BOOL=OFF \
	-DCMAKE_BUILD_TYPE=RelWithDebInfo \
	-DCMAKE_SHARED_LINKER_FLAGS="-Wl,-Bsymbolic -static-libstdc++" \
%ifarch s390
	-DCMAKE_C_FLAGS_RELWITHDEBINFO="%{optflags} -DNDEBUG" \
	-DCMAKE_CXX_FLAGS_RELWITHDEBINFO="%{optflags} -DNDEBUG" \
%endif
	-DCMAKE_INSTALL_PREFIX=%{_libdir}/%{name} \
	-DLLVM_TARGETS_TO_BUILD="X86;AMDGPU;PowerPC;NVPTX;SystemZ;AArch64;ARM;Mips;BPF" \
	-DLLVM_ENABLE_LIBCXX:BOOL=OFF \
	-DLLVM_ENABLE_ZLIB:BOOL=ON \
	-DLLVM_ENABLE_FFI:BOOL=ON \
	-DLLVM_ENABLE_RTTI:BOOL=ON \
%if %{with gold}
	-DLLVM_BINUTILS_INCDIR=%{_includedir} \
%endif
	\
	-DLLVM_BUILD_RUNTIME:BOOL=ON \
	\
	-DLLVM_INCLUDE_TOOLS:BOOL=ON \
	-DLLVM_BUILD_TOOLS:BOOL=ON \
	\
	-DLLVM_INCLUDE_TESTS:BOOL=ON \
	-DLLVM_BUILD_TESTS:BOOL=ON \
	\
	-DLLVM_INCLUDE_EXAMPLES:BOOL=ON \
	-DLLVM_BUILD_EXAMPLES:BOOL=OFF \
	\
	-DLLVM_INCLUDE_UTILS:BOOL=ON \
	-DLLVM_INSTALL_UTILS:BOOL=OFF \
	\
	-DLLVM_INCLUDE_DOCS:BOOL=ON \
	-DLLVM_BUILD_DOCS:BOOL=ON \
	-DLLVM_ENABLE_SPHINX:BOOL=ON \
	-DLLVM_ENABLE_DOXYGEN:BOOL=OFF \
	-DSPHINX_OUTPUT_HTML:BOOL=OFF \
	-DSPHINX_WARNINGS_AS_ERRORS:BOOL=OFF \
	\
	-DLLVM_BUILD_LLVM_DYLIB:BOOL=ON \
	-DLLVM_DYLIB_EXPORT_ALL:BOOL=ON \
	-DLLVM_LINK_LLVM_DYLIB:BOOL=ON \
	-DLLVM_BUILD_EXTERNAL_COMPILER_RT:BOOL=ON \
	-DLLVM_INSTALL_TOOLCHAIN_ONLY:BOOL=OFF \
	\
	-DSPHINX_EXECUTABLE=%{_bindir}/sphinx-build

make %{?_smp_mflags}

%install
cd _build
make install DESTDIR=%{buildroot}
cd -

# Move and symlink into FHS dirs
mkdir -p %{buildroot}%{_bindir}
for bin in %{buildroot}%{_libdir}/%{name}/bin/*
do
  # Cannot move llvm-config due to runtime prefix determination
  [ ${bin##*/} = llvm-config ] && continue
  # Already versioned binaries
  if [ ${bin%%%{major_version}} != $bin ]
  then
    mv $bin %{buildroot}%{_bindir}/${bin##*/}
    ln -s ../../../bin/${bin##*/} %{buildroot}%{_libdir}/%{name}/bin/${bin##*/}
  else
    # Unversioned binaries
    if [ -L $bin ]
    then
      target=$(readlink $bin)
      # Make the link point to the versioned binary if needed
      [ ${target%%%{major_version}} == $target ] && ln -sf ${target}-%{major_version} $bin
      [ $target == clang-%{major_version} ] && continue
    fi
    mv $bin %{buildroot}%{_bindir}/${bin##*/}-%{major_version}
    ln -s ../../../bin/${bin##*/}-%{major_version} %{buildroot}%{_libdir}/%{name}/bin/${bin##*/}
  fi
done
for dir in include
do
  mkdir -p %{buildroot}%{_prefix}/$dir/%{name}
  mv %{buildroot}%{_libdir}/%{name}/$dir/* %{buildroot}%{_prefix}/$dir/%{name}/
  rmdir %{buildroot}%{_libdir}/%{name}/$dir
  ln -s ../../$dir/%{name} %{buildroot}%{_libdir}/%{name}/$dir
done
mkdir -p %{buildroot}%{_libdir}/cmake
mv %{buildroot}%{_libdir}/%{name}/lib/cmake/llvm %{buildroot}%{_libdir}/cmake/%{name}
ln -s ../../../cmake/%{name} %{buildroot}%{_libdir}/%{name}/lib/cmake/llvm
mkdir -p %{buildroot}%{_datadir}
mv %{buildroot}%{_libdir}/%{name}/share/man %{buildroot}%{_datadir}/

# fix multi-lib
mv -v %{buildroot}%{_includedir}/%{name}/llvm/Config/llvm-config{,-%{__isa_bits}}.h
install -m 0644 %{SOURCE100} %{buildroot}%{_includedir}/%{name}/llvm/Config/llvm-config.h

# Create ld.so.conf.d entry
mkdir -p %{buildroot}%{_sysconfdir}/ld.so.conf.d
cat >> %{buildroot}%{_sysconfdir}/ld.so.conf.d/%{name}-%{_arch}.conf << EOF
%{_libdir}/%{name}/lib
EOF

# suffix mandir files with major version to avoid conflict with llvm
for i in %{buildroot}%{_mandir}/man1/*; do
       mv $i "${i%.*}-%{major_version}.1"
done

%check
cd _build
make V=1 check-all

%post libs -p /sbin/ldconfig
%postun libs -p /sbin/ldconfig

%files
%{_bindir}/*
%dir %{_libdir}/%{name}/bin
%{_libdir}/%{name}/bin/*
%exclude %{_libdir}/%{name}/bin/llvm-config
%{_mandir}/man1/*.1.*
%exclude %{_mandir}/man1/llvm-config-%{major_version}.1.*
%license LICENSE.TXT

%files libs
%config(noreplace) %{_sysconfdir}/ld.so.conf.d/%{name}-%{_arch}.conf
%dir %{_libdir}/%{name}
%dir %{_libdir}/%{name}/lib
%{_libdir}/%{name}/lib/BugpointPasses.so
%{_libdir}/%{name}/lib/LLVMHello.so
%if %{with gold}
%{_libdir}/%{name}/lib/LLVMgold.so
%endif
%{_libdir}/%{name}/lib/libLLVM-%{major_version}*.so
%{_libdir}/%{name}/lib/libLTO.so.%{major_version}*
%license LICENSE.TXT

%files devel
%{_libdir}/%{name}/bin/llvm-config
%{_mandir}/man1/llvm-config-%{major_version}.1.*
%{_includedir}/%{name}/llvm
%{_includedir}/%{name}/llvm-c
%{_libdir}/%{name}/include
%{_libdir}/%{name}/lib/libLLVM.so
%{_libdir}/%{name}/lib/libLTO.so
%{_libdir}/cmake/%{name}
%{_libdir}/%{name}/lib/cmake

%files static
%{_libdir}/%{name}/lib/*.a

%changelog
* Fri Feb 10 2017 Orion Poplawski <orion@cora.nwra.com> - 3.9.1-4
- Add patch to add sonames to libraries
- Make -static require ncurses-devel

* Thu Feb 9 2017 Orion Poplawski <orion@cora.nwra.com> - 3.9.1-3
- Install into libdir prefix

* Mon Jan 2 2017 Milan Bouchet-Valat <nalimilan@club.fr> - 3.9.1-2
- Add patches needed by Julia.
- Disable Sphinx docs (which currently cause the build to fail on Rawhide).
- Replace remaining spaces with tabs for consistency.
- Add dependency on -devel for -static package.
- Fix missing Requires(postun).
- Fix links to unversioned llvm-ar.

* Thu Dec 29 2016 Milan Bouchet-Valat <nalimilan@club.fr> - 3.9.1-1
- Create versioned llvm3.9 package.

* Tue Nov 29 2016 Josh Stone <jistone@redhat.com> - 3.9.0-7
- Apply backports from rust-lang/llvm#55, #57

* Tue Nov 01 2016 Dave Airlie <airlied@gmail.com - 3.9.0-6
- rebuild for new arches

* Wed Oct 26 2016 Dave Airlie <airlied@redhat.com> - 3.9.0-5
- apply the patch from -4

* Wed Oct 26 2016 Dave Airlie <airlied@redhat.com> - 3.9.0-4
- add fix for lldb out-of-tree build

* Mon Oct 17 2016 Josh Stone <jistone@redhat.com> - 3.9.0-3
- Apply backports from rust-lang/llvm#47, #48, #53, #54

* Sat Oct 15 2016 Josh Stone <jistone@redhat.com> - 3.9.0-2
- Apply an InstCombine backport via rust-lang/llvm#51

* Wed Sep 07 2016 Dave Airlie <airlied@redhat.com> - 3.9.0-1
- llvm 3.9.0
- upstream moved where cmake files are packaged.
- upstream dropped CppBackend

* Wed Jul 13 2016 Adam Jackson <ajax@redhat.com> - 3.8.1-1
- llvm 3.8.1
- Add mips target
- Fix some shared library mispackaging

* Tue Jun 07 2016 Jan Vcelak <jvcelak@fedoraproject.org> - 3.8.0-2
- fix color support detection on terminal

* Thu Mar 10 2016 Dave Airlie <airlied@redhat.com> 3.8.0-1
- llvm 3.8.0 release

* Wed Mar 09 2016 Dan Horák <dan[at][danny.cz> 3.8.0-0.3
- install back memory consumption workaround for s390

* Thu Mar 03 2016 Dave Airlie <airlied@redhat.com> 3.8.0-0.2
- llvm 3.8.0 rc3 release

* Fri Feb 19 2016 Dave Airlie <airlied@redhat.com> 3.8.0-0.1
- llvm 3.8.0 rc2 release

* Tue Feb 16 2016 Dan Horák <dan[at][danny.cz> 3.7.1-7
- recognize s390 as SystemZ when configuring build

* Sat Feb 13 2016 Dave Airlie <airlied@redhat.com> 3.7.1-6
- export C++ API for mesa.

* Sat Feb 13 2016 Dave Airlie <airlied@redhat.com> 3.7.1-5
- reintroduce llvm-static, clang needs it currently.

* Fri Feb 12 2016 Dave Airlie <airlied@redhat.com> 3.7.1-4
- jump back to single llvm library, the split libs aren't working very well.

* Fri Feb 05 2016 Dave Airlie <airlied@redhat.com> 3.7.1-3
- add missing obsoletes (#1303497)

* Thu Feb 04 2016 Fedora Release Engineering <releng@fedoraproject.org> - 3.7.1-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild

* Thu Jan 07 2016 Jan Vcelak <jvcelak@fedoraproject.org> 3.7.1-1
- new upstream release
- enable gold linker

* Wed Nov 04 2015 Jan Vcelak <jvcelak@fedoraproject.org> 3.7.0-100
- fix Requires for subpackages on the main package

* Tue Oct 06 2015 Jan Vcelak <jvcelak@fedoraproject.org> 3.7.0-100
- initial version using cmake build system