Accepting request 182946 from devel:tools:compiler

- Drop disable_neon_in_armv7.diff, neon seems to be working fine
- Add cmake-host-triple.patch to pass a host triple argument

- Create libLLVM and libclang subpackages.

- Fix finding internal headers on x86_64

- Fix ARM v5/v7 builds

- Create a baselibs.conf
  Provide *-32 Bit Packages for x86_64

- Initial version of a cmake based buildscript
  + Updated arm_suse_support.diff (patch6) to work with llvm 3.3
  + Set version in spec to 3.3

OBS-URL: https://build.opensuse.org/request/show/182946
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/llvm?expand=0&rev=46
This commit is contained in:
Stephan Kulow 2013-07-15 07:48:18 +00:00 committed by Git OBS Bridge
commit c7262921ec
8 changed files with 204 additions and 145 deletions

View File

@ -1,6 +1,6 @@
--- llvm/tools/clang/lib/Driver/ToolChains.cpp.orig 2012-11-22 10:26:49.202107824 +0100
+++ llvm/tools/clang/lib/Driver/ToolChains.cpp 2012-11-22 12:20:33.662825882 +0100
@@ -1056,10 +1056,12 @@ Generic_GCC::GCCInstallationDetector::GC
--- /tools/clang/lib/Driver/ToolChains.cpp.orig 2012-11-22 10:26:49.202107824 +0100
+++ /tools/clang/lib/Driver/ToolChains.cpp 2012-11-22 12:20:33.662825882 +0100
@@ -1082,11 +1082,13 @@ Generic_GCC::GCCInstallationDetector::GC
static const char *const ARMLibDirs[] = { "/lib" };
static const char *const ARMTriples[] = {
"arm-linux-gnueabi",
@ -9,7 +9,8 @@
};
static const char *const ARMHFTriples[] = {
"arm-linux-gnueabihf",
+ "armv7hl-suse-linux-gnueabi"
+ "armv7hl-suse-linux-gnueabi",
"armv7hl-redhat-linux-gnueabi"
};
static const char *const X86_64LibDirs[] = { "/lib64", "/lib" };

1
baselibs.conf Normal file
View File

@ -0,0 +1 @@
libLLVM

33
cmake-host-triple.patch Normal file
View File

@ -0,0 +1,33 @@
Index: llvm-3.3/cmake/modules/GetHostTriple.cmake
===================================================================
--- llvm-3.3.orig/cmake/modules/GetHostTriple.cmake
+++ llvm-3.3/cmake/modules/GetHostTriple.cmake
@@ -15,15 +15,19 @@ function( get_host_triple var )
set( value "i686-pc-mingw32" )
endif()
else( MSVC )
- set(config_guess ${LLVM_MAIN_SRC_DIR}/autoconf/config.guess)
- execute_process(COMMAND sh ${config_guess}
- RESULT_VARIABLE TT_RV
- OUTPUT_VARIABLE TT_OUT
- OUTPUT_STRIP_TRAILING_WHITESPACE)
- if( NOT TT_RV EQUAL 0 )
- message(FATAL_ERROR "Failed to execute ${config_guess}")
- endif( NOT TT_RV EQUAL 0 )
- set( value ${TT_OUT} )
+ if( NOT LLVM_HOST_TRIPLE )
+ set(config_guess ${LLVM_MAIN_SRC_DIR}/autoconf/config.guess)
+ execute_process(COMMAND sh ${config_guess}
+ RESULT_VARIABLE TT_RV
+ OUTPUT_VARIABLE TT_OUT
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ if( NOT TT_RV EQUAL 0 )
+ message(FATAL_ERROR "Failed to execute ${config_guess}")
+ endif( NOT TT_RV EQUAL 0 )
+ set( value ${TT_OUT} )
+ else( LLVM_HOST_TRIPLE )
+ set( value ${LLVM_HOST_TRIPLE} )
+ endif( NOT LLVM_HOST_TRIPLE )
endif( MSVC )
set( ${var} ${value} PARENT_SCOPE )
message(STATUS "Target triple: ${value}")

View File

@ -1,14 +0,0 @@
--- ./tools/clang/lib/Driver/Tools.cpp.orig 2012-11-22 10:37:49.686675877 +0100
+++ ./tools/clang/lib/Driver/Tools.cpp 2012-11-27 10:55:58.984167280 +0100
@@ -5763,8 +5763,9 @@ void linuxtools::Assemble::ConstructJob(
CmdArgs.push_back("-many");
} else if (getToolChain().getArch() == llvm::Triple::arm) {
StringRef MArch = getToolChain().getArchName();
- if (MArch == "armv7" || MArch == "armv7a" || MArch == "armv7-a")
- CmdArgs.push_back("-mfpu=neon");
+ // Do not use neon in openSUSE
+// if (MArch == "armv7" || MArch == "armv7a" || MArch == "armv7-a")
+// CmdArgs.push_back("-mfpu=neon");
StringRef ARMFloatABI = getARMFloatABI(getToolChain().getDriver(), Args,
getToolChain().getTriple());

View File

@ -28,4 +28,4 @@ diff -ur llvm.orig/tools/llvm-config/llvm-config.cpp llvm/tools/llvm-config/llvm
+ ActiveLibDir = ActivePrefix + "/lib64";
ActiveIncludeOption = "-I" + ActiveIncludeDir;
}

View File

@ -3,6 +3,7 @@ from Config import *
# it is a compiler and the package provides llvm-gcc-devel, llvm-gcc-c++-devel
addFilter("devel-file-in-non-devel-package .*/clang/.*/include/.*")
addFilter("devel-file-in-non-devel-package .*/clang/.*/lib/.*")
addFilter("zero-length .*/llvm-apidoc/.*")
addFilter("arch-dependent-file-in-usr-share .*/llvm-apidoc/.*")

View File

@ -1,3 +1,37 @@
-------------------------------------------------------------------
Thu Jul 4 11:55:43 UTC 2013 - idonmez@suse.com
- Drop disable_neon_in_armv7.diff, neon seems to be working fine
- Add cmake-host-triple.patch to pass a host triple argument
-------------------------------------------------------------------
Wed Jul 3 13:13:25 UTC 2013 - idonmez@suse.com
- Create libLLVM and libclang subpackages.
-------------------------------------------------------------------
Wed Jun 19 12:58:24 UTC 2013 - llunak@suse.com
- Fix finding internal headers on x86_64
-------------------------------------------------------------------
Wed Jun 19 12:41:30 UTC 2013 - idonmez@suse.com
- Fix ARM v5/v7 builds
-------------------------------------------------------------------
Tue Jun 18 13:42:57 UTC 2013 - tobias.johannes.klausmann@mni.thm.de
- Create a baselibs.conf
Provide *-32 Bit Packages for x86_64
-------------------------------------------------------------------
Thu Jun 13 18:33:31 UTC 2013 - tobias.johannes.klausmann@mni.thm.de
- Initial version of a cmake based buildscript
+ Updated arm_suse_support.diff (patch6) to work with llvm 3.3
+ Set version in spec to 3.3
-------------------------------------------------------------------
Thu Jun 13 11:42:33 UTC 2013 - idonmez@suse.com

255
llvm.spec
View File

@ -18,10 +18,11 @@
%define _revision 183898
%define _release_version 3.3
%define _supported_archs "arm,aarch64,powerpc,x86"
%define _supported_archs "AArch64;ARM;PowerPC;X86"
%define _experimental_archs "R600"
Name: llvm
Version: 3.2.91
Version: 3.3
Release: 0
Summary: Low Level Virtual Machine
License: NCSA
@ -40,13 +41,15 @@ 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
# PATCH-FIX-OPENSUSE disable_neon_in_armv7.diff -- Disable use of neon in armv7 openSUSE
Patch7: disable_neon_in_armv7.diff
# PATCH-FIX-OPENSUSE unreachable-code.patch -- Unreachable code warning triggered on SLE
Patch8: unreachable-code.patch
Patch7: unreachable-code.patch
Patch8: cmake-host-triple.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildRequires: autoconf
BuildRequires: automake
BuildRequires: cmake
%if 0%{?suse_version} >= 1220
BuildRequires: binutils-devel >= 2.21.90
%endif
@ -57,13 +60,10 @@ BuildRequires: flex
BuildRequires: gcc
BuildRequires: gcc-c++
BuildRequires: groff
%ifarch x86_64
# For tests
BuildRequires: glibc-devel-32bit
%endif
BuildRequires: libffi-devel
BuildRequires: libtool
BuildRequires: python-base
Requires: libLLVM = %{version}-%{release}
# llvm does not work on ppc, only ppc64
ExcludeArch: ppc
@ -75,8 +75,15 @@ 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: Libraries and Header Files for LLVM
Summary: Header Files for LLVM
Group: Development/Languages/Other
Requires: %{name} = %{version}
Requires: libffi-devel
@ -101,12 +108,20 @@ 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
@ -134,12 +149,8 @@ This package contains vim plugins for LLVM like syntax highlighting.
%if "%{_lib}" == "lib64"
%patch5 -p1
%endif
%ifarch %arm
%patch6 -p1
%endif
%ifarch armv7l armv7hl
%patch7 -p0
%endif
%patch7 -p1
%patch8 -p1
# We hardcode i586
@ -153,156 +164,138 @@ rm tools/clang/test/Driver/linux-ld.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/,/%{_lib}/,g tools/clang/lib/Driver/Tools.cpp tools/clang/test/Preprocessor/iwithprefix.c
sed -i s,/lib/,/%{_lib}/,g tools/clang/lib/Driver/Tools.cpp \
tools/clang/test/Preprocessor/iwithprefix.c
%endif
# Only enable target archs otherwise llvm-config is messed up
sed -i s,"subdirectories = .*","subdirectories = AArch64 ARM PowerPC X86", lib/Target/LLVMBuild.txt
sed -i s,"subdirectories = .*","subdirectories = AArch64 ARM PowerPC R600 X86", lib/Target/LLVMBuild.txt
sed -i s,"IntelJITEvents OProfileJIT","", lib/ExecutionEngine/LLVMBuild.txt
echo > utils/unittest/LLVMBuild.txt
%build
TOPLEVEL=$PWD
# as-needed avoids linking LLVMgold to LTO, just because cmake places -lLTO before the .o file is used
export SUSE_ASNEEDED=0
mkdir stage1 stage2
pushd stage1
mkdir Release
# autotools ignore --libdir
ln -s lib Release/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 ppc64
%define host_triple powerpc64-suse-linux
%endif
../configure \
--enable-optimized \
--disable-assertions \
--with-optimize-option="-O0" \
cmake -G "Unix Makefiles" \
-DBUILD_SHARED_LIBS=OFF \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_ASSERTIONS=OFF \
%ifarch %arm
--disable-sjlj-exceptions \
--disable-werror --enable-checking=release \
%ifarch armv5el armv5tel
--with-arch=armv5te --with-float=soft --with-mode=arm \
--build=armv5tel-suse-linux-gnueabi --host=armv5tel-suse-linux-gnueabi --target=armv5tel-suse-linux-gnueabi \
%endif
%ifarch armv7l armv7hl
--with-arch=armv7-a \
--with-tune=cortex-a9 \
--with-float=hard \
--with-fpu=vfpv3-d16 \
--with-abi=aapcs-vfp \
--build=armv7hl-suse-linux-gnueabi --host=armv7hl-suse-linux-gnueabi --target=armv7hl-suse-linux-gnueabi \
%if 0%{?suse_version} >= 1220
--with-mode=thumb \
-DLLVM_TARGETS_TO_BUILD=ARM \
%else
--with-mode=arm \
-DLLVM_TARGETS_TO_BUILD=%{_supported_archs} \
%endif
%endif
%endif
--enable-targets=host
-DCMAKE_C_FLAGS="-O0" \
-DCMAKE_CXX_FLAGS="-O0" \
-DLLVM_TARGET_ARCH=host \
-DLLVM_HOST_TRIPLE=%{host_triple} \
..
make %{?_smp_mflags} clang-only
make %{?_smp_mflags} clang
popd
pushd stage2
# autotools ignore --libdir
%ifnarch ppc64
mkdir Release+Debug
ln -s lib Release+Debug/lib64
export CC=$TOPLEVEL/stage1/bin/clang
export CXX=$TOPLEVEL/stage1/bin/clang++
cmake -G "Unix Makefiles" \
-DBUILD_SHARED_LIBS=ON \
%ifarch %arm ppc64
-DCMAKE_BUILD_TYPE=Release \
%else
mkdir Release
ln -s lib Release/lib64
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DLLVM_HOST_TRIPLE=%{host_triple} \
%endif
export CC=$TOPLEVEL/stage1/Release/bin/clang
export CXX=$TOPLEVEL/stage1/Release/bin/clang++
%ifarch armv7l armv7hl
# This fixes the armv7 build. (Allow to run stage2 without problem)
export CFLAGS="-mfloat-abi=hard -march=armv7-a -mtune=cortex-a9 -mfpu=vfpv3-d16"
export CXXFLAGS="-mfloat-abi=hard -march=armv7-a -mtune=cortex-a9 -mfpu=vfpv3-d16"
-DCMAKE_INSTALL_PREFIX=%{_prefix} \
%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
../configure \
--prefix=%{_prefix} \
--enable-optimized \
--disable-assertions \
--enable-pic \
--disable-timestamps \
%if "%{_lib}" == "lib64"
-DLLVM_LIBDIR_SUFFIX=64 \
-DCLANG_RESOURCE_DIR=../%{_lib}/clang/%{_release_version} \
%endif
-DLLVM_REQUIRES_RTTI=ON \
-DLLVM_ENABLE_TIMESTAMPS=OFF \
-DLLVM_ENABLE_ASSERTIONS=OFF \
-DLLVM_ENABLE_PIC=ON \
%if 0%{?suse_version} >= 1220
--with-binutils-include=/usr/include \
-DLLVM_BINUTILS_INCDIR=/usr/include \
%endif
%ifarch %arm
--with-optimize-option="-U_GLIBCXX_ATOMIC_BUILTINS" \
--disable-sjlj-exceptions \
--disable-werror --enable-checking=release \
%ifarch armv5el armv5tel
--with-arch=armv5te --with-float=soft --with-mode=arm \
%endif
%ifarch armv7l armv7hl
--with-arch=armv7-a \
--with-tune=cortex-a9 \
--with-float=hard \
--with-fpu=vfpv3-d16 \
--with-abi=aapcs-vfp \
%if 0%{?suse_version} >= 1220
--with-mode=thumb \
-DLLVM_TARGETS_TO_BUILD=ARM \
%else
--with-mode=arm \
-DLLVM_TARGETS_TO_BUILD=%{_supported_archs} \
-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=%{_experimental_archs} \
%endif
%endif
--enable-targets=arm \
%else
--enable-targets=%{_supported_archs} \
%endif
%ifnarch ppc64
--enable-debug-symbols \
--enable-debug-runtime \
%endif
--with-clang-resource-dir="../%{_lib}/clang/%{_release_version}"
-DLLVM_BUILD_TESTS=ON \
..
make %{?_smp_mflags} REQUIRES_RTTI=1
make %{?_smp_mflags}
%check
cd stage2
%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
# Due to http://llvm.org/bugs/show_bug.cgi?id=15242
for i in crash-narrowfunctiontest metadata remove_arguments_test; do
rm ../test/BugPoint/$i.ll;
done
make check
cd tools/clang
make test
make clang-test
%endif
%install
cd stage2
%makeinstall
make install DESTDIR=%{buildroot}
cd ..
# Fixup libdir
%if "%{_lib}" == "lib64"
mv %{buildroot}%{_prefix}/lib %{buildroot}%{_prefix}/lib64
%endif
# 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
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/
cp -r _build/html/* %{buildroot}%{_docdir}/llvm/html
cd ../tools/clang/docs
mkdir -p %{buildroot}%{_docdir}/llvm-clang/html
cp *.txt %{buildroot}%{_docdir}/llvm-clang
cp *.css *.png *.html %{buildroot}%{_docdir}/llvm-clang/html
cp -r analyzer %{buildroot}%{_docdir}/llvm-clang
cp -r _build/man/* %{buildroot}/usr/share/man/man1
cp -r _build/html/* %{buildroot}%{_docdir}/llvm-clang/html
cd ../../..
# cleanup
file %{buildroot}/%{_bindir}/* | awk -F: '$2~/ELF/{print $1}' | xargs -r chrpath -d
file %{buildroot}/%{_libdir}/%{name}/*.so | awk -F: '$2~/ELF/{print $1}' | xargs -r chrpath -d
find %{buildroot}%{_includedir}/clang -name '*.tmp' -exec rm {} +
chmod -x %{buildroot}/%{_libdir}/*.a
# install scan-build et al
install -d %{buildroot}%{_datadir}/clang
install -d %{buildroot}%{py_sitedir}
@ -356,19 +349,24 @@ 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}/libclang.a
rm %{buildroot}%{_libdir}/BugpointPasses.*
rm %{buildroot}%{_libdir}/LLVMHello.*
rm %{buildroot}%{_libdir}/libgtest*
rm %{buildroot}%{_mandir}/man1/lit.1
# Remove cmake files
rm -rf %{buildroot}/usr/share/llvm/cmake
%fdupes -s %{buildroot}%{_docdir}/%{name}
%fdupes -s %{buildroot}%{_docdir}/%{name}-doc
%post clang -p /sbin/ldconfig
%post -n libLLVM -p /sbin/ldconfig
%postun -n libLLVM -p /sbin/ldconfig
%postun clang -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
@ -380,23 +378,25 @@ rm %{buildroot}%{_libdir}/LLVMHello.*
%exclude %{_bindir}/%{name}-config
%{_bindir}/%{name}*
%{_bindir}/opt
%exclude %{_mandir}/man1/%{name}-config.1%{ext_man}
%{_mandir}/man1/bugpoint.1%{ext_man}
%exclude %{_mandir}/man1/lit.1%{ext_man}
%{_mandir}/man1/tblgen.1%{ext_man}
%{_mandir}/man1/llc.1%{ext_man}
%{_mandir}/man1/lli.1%{ext_man}
%exclude %{_mandir}/man1/%{name}-config.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}/c-index-test
%{_bindir}/ccc-analyzer
%{_bindir}/c++-analyzer
%{_bindir}/scan-build
@ -406,23 +406,27 @@ rm %{buildroot}%{_libdir}/LLVMHello.*
%{py_sitedir}/startfile.py
%{py_sitedir}/Resources
%{_datadir}/clang
%{_mandir}/man1/clang.1.gz
%{_libdir}/libclang.so
%{_mandir}/man1/clang.1%{ext_man}
%{_libdir}/libLTO.so
%{_libdir}/*profile*.a
%{_libdir}/libprofile_rt.so
%if 0%{?suse_version} >= 1220
%{_libdir}/LLVMgold.so
%{_libdir}/bfd-plugins/
%endif
%{_libdir}/clang
%{_libdir}/clang/%{_release_version}/lib/linux/
%files -n libclang
%defattr(-,root,root,-)
%exclude %{_libdir}/libclang.so
%{_libdir}/libclang*.so
%{_libdir}/libclang.so.*
%files clang-devel
%defattr(-,root,root)
%{_libdir}/libclang.so
%{_includedir}/clang
%{_includedir}/clang-c
%{_libdir}/libLTO.a
%{_libdir}/libclang*.a
%{_libdir}/*profile*.so
%doc %{_docdir}/llvm-clang
%files devel
@ -431,7 +435,6 @@ rm %{buildroot}%{_libdir}/LLVMHello.*
%doc %{_mandir}/man1/%{name}-config.1%{ext_man}
%{_includedir}/%{name}/
%{_includedir}/%{name}-c/
%{_libdir}/libLLVM*
%doc %{_docdir}/%{name}
%files vim-plugins