File wasi-compiler-rt.spec of Package wasi-compiler-rt

#
# spec file for package wasi-compiler-rt
#
# Copyright (c) 2022 SUSE LLC
#
# 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 https://bugs.opensuse.org/
#

%define _relver 14.0.6
%define _version %_relver%{?_rc:rc%_rc}
%define _tagver %_relver%{?_rc:-rc%_rc}
%define _minor  14.0
%define _sonum  14
%define _itsme14 1
# Integer version used by update-alternatives
%define _uaver  1406
%define _soclang 13
%define _socxx  1

%define wasi_sysroot %{_datadir}/wasi-sysroot/

Name:           wasi-compiler-rt
Version:        %_relver%{?_rc:~rc%_rc}
Release:        0
Summary:        WASI version of compiler-rt implementation for WebAssembly 
License:        Apache-2.0 WITH LLVM-exception AND NCSA
Group:          Development/Languages/Other
URL:            https://www.llvm.org
Source:         https://github.com/llvm/llvm-project/releases/download/llvmorg-%{_tagver}/compiler-rt-%{_version}.src.tar.xz
BuildRequires:  clang14
BuildRequires:  llvm14
BuildRequires:  glibc-devel
BuildRequires:  llvm14-devel
BuildRequires:  cmake >= 3.13.4
BuildRequires:  fdupes
BuildRequires:  lld
BuildRequires:  wasi-libc

%description

%prep
%setup -q -n compiler-rt-%{_version}.src

%build
export CC=clang-14
export CXX=clang++-14
export AR=llvm-ar
export NM=llvm-nm
# compiler-rt
%cmake \
    -DCMAKE_SYSROOT=%{wasi_sysroot} \
    -DCMAKE_INSTALL_PREFIX:PATH=%{_libdir}/clang/%{_version}/ \
    -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON \
    -DCMAKE_C_COMPILER_TARGET=wasm32-wasi \
    -DCMAKE_CXX_COMPILER_TARGET=wasm32-wasi \
    -DCMAKE_C_COMPILER_WORKS=ON \
    -DCMAKE_CXX_COMPILER_WORKS=ON \
    -DCMAKE_BUILD_TYPE=RelWithDebInfo \
    -DCOMPILER_RT_BAREMETAL_BUILD=On \
    -DCOMPILER_RT_BUILD_XRAY=OFF \
    -DLLVM_INCLUDE_BENCHMARKS:BOOL=OFF \
    -DCMAKE_AR=/usr/bin/llvm-ar \
    -DCMAKE_RANLIB=/usr/bin/llvm-ranlib \
    -DLLVM_INCLUDE_TESTS:BOOL=OFF \
    -DCOMPILER_RT_INCLUDE_TESTS=OFF \
    -DCOMPILER_RT_HAS_FPIC_FLAG=OFF \
    -DCOMPILER_RT_ENABLE_IOS=OFF \
    -DCOMPILER_RT_DEFAULT_TARGET_ONLY=On \
    -DCOMPILER_RT_OS_DIR=wasi \
    -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \
    ../lib/builtins
%cmake_build

%install
export CC=clang-14
export CXX=clang++-14
export AR=llvm-ar
export NM=llvm-nm
%cmake_install
# brp-scripts use system-installed `ar` and `strip`, which can't handle wasm-files
export NO_BRP_AR=true
export NO_BRP_STRIP_DEBUG=true

%files
%{_libdir}/clang/%{_version}
%changelog
openSUSE Build Service is sponsored by