Package: knxd
Version: 0.14.46-1
Severity: serious
Tags: patch experimental
Justification: ftbfs
User: ubuntu-de...@lists.ubuntu.com
Usertags: origin-ubuntu jammy ubuntu-patch

Hi Matthias,

In Ubuntu, we have found that the knxd package fails to build from source
because glibc header dependencies mean that the link() declaration from
unistd.h is now exposed in a context it wasn't previously, leading to a
namespace conflict:

[...]
g++ -DHAVE_CONFIG_H -I. -I../..  -I../../src/libserver -I../../src/backend -I../
../src/common -I../../src/usb -I/usr/include/libusb-1.0  -Wno-missing-field-init
ializers -Wdate-time -D_FORTIFY_SOURCE=2  -g -O2 -ffile-prefix-map=/<<PKGBUILDDI
R>>=. -flto=auto -ffat-lto-objects -flto=auto -ffat-lto-objects -fstack-protecto
r-strong -std=c++0x -Wno-subobject-linkage -MT knxd_args.o -MD -MP -MF .deps/knx
d_args.Tpo -c -o knxd_args.o knxd_args.cpp
knxd_args.cpp:71:13: error: ‘char link [99]’ redeclared as different kind of 
entity
   71 | char link[99] = "@.";
      |             ^
In file included from /usr/include/x86_64-linux-gnu/bits/sigstksz.h:24,
                 from /usr/include/signal.h:328,
                 from /usr/include/ev.h:162,
                 from /usr/include/ev++.h:46,
                 from ../../src/libserver/common.h:31,
                 from ../../src/libserver/trace.h:40,
                 from knxd_args.cpp:29:
/usr/include/unistd.h:818:12: note: previous declaration ‘int link(const char*, 
const char*)’
  818 | extern int link (const char *__from, const char *__to)
      |            ^~~~
[...]

  (https://launchpad.net/ubuntu/+source/knxd/0.14.46-1build1/+build/22982832)

glibc 2.34 is currently in Debian experimental, so this problem will also
affect Debian soon.

I've uploaded the attached patch to Ubuntu to fix the build failure there;
please consider including it in Debian.  You can of course choose any more
meaningful variable name of your choice if you don't like the one I've
chosen :), but I don't think it's worth the effort to try to mask the
standard symbol from the namespace in order to keep the current variable
name.

Thanks for considering,
-- 
Steve Langasek                   Give me a lever long enough and a Free OS
Debian Developer                   to set it on, and I can move the world.
Ubuntu Developer                                   https://www.debian.org/
slanga...@ubuntu.com                                     vor...@debian.org
diff -Nru knxd-0.14.46/debian/patches/glibc-2.34.patch 
knxd-0.14.46/debian/patches/glibc-2.34.patch
--- knxd-0.14.46/debian/patches/glibc-2.34.patch        1969-12-31 
16:00:00.000000000 -0800
+++ knxd-0.14.46/debian/patches/glibc-2.34.patch        2022-01-24 
09:17:19.000000000 -0800
@@ -0,0 +1,151 @@
+Description: Fix build failure with glibc 2.34
+ The code uses a generic variable name of 'link' which collides with a 
+ standard (unistd.h) function that as of glibc 2.34 happens to be 
+ indirectly exposed in the namespace for this file.  Address this by
+ renaming the variable.
+Author: Steve Langasek <steve.langa...@ubuntu.com>
+Last-Update: 2022-01-24
+Forwarded: no
+
+Index: knxd-0.14.46/src/server/knxd_args.cpp
+===================================================================
+--- knxd-0.14.46.orig/src/server/knxd_args.cpp
++++ knxd-0.14.46/src/server/knxd_args.cpp
+@@ -68,13 +68,13 @@
+ } while(0)
+ 
+ IniData ini;
+-char link[99] = "@.";
++char link_target[99] = "@.";
+ void link_to(const char *arg)
+ {
+   char *p;
+-  ++*link;
+-  strcpy(link+2,arg);
+-  p = strchr(link+2,':');
++  ++*link_target;
++  strcpy(link_target+2,arg);
++  p = strchr(link_target+2,':');
+   if (p)
+     *p = 0;
+ }
+@@ -163,10 +163,10 @@
+       {
+         link_to(name);
+         ITER(i, more_args)
+-        (*ini[link])[i->first] = i->second;
+-        (*ini[link])["filter"] = name;
++        (*ini[link_target])[i->first] = i->second;
++        (*ini[link_target])["filter"] = name;
+         more_args.clear();
+-        filters.push_back(link);
++        filters.push_back(link_target);
+       }
+     else
+       filters.push_back(name);
+@@ -232,7 +232,7 @@
+ {
+   va_list apl;
+   va_start(apl, ap);
+-  (*ini[link])["driver"] = arg;
++  (*ini[link_target])["driver"] = arg;
+   char *pa = NULL;
+ 
+   while(ap)
+@@ -250,7 +250,7 @@
+       if (*pa == '!') // required-argument flag
+         pa++;
+       if (*ap) // skip empty arguments
+-        (*ini[link])[pa] = ap;
++        (*ini[link_target])[pa] = ap;
+       ap = p2;
+     }
+   if (pa != NULL)
+@@ -280,7 +280,7 @@
+   else if(!strcmp(arg,"iptn"))
+     {
+       driver_argsv("ipt",ap, 
"!ip-address","dest-port","src-port","nat-ip","data-port", NULL);
+-      (*ini[link])["nat"] = "true";
++      (*ini[link_target])["nat"] = "true";
+     }
+   else if(!strcmp(arg,"ft12") || !strcmp(arg,"ncn5120") || 
!strcmp(arg,"tpuarts") || !strcmp(arg,"ft12cemi") || !strcmp(arg,"tpuart"))
+     {
+@@ -556,18 +556,18 @@
+       if (arguments->want_server)
+         die("You need -S after -D/-T/-R");
+       link_to("unix");
+-      ADD((*ini["main"])["connections"], link);
+-      (*ini[link])["server"] = "knxd_unix";
+-      // (*ini[link])["driver"] = "knx-link";
++      ADD((*ini["main"])["connections"], link_target);
++      (*ini[link_target])["server"] = "knxd_unix";
++      // (*ini[link_target])["driver"] = "knx-link";
+       const char *name = OPT_ARG(arg,state,NULL);
+       if (name)
+         {
+-          (*ini[link])["path"] = name;
+-          (*ini[link])["systemd-ignore"] = "false";
++          (*ini[link_target])["path"] = name;
++          (*ini[link_target])["systemd-ignore"] = "false";
+         }
+       else
+-        (*ini[link])["systemd-ignore"] = "true";
+-      arguments->stack(link);
++        (*ini[link_target])["systemd-ignore"] = "true";
++      arguments->stack(link_target);
+     }
+     break;
+ 
+@@ -576,19 +576,19 @@
+       if (arguments->want_server)
+         die("You need -S after -D/-T/-R");
+       link_to("tcp");
+-      ADD((*ini["main"])["connections"], link);
+-      (*ini[link])["server"] = "knxd_tcp";
+-      // (*ini[link])["driver"] = "knx-link";
++      ADD((*ini["main"])["connections"], link_target);
++      (*ini[link_target])["server"] = "knxd_tcp";
++      // (*ini[link_target])["driver"] = "knx-link";
+       const char *port = OPT_ARG(arg,state,"");
+       if (*port && atoi(port) > 0)
+         {
+-          (*ini[link])["port"] = port;
+-          (*ini[link])["systemd-ignore"] = "false";
++          (*ini[link_target])["port"] = port;
++          (*ini[link_target])["systemd-ignore"] = "false";
+         }
+       else
+-        (*ini[link])["systemd-ignore"] = "true";
++        (*ini[link_target])["systemd-ignore"] = "true";
+ 
+-      arguments->stack(link);
++      arguments->stack(link_target);
+     }
+     break;
+ 
+@@ -635,8 +635,8 @@
+         die("You cannot apply flags to the group cache.");
+ 
+       link_to("cache");
+-      (*ini["main"])["cache"] = link;
+-      arguments->stack(link);
++      (*ini["main"])["cache"] = link_target;
++      arguments->stack(link_target);
+       break;
+     case OPT_FORCE_BROADCAST:
+       (*ini["main"])["force-broadcast"] = "true";
+@@ -675,12 +675,12 @@
+       if (arguments->want_server)
+         die("You need -S after -D/-T/-R");
+       link_to(arg);
+-      ADD((*ini["main"])["connections"], link);
++      ADD((*ini["main"])["connections"], link_target);
+       char *ap = strchr(arg,':');
+       if (ap)
+         *ap++ = '\0';
+       driver_args(arg,ap);
+-      arguments->stack(link);
++      arguments->stack(link_target);
+       break;
+     }
+     case 'B':
diff -Nru knxd-0.14.46/debian/patches/series knxd-0.14.46/debian/patches/series
--- knxd-0.14.46/debian/patches/series  1969-12-31 16:00:00.000000000 -0800
+++ knxd-0.14.46/debian/patches/series  2022-01-24 09:12:14.000000000 -0800
@@ -0,0 +1 @@
+glibc-2.34.patch

Reply via email to