From c767e1d56ecce211063f7746acdb90cadd7bcea4 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Sun, 11 Nov 2018 20:54:42 +0100 Subject: [PATCH 01/23] add more examples --- debian/qualify-clang.sh | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/debian/qualify-clang.sh b/debian/qualify-clang.sh index 60391b6b..9a2506fc 100755 --- a/debian/qualify-clang.sh +++ b/debian/qualify-clang.sh @@ -80,7 +80,27 @@ echo '#include ' > foo.cc clang++-$VERSION -c foo.cc # Bug 913213 -echo '#include ' | clang-$VERSION -E - +echo '#include ' | clang-$VERSION -E - > /dev/null + +# Bug launchpad #1488254 +echo ' +#include +std::string hello = "Hello, world!\n"; +' > foo.cc + +echo ' +#include +#include +extern std::string hello; +int main() { + std::cout << hello; + return 0; +} ' > bar.cc + +g++ -c foo.cc && g++ foo.o bar.cc && ./a.out > /dev/null || true +clang++-$VERSION -c foo.cc && clang++-$VERSION foo.o bar.cc && ./a.out > /dev/null +g++ -c foo.cc && clang++ foo.o bar.cc && ./a.out > /dev/null || true +clang++-$VERSION -c foo.cc -fPIC && g++ foo.o bar.cc && ./a.out > /dev/null || true # bug 827866 echo 'bool testAndSet(void *atomic) { From e036ff8217eacc28731c048222b21e9c83c00099 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Sun, 11 Nov 2018 21:16:39 +0100 Subject: [PATCH 02/23] prepare the deactivation of stage2 --- debian/rules | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/debian/rules b/debian/rules index bb4e2cbd..2ba67bc5 100755 --- a/debian/rules +++ b/debian/rules @@ -4,6 +4,9 @@ TARGET_BUILD := build-llvm TARGET_BUILD_STAGE2 := $(TARGET_BUILD)/tools/clang/stage2-bins DEB_INST := $(CURDIR)/debian/tmp/ +# Disable to move the previous method +BUILD_METHOD := stage2 + GXX_VERSIONED_PACKAGE := $(shell dpkg-query -W -f '$${Depends}' g++ | grep -o 'g++-[0-9][0-9.]*' | tail -n1 ) GXX_VERSIONED_EXECUTABLE := $(shell dpkg -L $(GXX_VERSIONED_PACKAGE) | grep '/usr/bin/g++-[0-9][0-9.]*' | xargs ls -d | tail -n1 ) GCC_VERSION := $(subst /usr/bin/g++-,,$(GXX_VERSIONED_EXECUTABLE)) @@ -361,12 +364,13 @@ VERBOSE=VERBOSE=1 #VERBOSE=-v debian-full-build: - $(PRE_PROCESS) make $(NJOBS) -C $(TARGET_BUILD) $(VERBOSE) CXXFLAGS="$(CXXFLAGS_EXTRA)" LDFLAGS="$(LDFLAGS_EXTRA)" REQUIRES_RTTI=1 DEBUGMAKE=1 stage2 - + $(PRE_PROCESS) make $(NJOBS) -C $(TARGET_BUILD) $(VERBOSE) CXXFLAGS="$(CXXFLAGS_EXTRA)" LDFLAGS="$(LDFLAGS_EXTRA)" REQUIRES_RTTI=1 DEBUGMAKE=1 $(BUILD_METHOD) # Check the stage 2 build worked + if test "$(BUILD_METHOD)" = "stage2"; then \ if ! readelf --string-dump .comment $(TARGET_BUILD_STAGE2)/bin/clang 2>&1|grep -q "clang version"; then \ echo "clang hasn't been built using clang. Bye bye. Check that the stage2 build has been done."; \ + fi; \ fi touch $@ @@ -495,7 +499,11 @@ override_dh_auto_install: # Clean up temporary files to make sure the install works rm -rf $(find $(TARGET_BUILD) -wholename '*CMakeFiles*' -not -name CMakeLists.txt -a -name "*.dir" -type d) # install/fast enables a make install without recompiling temporary files - $(MAKE) -C $(TARGET_BUILD) $(VERBOSE) stage2-install DESTDIR=$(DEB_INST)/ + if test "$(BUILD_METHOD)" = "stage2"; then \ + $(MAKE) -C $(TARGET_BUILD) $(VERBOSE) stage2-install DESTDIR=$(DEB_INST)/; \ + else \ + $(MAKE) -C $(TARGET_BUILD) $(VERBOSE) install DESTDIR=$(DEB_INST)/; \ + fi # Not used on Linux. rm -f $(DEB_INST)/usr/lib/llvm-$(LLVM_VERSION)/bin/argdumper rm -f $(DEB_INST)/usr/lib/llvm-$(LLVM_VERSION)/share/clang/clang-format-bbedit.applescript From ac7fd96f9445896f7f50803dcc8a7018b0d50c09 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Sun, 11 Nov 2018 21:16:39 +0100 Subject: [PATCH 03/23] prepare the deactivation of stage2 --- debian/rules | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/debian/rules b/debian/rules index bb4e2cbd..2ba67bc5 100755 --- a/debian/rules +++ b/debian/rules @@ -4,6 +4,9 @@ TARGET_BUILD := build-llvm TARGET_BUILD_STAGE2 := $(TARGET_BUILD)/tools/clang/stage2-bins DEB_INST := $(CURDIR)/debian/tmp/ +# Disable to move the previous method +BUILD_METHOD := stage2 + GXX_VERSIONED_PACKAGE := $(shell dpkg-query -W -f '$${Depends}' g++ | grep -o 'g++-[0-9][0-9.]*' | tail -n1 ) GXX_VERSIONED_EXECUTABLE := $(shell dpkg -L $(GXX_VERSIONED_PACKAGE) | grep '/usr/bin/g++-[0-9][0-9.]*' | xargs ls -d | tail -n1 ) GCC_VERSION := $(subst /usr/bin/g++-,,$(GXX_VERSIONED_EXECUTABLE)) @@ -361,12 +364,13 @@ VERBOSE=VERBOSE=1 #VERBOSE=-v debian-full-build: - $(PRE_PROCESS) make $(NJOBS) -C $(TARGET_BUILD) $(VERBOSE) CXXFLAGS="$(CXXFLAGS_EXTRA)" LDFLAGS="$(LDFLAGS_EXTRA)" REQUIRES_RTTI=1 DEBUGMAKE=1 stage2 - + $(PRE_PROCESS) make $(NJOBS) -C $(TARGET_BUILD) $(VERBOSE) CXXFLAGS="$(CXXFLAGS_EXTRA)" LDFLAGS="$(LDFLAGS_EXTRA)" REQUIRES_RTTI=1 DEBUGMAKE=1 $(BUILD_METHOD) # Check the stage 2 build worked + if test "$(BUILD_METHOD)" = "stage2"; then \ if ! readelf --string-dump .comment $(TARGET_BUILD_STAGE2)/bin/clang 2>&1|grep -q "clang version"; then \ echo "clang hasn't been built using clang. Bye bye. Check that the stage2 build has been done."; \ + fi; \ fi touch $@ @@ -495,7 +499,11 @@ override_dh_auto_install: # Clean up temporary files to make sure the install works rm -rf $(find $(TARGET_BUILD) -wholename '*CMakeFiles*' -not -name CMakeLists.txt -a -name "*.dir" -type d) # install/fast enables a make install without recompiling temporary files - $(MAKE) -C $(TARGET_BUILD) $(VERBOSE) stage2-install DESTDIR=$(DEB_INST)/ + if test "$(BUILD_METHOD)" = "stage2"; then \ + $(MAKE) -C $(TARGET_BUILD) $(VERBOSE) stage2-install DESTDIR=$(DEB_INST)/; \ + else \ + $(MAKE) -C $(TARGET_BUILD) $(VERBOSE) install DESTDIR=$(DEB_INST)/; \ + fi # Not used on Linux. rm -f $(DEB_INST)/usr/lib/llvm-$(LLVM_VERSION)/bin/argdumper rm -f $(DEB_INST)/usr/lib/llvm-$(LLVM_VERSION)/share/clang/clang-format-bbedit.applescript From 93e8db6af012458325663bb222a0468d7de075c6 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Tue, 13 Nov 2018 12:06:46 +0100 Subject: [PATCH 04/23] working on 7.0.1 now --- debian/orig-tar.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/orig-tar.sh b/debian/orig-tar.sh index 0e2dcf3e..fa726547 100755 --- a/debian/orig-tar.sh +++ b/debian/orig-tar.sh @@ -20,7 +20,7 @@ set -e SVN_BASE_URL=http://llvm.org/svn/llvm-project/ MAJOR_VERSION=7 -CURRENT_VERSION=7 # Should be changed to 3.5.1 later +CURRENT_VERSION=7.0.1 # Should be changed to 3.5.1 later if test -n "$1"; then # http://llvm.org/svn/llvm-project/{cfe,llvm,compiler-rt,...}/branches/google/stable/ From e563ce161d65d151d463c1e647c127386f9a92c8 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Wed, 14 Nov 2018 11:51:04 +0100 Subject: [PATCH 05/23] Fix the misscompilation issue causing rustc to crash (Closes: #913271) Might cause some ABI issues but no real good solution. See https://bugs.llvm.org/show_bug.cgi?id=39427 --- debian/changelog | 3 +++ debian/patches/pr39427-misscompile.diff | 29 +++++++++++++++++++++++++ debian/patches/series | 1 + 3 files changed, 33 insertions(+) create mode 100644 debian/patches/pr39427-misscompile.diff diff --git a/debian/changelog b/debian/changelog index db86131b..26d86aaf 100644 --- a/debian/changelog +++ b/debian/changelog @@ -5,6 +5,9 @@ llvm-toolchain-7 (1:7.0.1~+rc2-3) unstable; urgency=medium * Try to integrate a pach to make pch reproducible Thanks to Rebecca Palmer for the patch (Closes: #877359) + * Fix the misscompilation issue causing rustc to crash (Closes: #913271) + Might cause some ABI issues but no real good solution. + See https://bugs.llvm.org/show_bug.cgi?id=39427 -- Sylvestre Ledru Thu, 08 Nov 2018 20:50:39 +0100 diff --git a/debian/patches/pr39427-misscompile.diff b/debian/patches/pr39427-misscompile.diff new file mode 100644 index 00000000..797e02b1 --- /dev/null +++ b/debian/patches/pr39427-misscompile.diff @@ -0,0 +1,29 @@ +Index: llvm-toolchain-7-7/include/llvm/ADT/Optional.h +=================================================================== +--- llvm-toolchain-7-7.orig/include/llvm/ADT/Optional.h ++++ llvm-toolchain-7-7/include/llvm/ADT/Optional.h +@@ -108,24 +108,6 @@ template st + } + }; + +-#if !defined(__GNUC__) || defined(__clang__) // GCC up to GCC7 miscompiles this. +-/// Storage for trivially copyable types only. +-template struct OptionalStorage { +- AlignedCharArrayUnion storage; +- bool hasVal = false; +- +- OptionalStorage() = default; +- +- OptionalStorage(const T &y) : hasVal(true) { new (storage.buffer) T(y); } +- OptionalStorage &operator=(const T &y) { +- *reinterpret_cast(storage.buffer) = y; +- hasVal = true; +- return *this; +- } +- +- void reset() { hasVal = false; } +-}; +-#endif + } // namespace optional_detail + + template class Optional { diff --git a/debian/patches/series b/debian/patches/series index fcce361e..b848aae0 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -88,3 +88,4 @@ remove-apple-clang-manpage.diff mips-rdhwr.diff clang-arm-default-vfp3-on-armv7a.patch reproducible-pch.diff +pr39427-misscompile.diff From 5e7c1dfabd3b1341d7c39d738941ce20e06cdd66 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Thu, 15 Nov 2018 14:16:02 +0100 Subject: [PATCH 06/23] add one more check --- debian/qualify-clang.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/debian/qualify-clang.sh b/debian/qualify-clang.sh index db8724b8..6c6ee3ff 100755 --- a/debian/qualify-clang.sh +++ b/debian/qualify-clang.sh @@ -22,6 +22,10 @@ if test ! -f /usr/bin/llvm-config-$VERSION; then echo "Install llvm-$VERSION & llvm-$VERSION-dev" exit 1 fi +if test ! -f /usr/lib/llvm-$VERSION/lib/libLLVM-$VERSION.so; then + echo "Install llvm-$VERSION-dev" + exit 1 +fi llvm-config-$VERSION --link-shared --libs &> /dev/null echo '#include From d6f8ecf3e0aa94386406a2c9cc5ff374301e496f Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Thu, 15 Nov 2018 14:16:18 +0100 Subject: [PATCH 07/23] remote temp files --- debian/qualify-clang.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/qualify-clang.sh b/debian/qualify-clang.sh index 6c6ee3ff..8de254d2 100755 --- a/debian/qualify-clang.sh +++ b/debian/qualify-clang.sh @@ -186,7 +186,7 @@ clang-$VERSION -fuse-ld=gold -shared -o libfoo.so bar.o # Still failing, commenting # clang-$VERSION -fuse-ld=gold -o y x.o libfoo.so -Wl,-R,. -rm -f x.c bar.c +rm -f x.c bar.c libfoo.so bar.o y x.o # test thinlto From d3d41b810378caa466181d3f1a1abe93b2a46703 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Thu, 15 Nov 2018 14:16:27 +0100 Subject: [PATCH 08/23] Add example: https://bugs.llvm.org/show_bug.cgi?id=39427 https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=913271 --- debian/qualify-clang.sh | 44 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/debian/qualify-clang.sh b/debian/qualify-clang.sh index 8de254d2..2ba570f0 100755 --- a/debian/qualify-clang.sh +++ b/debian/qualify-clang.sh @@ -312,6 +312,50 @@ echo 'int main() { ' > foo.c clang-$VERSION -g -o bar foo.c +# ABI issue between gcc & clang +# https://bugs.llvm.org/show_bug.cgi?id=39427 +# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=913271 +echo ' +#include +#include +namespace llvm { class Constant{}; class Type; class Value; } +extern llvm::Constant* bar (llvm::Type*, llvm::Constant*, llvm::ArrayRef, bool, llvm::Optional o, llvm::Type*); +#ifdef PART2 +llvm::Constant* bar (llvm::Type*, llvm::Constant*, llvm::ArrayRef, bool, llvm::Optional o, llvm::Type*) +{ + return o.hasValue()?static_cast(nullptr)+1:nullptr; +} +#endif +#ifndef PART2 +static llvm::Constant* doConstantRef(llvm::Type* type, llvm::Constant* var, llvm::ArrayRef steps) +{ + llvm::Optional inRangeIndex; + return bar(type, var, steps, false, inRangeIndex, nullptr); +} +bool foo() +{ + llvm::Constant* var = nullptr; + llvm::Value* zero = nullptr; + llvm::Value* indexes[2] = {zero, zero}; + llvm::ArrayRef steps(indexes, 2); + auto result = doConstantRef(nullptr, var, steps); + return result; +} +int main() +{ + return foo(); +} +#endif +' > foo.cpp +FLAGS="-I/usr/lib/llvm-$VERSION/include -fPIC -fvisibility-inlines-hidden -Werror=date-time -std=c++11 -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wdelete-non-virtual-dtor -Wno-comment -ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual -fno-strict-aliasing -fPIC -fvisibility-inlines-hidden -Werror=date-time -std=c++11 -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -ffunction-sections -fdata-sections -O2 -DNDEBUG -fno-exceptions -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS" + +clang++-$VERSION -c -o part1.o foo.cpp $FLAGS +if test -f /usr/bin/g++; then + g++ -c -o part2.o -DPART2 foo.cpp $FLAGS + clang++-$VERSION -o foo part1.o part2.o $FLAGS + ./foo || true +fi +rm part1.o part2.o if test ! -f /usr/lib/llvm-$VERSION/lib/libomp.so; then echo "Install libomp-$VERSION-dev"; From 4625379dd476076bd68208d6b991b358d65fe85d Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Fri, 16 Nov 2018 10:32:21 +0100 Subject: [PATCH 09/23] when the lld manpage have been moved, move it back --- debian/rules | 3 +++ 1 file changed, 3 insertions(+) diff --git a/debian/rules b/debian/rules index 2ba67bc5..a930ce9c 100755 --- a/debian/rules +++ b/debian/rules @@ -808,5 +808,8 @@ override_dh_auto_clean: rm -f $(CURDIR)/clang/tools/clang-format/clang-format-diff-$(LLVM_VERSION) rm -f $(CURDIR)/clang/tools/clang-format/clang-format-$(LLVM_VERSION).py rm -rf libcxx/build libcxxabi/build + if test -f lld/docs/ld.lld-$(LLVM_VERSION).1; then \ + mv lld/docs/ld.lld-$(LLVM_VERSION).1 lld/docs/ld.lld.1; \ + fi .PHONY: override_dh_strip preconfigure debian-full-build debian-libfuzzer-build debian-libcxx-build debian-libcxxabi-build From e1473e66f34fbf644c322cade0030753661ddb3d Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Fri, 16 Nov 2018 12:44:27 +0100 Subject: [PATCH 10/23] doesn't segfault anymore, enabling the test --- debian/qualify-clang.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/qualify-clang.sh b/debian/qualify-clang.sh index a6f4e13e..faea3118 100755 --- a/debian/qualify-clang.sh +++ b/debian/qualify-clang.sh @@ -373,7 +373,7 @@ clang++-$VERSION -c -o part1.o foo.cpp $FLAGS if test -f /usr/bin/g++; then g++ -c -o part2.o -DPART2 foo.cpp $FLAGS clang++-$VERSION -o foo part1.o part2.o $FLAGS - ./foo || true + ./foo fi rm part1.o part2.o From 34a2a44a1997b399646a5e5d8451f2588759a218 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Fri, 16 Nov 2018 12:45:18 +0100 Subject: [PATCH 11/23] use the versioned clang --- debian/qualify-clang.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/qualify-clang.sh b/debian/qualify-clang.sh index faea3118..d2d61d13 100755 --- a/debian/qualify-clang.sh +++ b/debian/qualify-clang.sh @@ -103,7 +103,7 @@ int main() { g++ -c foo.cc && g++ foo.o bar.cc && ./a.out > /dev/null || true clang++-$VERSION -c foo.cc && clang++-$VERSION foo.o bar.cc && ./a.out > /dev/null -g++ -c foo.cc && clang++ foo.o bar.cc && ./a.out > /dev/null || true +g++ -c foo.cc && clang++-$VERSION foo.o bar.cc && ./a.out > /dev/null || true clang++-$VERSION -c foo.cc -fPIC && g++ foo.o bar.cc && ./a.out > /dev/null || true # bug 827866 From 163175ca1d2464b1e6f9e5616a46356386575d81 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Fri, 16 Nov 2018 13:04:32 +0100 Subject: [PATCH 12/23] prepare a news about the bootstrap stage2 phase --- debian/NEWS | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/debian/NEWS b/debian/NEWS index 087e0b3d..edd628b7 100644 --- a/debian/NEWS +++ b/debian/NEWS @@ -1,3 +1,12 @@ +llvm-toolchain-7 (1:7.0.1-1) unstable; urgency=medium + + * llvm-toolchain packages are built using clang itself (stage2) + - stage1 = build clang with gcc + - stage2 = clang building itself + This could lead to some unexpected (but rare) ABI issues. + + -- Sylvestre Ledru Fri, 16 Nov 2018 13:00:39 +0100 + llvm-toolchain-7 (1:7-1) unstable; urgency=medium * From version 7, llvm-toolchain also provides libc++, libc++abi From 3830a1354e692d700951c40b27f6aaa4c3539898 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Fri, 16 Nov 2018 22:45:00 +0100 Subject: [PATCH 13/23] update the list of symbol for armhf --- debian/libomp5-X.Y.symbols.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/libomp5-X.Y.symbols.in b/debian/libomp5-X.Y.symbols.in index 8590dc96..8111d2f0 100644 --- a/debian/libomp5-X.Y.symbols.in +++ b/debian/libomp5-X.Y.symbols.in @@ -862,7 +862,7 @@ libomp.so.5 libomp5 #MINVER# kmp_get_stacksize_s_@VERSION 0.20130412 kmp_malloc@VERSION 0.20130412 kmp_malloc_@VERSION 0.20130412 - (arch=!mips64el)kmp_mutex_impl_info@VERSION 7 + (arch=!armhf !mips64el)kmp_mutex_impl_info@VERSION 7 kmp_realloc@VERSION 0.20130412 kmp_realloc_@VERSION 0.20130412 kmp_set_affinity@VERSION 0.20130412 From af56187b7d04d718f3f2229691885b102bb026a5 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Fri, 16 Nov 2018 22:45:51 +0100 Subject: [PATCH 14/23] workaround the build issues on armhf --- debian/rules | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/debian/rules b/debian/rules index a930ce9c..b8bdb470 100755 --- a/debian/rules +++ b/debian/rules @@ -87,6 +87,12 @@ ifneq (,$(findstring $(DEB_HOST_ARCH),armel)) CMAKE_EXTRA += -DLLVM_HOST_TRIPLE=arm-linux-gnueabi endif + +ifneq (,$(findstring $(DEB_HOST_ARCH),armhf)) +# avoid an issue with openmp on armhf + CMAKE_EXTRA += -DLLVM_HOST_TRIPLE=armv7l-unknown-linux-gnueabihf +endif + ifeq ($(shell dpkg --compare-versions $(shell dpkg-query -W -f '$${Version}' g++-$(GCC_VERSION)) ge 4.8-20121128-1~ ; echo $$?),0) control_vars = '-Vdep:devlibs=libstdc++-$(GCC_VERSION)-dev, libgcc-$(GCC_VERSION)-dev' \ '-Vdep:devlibs-objc=libobjc-$(GCC_VERSION)-dev' @@ -663,7 +669,9 @@ override_dh_shlibdeps: dh_shlibdeps -l$(DEB_INST)/usr/lib/llvm-$(LLVM_VERSION)/lib/ -Xlibclang_rt.asan -Xlibclang_rt.asan -Xlibclang_rt.asan-*.so -Xlibclang_rt.asan-*.so override_dh_installman: - mv lld/docs/ld.lld.1 lld/docs/ld.lld-$(LLVM_VERSION).1 + if test -f lld/docs/ld.lld.1; then \ + mv lld/docs/ld.lld.1 lld/docs/ld.lld-$(LLVM_VERSION).1; \ + fi dh_installman # Make sure that lli manpage is only in llvm-3.2-runtime (See #697117) rm -f $(CURDIR)/debian/llvm-$(LLVM_VERSION)/usr/share/man/man1/lli* From 250438ab06b43e8330be33192d753c0b3024ff19 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Fri, 16 Nov 2018 22:46:35 +0100 Subject: [PATCH 15/23] Workaround the build issues on armhf Thanks to Adrian Bunk for the idea --- debian/changelog | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/debian/changelog b/debian/changelog index 26d86aaf..e6f1bd41 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +llvm-toolchain-7 (1:7.0.1~+rc2-4) unstable; urgency=medium + + * Workaround the build issues on armhf + Thanks to Adrian Bunk for the idea + + -- Sylvestre Ledru Fri, 16 Nov 2018 22:46:29 +0100 + llvm-toolchain-7 (1:7.0.1~+rc2-3) unstable; urgency=medium * Disable gold for sparc* (Closes: #913260) From 63883db0f62b5d3042e185dd87bfce328a11b64e Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Sat, 17 Nov 2018 09:22:22 +0100 Subject: [PATCH 16/23] Remove useless symlink /usr/include/c++ -> ../lib/llvm-7/include/c++ (Closes: #913400) --- debian/changelog | 2 ++ debian/libc++-X.Y-dev.links.in | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index e6f1bd41..dc83a6dd 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,8 @@ llvm-toolchain-7 (1:7.0.1~+rc2-4) unstable; urgency=medium * Workaround the build issues on armhf Thanks to Adrian Bunk for the idea + * Remove useless symlink /usr/include/c++ -> ../lib/llvm-7/include/c++ + (Closes: #913400) -- Sylvestre Ledru Fri, 16 Nov 2018 22:46:29 +0100 diff --git a/debian/libc++-X.Y-dev.links.in b/debian/libc++-X.Y-dev.links.in index 4fa1b52e..73efe8f5 100644 --- a/debian/libc++-X.Y-dev.links.in +++ b/debian/libc++-X.Y-dev.links.in @@ -1,3 +1,2 @@ usr/lib/llvm-@LLVM_VERSION@/lib/libc++.so /usr/lib/x86_64-linux-gnu/libc++.so usr/lib/llvm-@LLVM_VERSION@/lib/libc++.a /usr/lib/x86_64-linux-gnu/libc++.a -usr/lib/llvm-@LLVM_VERSION@/include/c++ /usr/include/c++ From 3c22b2707eb890009a274e5b9f7b000f893114b6 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sun, 18 Nov 2018 23:48:29 +0100 Subject: [PATCH 17/23] New patches to fix hurd build. D54079-hurd-openmp.diff, D54338-hurd-libcxx-threads-build.diff, D54339-hurd-libcxx-threads-detection.diff, D54378-hurd-triple.diff, D54379-hurd-triple-clang.diff, D54677-hurd-path_max.diff, hurd-cxx-paths.diff --- debian/changelog | 9 + debian/patches/D54079-hurd-openmp.diff | 150 +++++++ .../D54338-hurd-libcxx-threads-build.diff | 24 + .../D54339-hurd-libcxx-threads-detection.diff | 18 + debian/patches/D54378-hurd-triple.diff | 74 ++++ debian/patches/D54379-hurd-triple-clang.diff | 413 ++++++++++++++++++ debian/patches/D54677-hurd-path_max.diff | 64 +++ debian/patches/hurd-cxx-paths.diff | 281 ++++++++++++ debian/patches/series | 9 + 9 files changed, 1042 insertions(+) create mode 100644 debian/patches/D54079-hurd-openmp.diff create mode 100644 debian/patches/D54338-hurd-libcxx-threads-build.diff create mode 100644 debian/patches/D54339-hurd-libcxx-threads-detection.diff create mode 100644 debian/patches/D54378-hurd-triple.diff create mode 100644 debian/patches/D54379-hurd-triple-clang.diff create mode 100644 debian/patches/D54677-hurd-path_max.diff create mode 100644 debian/patches/hurd-cxx-paths.diff diff --git a/debian/changelog b/debian/changelog index dc83a6dd..8bcfc4c7 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,12 @@ +llvm-toolchain-7 (1:7.0.1~+rc2-5) UNRELEASED; urgency=medium + + * D54079-hurd-openmp.diff, D54338-hurd-libcxx-threads-build.diff, + D54339-hurd-libcxx-threads-detection.diff, D54378-hurd-triple.diff, + D54379-hurd-triple-clang.diff, D54677-hurd-path_max.diff, + hurd-cxx-paths.diff: New patches to fix hurd build. + + -- Samuel Thibault Sun, 18 Nov 2018 23:43:55 +0100 + llvm-toolchain-7 (1:7.0.1~+rc2-4) unstable; urgency=medium * Workaround the build issues on armhf diff --git a/debian/patches/D54079-hurd-openmp.diff b/debian/patches/D54079-hurd-openmp.diff new file mode 100644 index 00000000..aa1a16df --- /dev/null +++ b/debian/patches/D54079-hurd-openmp.diff @@ -0,0 +1,150 @@ +r346310 | achurbanov | 2018-11-07 13:27:38 +0100 (Wed, 07 Nov 2018) | 6 lines + +Add Hurd support. + +Patch by samuel.thibault@ens-lyon.org + +Differential Revision: https://reviews.llvm.org/D54079 + +Index: llvm/openmp/runtime/src/kmp.h +=================================================================== +--- llvm/openmp/runtime/src/kmp.h.orig ++++ llvm/openmp/runtime/src/kmp.h +@@ -1048,6 +1048,10 @@ extern kmp_uint64 __kmp_now_nsec(); + /* TODO: tune for KMP_OS_NETBSD */ + #define KMP_INIT_WAIT 1024U /* initial number of spin-tests */ + #define KMP_NEXT_WAIT 512U /* susequent number of spin-tests */ ++#elif KMP_OS_HURD ++/* TODO: tune for KMP_OS_HURD */ ++#define KMP_INIT_WAIT 1024U /* initial number of spin-tests */ ++#define KMP_NEXT_WAIT 512U /* susequent number of spin-tests */ + #endif + + #if KMP_ARCH_X86 || KMP_ARCH_X86_64 +Index: llvm/openmp/runtime/src/kmp_ftn_entry.h +=================================================================== +--- llvm/openmp/runtime/src/kmp_ftn_entry.h.orig ++++ llvm/openmp/runtime/src/kmp_ftn_entry.h +@@ -369,7 +369,7 @@ int FTN_STDCALL KMP_EXPAND_NAME(FTN_GET_ + #else + int gtid; + +-#if KMP_OS_DARWIN || KMP_OS_FREEBSD || KMP_OS_NETBSD ++#if KMP_OS_DARWIN || KMP_OS_FREEBSD || KMP_OS_NETBSD || KMP_OS_HURD + gtid = __kmp_entry_gtid(); + #elif KMP_OS_WINDOWS + if (!__kmp_init_parallel || +Index: llvm/openmp/runtime/src/kmp_platform.h +=================================================================== +--- llvm/openmp/runtime/src/kmp_platform.h.orig ++++ llvm/openmp/runtime/src/kmp_platform.h +@@ -22,6 +22,7 @@ + #define KMP_OS_DARWIN 0 + #define KMP_OS_WINDOWS 0 + #define KMP_OS_CNK 0 ++#define KMP_OS_HURD 0 + #define KMP_OS_UNIX 0 /* disjunction of KMP_OS_LINUX, KMP_OS_DARWIN etc. */ + + #ifdef _WIN32 +@@ -59,13 +60,18 @@ + #define KMP_OS_CNK 1 + #endif + ++#if (defined __GNU__) ++#undef KMP_OS_HURD ++#define KMP_OS_HURD 1 ++#endif ++ + #if (1 != \ + KMP_OS_LINUX + KMP_OS_FREEBSD + KMP_OS_NETBSD + KMP_OS_DARWIN + \ +- KMP_OS_WINDOWS) ++ KMP_OS_WINDOWS + KMP_OS_HURD) + #error Unknown OS + #endif + +-#if KMP_OS_LINUX || KMP_OS_FREEBSD || KMP_OS_NETBSD || KMP_OS_DARWIN ++#if KMP_OS_LINUX || KMP_OS_FREEBSD || KMP_OS_NETBSD || KMP_OS_DARWIN || KMP_OS_HURD + #undef KMP_OS_UNIX + #define KMP_OS_UNIX 1 + #endif +Index: llvm/openmp/runtime/src/kmp_runtime.cpp +=================================================================== +--- llvm/openmp/runtime/src/kmp_runtime.cpp.orig ++++ llvm/openmp/runtime/src/kmp_runtime.cpp +@@ -7643,7 +7643,7 @@ __kmp_determine_reduction_method( + #if KMP_ARCH_X86_64 || KMP_ARCH_PPC64 || KMP_ARCH_AARCH64 || KMP_ARCH_MIPS64 + + #if KMP_OS_LINUX || KMP_OS_FREEBSD || KMP_OS_NETBSD || KMP_OS_WINDOWS || \ +- KMP_OS_DARWIN ++ KMP_OS_DARWIN || KMP_OS_HURD + + int teamsize_cutoff = 4; + +@@ -7670,7 +7670,7 @@ __kmp_determine_reduction_method( + + #elif KMP_ARCH_X86 || KMP_ARCH_ARM || KMP_ARCH_AARCH || KMP_ARCH_MIPS + +-#if KMP_OS_LINUX || KMP_OS_WINDOWS ++#if KMP_OS_LINUX || KMP_OS_WINDOWS || KMP_OS_HURD + + // basic tuning + +Index: llvm/openmp/runtime/src/thirdparty/ittnotify/ittnotify_static.c +=================================================================== +--- llvm/openmp/runtime/src/thirdparty/ittnotify/ittnotify_static.c.orig ++++ llvm/openmp/runtime/src/thirdparty/ittnotify/ittnotify_static.c +@@ -70,6 +70,10 @@ static const char* ittnotify_lib_name = + #define ANDROID_ITTNOTIFY_DEFAULT_PATH "/data/data/com.intel.vtune/intel/libittnotify.so" + #endif + ++#ifndef PATH_MAX ++#define PATH_MAX 4096 ++#endif ++ + + #ifndef LIB_VAR_NAME + #if ITT_ARCH==ITT_ARCH_IA32 || ITT_ARCH==ITT_ARCH_ARM || ITT_ARCH==ITT_ARCH_MIPS +Index: llvm/openmp/runtime/src/z_Linux_util.cpp +=================================================================== +--- llvm/openmp/runtime/src/z_Linux_util.cpp.orig ++++ llvm/openmp/runtime/src/z_Linux_util.cpp +@@ -444,8 +444,7 @@ void __kmp_terminate_thread(int gtid) { + determined exactly, FALSE if incremental refinement is necessary. */ + static kmp_int32 __kmp_set_stack_info(int gtid, kmp_info_t *th) { + int stack_data; +-#if KMP_OS_LINUX || KMP_OS_FREEBSD || KMP_OS_NETBSD +- /* Linux* OS only -- no pthread_getattr_np support on OS X* */ ++#if KMP_OS_LINUX || KMP_OS_FREEBSD || KMP_OS_NETBSD || KMP_OS_HURD + pthread_attr_t attr; + int status; + size_t size = 0; +@@ -497,7 +496,7 @@ static void *__kmp_launch_worker(void *t + sigset_t new_set, old_set; + #endif /* KMP_BLOCK_SIGNALS */ + void *exit_val; +-#if KMP_OS_LINUX || KMP_OS_FREEBSD || KMP_OS_NETBSD ++#if KMP_OS_LINUX || KMP_OS_FREEBSD || KMP_OS_NETBSD || KMP_OS_HURD + void *volatile padding = 0; + #endif + int gtid; +@@ -1765,7 +1764,7 @@ static int __kmp_get_xproc(void) { + + int r = 0; + +-#if KMP_OS_LINUX || KMP_OS_FREEBSD || KMP_OS_NETBSD ++#if KMP_OS_LINUX || KMP_OS_FREEBSD || KMP_OS_NETBSD || KMP_OS_HURD + + r = sysconf(_SC_NPROCESSORS_ONLN); + +@@ -1953,9 +1952,9 @@ int __kmp_is_address_mapped(void *addr) + int found = 0; + int rc; + +-#if KMP_OS_LINUX || KMP_OS_FREEBSD ++#if KMP_OS_LINUX || KMP_OS_FREEBSD || KMP_OS_HURD + +- /* On Linux* OS, read the /proc//maps pseudo-file to get all the address ++ /* On GNUish OSes, read the /proc//maps pseudo-file to get all the address + ranges mapped into the address space. */ + + char *name = __kmp_str_format("/proc/%d/maps", getpid()); diff --git a/debian/patches/D54338-hurd-libcxx-threads-build.diff b/debian/patches/D54338-hurd-libcxx-threads-build.diff new file mode 100644 index 00000000..55e5472e --- /dev/null +++ b/debian/patches/D54338-hurd-libcxx-threads-build.diff @@ -0,0 +1,24 @@ +r346763 | ldionne | 2018-11-13 18:00:04 +0100 (Tue, 13 Nov 2018) | 5 lines + +[libcxx] GNU/Hurd uses BSD-based interfaces, but does not (and won't) provide + +Reviewed as https://reviews.llvm.org/D54338. + +Thanks to sthibaul for the patch. + +Index: llvm-toolchain-7-7/libcxx/src/thread.cpp +=================================================================== +--- llvm-toolchain-7-7.orig/libcxx/src/thread.cpp ++++ llvm-toolchain-7-7/libcxx/src/thread.cpp +@@ -19,9 +19,9 @@ + + #if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) + # include +-# if defined(BSD) ++# if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) || defined(__APPLE__) + # include +-# endif // defined(BSD) ++# endif + #endif // defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) + + #if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) || defined(__CloudABI__) || defined(__Fuchsia__) diff --git a/debian/patches/D54339-hurd-libcxx-threads-detection.diff b/debian/patches/D54339-hurd-libcxx-threads-detection.diff new file mode 100644 index 00000000..dac013bd --- /dev/null +++ b/debian/patches/D54339-hurd-libcxx-threads-detection.diff @@ -0,0 +1,18 @@ +Fix threads detection on GNU/Hurd + +GNU/Hurd provides standard Posix threads + +https://reviews.llvm.org/D54339 + +Index: llvm-toolchain-7-7/libcxx/include/__config +=================================================================== +--- llvm-toolchain-7-7.orig/libcxx/include/__config ++++ llvm-toolchain-7-7/libcxx/include/__config +@@ -1110,6 +1110,7 @@ _LIBCPP_FUNC_VIS extern "C" void __sanit + defined(__Fuchsia__) || \ + defined(__NetBSD__) || \ + defined(__linux__) || \ ++ defined(__GNU__) || \ + defined(__APPLE__) || \ + defined(__CloudABI__) || \ + defined(__sun__) || \ diff --git a/debian/patches/D54378-hurd-triple.diff b/debian/patches/D54378-hurd-triple.diff new file mode 100644 index 00000000..2f57a2a1 --- /dev/null +++ b/debian/patches/D54378-hurd-triple.diff @@ -0,0 +1,74 @@ +Add Hurd triplet to LLVMSupport + +This introduces GNU Hurd as a new target OS. + +https://reviews.llvm.org/D54378 + +Index: llvm-toolchain-7-7.0.1~+rc2/include/llvm/ADT/Triple.h +=================================================================== +--- llvm-toolchain-7-7.0.1~+rc2.orig/include/llvm/ADT/Triple.h ++++ llvm-toolchain-7-7.0.1~+rc2/include/llvm/ADT/Triple.h +@@ -182,7 +182,8 @@ public: + Mesa3D, + Contiki, + AMDPAL, // AMD PAL Runtime +- LastOSType = AMDPAL ++ Hurd, // GNU/Hurd ++ LastOSType = Hurd + }; + enum EnvironmentType { + UnknownEnvironment, +@@ -578,9 +579,15 @@ public: + return getOS() == Triple::KFreeBSD; + } + ++ /// Tests whether the OS is Hurd. ++ bool isOSHurd() const { ++ return getOS() == Triple::Hurd; ++ } ++ + /// Tests whether the OS uses glibc. + bool isOSGlibc() const { +- return (getOS() == Triple::Linux || getOS() == Triple::KFreeBSD) && ++ return (getOS() == Triple::Linux || getOS() == Triple::KFreeBSD || ++ getOS() == Triple::Hurd) && + !isAndroid(); + } + +Index: llvm-toolchain-7-7.0.1~+rc2/lib/Support/Triple.cpp +=================================================================== +--- llvm-toolchain-7-7.0.1~+rc2.orig/lib/Support/Triple.cpp ++++ llvm-toolchain-7-7.0.1~+rc2/lib/Support/Triple.cpp +@@ -209,6 +209,7 @@ StringRef Triple::getOSTypeName(OSType K + case Mesa3D: return "mesa3d"; + case Contiki: return "contiki"; + case AMDPAL: return "amdpal"; ++ case Hurd: return "hurd"; + } + + llvm_unreachable("Invalid OSType"); +@@ -502,6 +503,7 @@ static Triple::OSType parseOS(StringRef + .StartsWith("mesa3d", Triple::Mesa3D) + .StartsWith("contiki", Triple::Contiki) + .StartsWith("amdpal", Triple::AMDPAL) ++ .StartsWith("hurd", Triple::Hurd) + .Default(Triple::UnknownOS); + } + +Index: llvm/unittests/ADT/TripleTest.cpp +=================================================================== +--- llvm/unittests/ADT/TripleTest.cpp (révision 346226) ++++ llvm/unittests/ADT/TripleTest.cpp (copie de travail) +@@ -93,6 +93,12 @@ + EXPECT_EQ(Triple::Contiki, T.getOS()); + EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment()); + ++ T = Triple("i386-pc-hurd-gnu"); ++ EXPECT_EQ(Triple::x86, T.getArch()); ++ EXPECT_EQ(Triple::PC, T.getVendor()); ++ EXPECT_EQ(Triple::Hurd, T.getOS()); ++ EXPECT_EQ(Triple::GNU, T.getEnvironment()); ++ + T = Triple("x86_64-pc-linux-gnu"); + EXPECT_EQ(Triple::x86_64, T.getArch()); + EXPECT_EQ(Triple::PC, T.getVendor()); diff --git a/debian/patches/D54379-hurd-triple-clang.diff b/debian/patches/D54379-hurd-triple-clang.diff new file mode 100644 index 00000000..c55fc548 --- /dev/null +++ b/debian/patches/D54379-hurd-triple-clang.diff @@ -0,0 +1,413 @@ +Add Hurd toolchain support to Clang + +https://reviews.llvm.org/D54379 + +Index: llvm-toolchain-7-7.0.1~+rc2/clang/lib/Basic/Targets/OSTargets.h +=================================================================== +--- llvm-toolchain-7-7.0.1~+rc2.orig/clang/lib/Basic/Targets/OSTargets.h ++++ llvm-toolchain-7-7.0.1~+rc2/clang/lib/Basic/Targets/OSTargets.h +@@ -270,6 +270,29 @@ public: + } + }; + ++// Hurd target ++template ++class LLVM_LIBRARY_VISIBILITY HurdTargetInfo : public OSTargetInfo { ++protected: ++ void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple, ++ MacroBuilder &Builder) const override { ++ // Linux defines; list based off of gcc output ++ DefineStd(Builder, "unix", Opts); ++ Builder.defineMacro("__GNU__"); ++ Builder.defineMacro("__gnu_hurd__"); ++ Builder.defineMacro("__MACH__"); ++ Builder.defineMacro("__GLIBC__"); ++ Builder.defineMacro("__ELF__"); ++ if (Opts.POSIXThreads) ++ Builder.defineMacro("_REENTRANT"); ++ if (Opts.CPlusPlus) ++ Builder.defineMacro("_GNU_SOURCE"); ++ } ++public: ++ HurdTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) ++ : OSTargetInfo(Triple, Opts) {} ++}; ++ + // Minix Target + template + class LLVM_LIBRARY_VISIBILITY MinixTargetInfo : public OSTargetInfo { +Index: llvm-toolchain-7-7.0.1~+rc2/clang/lib/Basic/Targets.cpp +=================================================================== +--- llvm-toolchain-7-7.0.1~+rc2.orig/clang/lib/Basic/Targets.cpp ++++ llvm-toolchain-7-7.0.1~+rc2/clang/lib/Basic/Targets.cpp +@@ -495,6 +495,8 @@ TargetInfo *AllocateTarget(const llvm::T + return new NaClTargetInfo(Triple, Opts); + case llvm::Triple::ELFIAMCU: + return new MCUX86_32TargetInfo(Triple, Opts); ++ case llvm::Triple::Hurd: ++ return new HurdTargetInfo(Triple, Opts); + default: + return new X86_32TargetInfo(Triple, Opts); + } +Index: llvm-toolchain-7-7.0.1~+rc2/clang/lib/Driver/CMakeLists.txt +=================================================================== +--- llvm-toolchain-7-7.0.1~+rc2.orig/clang/lib/Driver/CMakeLists.txt ++++ llvm-toolchain-7-7.0.1~+rc2/clang/lib/Driver/CMakeLists.txt +@@ -47,6 +47,7 @@ add_clang_library(clangDriver + ToolChains/Haiku.cpp + ToolChains/HIP.cpp + ToolChains/Hexagon.cpp ++ ToolChains/Hurd.cpp + ToolChains/Linux.cpp + ToolChains/MipsLinux.cpp + ToolChains/MinGW.cpp +Index: llvm-toolchain-7-7.0.1~+rc2/clang/lib/Driver/Driver.cpp +=================================================================== +--- llvm-toolchain-7-7.0.1~+rc2.orig/clang/lib/Driver/Driver.cpp ++++ llvm-toolchain-7-7.0.1~+rc2/clang/lib/Driver/Driver.cpp +@@ -26,6 +26,7 @@ + #include "ToolChains/HIP.h" + #include "ToolChains/Haiku.h" + #include "ToolChains/Hexagon.h" ++#include "ToolChains/Hurd.h" + #include "ToolChains/Lanai.h" + #include "ToolChains/Linux.h" + #include "ToolChains/MSVC.h" +@@ -399,6 +400,13 @@ static llvm::Triple computeTargetTriple( + + llvm::Triple Target(llvm::Triple::normalize(TargetTriple)); + ++ // GNU/Hurd's triple should have been -hurd-gnu*, but was historically made ++ // -gnu* only, and we can not change this, so we have to detect that case as ++ // being the Hurd OS. ++ if (TargetTriple.find("-unknown-gnu") != StringRef::npos || ++ TargetTriple.find("-pc-gnu") != StringRef::npos) ++ Target.setOSName("hurd"); ++ + // Handle Apple-specific options available here. + if (Target.isOSBinFormatMachO()) { + // If an explicit Darwin arch name is given, that trumps all. +@@ -4374,6 +4382,9 @@ const ToolChain &Driver::getToolChain(co + case llvm::Triple::Contiki: + TC = llvm::make_unique(*this, Target, Args); + break; ++ case llvm::Triple::Hurd: ++ TC = llvm::make_unique(*this, Target, Args); ++ break; + default: + // Of these targets, Hexagon is the only one that might have + // an OS of Linux, in which case it got handled above already. +Index: llvm-toolchain-7-7.0.1~+rc2/clang/lib/Driver/ToolChains/Clang.cpp +=================================================================== +--- llvm-toolchain-7-7.0.1~+rc2.orig/clang/lib/Driver/ToolChains/Clang.cpp ++++ llvm-toolchain-7-7.0.1~+rc2/clang/lib/Driver/ToolChains/Clang.cpp +@@ -528,7 +528,7 @@ static bool useFramePointerForTargetByDe + return !areOptimizationsEnabled(Args); + } + +- if (Triple.isOSLinux() || Triple.getOS() == llvm::Triple::CloudABI) { ++ if (Triple.isOSLinux() || Triple.getOS() == llvm::Triple::CloudABI || Triple.isOSHurd()) { + switch (Triple.getArch()) { + // Don't use a frame pointer on linux if optimizing for certain targets. + case llvm::Triple::mips64: +Index: llvm-toolchain-7-7.0.1~+rc2/clang/lib/Driver/ToolChains/Gnu.cpp +=================================================================== +--- llvm-toolchain-7-7.0.1~+rc2.orig/clang/lib/Driver/ToolChains/Gnu.cpp ++++ llvm-toolchain-7-7.0.1~+rc2/clang/lib/Driver/ToolChains/Gnu.cpp +@@ -1846,7 +1846,9 @@ void Generic_GCC::GCCInstallationDetecto + "i686-linux-gnu", "i686-pc-linux-gnu", "i486-linux-gnu", + "i386-linux-gnu", "i386-redhat-linux6E", "i686-redhat-linux", + "i586-redhat-linux", "i386-redhat-linux", "i586-suse-linux", +- "i486-slackware-linux", "i686-montavista-linux", "i586-linux-gnu"}; ++ "i486-slackware-linux", "i686-montavista-linux", "i586-linux-gnu", ++ "i386-gnu", "i486-gnu", "i586-gnu", ++ "i686-gnu"}; + + static const char *const MIPSLibDirs[] = {"/lib"}; + static const char *const MIPSTriples[] = {"mips-linux-gnu", "mips-mti-linux", +@@ -2210,6 +2212,9 @@ void Generic_GCC::GCCInstallationDetecto + // triple. + {"i386-linux-gnu/gcc/" + CandidateTriple.str(), "../../..", + (TargetArch == llvm::Triple::x86 && ++ TargetTriple.getOS() != llvm::Triple::Solaris)}, ++ {"i386-gnu/gcc/" + CandidateTriple.str(), "../../..", ++ (TargetArch == llvm::Triple::x86 && + TargetTriple.getOS() != llvm::Triple::Solaris)}}; + + for (auto &Suffix : Suffixes) { +Index: llvm-toolchain-7-7.0.1~+rc2/clang/lib/Driver/ToolChains/Hurd.cpp +=================================================================== +--- /dev/null ++++ llvm-toolchain-7-7.0.1~+rc2/clang/lib/Driver/ToolChains/Hurd.cpp +@@ -0,0 +1,191 @@ ++//===--- Hurd.cpp - Hurd ToolChain Implementations --------*- C++ -*-===// ++// ++// The LLVM Compiler Infrastructure ++// ++// This file is distributed under the University of Illinois Open Source ++// License. See LICENSE.TXT for details. ++// ++//===----------------------------------------------------------------------===// ++ ++#include "Hurd.h" ++#include "CommonArgs.h" ++#include "clang/Basic/VirtualFileSystem.h" ++#include "clang/Config/config.h" ++#include "clang/Driver/Driver.h" ++#include "clang/Driver/Options.h" ++#include "llvm/Support/Path.h" ++ ++using namespace clang::driver; ++using namespace clang::driver::toolchains; ++using namespace clang; ++using namespace llvm::opt; ++ ++using tools::addPathIfExists; ++ ++/// Get our best guess at the multiarch triple for a target. ++/// ++/// Debian-based systems are starting to use a multiarch setup where they use ++/// a target-triple directory in the library and header search paths. ++/// Unfortunately, this triple does not align with the vanilla target triple, ++/// so we provide a rough mapping here. ++static std::string getMultiarchTriple(const Driver &D, ++ const llvm::Triple &TargetTriple, ++ StringRef SysRoot) { ++ // For most architectures, just use whatever we have rather than trying to be ++ // clever. ++ switch (TargetTriple.getArch()) { ++ default: ++ break; ++ ++ // We use the existence of '/lib/' as a directory to detect some ++ // common hurd triples that don't quite match the Clang triple for both ++ // 32-bit and 64-bit targets. Multiarch fixes its install triples to these ++ // regardless of what the actual target triple is. ++ case llvm::Triple::x86: ++ if (D.getVFS().exists(SysRoot + "/lib/i386-gnu")) ++ return "i386-gnu"; ++ break; ++ } ++ ++ return TargetTriple.str(); ++} ++ ++static StringRef getOSLibDir(const llvm::Triple &Triple, const ArgList &Args) { ++ // It happens that only x86 and PPC use the 'lib32' variant of oslibdir, and ++ // using that variant while targeting other architectures causes problems ++ // because the libraries are laid out in shared system roots that can't cope ++ // with a 'lib32' library search path being considered. So we only enable ++ // them when we know we may need it. ++ // ++ // FIXME: This is a bit of a hack. We should really unify this code for ++ // reasoning about oslibdir spellings with the lib dir spellings in the ++ // GCCInstallationDetector, but that is a more significant refactoring. ++ ++ if (Triple.getArch() == llvm::Triple::x86) ++ return "lib32"; ++ ++ return Triple.isArch32Bit() ? "lib" : "lib64"; ++} ++ ++Hurd::Hurd(const Driver &D, const llvm::Triple &Triple, ++ const ArgList &Args) ++ : Generic_ELF(D, Triple, Args) { ++ std::string SysRoot = computeSysRoot(); ++ path_list &Paths = getFilePaths(); ++ ++ const std::string OSLibDir = getOSLibDir(Triple, Args); ++ const std::string MultiarchTriple = getMultiarchTriple(D, Triple, SysRoot); ++ ++ // Similar to the logic for GCC above, if we currently running Clang inside ++ // of the requested system root, add its parent library paths to ++ // those searched. ++ // FIXME: It's not clear whether we should use the driver's installed ++ // directory ('Dir' below) or the ResourceDir. ++ if (StringRef(D.Dir).startswith(SysRoot)) { ++ addPathIfExists(D, D.Dir + "/../lib/" + MultiarchTriple, Paths); ++ addPathIfExists(D, D.Dir + "/../" + OSLibDir, Paths); ++ } ++ ++ addPathIfExists(D, SysRoot + "/lib/" + MultiarchTriple, Paths); ++ addPathIfExists(D, SysRoot + "/lib/../" + OSLibDir, Paths); ++ ++ addPathIfExists(D, SysRoot + "/usr/lib/" + MultiarchTriple, Paths); ++ addPathIfExists(D, SysRoot + "/usr/lib/../" + OSLibDir, Paths); ++ ++ // If we are currently running Clang inside of the requested system root, add ++ // its parent library path to those searched. ++ // FIXME: It's not clear whether we should use the driver's installed ++ // directory ('Dir' below) or the ResourceDir. ++ if (StringRef(D.Dir).startswith(SysRoot)) ++ addPathIfExists(D, D.Dir + "/../lib", Paths); ++ ++ addPathIfExists(D, SysRoot + "/lib", Paths); ++ addPathIfExists(D, SysRoot + "/usr/lib", Paths); ++} ++ ++bool Hurd::HasNativeLLVMSupport() const { return true; } ++ ++Tool *Hurd::buildLinker() const { return new tools::gnutools::Linker(*this); } ++ ++Tool *Hurd::buildAssembler() const { ++ return new tools::gnutools::Assembler(*this); ++} ++ ++std::string Hurd::computeSysRoot() const { ++ if (!getDriver().SysRoot.empty()) ++ return getDriver().SysRoot; ++ ++ return std::string(); ++} ++ ++std::string Hurd::getDynamicLinker(const ArgList &Args) const { ++ const llvm::Triple::ArchType Arch = getArch(); ++ ++ if (Arch == llvm::Triple::x86) ++ return "/lib/ld.so"; ++ ++ llvm_unreachable("unsupported architecture"); ++} ++ ++void Hurd::AddClangSystemIncludeArgs(const ArgList &DriverArgs, ++ ArgStringList &CC1Args) const { ++ const Driver &D = getDriver(); ++ std::string SysRoot = computeSysRoot(); ++ ++ if (DriverArgs.hasArg(clang::driver::options::OPT_nostdinc)) ++ return; ++ ++ if (!DriverArgs.hasArg(options::OPT_nostdlibinc)) ++ addSystemInclude(DriverArgs, CC1Args, SysRoot + "/usr/local/include"); ++ ++ if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) { ++ SmallString<128> P(D.ResourceDir); ++ llvm::sys::path::append(P, "include"); ++ addSystemInclude(DriverArgs, CC1Args, P); ++ } ++ ++ if (DriverArgs.hasArg(options::OPT_nostdlibinc)) ++ return; ++ ++ // Check for configure-time C include directories. ++ StringRef CIncludeDirs(C_INCLUDE_DIRS); ++ if (CIncludeDirs != "") { ++ SmallVector dirs; ++ CIncludeDirs.split(dirs, ":"); ++ for (StringRef dir : dirs) { ++ StringRef Prefix = ++ llvm::sys::path::is_absolute(dir) ? StringRef(SysRoot) : ""; ++ addExternCSystemInclude(DriverArgs, CC1Args, Prefix + dir); ++ } ++ return; ++ } ++ ++ // Lacking those, try to detect the correct set of system includes for the ++ // target triple. ++ ++ const StringRef X86MultiarchIncludeDirs[] = { ++ "/usr/include/i386-gnu"}; ++ ++ ArrayRef MultiarchIncludeDirs; ++ switch (getTriple().getArch()) { ++ case llvm::Triple::x86: ++ MultiarchIncludeDirs = X86MultiarchIncludeDirs; ++ break; ++ default: ++ break; ++ } ++ ++ for (StringRef Dir : MultiarchIncludeDirs) { ++ if (D.getVFS().exists(SysRoot + Dir)) { ++ addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + Dir); ++ break; ++ } ++ } ++ ++ // Add an include of '/include' directly. This isn't provided by default by ++ // system GCCs, but is often used with cross-compiling GCCs, and harmless to ++ // add even when Clang is acting as-if it were a system compiler. ++ addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/include"); ++ ++ addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/usr/include"); ++} +Index: llvm-toolchain-7-7.0.1~+rc2/clang/lib/Driver/ToolChains/Hurd.h +=================================================================== +--- /dev/null ++++ llvm-toolchain-7-7.0.1~+rc2/clang/lib/Driver/ToolChains/Hurd.h +@@ -0,0 +1,46 @@ ++//===--- Hurd.h - Hurd ToolChain Implementations ----------*- C++ -*-===// ++// ++// The LLVM Compiler Infrastructure ++// ++// This file is distributed under the University of Illinois Open Source ++// License. See LICENSE.TXT for details. ++// ++//===----------------------------------------------------------------------===// ++ ++#ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_Hurd_H ++#define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_Hurd_H ++ ++#include "Gnu.h" ++#include "clang/Driver/ToolChain.h" ++ ++namespace clang { ++namespace driver { ++namespace toolchains { ++ ++class LLVM_LIBRARY_VISIBILITY Hurd : public Generic_ELF { ++public: ++ Hurd(const Driver &D, const llvm::Triple &Triple, ++ const llvm::opt::ArgList &Args); ++ ++ bool HasNativeLLVMSupport() const override; ++ ++ void ++ AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs, ++ llvm::opt::ArgStringList &CC1Args) const override; ++ ++ virtual std::string computeSysRoot() const; ++ ++ virtual std::string getDynamicLinker(const llvm::opt::ArgList &Args) const; ++ ++ std::vector ExtraOpts; ++ ++protected: ++ Tool *buildAssembler() const override; ++ Tool *buildLinker() const override; ++}; ++ ++} // end namespace toolchains ++} // end namespace driver ++} // end namespace clang ++ ++#endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_Hurd_H +Index: llvm-toolchain-7-7.0.1~+rc2/clang/lib/Frontend/InitHeaderSearch.cpp +=================================================================== +--- llvm-toolchain-7-7.0.1~+rc2.orig/clang/lib/Frontend/InitHeaderSearch.cpp ++++ llvm-toolchain-7-7.0.1~+rc2/clang/lib/Frontend/InitHeaderSearch.cpp +@@ -260,6 +260,7 @@ void InitHeaderSearch::AddDefaultCInclud + + switch (os) { + case llvm::Triple::Linux: ++ case llvm::Triple::Hurd: + case llvm::Triple::Solaris: + llvm_unreachable("Include management is handled in the driver."); + +@@ -412,6 +413,7 @@ + + switch (os) { + case llvm::Triple::Linux: ++ case llvm::Triple::Hurd: + case llvm::Triple::Solaris: + llvm_unreachable("Include management is handled in the driver."); + break; +@@ -460,6 +462,7 @@ + break; // Everything else continues to use this routine's logic. + + case llvm::Triple::Linux: ++ case llvm::Triple::Hurd: + case llvm::Triple::Solaris: + return; + + diff --git a/debian/patches/D54677-hurd-path_max.diff b/debian/patches/D54677-hurd-path_max.diff new file mode 100644 index 00000000..12b09168 --- /dev/null +++ b/debian/patches/D54677-hurd-path_max.diff @@ -0,0 +1,64 @@ +[hurd] Fix unconditional use of PATH_MAX + +The GNU/Hurd system does not define an arbitrary PATH_MAX limitation, the POSIX 2001 realpath extension can be used instead, and the size of symlinks can be determined. + +https://reviews.llvm.org/D54677 + +Index: llvm/libcxx/src/filesystem/operations.cpp +=================================================================== +--- llvm/libcxx/src/filesystem/operations.cpp (révision 347139) ++++ llvm/libcxx/src/filesystem/operations.cpp (copie de travail) +@@ -530,11 +530,20 @@ + ErrorHandler err("canonical", ec, &orig_p, &cwd); + + path p = __do_absolute(orig_p, &cwd, ec); ++#if _POSIX_VERSION >= 200112 || defined(__GLIBC__) ++ char *buff; ++ if ((buff = ::realpath(p.c_str(), NULL)) == nullptr) ++ return err.report(capture_errno()); ++ path ret = {buff}; ++ free(buff); ++ return ret; ++#else + char buff[PATH_MAX + 1]; + char* ret; + if ((ret = ::realpath(p.c_str(), buff)) == nullptr) + return err.report(capture_errno()); + return {ret}; ++#endif + } + + void __copy(const path& from, const path& to, copy_options options, +@@ -1076,16 +1085,27 @@ + path __read_symlink(const path& p, error_code* ec) { + ErrorHandler err("read_symlink", ec, &p); + +- char buff[PATH_MAX + 1]; +- error_code m_ec; ++ struct stat sb; ++ if (lstat(p.c_str(), &sb) == -1) { ++ return err.report(capture_errno()); ++ } ++ size_t size = sb.st_size + 1; ++ char *buff = (char*) malloc(size); ++ if (buff == NULL) { ++ return err.report(capture_errno()); ++ } ++ + ::ssize_t ret; +- if ((ret = ::readlink(p.c_str(), buff, PATH_MAX)) == -1) { ++ if ((ret = ::readlink(p.c_str(), buff, size)) == -1) { ++ free(buff); + return err.report(capture_errno()); + } +- _LIBCPP_ASSERT(ret <= PATH_MAX, "TODO"); ++ _LIBCPP_ASSERT(ret < size, "TODO"); + _LIBCPP_ASSERT(ret > 0, "TODO"); + buff[ret] = 0; +- return {buff}; ++ path res = {buff}; ++ free(buff); ++ return res; + } + + bool __remove(const path& p, error_code* ec) { diff --git a/debian/patches/hurd-cxx-paths.diff b/debian/patches/hurd-cxx-paths.diff new file mode 100644 index 00000000..316e9ee2 --- /dev/null +++ b/debian/patches/hurd-cxx-paths.diff @@ -0,0 +1,281 @@ +This should be factorized with Linux.cpp and the GNU/kFreeBSD case. + +Index: llvm-toolchain-7-7.0.1~+rc2/clang/lib/Driver/ToolChains/Hurd.cpp +=================================================================== +--- llvm-toolchain-7-7.0.1~+rc2.orig/clang/lib/Driver/ToolChains/Hurd.cpp ++++ llvm-toolchain-7-7.0.1~+rc2/clang/lib/Driver/ToolChains/Hurd.cpp +@@ -67,15 +67,102 @@ static StringRef getOSLibDir(const llvm: + return Triple.isArch32Bit() ? "lib" : "lib64"; + } + ++static void addMultilibsFilePaths(const Driver &D, const MultilibSet &Multilibs, ++ const Multilib &Multilib, ++ StringRef InstallPath, ++ ToolChain::path_list &Paths) { ++ if (const auto &PathsCallback = Multilibs.filePathsCallback()) ++ for (const auto &Path : PathsCallback(Multilib)) ++ addPathIfExists(D, InstallPath + Path, Paths); ++} ++ + Hurd::Hurd(const Driver &D, const llvm::Triple &Triple, + const ArgList &Args) + : Generic_ELF(D, Triple, Args) { ++ GCCInstallation.init(Triple, Args); ++ Multilibs = GCCInstallation.getMultilibs(); + std::string SysRoot = computeSysRoot(); ++ ++ // Cross-compiling binutils and GCC installations (vanilla and openSUSE at ++ // least) put various tools in a triple-prefixed directory off of the parent ++ // of the GCC installation. We use the GCC triple here to ensure that we end ++ // up with tools that support the same amount of cross compiling as the ++ // detected GCC installation. For example, if we find a GCC installation ++ // targeting x86_64, but it is a bi-arch GCC installation, it can also be ++ // used to target i386. ++ // FIXME: This seems unlikely to be Linux- or Hurd-specific. ++ ToolChain::path_list &PPaths = getProgramPaths(); ++ PPaths.push_back(Twine(GCCInstallation.getParentLibPath() + "/../" + ++ GCCInstallation.getTriple().str() + "/bin") ++ .str()); ++ ++#ifdef ENABLE_LINKER_BUILD_ID ++ ExtraOpts.push_back("--build-id"); ++#endif ++ ++ // The selection of paths to try here is designed to match the patterns which ++ // the GCC driver itself uses, as this is part of the GCC-compatible driver. ++ // This was determined by running GCC in a fake filesystem, creating all ++ // possible permutations of these directories, and seeing which ones it added ++ // to the link paths. + path_list &Paths = getFilePaths(); + + const std::string OSLibDir = getOSLibDir(Triple, Args); + const std::string MultiarchTriple = getMultiarchTriple(D, Triple, SysRoot); + ++ // Add the multilib suffixed paths where they are available. ++ if (GCCInstallation.isValid()) { ++ const llvm::Triple &GCCTriple = GCCInstallation.getTriple(); ++ const std::string &LibPath = GCCInstallation.getParentLibPath(); ++ const Multilib &Multilib = GCCInstallation.getMultilib(); ++ const MultilibSet &Multilibs = GCCInstallation.getMultilibs(); ++ ++ // Add toolchain / multilib specific file paths. ++ addMultilibsFilePaths(D, Multilibs, Multilib, ++ GCCInstallation.getInstallPath(), Paths); ++ ++ // Sourcery CodeBench MIPS toolchain holds some libraries under ++ // a biarch-like suffix of the GCC installation. ++ addPathIfExists(D, GCCInstallation.getInstallPath() + Multilib.gccSuffix(), ++ Paths); ++ ++ // GCC cross compiling toolchains will install target libraries which ship ++ // as part of the toolchain under // rather than as ++ // any part of the GCC installation in ++ // //gcc//. This decision is somewhat ++ // debatable, but is the reality today. We need to search this tree even ++ // when we have a sysroot somewhere else. It is the responsibility of ++ // whomever is doing the cross build targeting a sysroot using a GCC ++ // installation that is *not* within the system root to ensure two things: ++ // ++ // 1) Any DSOs that are linked in from this tree or from the install path ++ // above must be present on the system root and found via an ++ // appropriate rpath. ++ // 2) There must not be libraries installed into ++ // // unless they should be preferred over ++ // those within the system root. ++ // ++ // Note that this matches the GCC behavior. See the below comment for where ++ // Clang diverges from GCC's behavior. ++ addPathIfExists(D, LibPath + "/../" + GCCTriple.str() + "/lib/../" + ++ OSLibDir + Multilib.osSuffix(), ++ Paths); ++ ++ // If the GCC installation we found is inside of the sysroot, we want to ++ // prefer libraries installed in the parent prefix of the GCC installation. ++ // It is important to *not* use these paths when the GCC installation is ++ // outside of the system root as that can pick up unintended libraries. ++ // This usually happens when there is an external cross compiler on the ++ // host system, and a more minimal sysroot available that is the target of ++ // the cross. Note that GCC does include some of these directories in some ++ // configurations but this seems somewhere between questionable and simply ++ // a bug. ++ if (StringRef(LibPath).startswith(SysRoot)) { ++ addPathIfExists(D, LibPath + "/" + MultiarchTriple, Paths); ++ addPathIfExists(D, LibPath + "/../" + OSLibDir, Paths); ++ } ++ } ++ + // Similar to the logic for GCC above, if we currently running Clang inside + // of the requested system root, add its parent library paths to + // those searched. +@@ -92,8 +179,40 @@ Hurd::Hurd(const Driver &D, const llvm:: + addPathIfExists(D, SysRoot + "/usr/lib/" + MultiarchTriple, Paths); + addPathIfExists(D, SysRoot + "/usr/lib/../" + OSLibDir, Paths); + +- // If we are currently running Clang inside of the requested system root, add +- // its parent library path to those searched. ++ // Try walking via the GCC triple path in case of biarch or multiarch GCC ++ // installations with strange symlinks. ++ if (GCCInstallation.isValid()) { ++ addPathIfExists(D, ++ SysRoot + "/usr/lib/" + GCCInstallation.getTriple().str() + ++ "/../../" + OSLibDir, ++ Paths); ++ ++ // Add the 'other' biarch variant path ++ Multilib BiarchSibling; ++ if (GCCInstallation.getBiarchSibling(BiarchSibling)) { ++ addPathIfExists(D, GCCInstallation.getInstallPath() + ++ BiarchSibling.gccSuffix(), ++ Paths); ++ } ++ ++ // See comments above on the multilib variant for details of why this is ++ // included even from outside the sysroot. ++ const std::string &LibPath = GCCInstallation.getParentLibPath(); ++ const llvm::Triple &GCCTriple = GCCInstallation.getTriple(); ++ const Multilib &Multilib = GCCInstallation.getMultilib(); ++ addPathIfExists(D, LibPath + "/../" + GCCTriple.str() + "/lib" + ++ Multilib.osSuffix(), ++ Paths); ++ ++ // See comments above on the multilib variant for details of why this is ++ // only included from within the sysroot. ++ if (StringRef(LibPath).startswith(SysRoot)) ++ addPathIfExists(D, LibPath, Paths); ++ } ++ ++ // Similar to the logic for GCC above, if we are currently running Clang ++ // inside of the requested system root, add its parent library path to those ++ // searched. + // FIXME: It's not clear whether we should use the driver's installed + // directory ('Dir' below) or the ResourceDir. + if (StringRef(D.Dir).startswith(SysRoot)) +@@ -161,6 +280,16 @@ void Hurd::AddClangSystemIncludeArgs(con + // Lacking those, try to detect the correct set of system includes for the + // target triple. + ++ // Add include directories specific to the selected multilib set and multilib. ++ if (GCCInstallation.isValid()) { ++ const auto &Callback = Multilibs.includeDirsCallback(); ++ if (Callback) { ++ for (const auto &Path : Callback(GCCInstallation.getMultilib())) ++ addExternCSystemIncludeIfExists( ++ DriverArgs, CC1Args, GCCInstallation.getInstallPath() + Path); ++ } ++ } ++ + const StringRef X86MultiarchIncludeDirs[] = { + "/usr/include/i386-gnu"}; + +@@ -187,3 +316,94 @@ void Hurd::AddClangSystemIncludeArgs(con + + addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/usr/include"); + } ++ ++static std::string DetectLibcxxIncludePath(StringRef base) { ++ std::error_code EC; ++ int MaxVersion = 0; ++ std::string MaxVersionString = ""; ++ for (llvm::sys::fs::directory_iterator LI(base, EC), LE; !EC && LI != LE; ++ LI = LI.increment(EC)) { ++ StringRef VersionText = llvm::sys::path::filename(LI->path()); ++ int Version; ++ if (VersionText[0] == 'v' && ++ !VersionText.slice(1, StringRef::npos).getAsInteger(10, Version)) { ++ if (Version > MaxVersion) { ++ MaxVersion = Version; ++ MaxVersionString = VersionText; ++ } ++ } ++ } ++ return MaxVersion ? (base + "/" + MaxVersionString).str() : ""; ++} ++ ++void Hurd::addLibCxxIncludePaths(const llvm::opt::ArgList &DriverArgs, ++ llvm::opt::ArgStringList &CC1Args) const { ++ const std::string& SysRoot = computeSysRoot(); ++ const std::string LibCXXIncludePathCandidates[] = { ++ DetectLibcxxIncludePath(getDriver().ResourceDir + "/include/c++"), ++ DetectLibcxxIncludePath(getDriver().Dir + "/../include/c++"), ++ // If this is a development, non-installed, clang, libcxx will ++ // not be found at ../include/c++ but it likely to be found at ++ // one of the following two locations: ++ DetectLibcxxIncludePath(SysRoot + "/usr/local/include/c++"), ++ DetectLibcxxIncludePath(SysRoot + "/usr/include/c++") }; ++ for (const auto &IncludePath : LibCXXIncludePathCandidates) { ++ if (IncludePath.empty() || !getVFS().exists(IncludePath)) ++ continue; ++ // Use the first candidate that exists. ++ addSystemInclude(DriverArgs, CC1Args, IncludePath); ++ return; ++ } ++} ++ ++void Hurd::addLibStdCxxIncludePaths(const llvm::opt::ArgList &DriverArgs, ++ llvm::opt::ArgStringList &CC1Args) const { ++ // We need a detected GCC installation on Hurd to provide libstdc++'s ++ // headers. ++ if (!GCCInstallation.isValid()) ++ return; ++ ++ // By default, look for the C++ headers in an include directory adjacent to ++ // the lib directory of the GCC installation. Note that this is expect to be ++ // equivalent to '/usr/include/c++/X.Y' in almost all cases. ++ StringRef LibDir = GCCInstallation.getParentLibPath(); ++ StringRef InstallDir = GCCInstallation.getInstallPath(); ++ StringRef TripleStr = GCCInstallation.getTriple().str(); ++ const Multilib &Multilib = GCCInstallation.getMultilib(); ++ const std::string GCCMultiarchTriple = getMultiarchTriple( ++ getDriver(), GCCInstallation.getTriple(), getDriver().SysRoot); ++ const std::string TargetMultiarchTriple = ++ getMultiarchTriple(getDriver(), getTriple(), getDriver().SysRoot); ++ const GCCVersion &Version = GCCInstallation.getVersion(); ++ ++ // The primary search for libstdc++ supports multiarch variants. ++ if (addLibStdCXXIncludePaths(LibDir.str() + "/../include", ++ "/c++/" + Version.Text, TripleStr, ++ GCCMultiarchTriple, TargetMultiarchTriple, ++ Multilib.includeSuffix(), DriverArgs, CC1Args)) ++ return; ++ ++ // Otherwise, fall back on a bunch of options which don't use multiarch ++ // layouts for simplicity. ++ const std::string LibStdCXXIncludePathCandidates[] = { ++ // Gentoo is weird and places its headers inside the GCC install, ++ // so if the first attempt to find the headers fails, try these patterns. ++ InstallDir.str() + "/include/g++-v" + Version.Text, ++ InstallDir.str() + "/include/g++-v" + Version.MajorStr + "." + ++ Version.MinorStr, ++ InstallDir.str() + "/include/g++-v" + Version.MajorStr, ++ // Android standalone toolchain has C++ headers in yet another place. ++ LibDir.str() + "/../" + TripleStr.str() + "/include/c++/" + Version.Text, ++ // Freescale SDK C++ headers are directly in /usr/include/c++, ++ // without a subdirectory corresponding to the gcc version. ++ LibDir.str() + "/../include/c++", ++ }; ++ ++ for (const auto &IncludePath : LibStdCXXIncludePathCandidates) { ++ if (addLibStdCXXIncludePaths(IncludePath, /*Suffix*/ "", TripleStr, ++ /*GCCMultiarchTriple*/ "", ++ /*TargetMultiarchTriple*/ "", ++ Multilib.includeSuffix(), DriverArgs, CC1Args)) ++ break; ++ } ++} +Index: llvm-toolchain-7-7.0.1~+rc2/clang/lib/Driver/ToolChains/Hurd.h +=================================================================== +--- llvm-toolchain-7-7.0.1~+rc2.orig/clang/lib/Driver/ToolChains/Hurd.h ++++ llvm-toolchain-7-7.0.1~+rc2/clang/lib/Driver/ToolChains/Hurd.h +@@ -25,6 +25,12 @@ public: + void + AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs, + llvm::opt::ArgStringList &CC1Args) const override; ++ void addLibCxxIncludePaths( ++ const llvm::opt::ArgList &DriverArgs, ++ llvm::opt::ArgStringList &CC1Args) const override; ++ void addLibStdCxxIncludePaths( ++ const llvm::opt::ArgList &DriverArgs, ++ llvm::opt::ArgStringList &CC1Args) const override; + + virtual std::string computeSysRoot() const; + diff --git a/debian/patches/series b/debian/patches/series index b848aae0..ca9b7051 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -89,3 +89,12 @@ mips-rdhwr.diff clang-arm-default-vfp3-on-armv7a.patch reproducible-pch.diff pr39427-misscompile.diff + +# Hurd port +D54079-hurd-openmp.diff +D54338-hurd-libcxx-threads-build.diff +D54339-hurd-libcxx-threads-detection.diff +D54378-hurd-triple.diff +D54379-hurd-triple-clang.diff +D54677-hurd-path_max.diff +hurd-cxx-paths.diff From bde1bb9e42bba5ec6cd3bb7f5f2e90402dddee59 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Wed, 21 Nov 2018 09:17:14 +0100 Subject: [PATCH 18/23] add a testcase for bug https://bugs.debian.org/cgi-bin/bugreport.cgi\?bug=914201 --- debian/qualify-clang.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/debian/qualify-clang.sh b/debian/qualify-clang.sh index d2d61d13..08e61353 100755 --- a/debian/qualify-clang.sh +++ b/debian/qualify-clang.sh @@ -496,6 +496,18 @@ int main() clang++-$VERSION -stdlib=libc++ -Wall -Werror foo.cpp -o foo ./foo +# Bug https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=914201 +echo ' +#include +int main(void) +{ + double f = 2.0; + if (isnan(f)) + return 1; + return 0; +}' > foo.c +clang-$VERSION -Wconversion -Werror foo.c || true + if test -f /usr/bin/g++; then g++ -nostdinc++ -I/usr/lib/llvm-$VERSION/bin/../include/c++/v1/ -L/usr/lib/llvm-$VERSION/lib/ \ foo.cpp -nodefaultlibs -std=c++17 -lc++ -lc++abi -lm -lc -lgcc_s -lgcc|| true From 52ca5481526e3c858fe66fb7f174b4f21494f13f Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Wed, 21 Nov 2018 12:03:51 +0100 Subject: [PATCH 19/23] more patch applied upstream --- debian/changelog | 9 ++++-- debian/patches/mips-rdhwr.diff | 50 ---------------------------------- debian/patches/series | 1 - 3 files changed, 7 insertions(+), 53 deletions(-) delete mode 100644 debian/patches/mips-rdhwr.diff diff --git a/debian/changelog b/debian/changelog index 8bcfc4c7..7a83371d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,11 +1,16 @@ -llvm-toolchain-7 (1:7.0.1~+rc2-5) UNRELEASED; urgency=medium +llvm-toolchain-7 (1:7.0.1~svn347285-1~exp1) UNRELEASED; urgency=medium + [ Samuel Thibault ] * D54079-hurd-openmp.diff, D54338-hurd-libcxx-threads-build.diff, D54339-hurd-libcxx-threads-detection.diff, D54378-hurd-triple.diff, D54379-hurd-triple-clang.diff, D54677-hurd-path_max.diff, hurd-cxx-paths.diff: New patches to fix hurd build. - -- Samuel Thibault Sun, 18 Nov 2018 23:43:55 +0100 + [ Sylvestre Ledru ] + * experimental New snapshot release + * Remove mips-rdhwr.diff as it has been applied upstream + + -- Sylvestre Ledru Wed, 21 Nov 2018 09:45:00 +0100 llvm-toolchain-7 (1:7.0.1~+rc2-4) unstable; urgency=medium diff --git a/debian/patches/mips-rdhwr.diff b/debian/patches/mips-rdhwr.diff deleted file mode 100644 index f7eef110..00000000 --- a/debian/patches/mips-rdhwr.diff +++ /dev/null @@ -1,50 +0,0 @@ -Index: llvm-toolchain-7-7/lib/Target/Mips/Mips64InstrInfo.td -=================================================================== ---- llvm-toolchain-7-7.orig/lib/Target/Mips/Mips64InstrInfo.td -+++ llvm-toolchain-7-7/lib/Target/Mips/Mips64InstrInfo.td -@@ -1139,3 +1139,6 @@ def SLTUImm64 : MipsAsmPseudoInst<(outs - "sltu\t$rs, $rt, $imm">, GPR_64; - def : MipsInstAlias<"sltu\t$rs, $imm", (SLTUImm64 GPR64Opnd:$rs, GPR64Opnd:$rs, - imm64:$imm)>, GPR_64; -+ -+def : MipsInstAlias<"rdhwr $rt, $rs", -+ (RDHWR64 GPR64Opnd:$rt, HWRegsOpnd:$rs, 0), 1>, GPR_64; -Index: llvm-toolchain-7-7/test/CodeGen/Mips/tls.ll -=================================================================== ---- llvm-toolchain-7-7.orig/test/CodeGen/Mips/tls.ll -+++ llvm-toolchain-7-7/test/CodeGen/Mips/tls.ll -@@ -48,14 +48,14 @@ entry: - ; STATIC32-LABEL: f1: - ; STATIC32: lui $[[R0:[0-9]+]], %tprel_hi(t1) - ; STATIC32: addiu $[[R1:[0-9]+]], $[[R0]], %tprel_lo(t1) --; STATIC32: rdhwr $3, $29 -+; STATIC32: rdhwr $3, $29{{$}} - ; STATIC32: addu $[[R2:[0-9]+]], $3, $[[R1]] - ; STATIC32: lw $2, 0($[[R2]]) - - ; STATIC64-LABEL: f1: - ; STATIC64: lui $[[R0:[0-9]+]], %tprel_hi(t1) - ; STATIC64: daddiu $[[R1:[0-9]+]], $[[R0]], %tprel_lo(t1) --; STATIC64: rdhwr $3, $29, 0 -+; STATIC64: rdhwr $3, $29{{$}} - ; STATIC64: daddu $[[R2:[0-9]+]], $3, $[[R0]] - ; STATIC64: lw $2, 0($[[R2]]) - } -@@ -101,7 +101,7 @@ entry: - ; STATIC32-LABEL: f2: - ; STATIC32: lui $[[R0:[0-9]+]], %hi(__gnu_local_gp) - ; STATIC32: addiu $[[GP:[0-9]+]], $[[R0]], %lo(__gnu_local_gp) --; STATIC32: rdhwr $3, $29 -+; STATIC32: rdhwr $3, $29{{$}} - ; STATIC32: lw $[[R0:[0-9]+]], %gottprel(t2)($[[GP]]) - ; STATIC32: addu $[[R1:[0-9]+]], $3, $[[R0]] - ; STATIC32: lw $2, 0($[[R1]]) -@@ -109,7 +109,7 @@ entry: - ; STATIC64-LABEL: f2: - ; STATIC64: lui $[[R0:[0-9]+]], %hi(%neg(%gp_rel(f2))) - ; STATIC64: daddiu $[[GP:[0-9]+]], $[[R0]], %lo(%neg(%gp_rel(f2))) --; STATIC64: rdhwr $3, $29 -+; STATIC64: rdhwr $3, $29{{$}} - ; STATIC64: ld $[[R0:[0-9]+]], %gottprel(t2)($[[GP]]) - ; STATIC64: daddu $[[R1:[0-9]+]], $3, $[[R0]] - ; STATIC64: lw $2, 0($[[R1]]) diff --git a/debian/patches/series b/debian/patches/series index ca9b7051..07afa1e2 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -85,7 +85,6 @@ clangd-atomic-cmake.patch rustc-aarch64-test-failure.diff symbolizer-path.diff remove-apple-clang-manpage.diff -mips-rdhwr.diff clang-arm-default-vfp3-on-armv7a.patch reproducible-pch.diff pr39427-misscompile.diff From 144b3435473ca40148fd806a8554b9e85fdb2ad9 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Wed, 21 Nov 2018 12:04:26 +0100 Subject: [PATCH 20/23] rebase of the patches --- debian/patches/D54677-hurd-path_max.diff | 10 +++++----- debian/patches/hurd-cxx-paths.diff | 18 +++++++++--------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/debian/patches/D54677-hurd-path_max.diff b/debian/patches/D54677-hurd-path_max.diff index 12b09168..f0cafd11 100644 --- a/debian/patches/D54677-hurd-path_max.diff +++ b/debian/patches/D54677-hurd-path_max.diff @@ -4,11 +4,11 @@ The GNU/Hurd system does not define an arbitrary PATH_MAX limitation, the POSIX https://reviews.llvm.org/D54677 -Index: llvm/libcxx/src/filesystem/operations.cpp +Index: llvm-toolchain-7_7.0.1~svn347285/libcxx/src/filesystem/operations.cpp =================================================================== ---- llvm/libcxx/src/filesystem/operations.cpp (révision 347139) -+++ llvm/libcxx/src/filesystem/operations.cpp (copie de travail) -@@ -530,11 +530,20 @@ +--- llvm-toolchain-7_7.0.1~svn347285.orig/libcxx/src/filesystem/operations.cpp ++++ llvm-toolchain-7_7.0.1~svn347285/libcxx/src/filesystem/operations.cpp +@@ -531,11 +531,20 @@ path __canonical(path const& orig_p, err ErrorHandler err("canonical", ec, &orig_p, &cwd); path p = __do_absolute(orig_p, &cwd, ec); @@ -29,7 +29,7 @@ Index: llvm/libcxx/src/filesystem/operations.cpp } void __copy(const path& from, const path& to, copy_options options, -@@ -1076,16 +1085,27 @@ +@@ -1077,16 +1086,27 @@ void __permissions(const path& p, perms path __read_symlink(const path& p, error_code* ec) { ErrorHandler err("read_symlink", ec, &p); diff --git a/debian/patches/hurd-cxx-paths.diff b/debian/patches/hurd-cxx-paths.diff index 316e9ee2..a3068846 100644 --- a/debian/patches/hurd-cxx-paths.diff +++ b/debian/patches/hurd-cxx-paths.diff @@ -1,9 +1,9 @@ This should be factorized with Linux.cpp and the GNU/kFreeBSD case. -Index: llvm-toolchain-7-7.0.1~+rc2/clang/lib/Driver/ToolChains/Hurd.cpp +Index: llvm-toolchain-7_7.0.1~svn347285/clang/lib/Driver/ToolChains/Hurd.cpp =================================================================== ---- llvm-toolchain-7-7.0.1~+rc2.orig/clang/lib/Driver/ToolChains/Hurd.cpp -+++ llvm-toolchain-7-7.0.1~+rc2/clang/lib/Driver/ToolChains/Hurd.cpp +--- llvm-toolchain-7_7.0.1~svn347285.orig/clang/lib/Driver/ToolChains/Hurd.cpp ++++ llvm-toolchain-7_7.0.1~svn347285/clang/lib/Driver/ToolChains/Hurd.cpp @@ -67,15 +67,102 @@ static StringRef getOSLibDir(const llvm: return Triple.isArch32Bit() ? "lib" : "lib64"; } @@ -150,7 +150,7 @@ Index: llvm-toolchain-7-7.0.1~+rc2/clang/lib/Driver/ToolChains/Hurd.cpp // FIXME: It's not clear whether we should use the driver's installed // directory ('Dir' below) or the ResourceDir. if (StringRef(D.Dir).startswith(SysRoot)) -@@ -161,6 +280,16 @@ void Hurd::AddClangSystemIncludeArgs(con +@@ -163,6 +282,16 @@ void Hurd::AddClangSystemIncludeArgs(con // Lacking those, try to detect the correct set of system includes for the // target triple. @@ -167,7 +167,7 @@ Index: llvm-toolchain-7-7.0.1~+rc2/clang/lib/Driver/ToolChains/Hurd.cpp const StringRef X86MultiarchIncludeDirs[] = { "/usr/include/i386-gnu"}; -@@ -187,3 +316,94 @@ void Hurd::AddClangSystemIncludeArgs(con +@@ -189,3 +318,94 @@ void Hurd::AddClangSystemIncludeArgs(con addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/usr/include"); } @@ -262,11 +262,11 @@ Index: llvm-toolchain-7-7.0.1~+rc2/clang/lib/Driver/ToolChains/Hurd.cpp + break; + } +} -Index: llvm-toolchain-7-7.0.1~+rc2/clang/lib/Driver/ToolChains/Hurd.h +Index: llvm-toolchain-7_7.0.1~svn347285/clang/lib/Driver/ToolChains/Hurd.h =================================================================== ---- llvm-toolchain-7-7.0.1~+rc2.orig/clang/lib/Driver/ToolChains/Hurd.h -+++ llvm-toolchain-7-7.0.1~+rc2/clang/lib/Driver/ToolChains/Hurd.h -@@ -25,6 +25,12 @@ public: +--- llvm-toolchain-7_7.0.1~svn347285.orig/clang/lib/Driver/ToolChains/Hurd.h ++++ llvm-toolchain-7_7.0.1~svn347285/clang/lib/Driver/ToolChains/Hurd.h +@@ -27,6 +27,12 @@ public: void AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const override; From 9129d72e28232a01e17fbe10acaec6d3192932b9 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Wed, 21 Nov 2018 12:27:24 +0100 Subject: [PATCH 21/23] Fix a baseline violation on armhf (Closes: #914268) clang-arm-default-vfp3-on-armv7a.patch has been updated to disable neon in another place --- debian/changelog | 4 +++- .../patches/clang-arm-default-vfp3-on-armv7a.patch | 12 ++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 7a83371d..c5e24492 100644 --- a/debian/changelog +++ b/debian/changelog @@ -7,8 +7,10 @@ llvm-toolchain-7 (1:7.0.1~svn347285-1~exp1) UNRELEASED; urgency=medium hurd-cxx-paths.diff: New patches to fix hurd build. [ Sylvestre Ledru ] - * experimental New snapshot release * Remove mips-rdhwr.diff as it has been applied upstream + * Fix a baseline violation on armhf (Closes: #914268) + clang-arm-default-vfp3-on-armv7a.patch has been updated to disable + neon in another place -- Sylvestre Ledru Wed, 21 Nov 2018 09:45:00 +0100 diff --git a/debian/patches/clang-arm-default-vfp3-on-armv7a.patch b/debian/patches/clang-arm-default-vfp3-on-armv7a.patch index ce4daf4e..7179927b 100644 --- a/debian/patches/clang-arm-default-vfp3-on-armv7a.patch +++ b/debian/patches/clang-arm-default-vfp3-on-armv7a.patch @@ -11,3 +11,15 @@ Index: llvm-toolchain-7-7/include/llvm/Support/ARMTargetParser.def ARM_ARCH("armv7ve", ARMV7VE, "7VE", "v7ve", ARMBuildAttrs::CPUArch::v7, FK_NEON, (ARM::AEK_SEC | ARM::AEK_MP | ARM::AEK_VIRT | ARM::AEK_HWDIVARM | ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP)) +Index: llvm-toolchain-7-7/lib/Target/ARM/ARM.td +=================================================================== +--- llvm-toolchain-7-7.orig/lib/Target/ARM/ARM.td ++++ llvm-toolchain-7-7/lib/Target/ARM/ARM.td +@@ -558,7 +558,6 @@ def ARMv6sm : Architecture<"armv6s-m", + FeatureStrictAlign]>; + + def ARMv7a : Architecture<"armv7-a", "ARMv7a", [HasV7Ops, +- FeatureNEON, + FeatureDB, + FeatureDSP, + FeatureAClass]>; From 4f3a67d8244daf6d29e75556e2b198a628bd32f7 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Wed, 21 Nov 2018 12:29:59 +0100 Subject: [PATCH 22/23] prepare upload --- debian/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index c5e24492..7a099dd4 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -llvm-toolchain-7 (1:7.0.1~svn347285-1~exp1) UNRELEASED; urgency=medium +llvm-toolchain-7 (1:7.0.1~+rc2-5) unstable; urgency=medium [ Samuel Thibault ] * D54079-hurd-openmp.diff, D54338-hurd-libcxx-threads-build.diff, From db50715aa8526e57678be47d14c966e7cc13d5a7 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Wed, 21 Nov 2018 22:40:43 +0100 Subject: [PATCH 23/23] also ignore libclangTidyModernizeModule.a --- debian/rules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/rules b/debian/rules index b8bdb470..caa1c9bb 100755 --- a/debian/rules +++ b/debian/rules @@ -692,7 +692,7 @@ endif # endif ifeq ($(shell dpkg --compare-versions $(shell dpkg-query -W -f '$${Version}' binutils) ge 2.28 ; echo $$?),0) # strip segfaults on libFuzzer.a - dh_strip -a -v -XlibFuzzer.a -Xlibc++.a -Xlibc++abi.a -Xlibc++experimental.a + dh_strip -a -v -XlibFuzzer.a -Xlibc++.a -Xlibc++abi.a -Xlibc++experimental.a -XlibclangTidyModernizeModule.a else dh_strip -a -v endif