Bug#908847: llvm-toolchain-6.0: FTBFS on hurd-i386

2018-10-25 Thread Sylvestre Ledru
Le 25/10/2018 à 00:49, Samuel Thibault a écrit :
> Hello,
> 
> There was an issue with paths returned by llvm-config, discussed
> upstream on https://reviews.llvm.org/D53557 , I'd like to NMU the fix
> commited upstream attached here, may I proceed?
> 
> Samuel
> 
I would prefer you open a new bug for that (bugs are cheap).
Besides that, yeah, well done :)

S



Bug#908847: llvm-toolchain-6.0: FTBFS on hurd-i386

2018-10-24 Thread Samuel Thibault
Hello,

There was an issue with paths returned by llvm-config, discussed
upstream on https://reviews.llvm.org/D53557 , I'd like to NMU the fix
commited upstream attached here, may I proceed?

Samuel
[hurd] Make getMainExecutable get the real binary path

On GNU/Hurd, llvm-config is returning bogus value, such as:

$ llvm-config-6.0 --includedir
/usr/include

while it should be:
$ llvm-config-6.0 --includedir
/usr/lib/llvm-6.0/include

This is because getMainExecutable does not get the actual installation
path. On GNU/Hurd, /proc/self/exe is indeed a symlink to the path that
was used to start the program, and not the eventual binary file. Llvm's
getMainExecutable thus needs to run realpath over it to get the actual
place where llvm was installed (/usr/lib/llvm-6.0/bin/llvm-config), and
not /usr/bin/llvm-config-6.0. This will not change the result on Linux,
where /proc/self/exe already points to the eventual file.

Patch by Samuel Thibault!

While making changes here, I reformatted this block a bit to reduce
indentation and match 2 space indent style.

Differential Revision: https://reviews.llvm.org/D53557

Index: llvm/trunk/lib/Support/Unix/Path.inc
===
--- llvm/trunk/lib/Support/Unix/Path.inc
+++ llvm/trunk/lib/Support/Unix/Path.inc
@@ -179,14 +179,34 @@
   char exe_path[MAXPATHLEN];
   StringRef aPath("/proc/self/exe");
   if (sys::fs::exists(aPath)) {
-  // /proc is not always mounted under Linux (chroot for example).
-  ssize_t len = readlink(aPath.str().c_str(), exe_path, sizeof(exe_path));
-  if (len >= 0)
-  return std::string(exe_path, len);
+// /proc is not always mounted under Linux (chroot for example).
+ssize_t len = readlink(aPath.str().c_str(), exe_path, sizeof(exe_path));
+if (len < 0)
+  return "";
+
+// Null terminate the string for realpath. readlink never null
+// terminates its output.
+len = std::min(len, long(sizeof(exe_path) - 1));
+exe_path[len] = '\0';
+
+// At least on GNU/Hurd, /proc/self/exe is a symlink to the path that
+// was used to start the program, and not the eventual binary file.
+// We thus needs to run realpath over it to get the actual place
+// where llvm was installed.
+#if _POSIX_VERSION >= 200112 || defined(__GLIBC__)
+char *real_path = realpath(exe_path, NULL);
+std::string ret = std::string(real_path);
+free(real_path);
+return ret;
+#else
+char real_path[MAXPATHLEN];
+realpath(exe_path, real_path);
+return std::string(real_path);
+#endif
   } else {
-  // Fall back to the classical detection.
-  if (getprogpath(exe_path, argv0))
-return exe_path;
+// Fall back to the classical detection.
+if (getprogpath(exe_path, argv0))
+  return exe_path;
   }
 #elif defined(HAVE_DLFCN_H) && defined(HAVE_DLADDR)
   // Use dladdr to get executable path if available.


Bug#908847: llvm-toolchain-6.0: FTBFS on hurd-i386

2018-10-20 Thread Sylvestre Ledru


Le 18/10/2018 à 19:39, Svante Signell a écrit :
> On Thu, 2018-10-18 at 16:55 +0200, Samuel Thibault wrote:
>> Sylvestre Ledru, le jeu. 18 oct. 2018 16:52:46 +0200, a ecrit:
>>> Do you want me to forward this upstream or are you going to do it?
>> Svante, that's a question for you ;)
> Sylvestre,
>
> If you have the time and the channel to upstream already set up, please
> do.
>
> Thanks,
> Svante

Hello

Upstream replied here:

https://reviews.llvm.org/D53410#1268678

Cheers

S



Bug#908847: llvm-toolchain-6.0: FTBFS on hurd-i386

2018-10-18 Thread Svante Signell
On Thu, 2018-10-18 at 16:55 +0200, Samuel Thibault wrote:
> Sylvestre Ledru, le jeu. 18 oct. 2018 16:52:46 +0200, a ecrit:
> > 
> 
> > Do you want me to forward this upstream or are you going to do it?
> 
> Svante, that's a question for you ;)

Sylvestre,

If you have the time and the channel to upstream already set up, please
do.

Thanks,
Svante



Bug#908847: llvm-toolchain-6.0: FTBFS on hurd-i386

2018-10-18 Thread Sylvestre Ledru
Le 18/10/2018 à 16:37, Samuel Thibault a écrit :
> Sylvestre Ledru, le jeu. 18 oct. 2018 16:35:31 +0200, a ecrit:
>> Le 18/10/2018 à 16:30, Samuel Thibault a écrit :
>>> Hello,
>>>
>>> Svante Signell, le sam. 15 sept. 2018 01:45:06 +0200, a ecrit:
 Currently llvm-toolchain-6.0 FTBFS on GNU/Hurd due to missing porting
 issues. Attached are three patches to fix this:
>>>
>>> As this is blocking a hell lot of packages, I have uploaded the attached
>>> NMU to delayed/5.
>> No need to delay it!
> 
> Ok, reuploaded in the non-delayed queue :)
> 

merci :)

I took your patches in 7 (small rebase)

Do you want me to forward this upstream or are you going to do it?

S



Bug#908847: llvm-toolchain-6.0: FTBFS on hurd-i386

2018-10-18 Thread Samuel Thibault
Sylvestre Ledru, le jeu. 18 oct. 2018 16:52:46 +0200, a ecrit:
> Le 18/10/2018 à 16:37, Samuel Thibault a écrit :
> > Sylvestre Ledru, le jeu. 18 oct. 2018 16:35:31 +0200, a ecrit:
> >> Le 18/10/2018 à 16:30, Samuel Thibault a écrit :
> >>> Svante Signell, le sam. 15 sept. 2018 01:45:06 +0200, a ecrit:
>  Currently llvm-toolchain-6.0 FTBFS on GNU/Hurd due to missing porting
>  issues. Attached are three patches to fix this:
> >>>
> >>> As this is blocking a hell lot of packages, I have uploaded the attached
> >>> NMU to delayed/5.
> >> No need to delay it!
> > 
> > Ok, reuploaded in the non-delayed queue :)
> 
> merci :)
> 
> I took your patches in 7 (small rebase)

Thanks!

> Do you want me to forward this upstream or are you going to do it?

Svante, that's a question for you ;)

Samuel



Bug#908847: llvm-toolchain-6.0: FTBFS on hurd-i386

2018-10-18 Thread Samuel Thibault
Sylvestre Ledru, le jeu. 18 oct. 2018 16:35:31 +0200, a ecrit:
> Le 18/10/2018 à 16:30, Samuel Thibault a écrit :
> > Hello,
> > 
> > Svante Signell, le sam. 15 sept. 2018 01:45:06 +0200, a ecrit:
> >> Currently llvm-toolchain-6.0 FTBFS on GNU/Hurd due to missing porting
> >> issues. Attached are three patches to fix this:
> > 
> > As this is blocking a hell lot of packages, I have uploaded the attached
> > NMU to delayed/5.
> No need to delay it!

Ok, reuploaded in the non-delayed queue :)

Samuel



Bug#908847: llvm-toolchain-6.0: FTBFS on hurd-i386

2018-10-18 Thread Sylvestre Ledru
Le 18/10/2018 à 16:30, Samuel Thibault a écrit :
> Hello,
> 
> Svante Signell, le sam. 15 sept. 2018 01:45:06 +0200, a ecrit:
>> Currently llvm-toolchain-6.0 FTBFS on GNU/Hurd due to missing porting
>> issues. Attached are three patches to fix this:
> 
> As this is blocking a hell lot of packages, I have uploaded the attached
> NMU to delayed/5.
Bonjour,

No need to delay it!

Thanks!
S



Bug#908847: llvm-toolchain-6.0: FTBFS on hurd-i386

2018-10-18 Thread Samuel Thibault
Hello,

Svante Signell, le sam. 15 sept. 2018 01:45:06 +0200, a ecrit:
> Currently llvm-toolchain-6.0 FTBFS on GNU/Hurd due to missing porting
> issues. Attached are three patches to fix this:

As this is blocking a hell lot of packages, I have uploaded the attached
NMU to delayed/5.

Samuel
diff -Nru llvm-toolchain-6.0-6.0.1/debian/changelog 
llvm-toolchain-6.0-6.0.1/debian/changelog
--- llvm-toolchain-6.0-6.0.1/debian/changelog   2018-09-14 07:24:02.0 
+
+++ llvm-toolchain-6.0-6.0.1/debian/changelog   2018-10-16 20:18:39.0 
+
@@ -1,3 +1,13 @@
+llvm-toolchain-6.0 (1:6.0.1-9.1) unstable; urgency=medium
+
+  * Non-maintainer upload.
+  * Apply hurd fixes (Closes: #908847).
+- hurd-lib_Support_Unix_Path.inc.diff
+- hurd-pathmax.diff
+- hurd-tools_llvm-shlib_CMakeLists.txt.diff
+
+ -- Samuel Thibault   Tue, 16 Oct 2018 20:18:39 +
+
 llvm-toolchain-6.0 (1:6.0.1-9) unstable; urgency=medium
 
   [ John Paul Adrian Glaubitz ]
diff -Nru 
llvm-toolchain-6.0-6.0.1/debian/patches/hurd-lib_Support_Unix_Path.inc.diff 
llvm-toolchain-6.0-6.0.1/debian/patches/hurd-lib_Support_Unix_Path.inc.diff
--- llvm-toolchain-6.0-6.0.1/debian/patches/hurd-lib_Support_Unix_Path.inc.diff 
1970-01-01 00:00:00.0 +
+++ llvm-toolchain-6.0-6.0.1/debian/patches/hurd-lib_Support_Unix_Path.inc.diff 
2018-10-16 20:16:49.0 +
@@ -0,0 +1,52 @@
+Index: llvm-toolchain-6.0-6.0.1/lib/Support/Unix/Path.inc
+===
+--- llvm-toolchain-6.0-6.0.1.orig/lib/Support/Unix/Path.inc
 llvm-toolchain-6.0-6.0.1/lib/Support/Unix/Path.inc
+@@ -98,7 +98,7 @@
+ #define STATVFS_F_FRSIZE(vfs) static_cast(vfs.f_bsize)
+ #endif
+ 
+-#if defined(__NetBSD__)
++#if defined(__NetBSD__) || defined(__GNU__)
+ #define STATVFS_F_FLAG(vfs) (vfs).f_flag
+ #else
+ #define STATVFS_F_FLAG(vfs) (vfs).f_flags
+@@ -111,7 +111,7 @@ namespace sys  {
+ namespace fs {
+ #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) ||
 \
+ defined(__minix) || defined(__FreeBSD_kernel__) || defined(__linux__) ||  
 \
+-defined(__CYGWIN__) || defined(__DragonFly__) || defined(_AIX)
++defined(__CYGWIN__) || defined(__DragonFly__) || defined(_AIX) || 
defined(__GNU__)
+ static int
+ test_dir(char ret[PATH_MAX], const char *dir, const char *bin)
+ {
+@@ -187,7 +187,7 @@ std::string getMainExecutable(const char
+ 
+   if (getprogpath(exe_path, argv0) != NULL)
+ return exe_path;
+-#elif defined(__linux__) || defined(__CYGWIN__)
++#elif defined(__linux__) || defined(__CYGWIN__) || defined(__GNU__)
+   char exe_path[MAXPATHLEN];
+   StringRef aPath("/proc/self/exe");
+   if (sys::fs::exists(aPath)) {
+@@ -360,7 +360,7 @@ std::error_code remove(const Twine 
+ }
+ 
+ static bool is_local_impl(struct STATVFS ) {
+-#if defined(__linux__)
++#if defined(__linux__) || defined(__GNU__)
+ #ifndef NFS_SUPER_MAGIC
+ #define NFS_SUPER_MAGIC 0x6969
+ #endif
+@@ -370,7 +370,11 @@ static bool is_local_impl(struct STATVFS
+ #ifndef CIFS_MAGIC_NUMBER
+ #define CIFS_MAGIC_NUMBER 0xFF534D42
+ #endif
++#ifdef __GNU__
++  switch ((uint32_t)Vfs.__f_type) {
++#else
+   switch ((uint32_t)Vfs.f_type) {
++#endif
+   case NFS_SUPER_MAGIC:
+   case SMB_SUPER_MAGIC:
+   case CIFS_MAGIC_NUMBER:
diff -Nru llvm-toolchain-6.0-6.0.1/debian/patches/hurd-pathmax.diff 
llvm-toolchain-6.0-6.0.1/debian/patches/hurd-pathmax.diff
--- llvm-toolchain-6.0-6.0.1/debian/patches/hurd-pathmax.diff   2018-09-14 
07:24:02.0 +
+++ llvm-toolchain-6.0-6.0.1/debian/patches/hurd-pathmax.diff   2018-10-16 
20:18:39.0 +
@@ -75,3 +75,19 @@
  /* Open the host .cu file and the kernel .hu and .cu files for writing.
   * Add the necessary includes.
   */
+Index: 
llvm-toolchain-6.0-6.0.1/clang/lib/Frontend/ModuleDependencyCollector.cpp
+===
+--- 
llvm-toolchain-6.0-6.0.1.orig/clang/lib/Frontend/ModuleDependencyCollector.cpp
 llvm-toolchain-6.0-6.0.1/clang/lib/Frontend/ModuleDependencyCollector.cpp
+@@ -97,6 +97,11 @@ struct ModuleDependencyMMCallbacks : pub
+ 
+ }
+ 
++// For GNU Hurd
++#if defined(__GNU__) && !defined(PATH_MAX)
++# define PATH_MAX 4096
++#endif
++
+ // TODO: move this to Support/Path.h and check for HAVE_REALPATH?
+ static bool real_path(StringRef SrcPath, SmallVectorImpl ) {
+ #ifdef LLVM_ON_UNIX
diff -Nru 
llvm-toolchain-6.0-6.0.1/debian/patches/hurd-tools_llvm-shlib_CMakeLists.txt.diff
 
llvm-toolchain-6.0-6.0.1/debian/patches/hurd-tools_llvm-shlib_CMakeLists.txt.diff
--- 
llvm-toolchain-6.0-6.0.1/debian/patches/hurd-tools_llvm-shlib_CMakeLists.txt.diff
   1970-01-01 00:00:00.0 +
+++ 
llvm-toolchain-6.0-6.0.1/debian/patches/hurd-tools_llvm-shlib_CMakeLists.txt.diff
   2018-10-16 20:16:49.0 +
@@ -0,0 +1,12 @@
+Index: llvm-toolchain-6.0-6.0.1/tools/llvm-shlib/CMakeLists.txt
+===
+--- 

Bug#908847: llvm-toolchain-6.0: FTBFS on hurd-i386

2018-09-14 Thread Svante Signell
Source: llvm-toolchain-6.0
Version: 6.0.1-9
Severity: important
Tags: ftbfs, patch
User: debian-h...@lists.debian.org
Usertags: hurd-i386

Hello,

Currently llvm-toolchain-6.0 FTBFS on GNU/Hurd due to missing porting
issues. Attached are three patches to fix this:
lib_Support_Unix_Path.inc.diff
tools_llvm-shlib_CMakeLists.txt.diff
clang_lib_Frontend_ModuleDependencyCollector.cpp.dif

The last patch is a PATH_MAX issue. Maybe it could be integrated with
the already present hurd-pathmax.diff patch.

Additionally the patch debian_rules.diff adds GNU/Hurd to the
architectures capable of using the gold linker.

Thanks!Index: llvm-toolchain-6.0-6.0.1/clang/lib/Frontend/ModuleDependencyCollector.cpp
===
--- llvm-toolchain-6.0-6.0.1.orig/clang/lib/Frontend/ModuleDependencyCollector.cpp
+++ llvm-toolchain-6.0-6.0.1/clang/lib/Frontend/ModuleDependencyCollector.cpp
@@ -97,6 +97,11 @@ struct ModuleDependencyMMCallbacks : pub
 
 }
 
+// For GNU Hurd
+#if defined(__GNU__) && !defined(PATH_MAX)
+# define PATH_MAX 4096
+#endif
+
 // TODO: move this to Support/Path.h and check for HAVE_REALPATH?
 static bool real_path(StringRef SrcPath, SmallVectorImpl ) {
 #ifdef LLVM_ON_UNIX
--- a/debian/rules	2018-09-12 10:48:35.0 +0200
+++ b/debian/rules	2018-09-14 13:35:50.0 +0200
@@ -84,7 +84,7 @@
 	control_vars = '-Vdep:devlibs=libstdc++6-$(GCC_VERSION)-dev'
 endif
 
-BINUTILS_GOLD_ARCHS := amd64 arm64 armhf i386 ppc64 ppc64el sparc sparc64 x32 s390x
+BINUTILS_GOLD_ARCHS := amd64 arm64 armhf i386 ppc64 ppc64el sparc sparc64 x32 s390x hurd-i386
 ifeq ($(shell dpkg --compare-versions $(shell dpkg-query -W -f '$${Version}' binutils) ge 2.23.1-1~exp3 ; echo $$?),0)
 ifneq (,$(filter $(DEB_HOST_ARCH),$(BINUTILS_GOLD_ARCHS)))
 # -fused-ld=gold enables the gold linker (but is not supported by all archs / distro)
Index: llvm-toolchain-6.0-6.0.1/lib/Support/Unix/Path.inc
===
--- llvm-toolchain-6.0-6.0.1.orig/lib/Support/Unix/Path.inc
+++ llvm-toolchain-6.0-6.0.1/lib/Support/Unix/Path.inc
@@ -98,7 +98,7 @@
 #define STATVFS_F_FRSIZE(vfs) static_cast(vfs.f_bsize)
 #endif
 
-#if defined(__NetBSD__)
+#if defined(__NetBSD__) || defined(__GNU__)
 #define STATVFS_F_FLAG(vfs) (vfs).f_flag
 #else
 #define STATVFS_F_FLAG(vfs) (vfs).f_flags
@@ -111,7 +111,7 @@ namespace sys  {
 namespace fs {
 #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || \
 defined(__minix) || defined(__FreeBSD_kernel__) || defined(__linux__) ||   \
-defined(__CYGWIN__) || defined(__DragonFly__) || defined(_AIX)
+defined(__CYGWIN__) || defined(__DragonFly__) || defined(_AIX) || defined(__GNU__)
 static int
 test_dir(char ret[PATH_MAX], const char *dir, const char *bin)
 {
@@ -187,7 +187,7 @@ std::string getMainExecutable(const char
 
   if (getprogpath(exe_path, argv0) != NULL)
 return exe_path;
-#elif defined(__linux__) || defined(__CYGWIN__)
+#elif defined(__linux__) || defined(__CYGWIN__) || defined(__GNU__)
   char exe_path[MAXPATHLEN];
   StringRef aPath("/proc/self/exe");
   if (sys::fs::exists(aPath)) {
@@ -360,7 +360,7 @@ std::error_code remove(const Twine 
 }
 
 static bool is_local_impl(struct STATVFS ) {
-#if defined(__linux__)
+#if defined(__linux__) || defined(__GNU__)
 #ifndef NFS_SUPER_MAGIC
 #define NFS_SUPER_MAGIC 0x6969
 #endif
@@ -370,7 +370,11 @@ static bool is_local_impl(struct STATVFS
 #ifndef CIFS_MAGIC_NUMBER
 #define CIFS_MAGIC_NUMBER 0xFF534D42
 #endif
+#ifdef __GNU__
+  switch ((uint32_t)Vfs.__f_type) {
+#else
   switch ((uint32_t)Vfs.f_type) {
+#endif
   case NFS_SUPER_MAGIC:
   case SMB_SUPER_MAGIC:
   case CIFS_MAGIC_NUMBER:
Index: llvm-toolchain-6.0-6.0.1/tools/llvm-shlib/CMakeLists.txt
===
--- llvm-toolchain-6.0-6.0.1.orig/tools/llvm-shlib/CMakeLists.txt
+++ llvm-toolchain-6.0-6.0.1/tools/llvm-shlib/CMakeLists.txt
@@ -40,6 +40,7 @@ set_property(TARGET LLVM PROPERTY VERSIO
 list(REMOVE_DUPLICATES LIB_NAMES)
 if(("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") OR (MINGW) OR (HAIKU)
OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "FreeBSD")
+   OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "GNU")
OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "DragonFly")
OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "SunOS")) # FIXME: It should be "GNU ld for elf"
   configure_file(