From a4bd7c8f5d21a7434cb2dcd97873eb0a80c7e1bf Mon Sep 17 00:00:00 2001 From: Conrad Meyer Date: Fri, 5 Aug 2016 17:35:30 +0000 Subject: [PATCH] elfutils: Fix port build after recent basename() API break The previous basename() API was shadowing bugs anyway. This Linux-originated library assumes GNU basename(3) behavior. GNU basename(3) is non-destructive and non-allocating; it always returns a pointer into the original string. This library uses that behavior to do things like compare pointer results directly (the source path was already a basename) or subtract pointer values directly (compute the substring that constitutes dirname). Resolve the issue by aliasing all internal elfutils basename() invocations through an implementation of GNU basename(3) named "eu_basename." Build log highlighting the problem: http://beefy4.nyi.freebsd.org/data/head-amd64-default/p419462_s303652/logs/elfutils-0.163_6.log Approved by: bdrewery Differential Revision: https://reviews.freebsd.org/D7404 --- devel/elfutils/Makefile | 2 +- devel/elfutils/files/patch-lib_eu-config.h | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/devel/elfutils/Makefile b/devel/elfutils/Makefile index 9cc691c0796a..c6d71ff4fef6 100644 --- a/devel/elfutils/Makefile +++ b/devel/elfutils/Makefile @@ -3,7 +3,7 @@ PORTNAME= elfutils PORTVERSION= 0.163 -PORTREVISION= 6 +PORTREVISION= 7 CATEGORIES= devel MASTER_SITES= https://fedorahosted.org/releases/e/l/elfutils/${PORTVERSION}/ diff --git a/devel/elfutils/files/patch-lib_eu-config.h b/devel/elfutils/files/patch-lib_eu-config.h index 74377ed88304..e5943f68b3e9 100644 --- a/devel/elfutils/files/patch-lib_eu-config.h +++ b/devel/elfutils/files/patch-lib_eu-config.h @@ -1,6 +1,6 @@ --- lib/eu-config.h.orig 2015-06-11 11:38:55 UTC +++ lib/eu-config.h -@@ -187,4 +187,147 @@ asm (".section predict_data, \"aw\"; .pr +@@ -187,4 +187,167 @@ asm (".section predict_data, \"aw\"; .pr #endif @@ -57,6 +57,26 @@ + return (realpath(path, NULL)); +} + ++/* ++ * A GNU-like basename(). ++ * ++ * Unlike POSIX basename(3), this version never modifies its argument. If the ++ * argument ends in a slash, it returns the empty string. ++ */ ++static inline char * ++eu_basename(const char *path) ++{ ++ const char *slash; ++ ++ slash = strrchr(path, '/'); ++ if (slash != NULL) ++ slash++; ++ else ++ slash = path; ++ return (__DECONST(char *, slash)); ++} ++#define basename eu_basename ++ +#ifndef TEMP_FAILURE_RETRY +#define TEMP_FAILURE_RETRY(expr) ({ \ + long value; \