Skip to contentSkip to conversation

package/ndisc6: fix for codesourcery compilation

PATCH New Vadym Kochan 2 participants 4 messages May 9, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/ndisc6: fix for codesourcery compilation

trace-{udp,tcp}.c uses BSD-style headers, it builds ok on some latest libc compilation because they use:

__extension__ union

but for example on codesourcery toolchain 4.x version it requires that __FAVOR_BSD is defined. So fix it by defining this define only for tcp/udp headers.

---
 ...x-compilation-for-codesourcery-toolc.patch | 46 +++++++++++++++++++
 1 file changed, 46 insertions(+)
 create mode 100644 package/ndisc6/0002-trace-udp-tcp-fix-compilation-for-codesourcery-toolc.patch
package/ndisc6/0002-trace-udp-tcp-fix-compilation-for-codesourcery-toolc.patch new file +46 -0
new file mode 100644
index 0000000000..58b7584b4f
@@ -0,0 +1,46 @@
+From f654332ff631bf31e12c65685fd504166c93ef7f Mon Sep 17 00:00:00 2001
+From: Vadym Kochan <[email protected]>
+Date: Sat, 9 May 2020 19:29:24 +0300
+Subject: [PATCH] trace-{udp,tcp}: fix compilation for codesourcery toolchain
+
+Use __FAVOR_BSD define to enable BSD-like tcp/udp headers only
+for this particular case. Looks like this is needed for some old
+gcc versions (4.x?) because modern libc implementations uses:
+
+    __extension__ union
+
+to use both headers variants.
+
+Signed-off-by: Vadym Kochan <[email protected]>
+---
+ src/trace-tcp.c | 1 +
+ src/trace-udp.c | 1 +
+ 2 files changed, 2 insertions(+)
+
+diff --git a/src/trace-tcp.c b/src/trace-tcp.c
+index 1b367ae..5d6ab8f 100644
+--- a/src/trace-tcp.c
++++ b/src/trace-tcp.c
+@@ -33,6 +33,7 @@
+ #include <unistd.h> // getpid()
+ #include <sys/socket.h> // SOCK_STREAM
+ #include <netinet/in.h>
++#define __FAVOR_BSD
+ #include <netinet/tcp.h>
+ 
+ #include "traceroute.h"
+diff --git a/src/trace-udp.c b/src/trace-udp.c
+index aa9364e..6b287ec 100644
+--- a/src/trace-udp.c
++++ b/src/trace-udp.c
+@@ -32,6 +32,7 @@
+ #include <sys/types.h>
+ #include <sys/socket.h> // SOCK_DGRAM
+ #include <netinet/in.h>
++#define __FAVOR_BSD
+ #include <netinet/udp.h>
+ 
+ #include "traceroute.h"
+-- 
+2.26.2
+
Signature · 1 line
2.26.2
#1 lore raw

PATCH 1/1 package/ndisc6: fix for codesourcery compilation

Quoted 5 lines · On Sat, 9 May 2020 20:05:03 +0300 Vadym Kochan <[email protected]> wrote:

trace-{udp,tcp}.c uses BSD-style headers, it builds ok on some latest libc compilation because they use:

__extension__ union

Quoted 7 lines

but for example on codesourcery toolchain 4.x version it requires that __FAVOR_BSD is defined. So fix it by defining this define only for tcp/udp headers.

Fixing issues for "codesourcery compilation" is wrong. What is being fixed is either a glibc-version related issue, or a gcc-version related issue. But we don't fix things for one specific toolchain.

Could you investigate a bit more, and reword the patch and commit log accordingly ?

Thanks a lot,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#2 lore raw

PATCH 1/1 package/ndisc6: fix for codesourcery compilation

Quoted 14 lines · Thomas Petazzoni
Quoted 11 lines · On Sat, 9 May 2020 20:05:03 +0300 Vadym Kochan <[email protected]> wrote:

trace-{udp,tcp}.c uses BSD-style headers, it builds ok on some latest libc compilation because they use:

__extension__ union

but for example on codesourcery toolchain 4.x version it requires that __FAVOR_BSD is defined. So fix it by defining this define only for tcp/udp headers.

Quoted 9 lines
Quoted 1 line

Fixing issues for "codesourcery compilation" is wrong. What is being fixed is either a glibc-version related issue, or a gcc-version related issue. But we don't fix things for one specific toolchain.

Could you investigate a bit more, and reword the patch and commit log accordingly ?

You are right, actually it was easier refer to codesourcery toolchain, but yes the issue is related to glibc implementation in this case. Will try to re-do the description.

#3 lore raw

PATCH 1/1 package/ndisc6: fix for codesourcery compilation

Quoted 21 lines · On Sat, May 09, 2020 at 09:24:52PM +0300, vadim4j at gmail.com wrote:
Quoted 20 lines · Thomas Petazzoni
Quoted 5 lines · On Sat, 9 May 2020 20:05:03 +0300 Vadym Kochan <[email protected]> wrote:

trace-{udp,tcp}.c uses BSD-style headers, it builds ok on some latest libc compilation because they use:

__extension__ union

Quoted 7 lines

but for example on codesourcery toolchain 4.x version it requires that __FAVOR_BSD is defined. So fix it by defining this define only for tcp/udp headers.

Fixing issues for "codesourcery compilation" is wrong. What is being fixed is either a glibc-version related issue, or a gcc-version related issue. But we don't fix things for one specific toolchain.

Quoted 7 lines
Quoted 3 lines

Could you investigate a bit more, and reword the patch and commit log accordingly ?

You are right, actually it was easier refer to codesourcery toolchain, but yes the issue is related to glibc implementation in this case. Will try to re-do the description.

I sent v2, and updated status in patchwork.

Regards,
Vadym Kochan