Accepting request 424333 from home:scarabeus_iv:branches:devel:tools:compiler
- Convert to use %cmake macros - Start conversion to use cmake macros with now introduced compatibility for ninja - Reduce number of threads if we don't have enough memory - Add patch for the nonvoid returns: * llvm-nonvoid-return.patch OBS-URL: https://build.opensuse.org/request/show/424333 OBS-URL: https://build.opensuse.org/package/show/devel:tools:compiler/llvm?expand=0&rev=466
This commit is contained in:
committed by
Git OBS Bridge
parent
b4b09af30a
commit
dc80bb7862
128
llvm.spec
128
llvm.spec
@@ -77,6 +77,7 @@ Patch8: revert-cmake-soname.patch
|
||||
Patch9: lldb-cmake.patch
|
||||
Patch10: glibc-2.23-libcxx.patch
|
||||
Patch11: glibc-2.24-libcxx.patch
|
||||
Patch12: llvm-nonvoid-return.patch
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
||||
BuildRequires: binutils-devel >= 2.21.90
|
||||
BuildRequires: bison
|
||||
@@ -91,6 +92,7 @@ BuildRequires: libstdc++-devel
|
||||
BuildRequires: libtool
|
||||
BuildRequires: ncurses-devel
|
||||
BuildRequires: ninja
|
||||
BuildRequires: procps
|
||||
BuildRequires: python-base
|
||||
BuildRequires: python-xml
|
||||
# llvm does not work on ppc or s390
|
||||
@@ -193,6 +195,7 @@ disassembler.
|
||||
%patch10
|
||||
%patch11
|
||||
%endif
|
||||
%patch12 -p1
|
||||
|
||||
# Move into right place
|
||||
mv cfe-%{version}.src tools/clang
|
||||
@@ -235,88 +238,93 @@ EOF
|
||||
%endif
|
||||
|
||||
%build
|
||||
TOPLEVEL=$PWD
|
||||
mkdir stage1 stage2
|
||||
pushd stage1
|
||||
|
||||
export CC=gcc
|
||||
export CXX=g++
|
||||
|
||||
cmake -G "Ninja" \
|
||||
-DBUILD_SHARED_LIBS=ON \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DLLVM_ENABLE_ASSERTIONS=OFF \
|
||||
-DLLVM_TARGETS_TO_BUILD=host \
|
||||
-DLLDB_DISABLE_PYTHON=ON \
|
||||
..
|
||||
|
||||
ninja %{?_smp_mflags} clang -v
|
||||
|
||||
popd
|
||||
pushd stage2
|
||||
|
||||
export CC=$TOPLEVEL/stage1/bin/clang
|
||||
export CXX=$TOPLEVEL/stage1/bin/clang++
|
||||
|
||||
cmake -G "Ninja" \
|
||||
-DBUILD_SHARED_LIBS=ON \
|
||||
%ifarch %arm ppc64 ppc64le
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
%else
|
||||
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
|
||||
%endif
|
||||
-DCMAKE_INSTALL_PREFIX=%{_prefix} \
|
||||
# Disable c/xx/flags as the clang fails to build with hardening right now
|
||||
#flags="%{optflags} -fno-strict-aliasing"
|
||||
flags="-fno-strict-aliasing"
|
||||
%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" \
|
||||
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" \
|
||||
flags+=" -mfloat-abi=hard -march=armv7-a -mtune=cortex-a9 -mfpu=vfpv3-d16"
|
||||
%endif
|
||||
# do not eat all memory
|
||||
ninjaproc="%{?jobs:%{jobs}}"
|
||||
echo "Available memory:"
|
||||
free
|
||||
echo "System limits:"
|
||||
ulimit -a
|
||||
if test -n "$ninjaproc" -a "$ninjaproc" -gt 1 ; then
|
||||
mem_per_process=1000
|
||||
max_mem=`LANG=C free -t -m | sed -n "s|^Mem: *\([0-9]*\).*$|\1|p"`
|
||||
max_jobs="$(($max_mem / $mem_per_process))"
|
||||
test "$ninjaproc" -gt "$max_jobs" && ninjaproc="$max_jobs" && echo "Warning: Reducing number of jobs to $max_jobs because of memory limits"
|
||||
test "$ninjaproc" -le 0 && ninjaproc=1 && echo "Warning: Do not use the parallel build at all becuse of memory limits"
|
||||
fi
|
||||
|
||||
%define __builder ninja
|
||||
%define __builddir stage1
|
||||
# -z,now is breaking now, it needs to be fixed
|
||||
%cmake \
|
||||
-DCMAKE_C_FLAGS="$flags" \
|
||||
-DCMAKE_CXX_FLAGS="$flags" \
|
||||
-DLLVM_ENABLE_ASSERTIONS=OFF \
|
||||
-DLLVM_TARGETS_TO_BUILD=host \
|
||||
-DLLDB_DISABLE_PYTHON=ON \
|
||||
-DCMAKE_SKIP_RPATH:BOOL=OFF \
|
||||
-DCMAKE_EXE_LINKER_FLAGS="-Wl,--as-needed" \
|
||||
-DCMAKE_MODULE_LINKER_FLAGS="-Wl,--as-needed" \
|
||||
-DCMAKE_SHARED_LINKER_FLAGS="-Wl,--as-needed"
|
||||
ninja -v -j $ninjaproc
|
||||
cd ..
|
||||
|
||||
%define __builddir build
|
||||
export CC=${PWD}/stage1/bin/clang
|
||||
export CXX=${PWD}/stage1/bin/clang++
|
||||
# -z,now is breaking now, it needs to be fixed
|
||||
%cmake \
|
||||
-DCMAKE_C_FLAGS="$flags" \
|
||||
-DCMAKE_CXX_FLAGS="$flags" \
|
||||
-DLLVM_REQUIRES_RTTI=ON \
|
||||
-DLLVM_ENABLE_TIMESTAMPS=OFF \
|
||||
-DLLVM_ENABLE_ASSERTIONS=OFF \
|
||||
-DLLVM_ENABLE_PIC=ON \
|
||||
-DLLVM_BINUTILS_INCDIR=/usr/include \
|
||||
%ifarch %{ix86} x86_64
|
||||
-DLLVM_TARGETS_TO_BUILD="all" \
|
||||
%else
|
||||
-DLLVM_TARGETS_TO_BUILD=host \
|
||||
%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 \
|
||||
-DLLVM_BINUTILS_INCDIR=/usr/include \
|
||||
%ifarch %{ix86} x86_64
|
||||
-DLLVM_TARGETS_TO_BUILD="all" \
|
||||
%else
|
||||
-DLLVM_TARGETS_TO_BUILD=host \
|
||||
-DLLVM_LIBDIR_SUFFIX=64 \
|
||||
%endif
|
||||
%if %{build_lldb}
|
||||
-DLLDB_DISABLE_PYTHON=ON \
|
||||
-DLLDB_DISABLE_PYTHON=ON \
|
||||
%endif
|
||||
..
|
||||
|
||||
ninja %{?_smp_mflags} -v
|
||||
-DCMAKE_SKIP_RPATH:BOOL=OFF \
|
||||
-DCMAKE_EXE_LINKER_FLAGS="-Wl,--as-needed" \
|
||||
-DCMAKE_MODULE_LINKER_FLAGS="-Wl,--as-needed" \
|
||||
-DCMAKE_SHARED_LINKER_FLAGS="-Wl,--as-needed"
|
||||
ninja -v -j $ninjaproc
|
||||
|
||||
%check
|
||||
cd stage2
|
||||
cd build
|
||||
%ifnarch armv7hl armv7l
|
||||
%if 0%{!?qemu_user_space_build:1}
|
||||
# we just do not have enough memory with qemu emulation
|
||||
|
||||
ninja check
|
||||
ninja clang-test
|
||||
ninja -v %{?_smp_mflags} check
|
||||
ninja -v %{?_smp_mflags} clang-test
|
||||
|
||||
%if %{build_libcxx}
|
||||
|
||||
ninja check-libcxx
|
||||
ninja check-libcxxabi
|
||||
ninja -v %{?_smp_mflags} check-libcxx
|
||||
ninja -v %{?_smp_mflags} check-libcxxabi
|
||||
%endif
|
||||
|
||||
%endif
|
||||
%endif
|
||||
|
||||
%install
|
||||
cd stage2
|
||||
DESTDIR=%{buildroot} ninja install
|
||||
cd ..
|
||||
|
||||
%cmake_install
|
||||
# Build man/html pages
|
||||
cd docs
|
||||
# Docs are prebuilt due to sphinx dependency
|
||||
|
Reference in New Issue
Block a user