ports/188678: benchmarks/bonnie++ Clang/libc++ compatibility patch

Matthew Rezny matthew at reztek.cz
Wed Apr 16 01:50:02 UTC 2014


>Number:         188678
>Category:       ports
>Synopsis:       benchmarks/bonnie++ Clang/libc++ compatibility patch
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Wed Apr 16 01:50:01 UTC 2014
>Closed-Date:
>Last-Modified:
>Originator:     Matthew Rezny
>Release:        10-STABLE
>Organization:
RezTek, s.r.o.
>Environment:
FreeBSD desktop.reztek 10.0-STABLE FreeBSD 10.0-STABLE #0 r264285: Thu Apr 10 01:49:39 CEST 2014     root at desktop.reztek:/usr/obj/usr/src/sys/DESKTOP  amd64
>Description:
bonnie++ currently has GCC=any in the Makefile. The history of the port indicates prior attempts to make it compatible with Clang, but problems with libc++ have prevented those efforts. I decided to dig in a little deeper.

The cause of the problem is the definition of min and max. They should come from the algorithm header instead of being defined directly. The configure script probes for algorithm, but the file port.h only checks for configure flags to indicate presence of algo or algo.h, falling back to defining min and max if neither of those are present. Worse, we had a patch that dropped all the checks in that file and just forced defining min and max. If we instead add recognition of the flag from configure for using the algorithm header to define min and max, then this port builds fine with Clang and libc++.

>How-To-Repeat:
Remove GCC=any from the Makefile
>Fix:
Use the HAVE_ALGORITHM result from configure script to #include <algorithm> in order to properly define min and max.

While I'm at it, move instances of "using namespace std;" to come after header includes to eliminate all the warnings about implicitly defining namespace std, and fix the definition of PRINTF_OFF_T to quash a printf format warning.

This patch does all that.


Patch attached with submission follows:

Index: benchmarks/bonnie++/Makefile
===================================================================
--- benchmarks/bonnie++/Makefile	(revision 350650)
+++ benchmarks/bonnie++/Makefile	(working copy)
@@ -14,7 +14,6 @@
 LICENSE=	GPLv2
 
 GNU_CONFIGURE=	yes
-USE_GCC=	any
 
 USES=	shebangfix
 SHEBANG_FILES=	bon_csv2txt.in
Index: benchmarks/bonnie++/files/patch-bonnie.h.in
===================================================================
--- benchmarks/bonnie++/files/patch-bonnie.h.in	(revision 0)
+++ benchmarks/bonnie++/files/patch-bonnie.h.in	(working copy)
@@ -0,0 +1,20 @@
+--- bonnie.h.in.orig    2009-08-21 18:45:50.068536643 +0000
++++ bonnie.h.in 2009-08-21 18:45:58.564755017 +0000
+@@ -1,8 +1,6 @@
+ #ifndef BONNIE
+ #define BONNIE
+ 
+-using namespace std;
+-
+ #define BON_VERSION "@version@"
+ #define CSV_VERSION "@csv_version@"
+ 
+@@ -12,6 +10,8 @@
+ #include <sys/stat.h>
+ #include <fcntl.h>
+ 
++using namespace std;
++
+ typedef FILE *PFILE;
+ 
+ #define SemKey 4711

Index: benchmarks/bonnie++/files/patch-duration.cpp
===================================================================
--- benchmarks/bonnie++/files/patch-duration.cpp	(revision 0)
+++ benchmarks/bonnie++/files/patch-duration.cpp	(working copy)
@@ -0,0 +1,17 @@
+--- duration.cpp.orig   2009-08-21 18:45:50.068536643 +0000
++++ duration.cpp        2009-08-21 18:45:58.564755017 +0000
+@@ -1,5 +1,3 @@
+-using namespace std;
+-
+ #include <stdlib.h>
+ 
+ #include "duration.h"
+@@ -20,6 +18,8 @@
+ #endif
+ #endif
+ 
++using namespace std;
++
+ Duration_Base::Duration_Base()
+  : m_start(0.0)
+  , m_max(0.0)

Index: benchmarks/bonnie++/files/patch-port.h.in
===================================================================
--- benchmarks/bonnie++/files/patch-port.h.in	(revision 350650)
+++ benchmarks/bonnie++/files/patch-port.h.in	(working copy)
@@ -1,21 +1,35 @@
 --- port.h.in.orig	2009-08-21 18:45:50.068536643 +0000
 +++ port.h.in	2009-08-21 18:45:58.564755017 +0000
-@@ -3,18 +3,8 @@
- 
+@@ -4,12 +4,12 @@
  #include "conf.h"
  
--#ifndef HAVE_MIN_MAX
+ #ifndef HAVE_MIN_MAX
 -#if defined(HAVE_ALGO_H) || defined(HAVE_ALGO)
 -#ifdef HAVE_ALGO
--#include <algo>
++#if defined(HAVE_ALGORITHM)
++#include <algorithm>
++#elif defined(HAVE_ALGO)
+ #include <algo>
 -#else
--#include <algo.h>
++#elif defined(HAVE_ALGO_H)
+ #include <algo.h>
 -#endif
--#else
+ #else
  #define min(XX,YY) ((XX) < (YY) ? (XX) : (YY))
  #define max(XX,YY) ((XX) > (YY) ? (XX) : (YY))
+@@ -19,14 +19,7 @@
+ @semun@
+ @bool@
+ @snprintf@
+-#ifndef _LARGEFILE64_SOURCE
+- at large_file@
 -#endif
+-#ifdef _LARGEFILE64_SOURCE
+-#define OFF_T_PRINTF "%lld"
+-#else
+-#define OFF_T_PRINTF "%d"
 -#endif
++#define OFF_T_PRINTF "%ld"
  
- @semun@
- @bool@
+ #if @true_false@
+ #define false 0
Index: benchmarks/bonnie++/files/patch-rand.h
===================================================================
--- benchmarks/bonnie++/files/patch-rand.h	(revision 0)
+++ benchmarks/bonnie++/files/patch-rand.h	(working copy)
@@ -0,0 +1,15 @@
+--- rand.h.orig 2009-08-21 18:45:50.068536643 +0000
++++ rand.h      2009-08-21 18:45:58.564755017 +0000
+@@ -1,11 +1,11 @@
+ #ifndef RAND_H
+ #define RAND_H
+ 
+-using namespace std;
+ #include "port.h"
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string>
++using namespace std;
+ 
+ class Rand
+ {



>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-ports-bugs mailing list