1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-12-23 04:23:08 +00:00

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
This commit is contained in:
Conrad Meyer 2016-08-05 17:35:30 +00:00
parent fbf8ca0628
commit a4bd7c8f5d
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=419697
2 changed files with 22 additions and 2 deletions

View File

@ -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}/

View File

@ -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; \