diff --git a/0001-libomp-Explicitly-include-string-header-NFC.patch b/0001-libomp-Explicitly-include-string-header-NFC.patch new file mode 100644 index 0000000000000000000000000000000000000000..775002e6692031af530ecd785b0ad873b055e648 --- /dev/null +++ b/0001-libomp-Explicitly-include-string-header-NFC.patch @@ -0,0 +1,26 @@ +From f2ddf903f588021507faefec15d360edb1e425e5 Mon Sep 17 00:00:00 2001 +From: Nikita Popov +Date: Fri, 20 Jan 2023 10:11:01 +0100 +Subject: [PATCH] [libomp] Explicitly include header (NFC) + +This is required to build against libstdc++ 13. Debug.h uses +std::stoi() from without explicitly including it. +--- + openmp/libomptarget/include/Debug.h | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/openmp/libomptarget/include/Debug.h b/openmp/libomptarget/include/Debug.h +index 4e7da8b7d53f..387dfe50659e 100644 +--- a/openmp/libomptarget/include/Debug.h ++++ b/openmp/libomptarget/include/Debug.h +@@ -39,6 +39,7 @@ + + #include + #include ++#include + + /// 32-Bit field data attributes controlling information presented to the user. + enum OpenMPInfoType : uint32_t { +-- +2.39.0 + diff --git a/README.md b/README.md index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..7342728d557c602f51c6d278bba9f3dd9faaf356 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,11 @@ +Anolis OS +======================================= +# 代码仓库说明 +## 分支说明 +>进行代码开发工作时,请注意选择当前版本对应的分支 +* aX分支为对应大版本的主分支,如a8分支对应当前最新版本 +* aX.Y分支为对应小版本的维护分支,如a8.2分支对应8.2版本 +## 开发流程 +1. 首先fork目标分支到自己的namespace +2. 在自己的fork分支上做出修改 +3. 向对应的仓库中提交merge request,源分支为fork分支 diff --git a/libomp.spec b/libomp.spec new file mode 100644 index 0000000000000000000000000000000000000000..aed93b9e9887ed68000dc38471d68cd280021c16 --- /dev/null +++ b/libomp.spec @@ -0,0 +1,143 @@ +%define anolis_release 1 +%global toolchain clang + +%undefine _include_frame_pointers + +%global maj_ver 15 +%global libomp_version %{maj_ver}.0.7 +%global libomp_srcdir openmp-%{libomp_version}.src + +%global libomp_arch %{_arch} + +Name: libomp +Version: %{libomp_version} +Release: %{anolis_release}%{?dist} +Summary: OpenMP runtime for clang + +License: Apache-2.0 WITH LLVM-exception OR NCSA +URL: http://openmp.llvm.org +Source0: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{libomp_version}/%{libomp_srcdir}.tar.xz +Source3: run-lit-tests +Source4: lit.distro.cfg.py + +# TODO: Not needed with LLVM 16. +Patch1: 0001-libomp-Explicitly-include-string-header-NFC.patch + +BuildRequires: clang +# For clang-offload-packager +BuildRequires: clang-tools-extra +BuildRequires: cmake +BuildRequires: ninja-build +BuildRequires: elfutils-libelf-devel +BuildRequires: perl +BuildRequires: perl-Data-Dumper +BuildRequires: perl-Encode +BuildRequires: libffi-devel + +# libomptarget needs the llvm cmake files +BuildRequires: llvm-devel + +Requires: elfutils-libelf + +%description +OpenMP runtime for clang. + +%package devel +Summary: OpenMP header files +Requires: %{name} = %{version}-%{release} +Requires: clang-resource-filesystem = %{version} + +%description devel +OpenMP header files. + +%package test +Summary: OpenMP regression tests +Requires: %{name} = %{version}-%{release} +Requires: %{name}-devel = %{version}-%{release} +Requires: clang +Requires: llvm +Requires: python3-lit + +%description test +OpenMP regression tests + +%prep +%autosetup -n %{libomp_srcdir} -p2 + +%build + +%cmake -GNinja \ + -DLIBOMP_INSTALL_ALIASES=OFF \ + -DCMAKE_MODULE_PATH=%{_libdir}/cmake/llvm \ + -DLLVM_DIR=%{_libdir}/cmake/llvm \ + -DCMAKE_INSTALL_INCLUDEDIR=%{_libdir}/clang/%{libomp_version}/include \ + -DOPENMP_LIBDIR_SUFFIX=64 \ + -DCMAKE_SKIP_RPATH:BOOL=ON + +%cmake_build + + +%install +%cmake_install + +# Test package setup +%global libomp_srcdir %{_datadir}/libomp/src/ +%global libomp_testdir %{libomp_srcdir}/runtime/test/ +%global lit_cfg %{libomp_testdir}/%{_arch}.site.cfg.py +%global lit_distro_cfg %{_datadir}/libomp/lit.distro.cfg.py + +install -d %{buildroot}%{libomp_srcdir}/runtime +cp -R runtime/test %{buildroot}%{libomp_srcdir}/runtime +cp -R runtime/src %{buildroot}%{libomp_srcdir}/runtime + +# Generate lit config files. Strip off the last line that initiates the +# test run, so we can customize the configuration. +head -n -1 %{_vpath_builddir}/runtime/test/lit.site.cfg >> %{buildroot}%{lit_cfg} + +# Install custom distro config file +cp %{SOURCE4} %{buildroot}%{lit_distro_cfg} + +# Patch lit config files to load custom distro config +echo "lit_config.load_config(config, '%{lit_distro_cfg}')" >> %{buildroot}%{lit_cfg} + +# Install test script +install -d %{buildroot}%{_libexecdir}/tests/libomp +install -m 0755 %{SOURCE3} %{buildroot}%{_libexecdir}/tests/libomp + +# Remove static libraries with equivalent shared libraries +rm -rf %{buildroot}%{_libdir}/libarcher_static.a + +%check +%cmake_build --target check-openmp + +%files +%license LICENSE.TXT +%{_libdir}/libomp.so +%{_libdir}/libompd.so +%{_libdir}/libarcher.so +%{_libdir}/libomptarget.rtl.amdgpu.so.%{maj_ver} +%{_libdir}/libomptarget.rtl.cuda.so.%{maj_ver} +%{_libdir}/libomptarget.rtl.%{libomp_arch}.so.%{maj_ver} +%{_libdir}/libomptarget.so.%{maj_ver} + +%files devel +%{_libdir}/clang/%{libomp_version}/include/omp.h +%{_libdir}/cmake/openmp/FindOpenMPTarget.cmake +%{_libdir}/clang/%{libomp_version}/include/omp-tools.h +%{_libdir}/clang/%{libomp_version}/include/ompt.h +%{_libdir}/clang/%{libomp_version}/include/ompt-multiplex.h +%{_libdir}/libomptarget.rtl.amdgpu.so +%{_libdir}/libomptarget.rtl.cuda.so +%{_libdir}/libomptarget.rtl.%{libomp_arch}.so +%{_libdir}/libomptarget.devicertl.a +%{_libdir}/libomptarget-amdgpu-*.bc +%{_libdir}/libomptarget-nvptx-*.bc +%{_libdir}/libomptarget.so + +%files test +%{_datadir}/libomp +%{_libexecdir}/tests/libomp/ + +%changelog +* Wed Feb 1 2023 Funda Wang - 15.0.7-1 +- Import package for anolis 23 diff --git a/lit.distro.cfg.py b/lit.distro.cfg.py new file mode 100644 index 0000000000000000000000000000000000000000..10d1f1f5c726d6cb64c0cf0c49baff6b903f094f --- /dev/null +++ b/lit.distro.cfg.py @@ -0,0 +1,15 @@ +import tempfile + +compiler = '%(libomp_compiler)s' % lit_config.params +config.test_filecheck = '%(bindir)s/FileCheck' % lit_config.params +config.omp_header_directory = '%(includedir)s' % lit_config.params +config.libomp_obj_root = tempfile.mkdtemp() +config.library_dir = '%(libdir)s' % lit_config.params +test_root = '%(libomp_test_root)s' % lit_config.params + +# Lit will default to the compiler used to build openmp, which is gcc, but we +# want to run the tests using clang. +config.test_compiler_features = ['clang'] +config.test_c_compiler = 'clang' +config.test_cxx_compiler = 'clang++' +lit_config.load_config(config, '%(libomp_test_root)s/lit.cfg' % lit_config.params) diff --git a/openmp-15.0.7.src.tar.xz b/openmp-15.0.7.src.tar.xz new file mode 100644 index 0000000000000000000000000000000000000000..636471de60579c4a45952548fa9807d7fb7cfa99 Binary files /dev/null and b/openmp-15.0.7.src.tar.xz differ diff --git a/run-lit-tests b/run-lit-tests new file mode 100644 index 0000000000000000000000000000000000000000..18dbec562cc6324bbf88741c4cef1f85a482c6f5 --- /dev/null +++ b/run-lit-tests @@ -0,0 +1,59 @@ +#!/usr/bin/bash + +usage() { + echo "usage: `basename $0` [OPTIONS]" + echo " --threads NUM The number of threads to use for running tests." +} + + +threads_arg='' + +while [ $# -gt 0 ]; do + case $1 in + --threads) + shift + threads_arg="--threads $1" + ;; + --multilib-arch) + shift + ARCH=$1 + ;; + * ) + echo "unknown option: $1" + echo "" + usage + exit 1 + ;; + esac + shift +done + + +set -xe + +if [ -z "$ARCH" ]; then + ARCH=`rpm --eval '%_arch'` +fi + +case $ARCH in + arm) + ;& + i686) + LIB_DIR="/usr/lib/" + ;; + *) + LIB_DIR="/usr/lib64/" + ;; +esac + +BIN_DIR="/usr/bin/" +INCLUDE_DIR="/usr/include/" + +lit $threads_arg -v \ + --config-prefix $ARCH \ + -Dlibomp_compiler=clang \ + -Dbindir=$BIN_DIR \ + -Dlibdir=$LIB_DIR \ + -Dincludedir=$INCLUDE_DIR \ + -Dlibomp_test_root=/usr/share/libomp/src/runtime/test \ + /usr/share/libomp/src/runtime/test