From 430f8ff5a8a50067b9444b407d89f7d52230af94 Mon Sep 17 00:00:00 2001 From: Reshabh Sharma Date: Tue, 10 Jul 2018 21:05:15 +0000 Subject: [PATCH] Integrating OpenMP in toolchain --- debian/control | 103 ++++++++++++++++++++- debian/libomp-X.Y-dev.install.in | 4 + debian/libomp-X.Y-doc.docs.in | 1 + debian/libomp5-X.Y.install.in | 1 + debian/libomp5-X.Y.lintian-overrides.in | 1 + debian/orig-tar.sh | 10 ++ debian/patches/openmp-check-execstack.diff | 14 +++ debian/patches/openmp-mips-affinity.patch | 56 +++++++++++ debian/patches/openmp-soname.diff | 14 +++ debian/patches/series | 3 + debian/rules | 26 ++++++ debian/unpack.sh | 3 +- 12 files changed, 234 insertions(+), 2 deletions(-) create mode 100644 debian/libomp-X.Y-dev.install.in create mode 100644 debian/libomp-X.Y-doc.docs.in create mode 100644 debian/libomp5-X.Y.install.in create mode 100644 debian/libomp5-X.Y.lintian-overrides.in create mode 100644 debian/patches/openmp-check-execstack.diff create mode 100644 debian/patches/openmp-mips-affinity.patch create mode 100644 debian/patches/openmp-soname.diff diff --git a/debian/control b/debian/control index 74649479..1923d685 100644 --- a/debian/control +++ b/debian/control @@ -10,7 +10,8 @@ Build-Depends: debhelper (>= 9.0), flex, bison, dejagnu, tcl, expect, libjsoncpp-dev, pkg-config, lcov, procps, help2man, zlib1g-dev, g++-multilib [amd64 i386 kfreebsd-amd64 mips mips64 mips64el mipsel powerpc ppc64 s390 s390x sparc sparc64 x32], - libjs-mathjax + libjs-mathjax, + doxygen, gfortran # ocaml-nox [amd64 arm64 armel armhf i386 ppc64el s390x], # ocaml-findlib [amd64 arm64 armel armhf i386 ppc64el s390x], # libctypes-ocaml-dev [amd64 arm64 armel armhf i386 ppc64el s390x], @@ -473,3 +474,103 @@ Description: Next generation, high-performance debugger, header files Project, such as the Clang expression parser and LLVM disassembler. . This package provides the header files to build extension over lldb. + + +# ------------- openmp ------------- + +Package: libiomp-7-dev +Section: libdevel +Architecture: any +Depends: libomp-7-dev (= ${binary:Version}), ${shlibs:Depends}, ${misc:Depends} +Description: Intel OpenMP runtime - dev package - transition package + The runtime is the part of the OpenMP implementation that your code is + linked against, and that manages the multiple threads in an OpenMP program + while it is executing. + . + This package has been replaced by the LLVM sources. This is the Intel version + moved under the LLVM umbrella. This is a dependency package. + +Package: libomp-7-dev +Section: libdevel +Architecture: any +Depends: libomp5-7 (= ${binary:Version}), ${shlibs:Depends}, ${misc:Depends} +Suggests: libomp-7-doc +Replaces: libiomp-7-dev (<< 3.7-1) +Breaks: libiomp-7-dev (<< 3.7-1) +Description: LLVM OpenMP runtime - dev package + The runtime is the part of the OpenMP implementation that your code is + linked against, and that manages the multiple threads in an OpenMP program + while it is executing. + +Package: libiomp5-7 +Section: libs +Architecture: any +Depends: libomp5-7, ${shlibs:Depends}, ${misc:Depends} +Description: Intel OpenMP runtime - transition package + The runtime is the part of the OpenMP implementation that your code is + linked against, and that manages the multiple threads in an OpenMP program + while it is executing. + . + This package has been replaced by the LLVM sources. This is the Intel version + moved under the LLVM umbrella. This is a dependency package. + +Package: libomp5-7 +Multi-Arch: same +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Replaces: libiomp5-7 (<< 3.7-1) +Breaks: libiomp5-7 (<< 3.7-1) +Description: LLVM OpenMP runtime + The runtime is the part of the OpenMP implementation that your code is + linked against, and that manages the multiple threads in an OpenMP program + while it is executing. + +Package: libiomp5-7-dbg +Section: debug +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends}, libomp5-7 (= ${binary:Version}) +Description: Intel OpenMP runtime - Debug transition package + The runtime is the part of the OpenMP implementation that your code is + linked against, and that manages the multiple threads in an OpenMP program + while it is executing. + . + This package has been replaced by the LLVM sources. This is the Intel version + moved under the LLVM umbrella. This is a dependency package. + + +Package: libomp5-7-dbg +Section: debug +Architecture: any +Multi-Arch: same +Depends: ${shlibs:Depends}, ${misc:Depends}, libomp5-7 (= ${binary:Version}) +Replaces: libiomp5-7-dbg (<< 3.7-1) +Breaks: libiomp5-7-dbg (<< 3.7-1) +Description: LLVM OpenMP runtime - Debug package + The runtime is the part of the OpenMP implementation that your code is + linked against, and that manages the multiple threads in an OpenMP program + while it is executing. + +Package: libiomp-7-doc +Section: doc +Architecture: all +Depends: ${shlibs:Depends}, ${misc:Depends}, libomp-7-doc +Description: Intel OpenMP runtime - Documentation - Transition package + The runtime is the part of the OpenMP implementation that your code is + linked against, and that manages the multiple threads in an OpenMP program + while it is executing. + . + This package has been replaced by the LLVM sources. This is the Intel version + moved under the LLVM umbrella. This is a dependency package. + +Package: libomp-7-doc +Section: doc +Architecture: all +Depends: ${shlibs:Depends}, ${misc:Depends}, libjs-jquery +Replaces: libiomp-7-doc (<< 3.7-1) +Breaks: libiomp-7-doc (<< 3.7-1) +Description: LLVM OpenMP runtime - Documentation + The runtime is the part of the OpenMP implementation that your code is + linked against, and that manages the multiple threads in an OpenMP program + while it is executing. + . + This package contains the documentation of this package. diff --git a/debian/libomp-X.Y-dev.install.in b/debian/libomp-X.Y-dev.install.in new file mode 100644 index 00000000..41d4514b --- /dev/null +++ b/debian/libomp-X.Y-dev.install.in @@ -0,0 +1,4 @@ +/usr/lib/llvm-@LLVM_VERSION@/include/openmp/omp*.h +/usr/lib/llvm-@LLVM_VERSION@/lib/libgomp.so +/usr/lib/llvm-@LLVM_VERSION@/lib/libiomp5.so +/usr/lib/llvm-@LLVM_VERSION@/lib/libomp.so diff --git a/debian/libomp-X.Y-doc.docs.in b/debian/libomp-X.Y-doc.docs.in new file mode 100644 index 00000000..fbb48ae0 --- /dev/null +++ b/debian/libomp-X.Y-doc.docs.in @@ -0,0 +1 @@ +openmp/runtime/doc/doxygen/generated/html/ diff --git a/debian/libomp5-X.Y.install.in b/debian/libomp5-X.Y.install.in new file mode 100644 index 00000000..19af41ce --- /dev/null +++ b/debian/libomp5-X.Y.install.in @@ -0,0 +1 @@ +usr/lib/llvm-@LLVM_VERSION@/lib/libomp.so.5 diff --git a/debian/libomp5-X.Y.lintian-overrides.in b/debian/libomp5-X.Y.lintian-overrides.in new file mode 100644 index 00000000..f2258471 --- /dev/null +++ b/debian/libomp5-X.Y.lintian-overrides.in @@ -0,0 +1 @@ +libomp5-@LLVM_VERSION@: postinst-must-call-ldconfig usr/lib/*/libomp-@LLVM_VERSION@.so.5 diff --git a/debian/orig-tar.sh b/debian/orig-tar.sh index 4c9f8129..65f2b0d3 100755 --- a/debian/orig-tar.sh +++ b/debian/orig-tar.sh @@ -6,7 +6,9 @@ # llvm-toolchain-snapshot-3.2_3.2repack.orig-lld.tar.bz2 # llvm-toolchain-snapshot-3.2_3.2repack.orig-lldb.tar.bz2 # llvm-toolchain-snapshot-3.2_3.2repack.orig-polly.tar.bz2 +# llvm-toolchain-snapshot-3.2_3.2repack.orig-openmp.tar.bz2 # llvm-toolchain-snapshot-3.2_3.2repack.orig.tar.bz2 + set -e # TODO rest of the options @@ -182,6 +184,14 @@ rm -rf $LLDB_TARGET/www/ tar jcf $FULL_VERSION.orig-lldb.tar.bz2 $LLDB_TARGET rm -rf $LLDB_TARGET +# OPENMP +OPENMP_TARGET=openmp_$VERSION +checkout_sources openmp $(get_svn_url openmp $BRANCH $TAG) $OPENMP_TARGET "$BRANCH" $REVISION +rm -rf $OPENMP_TARGET/www/ +tar jcf $FULL_VERSION.orig-openmp.tar.bz2 $OPENMP_TARGET +rm -rf $OPENMP_TARGET + + PATH_DEBIAN="$(pwd)/$(dirname $0)/../" echo "going into $PATH_DEBIAN" export DEBFULLNAME="Sylvestre Ledru" diff --git a/debian/patches/openmp-check-execstack.diff b/debian/patches/openmp-check-execstack.diff new file mode 100644 index 00000000..5bfbc2c8 --- /dev/null +++ b/debian/patches/openmp-check-execstack.diff @@ -0,0 +1,14 @@ +Index: llvm-toolchain-snapshot_7~svn335949/openmp/runtime/tools/check-execstack.pl +=================================================================== +--- llvm-toolchain-snapshot_7~svn335949.orig/openmp/runtime/tools/check-execstack.pl ++++ llvm-toolchain-snapshot_7~svn335949/openmp/runtime/tools/check-execstack.pl +@@ -46,7 +46,8 @@ sub execstack($) { + # GNU_STACK 0x000000 0x00000000 0x00000000 0x00000 0x00000 RWE 0x4 + # Linux* OS Intel(R) 64: + # GNU_STACK 0x000000 0x0000000000000000 0x0000000000000000 0x000000 0x000000 RWE 0x8 +- if ( $stack[ 0 ] !~ m{\A\s*(?:GNU_)?STACK(?:\s+0x[0-9a-f]+){5}\s+([R ][W ][E ])\s+0x[0-9a-f]+\s*\z} ) { ++# if ( $stack[ 0 ] !~ m{\A\s*(?:GNU_)?STACK(?:\s+0x[0-9a-f]+){5}\s+([R ][W ][E ])\s+0x[0-9a-f]+\s*\z} ) { ++ if ( $stack[ 0 ] !~ m{\A\s*(?:GNU_)?STACK(?:\s+0x[0-9a-f]+){5}\s+([R ][W ][E ])\s+0(?:x[0-9a-f]+)*\s*\z} ) { + runtime_error( "$file: Cannot parse stack segment line:", ">>> $stack[ 0 ]" ); + }; # if + my $attrs = $1; diff --git a/debian/patches/openmp-mips-affinity.patch b/debian/patches/openmp-mips-affinity.patch new file mode 100644 index 00000000..10a868e9 --- /dev/null +++ b/debian/patches/openmp-mips-affinity.patch @@ -0,0 +1,56 @@ +Index: llvm-toolchain-snapshot_7~svn335949/openmp/runtime/src/kmp_affinity.h +=================================================================== +--- llvm-toolchain-snapshot_7~svn335949.orig/openmp/runtime/src/kmp_affinity.h ++++ llvm-toolchain-snapshot_7~svn335949/openmp/runtime/src/kmp_affinity.h +@@ -212,28 +212,29 @@ public: + #elif __NR_sched_getaffinity != 223 + #error Wrong code for getaffinity system call. + #endif /* __NR_sched_getaffinity */ +-#elif KMP_ARCH_MIPS +-#ifndef __NR_sched_setaffinity +-#define __NR_sched_setaffinity 4239 +-#elif __NR_sched_setaffinity != 4239 +-#error Wrong code for setaffinity system call. +-#endif /* __NR_sched_setaffinity */ +-#ifndef __NR_sched_getaffinity +-#define __NR_sched_getaffinity 4240 +-#elif __NR_sched_getaffinity != 4240 +-#error Wrong code for getaffinity system call. +-#endif /* __NR_sched_getaffinity */ +-#elif KMP_ARCH_MIPS64 +-#ifndef __NR_sched_setaffinity +-#define __NR_sched_setaffinity 5195 +-#elif __NR_sched_setaffinity != 5195 +-#error Wrong code for setaffinity system call. +-#endif /* __NR_sched_setaffinity */ +-#ifndef __NR_sched_getaffinity +-#define __NR_sched_getaffinity 5196 +-#elif __NR_sched_getaffinity != 5196 +-#error Wrong code for getaffinity system call. +-#endif /* __NR_sched_getaffinity */ ++# elif KMP_ARCH_MIPS ++# ifndef __NR_sched_setaffinity ++# define __NR_sched_setaffinity 4239 ++# elif __NR_sched_setaffinity != 4239 ++# error Wrong code for setaffinity system call. ++# endif /* __NR_sched_setaffinity */ ++# ifndef __NR_sched_getaffinity ++# define __NR_sched_getaffinity 4240 ++# elif __NR_sched_getaffinity != 4240 ++# error Wrong code for getaffinity system call. ++# endif /* __NR_sched_getaffinity */ ++# elif KMP_ARCH_MIPS64 ++# ifndef __NR_sched_setaffinity ++# define __NR_sched_setaffinity 5195 ++# elif __NR_sched_setaffinity != 5195 ++# error Wrong code for setaffinity system call. ++# endif /* __NR_sched_setaffinity */ ++# ifndef __NR_sched_getaffinity ++# define __NR_sched_getaffinity 5196 ++# elif __NR_sched_getaffinity != 5196 ++# error Wrong code for getaffinity system call. ++# endif /* __NR_sched_getaffinity */ ++# else + #error Unknown or unsupported architecture + #endif /* KMP_ARCH_* */ + class KMPNativeAffinity : public KMPAffinity { diff --git a/debian/patches/openmp-soname.diff b/debian/patches/openmp-soname.diff new file mode 100644 index 00000000..55daa855 --- /dev/null +++ b/debian/patches/openmp-soname.diff @@ -0,0 +1,14 @@ +Index: llvm-toolchain-snapshot_7~svn335949/openmp/runtime/CMakeLists.txt +=================================================================== +--- llvm-toolchain-snapshot_7~svn335949.orig/openmp/runtime/CMakeLists.txt ++++ llvm-toolchain-snapshot_7~svn335949/openmp/runtime/CMakeLists.txt +@@ -357,7 +357,8 @@ else() + set(LIBOMP_INSTALL_KIND ARCHIVE) + endif() + +-set(LIBOMP_LIB_FILE ${LIBOMP_LIB_NAME}${LIBOMP_LIBRARY_SUFFIX}) ++set(LIBOMP_LIB_FILE ${LIBOMP_LIB_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}.${LIBOMP_VERSION_MAJOR}) ++ + + # Optional backwards compatibility aliases. + set(LIBOMP_INSTALL_ALIASES TRUE CACHE BOOL diff --git a/debian/patches/series b/debian/patches/series index 6f82213f..3e90f667 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -51,3 +51,6 @@ remove-test-freezing.diff 0048-Set-html_static_path-_static-everywhere.patch 0049-Use-Debian-provided-MathJax-everywhere.patch impl-path-hurd.diff +openmp-check-execstack.diff +openmp-soname.diff +openmp-mips-affinity.patch diff --git a/debian/rules b/debian/rules index 9609d286..eee248b7 100755 --- a/debian/rules +++ b/debian/rules @@ -14,6 +14,7 @@ ifeq ($(LLVM_VERSION),$(LLVM_VERSION_FULL)) endif SONAME_EXT := 1 +SONAME_OPENMP := 5 # Manage the case when the version is 3.5~svn213052-1~exp1 or 3.4.2-1 DEBIAN_REVISION := $(shell dpkg-parsechangelog | sed -rne "s,^Version: 1:([0-9.]+)(~|-)(.*),\3,p") ifneq (,$(filter parallel=%,$(subst $(COMMA), ,$(DEB_BUILD_OPTIONS)))) @@ -176,6 +177,14 @@ ifeq (,$(filter $(DEB_HOST_ARCH_OS),linux)) LIBFUZZER_ENABLE=no endif +ifneq (,$(filter $(DEB_HOST_ARCH), mips mipsel)) + LIBOMP_ARCH = mips +endif + +ifneq (,$(filter $(DEB_HOST_ARCH), mips64 mips64el)) + LIBOMP_ARCH = mips64 +endif + %: dh $@ $(DH_OPTIONS) @@ -243,6 +252,13 @@ override_dh_auto_configure: preconfigure ln -s ../compiler-rt .; \ readlink compiler-rt + cd projects/ && \ + if test -h openmp; then \ + rm openmp; \ + fi; \ + ln -s ../openmp .; \ + readlink openmp + # Configure coverity (we need the compilers) + work around perf issues -(if test $(COVERITY_ENABLE) -eq 1; then \ export PATH=$$PATH:/opt/cov-analysis/bin/; \ @@ -351,6 +367,8 @@ build_doc: echo "Generating manpage of $$f"; \ LD_LIBRARY_PATH=$(DEB_INST)/usr/lib/llvm-$(LLVM_VERSION)/lib/:/usr/lib/*/libfakeroot help2man --no-info --version-string=$(LLVM_VERSION) $(TARGET_BUILD)/bin/$$f > debian/man/$$f-$(LLVM_VERSION).1; \ done + cd openmp/runtime && doxygen doc/doxygen/config + cd openmp/runtime/doc/doxygen/generated/html/ && rm jquery.js && ln -s /usr/share/javascript/jquery/jquery.js override_dh_auto_install: # Clean up temporary files to make sure the install works @@ -369,6 +387,12 @@ override_dh_auto_install: cd debian/tmp/usr/lib/llvm-$(LLVM_VERSION)/lib/ && rm -f libclang.so.$(SONAME_EXT) libclang-$(LLVM_VERSION).so; \ ln -s libclang-$(LLVM_VERSION).so.$(SONAME_EXT) libclang.so.$(SONAME_EXT) + cd debian/tmp/usr/lib/llvm-$(LLVM_VERSION)/lib && rm -f libomp.so; \ + ln -s libomp.so.$(SONAME_OPENMP) libomp.so + + mkdir -p debian/tmp/usr/lib/llvm-$(LLVM_VERSION)/include/openmp + cp openmp/runtime/exports/common.dia.50.ompt.optional/include/* debian/tmp/usr/lib/llvm-$(LLVM_VERSION)/include/openmp + # Remove artefact (where compiler-rt is built) # if test -d $(TARGET_BUILD)/tools/clang/runtime/compiler-rt/clang_linux; then \ # cd $(TARGET_BUILD)/tools/clang/runtime/compiler-rt/clang_linux && rm -rf $$(find . -mindepth 2 -maxdepth 2 -type d) && rm -rf $$(find -empty) && rm -rf */.dir; \ @@ -492,6 +516,7 @@ override_dh_makeshlibs: dh_makeshlibs -plibclang$(SONAME_EXT)-$(LLVM_VERSION) -V"libclang$(SONAME_EXT)-$(LLVM_VERSION) (>= 1:7~svn298832-1~)" -- -c4 dh_makeshlibs -pliblldb-$(LLVM_VERSION) -V"liblldb-$(LLVM_VERSION) (>= 1:7~svn298832-1~)" dh_makeshlibs -plibllvm$(LLVM_VERSION) -V"libllvm$(LLVM_VERSION) (>= 1:7~svn298832-1~)" + dh_makeshlibs -plibomp$(SONAME_OPENMP)-$(LLVM_VERSION) -V"libomp$(SONAME_OPENMP)-$(LLVM_VERSION)) (>= 1:7~svn298832-1~)" dh_makeshlibs --remaining-packages override_dh_shlibdeps: @@ -513,6 +538,7 @@ ifeq (0, $(strip $(shell dpkg --compare-versions $(DH_VERSION) ge 9.20160114; ec dh_strip -p libclang$(SONAME_EXT)-$(LLVM_VERSION) --dbgsym-migration='libclang$(SONAME_EXT)-$(LLVM_VERSION)-dbg (<< 1:7~svn327768-1~)' dh_strip -p libllvm$(LLVM_VERSION) --dbgsym-migration='libllvm$(LLVM_VERSION)-dbg (<< 1:7~svn327768-1~)' dh_strip -p liblldb-$(LLVM_VERSION) --dbgsym-migration='liblldb-$(LLVM_VERSION)-dbg (<< 1:7~svn327768-1~)' + dh_strip -p libomp$(SONAME_OPENMP)-$(LLVM_VERSION) --dbgsym-migration='libomp$(SONAME_OPENMP)-$(LLVM_VERSION)-dbg (<< 1:7~svn327768-1~)' endif # ifeq (${LLD_ENABLE},yes) # dh_strip -p liblld-$(LLVM_VERSION) --dbg-package=liblld-$(LLVM_VERSION)-dbg diff --git a/debian/unpack.sh b/debian/unpack.sh index 2017d3d7..4b3dd732 100644 --- a/debian/unpack.sh +++ b/debian/unpack.sh @@ -5,7 +5,7 @@ SVN_REV=`ls -1 *svn*bz2 | tail -1|perl -ne 'print "$1\n" if /svn(\d+)/;' | sort echo "Unpack of llvm" tar jxf llvm-toolchain-snapshot_$MAJOR_VERSION~svn$SVN_REV.orig.tar.bz2 cd llvm-toolchain-snapshot_$MAJOR_VERSION~svn$SVN_REV/ || ( echo "Bad SVN_REV:\"$SVN_REV\"" && exit 1 ) -for f in ../llvm-toolchain-snapshot_$MAJOR_VERSION~svn$SVN_REV.orig-clang.tar.bz2 ../llvm-toolchain-snapshot_$MAJOR_VERSION~svn$SVN_REV.orig-clang-tools-extra.tar.bz2 ../llvm-toolchain-snapshot_$MAJOR_VERSION~svn$SVN_REV.orig-compiler-rt.tar.bz2 ../llvm-toolchain-snapshot_$MAJOR_VERSION~svn$SVN_REV.orig-lld.tar.bz2 ../llvm-toolchain-snapshot_$MAJOR_VERSION~svn$SVN_REV.orig-lldb.tar.bz2 ../llvm-toolchain-snapshot_$MAJOR_VERSION~svn$SVN_REV.orig-polly.tar.bz2; do +for f in ../llvm-toolchain-snapshot_$MAJOR_VERSION~svn$SVN_REV.orig-clang.tar.bz2 ../llvm-toolchain-snapshot_$MAJOR_VERSION~svn$SVN_REV.orig-clang-tools-extra.tar.bz2 ../llvm-toolchain-snapshot_$MAJOR_VERSION~svn$SVN_REV.orig-compiler-rt.tar.bz2 ../llvm-toolchain-snapshot_$MAJOR_VERSION~svn$SVN_REV.orig-lld.tar.bz2 ../llvm-toolchain-snapshot_$MAJOR_VERSION~svn$SVN_REV.orig-lldb.tar.bz2 ../llvm-toolchain-snapshot_$MAJOR_VERSION~svn$SVN_REV.orig-polly.tar.bz2 ../llvm-toolchain-snapshot_$MAJOR_VERSION~svn$SVN_REV.orig-openmp.tar.bz2; do if test -e $f; then echo "unpack of $f" tar jxf $f @@ -17,5 +17,6 @@ ln -s compiler-rt_$MAJOR_VERSION~svn$SVN_REV compiler-rt ln -s polly_$MAJOR_VERSION~svn$SVN_REV polly ln -s lld_$MAJOR_VERSION~svn$SVN_REV lld ln -s lldb_$MAJOR_VERSION~svn$SVN_REV lldb +ln -s openmp_$MAJOR_VERSION~svn$SVN_REV openmp cp -R ../snapshot/debian . QUILT_PATCHES=debian/patches/ quilt push -a --fuzz=0