diff --git a/README.en.md b/README.en.md new file mode 100644 index 0000000000000000000000000000000000000000..e750ce2a3db302d6f9b147455041ece41c5db2e4 --- /dev/null +++ b/README.en.md @@ -0,0 +1,21 @@ +# The LLVM Compiler Infrastructure + +#### Description +The LLVM Core libraries provide a modern source- and target-independent optimizer, along with code generation support for many popular CPUs (as well as some less common ones!) These libraries are built around a well specified code representation known as the LLVM intermediate representation ("LLVM IR"). + +#### Contribution + +1. Fork the repository +2. Create Feat_xxx branch +3. Commit your code +4. Create Pull Request + + +#### Gitee Feature + +1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md +2. Gitee blog [blog.gitee.com](https://blog.gitee.com) +3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore) +4. The most valuable open source project [GVP](https://gitee.com/gvp) +5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help) +6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) diff --git a/README.md b/README.md new file mode 100644 index 0000000000000000000000000000000000000000..53337a6b037b7f4a5cbab3d15e37b3f7c3d992d9 --- /dev/null +++ b/README.md @@ -0,0 +1,21 @@ +# The LLVM Compiler Infrastructure + +#### 介绍 +The LLVM Core libraries provide a modern source- and target-independent optimizer, along with code generation support for many popular CPUs (as well as some less common ones!) These libraries are built around a well specified code representation known as the LLVM intermediate representation ("LLVM IR"). + +#### 参与贡献 + +1. Fork 本仓库 +2. 新建 Feat_xxx 分支 +3. 提交代码 +4. 新建 Pull Request + + +#### 特技 + +1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md +2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com) +3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目 +4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目 +5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help) +6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) diff --git a/llvm.spec b/llvm.spec index eb37aa8af66f2ca7aed1e092f3e3db347591fedf..7e9d1b2e290292543db40a79c8ef5e3823ae6ef1 100644 --- a/llvm.spec +++ b/llvm.spec @@ -1,124 +1,182 @@ -%bcond_with check +%bcond_with sys_llvm +%bcond_without check -Name: llvm -Version: 12.0.1 -Release: 5 +%global maj_ver 12 +%global min_ver 0 +%global patch_ver 1 + +%if %{with sys_llvm} +%global pkg_name llvm +%global install_prefix %{_prefix} +%else +%global pkg_name llvm%{maj_ver} +%global install_prefix %{_libdir}/%{name} +%endif + +%global install_bindir %{install_prefix}/bin +%global install_includedir %{install_prefix}/include +%if 0%{?__isa_bits} == 64 +%global install_libdir %{install_prefix}/lib64 +%else +%global install_libdir %{install_prefix}/lib +%endif +%global install_srcdir %{install_prefix}/src +%global install_docdir %{install_prefix}/share/doc + +%global max_link_jobs %{_smp_build_ncpus} +%global targets_to_build "all" +%global experimental_targets_to_build "" + +%global build_install_prefix %{buildroot}%{install_prefix} +%global llvm_triple %{_host} + +# Disable LTO as this causes crash if gcc lto enabled. +%define _lto_cflags %{nil} + +Name: %{pkg_name} +Version: %{maj_ver}.%{min_ver}.%{patch_ver} +Release: 6 Summary: The Low Level Virtual Machine + License: NCSA URL: http://llvm.org -Source0: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{version}/%{name}-%{version}.src.tar.xz - -BuildRequires: gcc gcc-c++ cmake ninja-build zlib-devel libffi-devel ncurses-devel libstdc++-static -BuildRequires: python3-sphinx binutils-devel valgrind-devel libedit-devel python3-devel -BuildRequires: python3-recommonmark +Source0: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{version}/llvm-%{version}.src.tar.xz + +BuildRequires: binutils-devel +BuildRequires: cmake +BuildRequires: gcc +BuildRequires: gcc-c++ +BuildRequires: libedit-devel +BuildRequires: libffi-devel +BuildRequires: multilib-rpm-config +BuildRequires: ncurses-devel +BuildRequires: ninja-build +BuildRequires: python3-devel +BuildRequires: python3-psutil +BuildRequires: python3-recommonmark +BuildRequires: python3-sphinx +BuildRequires: python3-setuptools +BuildRequires: zlib-devel + +Requires: %{name}-libs%{?_isa} = %{version}-%{release} + +Provides: llvm(major) = %{maj_ver} %description LLVM is a compiler infrastructure designed for compile-time, link-time, runtime, and idle-time optimization of programs from arbitrary programming -languages. +languages. The compiler infrastructure includes mirror sets of programming +tools as well as libraries with equivalent functionality. + +%package devel +Summary: Libraries and header files for LLVM +Requires: %{name}%{?_isa} = %{version}-%{release} +Requires: %{name}-libs%{?_isa} = %{version}-%{release} +Requires: libedit-devel +Requires: %{name}-static%{?_isa} = %{version}-%{release} -The LLVM compiler infrastructure supports a wide range of projects, -from industrial strength compilers to specialized JIT applications -to small research projects. +Requires(post): %{_sbindir}/alternatives +Requires(postun): %{_sbindir}/alternatives + +Provides: llvm-devel(major) = %{maj_ver} + +%description devel +This package contains library and header files needed to develop new native +programs that use the LLVM infrastructure. + +%package doc +Summary: Documentation for LLVM +BuildArch: noarch +Requires: %{name} = %{version}-%{release} + +%description doc +Documentation for the LLVM compiler infrastructure. %package libs -Summary:LLVM shared libraries +Summary: LLVM shared libraries %description libs Shared libraries for the LLVM compiler infrastructure. -%package devel -Summary: Development files for %{name} -Requires: %{name} = %{version}-%{release} -Requires: libedit-devel python3-lit binutils gcc -Requires(post): %{_sbindir}/alternatives -Requires(postun):%{_sbindir}/alternatives -Provides: %{name}-static = %{version}-%{release} -Obsoletes: %{name}-static < %{version}-%{release} -Provides: %{name}-googletest = %{version}-%{release} -Obsoletes: %{name}-googletest < %{version}-%{release} -Provides: %{name}-test = %{version}-%{release} -Obsoletes: %{name}-test < %{version}-%{release} - -%description devel -The %{name}-devel package contains libraries and header files for -developing applications that use %{name}. - -%package help -Summary: Doc files for %{name} -Buildarch: noarch -Requires: man -Provides: %{name}-doc = %{version}-%{release} -Obsoletes: %{name}-doc < %{version}-%{release} - -%description help -The %{name}-help package contains doc files for %{name}. +%package static +Summary: LLVM static libraries +Conflicts: %{name}-devel < 8 + +Provides: llvm-static(major) = %{maj_ver} + +%description static +Static libraries for the LLVM compiler infrastructure. + +%package test +Summary: LLVM regression tests +Requires: %{name}%{?_isa} = %{version}-%{release} +Requires: %{name}-libs%{?_isa} = %{version}-%{release} + +Provides: llvm-test(major) = %{maj_ver} + +%description test +LLVM regression tests. + +%package googletest +Summary: LLVM's modified googletest sources + +%description googletest +LLVM's modified googletest sources. %prep -%autosetup -n %{name}-%{version}.src -p1 -pathfix.py -i %{__python3} -pn test/BugPoint/compile-custom.ll.py tools/opt-viewer/*.py +%setup -T -q -b 0 -n llvm-%{version}.src + +pathfix.py -i %{__python3} -pn \ + test/BugPoint/compile-custom.ll.py \ + tools/opt-viewer/*.py \ + utils/update_cc_test_checks.py %build -#TODO: -DLLVM_TARGETS_TO_BUILD=all in needed(temporarily) when build rust, -# clarification is required in the future mkdir -p _build cd _build -%global optflags %(echo %{optflags} | sed 's/-g /-g1 /') -%cmake .. -G Ninja \ + +%cmake .. -G Ninja \ -DBUILD_SHARED_LIBS:BOOL=OFF \ - -DLLVM_PARALLEL_LINK_JOBS=1 \ + -DLLVM_PARALLEL_LINK_JOBS=%{max_link_jobs} \ -DCMAKE_BUILD_TYPE=RelWithDebInfo \ -DCMAKE_SKIP_RPATH:BOOL=ON \ - -DCMAKE_C_FLAGS_RELWITHDEBINFO="%{optflags} -DNDEBUG -fPIE -fPIC" \ - -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="%{optflags} -DNDEBUG -fPIE -fPIC" \ - -DCMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO="%{optflags} -pie" \ -%if 0%{?__isa_bits} == 64 - -DLLVM_LIBDIR_SUFFIX=64 \ -%else - -DLLVM_LIBDIR_SUFFIX= \ -%endif -%if 0 -%ifarch %ix86 x86_64 - -DLLVM_TARGETS_TO_BUILD="X86;AMDGPU;NVPTX;BPF;ARM;AArch64" \ -%endif -%ifarch aarch64 - -DLLVM_TARGETS_TO_BUILD="AArch64;AMDGPU;BPF" \ -%endif -%ifarch %{arm} - -DLLVM_TARGETS_TO_BUILD="ARM;AMDGPU;BPF" \ -%endif -%endif - -DLLVM_TARGETS_TO_BUILD=all \ + -DLLVM_TARGETS_TO_BUILD=%{targets_to_build} \ -DLLVM_ENABLE_LIBCXX:BOOL=OFF \ -DLLVM_ENABLE_ZLIB:BOOL=ON \ -DLLVM_ENABLE_FFI:BOOL=ON \ -DLLVM_ENABLE_RTTI:BOOL=ON \ + -DLLVM_USE_PERF:BOOL=ON \ -DLLVM_BINUTILS_INCDIR=%{_includedir} \ - -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=AVR \ + -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=%{experimental_targets_to_build} \ -DLLVM_BUILD_RUNTIME:BOOL=ON \ -DLLVM_INCLUDE_TOOLS:BOOL=ON \ -DLLVM_BUILD_TOOLS:BOOL=ON \ -DLLVM_INCLUDE_TESTS:BOOL=ON \ - -DLLVM_BUILD_TESTS:BOOL=OFF \ + -DLLVM_BUILD_TESTS:BOOL=ON \ + -DLLVM_LIT_ARGS=-v \ -DLLVM_INCLUDE_EXAMPLES:BOOL=ON \ -DLLVM_BUILD_EXAMPLES:BOOL=OFF \ -DLLVM_INCLUDE_UTILS:BOOL=ON \ -DLLVM_INSTALL_UTILS:BOOL=ON \ - -DLLVM_UTILS_INSTALL_DIR:PATH=%{_bindir} \ - -DLLVM_TOOLS_INSTALL_DIR:PATH=bin \ -DLLVM_INCLUDE_DOCS:BOOL=ON \ -DLLVM_BUILD_DOCS:BOOL=ON \ -DLLVM_ENABLE_SPHINX:BOOL=ON \ -DLLVM_ENABLE_DOXYGEN:BOOL=OFF \ - -DLLVM_VERSION_SUFFIX='' \ -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 \ + -DLLVM_DEFAULT_TARGET_TRIPLE=%{llvm_triple} \ -DSPHINX_WARNINGS_AS_ERRORS=OFF \ - -DLLVM_INSTALL_SPHINX_HTML_DIR=%{_pkgdocdir}/html \ - -DSPHINX_EXECUTABLE=%{_bindir}/sphinx-build-3 + -DCMAKE_INSTALL_PREFIX=%{install_prefix} \ + -DLLVM_INSTALL_SPHINX_HTML_DIR=%{install_docdir}/html \ + -DSPHINX_EXECUTABLE=%{_bindir}/sphinx-build-3 \ +%if 0%{?__isa_bits} == 64 + -DLLVM_LIBDIR_SUFFIX=64 \ +%else + -DLLVM_LIBDIR_SUFFIX= \ +%endif + -DLLVM_INCLUDE_BENCHMARKS=OFF %ninja_build LLVM %ninja_build @@ -126,81 +184,109 @@ cd _build %install %ninja_install -C _build -find %{buildroot}%{_libdir}/cmake/llvm -type f | xargs sed -i "s|%{buildroot}||g" -mv -v %{buildroot}%{_bindir}/llvm-config{,-%{__isa_bits}} +mkdir -p %{buildroot}/%{_bindir} -for f in llvm-isel-fuzzer llvm-opt-fuzzer; do -install -m 0755 ./_build/bin/$f %{buildroot}%{_bindir} +# Install binaries needed for lit tests +for f in llvm-isel-fuzzer llvm-opt-fuzzer +do + install -m 0755 %{_builddir}/llvm-%{version}.src/_build/bin/$f %{buildroot}%{install_bindir} done -%global install_srcdir %{buildroot}%{_datadir}/llvm/src -%global lit_cfg test/lit.site.cfg.py -%global lit_unit_cfg test/Unit/lit.site.cfg.py - -install -d %{install_srcdir} -install -d %{install_srcdir}/utils/ -cp -R utils/unittest %{install_srcdir}/utils/ +%if 0%{?__isa_bits} == 64 +install %{_builddir}/llvm-%{version}.src/_build/lib64/libLLVMTestingSupport.a %{buildroot}%{install_libdir} +%else +install %{_builddir}/llvm-%{version}.src/_build/lib/libLLVMTestingSupport.a %{buildroot}%{install_libdir} +%endif -cat _build/test/lit.site.cfg.py >> %{lit_cfg} -cat _build/test/Unit/lit.site.cfg.py >> %{lit_unit_cfg} -sed -i -e s~`pwd`/_build~%{_prefix}~g -e s~`pwd`~.~g %{lit_cfg} %{lit_cfg} %{lit_unit_cfg} +# Install gtest sources so clang can use them for gtest +install -d %{buildroot}%{install_srcdir} +install -d %{buildroot}%{install_srcdir}/utils/ +cp -R %{_builddir}/llvm-%{version}.src/utils/unittest %{buildroot}%{install_srcdir}/utils/ + +# Clang needs these for running lit tests. +cp %{_builddir}/llvm-%{version}.src/utils/update_cc_test_checks.py %{buildroot}%{install_srcdir}/utils/ +cp -R %{_builddir}/llvm-%{version}.src/utils/UpdateTestChecks %{buildroot}%{install_srcdir}/utils/ -sed -i 's~\(config.llvm_obj_root = \)"[^"]\+"~\1"%{_libdir}/%{name}"~' %{lit_unit_cfg} +# Move header files +mkdir -p %{buildroot}/%{install_includedir} +ln -s ../../../%{install_includedir}/llvm %{buildroot}/%{install_includedir}/llvm +ln -s ../../../%{install_includedir}/llvm-c %{buildroot}/%{install_includedir}/llvm-c -install -d %{buildroot}%{_libexecdir}/tests/llvm +# Fix multi-lib +%multilib_fix_c_header --file %{install_includedir}/llvm/Config/llvm-config.h -install -d %{buildroot}%{_datadir}/llvm/ -tar -czf %{install_srcdir}/test.tar.gz test/ +# 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 +%{install_libdir} +EOF -mkdir -p %{buildroot}%{_libdir}/%{name} -cp -R _build/unittests %{buildroot}%{_libdir}/%{name}/ -find %{buildroot}%{_libdir}/%{name} -ignore_readdir_race -iname 'cmake*' -exec rm -Rf '{}' ';' || true +# Remove opt-viewer, since this is just a compatibility package. +rm -Rf %{build_install_prefix}/share/opt-viewer %check %if %{with check} -cd _build -ninja check-all || : +LD_LIBRARY_PATH=%{buildroot}/%{install_libdir} %{__ninja} check-all -C ./_build/ %endif -%post -p /sbin/ldconfig -%postun -p /sbin/ldconfig - -%post devel -%{_sbindir}/update-alternatives --install %{_bindir}/llvm-config llvm-config %{_bindir}/llvm-config-%{__isa_bits} %{__isa_bits} - -%postun devel -if [ $1 -eq 0 ]; then - %{_sbindir}/update-alternatives --remove llvm-config %{_bindir}/llvm-config-%{__isa_bits} -fi +%ldconfig_scriptlets libs %files %license LICENSE.TXT -%{_bindir}/* -%{_libdir}/%{name}/* -%{_datadir}/opt-viewer/* -%exclude %{_bindir}/llvm-config-%{__isa_bits} -%exclude %{_libdir}/%{name}/unittests/ +%{install_prefix}/share/man/man1/* +%{install_bindir}/* +%exclude %{install_bindir}/not +%exclude %{install_bindir}/count +%exclude %{install_bindir}/yaml-bench +%exclude %{install_bindir}/lli-child-target +%exclude %{install_bindir}/llvm-isel-fuzzer +%exclude %{install_bindir}/llvm-opt-fuzzer %files libs -%{_libdir}/*.so* -%exclude %{_libdir}/libLLVM.so +%license LICENSE.TXT +%{install_libdir}/libLLVM-%{maj_ver}.so +%config(noreplace) %{_sysconfdir}/ld.so.conf.d/%{name}-%{_arch}.conf +%{install_libdir}/LLVMgold.so +%{install_libdir}/libLLVM-%{maj_ver}.%{min_ver}*.so +%{install_libdir}/libLTO.so* +%exclude %{install_libdir}/libLTO.so +%{install_libdir}/libRemarks.so* %files devel -%{_bindir}/llvm-config-%{__isa_bits} -%{_includedir}/llvm/* -%{_includedir}/llvm-c/* -%{_libdir}/cmake/llvm/* -%{_libdir}/libLLVM.so -%{_libdir}/*.a -%{_datadir}/llvm/src/utils -%{_libdir}/%{name}/unittests/ -%{_datadir}/llvm/src/test.tar.gz - -%files help -%doc %{_pkgdocdir}/html -%{_mandir}/man1/* +%license LICENSE.TXT +%{install_includedir}/llvm +%{install_includedir}/llvm-c +%{install_libdir}/libLTO.so +%{install_libdir}/libLLVM.so +%{install_libdir}/cmake/llvm + +%files doc +%license LICENSE.TXT +%doc %{install_docdir}/html + +%files static +%license LICENSE.TXT +%{install_libdir}/*.a +%exclude %{install_libdir}/libLLVMTestingSupport.a + +%files test +%license LICENSE.TXT +%{install_bindir}/not +%{install_bindir}/count +%{install_bindir}/yaml-bench +%{install_bindir}/lli-child-target +%{install_bindir}/llvm-isel-fuzzer +%{install_bindir}/llvm-opt-fuzzer + +%files googletest +%license LICENSE.TXT +%{install_srcdir}/utils +%{install_libdir}/libLLVMTestingSupport.a %changelog +* Sat Jul 08 2023 cf-zhao -12.0.1-6 +- Make this spec file support both system-version and multi-version. + * Tue Feb 14 2023 cf-zhao - 12.0.1-5 - Disable check temporarily to avoid a build error that `rmbuild` cannot - remove a file due to no permission.