ports/132294: [PATCH] lang/ruby18: Add option to build with Profile-Guided Optimization
Mario Sergio Fujikawa Ferreira
lioux at FreeBSD.org
Wed Mar 4 00:10:04 UTC 2009
>Number: 132294
>Category: ports
>Synopsis: [PATCH] lang/ruby18: Add option to build with Profile-Guided Optimization
>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 Mar 04 00:10:02 UTC 2009
>Closed-Date:
>Last-Modified:
>Originator: Mario Sergio Fujikawa Ferreira
>Release: FreeBSD 7.1-STABLE i386
>Organization:
>Environment:
System: FreeBSD exxodus.fedaykin.here 7.1-STABLE FreeBSD 7.1-STABLE #57: Tue Feb 24 03:51:58 BRT 2009
>Description:
- Add WITH_PGO to build with Profile-Guided Optimization
Port maintainer (stas at FreeBSD.org) is cc'd.
Generated with FreeBSD Port Tools 0.77
>How-To-Repeat:
>Fix:
--- ruby+pgo-1.8.7.72_1,1.patch begins here ---
Index: Makefile
===================================================================
RCS file: /home/pcvs/ports/lang/ruby18/Makefile,v
retrieving revision 1.140
diff -d -u -u -r1.140 Makefile
--- Makefile 12 Feb 2009 17:54:27 -0000 1.140
+++ Makefile 3 Mar 2009 23:59:58 -0000
@@ -38,6 +38,7 @@
ONIGURUMA "Build with oniguruma regular expressions lib" off \
GCPATCH "Build with GC performance statistics collector" off \
IPV6 "Enable IPv6 support" on \
+ PGO "Enable Profile-Guided Optimization" off \
RDOC "Build and install Rdoc indexes" off \
DEBUG "Compile-in debug info" off
@@ -57,6 +58,10 @@
CFLAGS+= ${PTHREAD_CFLAGS} # Keep this, else ruby will fail to load
LDFLAGS+= ${PTHREAD_LIBS} # libraries dependent op libpthread.
+.if defined(WITH_PGO)
+PKGNAMESUFFIX:= ${PKGNAMESUFFIX}+pgo
+.endif
+
.if defined(WITH_PTHREADS)
CONFIGURE_ARGS+=--enable-pthread
PKGNAMESUFFIX:= ${PKGNAMESUFFIX}+pthreads
@@ -98,8 +103,14 @@
CONFIGURE_ARGS+= --enable-ipv6
.endif
+.if defined(WITH_PGO)
+CONFIGURE_ENV= CFLAGS="${CFLAGS} -fprofile-generate" \
+ LDFLAGS="-fprofile-generate" \
+ LIBS="${LDFLAGS}"
+.else
CONFIGURE_ENV= CFLAGS="${CFLAGS}" \
LIBS="${LDFLAGS}"
+.endif
.if ${RUBY_VER} == ${RUBY_DEFAULT_VER}
MLINKS= ${RUBY_NAME}.1 ruby.1
@@ -170,6 +181,13 @@
cd ${WRKSRC}/ && ${PATCH} -p0 < ${PATCHDIR}/extrapatch-oniguruma-reggnu.c
.endif
+.if defined(WITH_PGO)
+.if target(pre-build)
+.error Makefile error since pre-build target has already been defined
+.endif
+pre-build: pgo
+.endif
+
post-build:
#
# Hack to allow modules to be installed into separate PREFIX and/or under user
@@ -321,4 +339,38 @@
(cd ${WRKSRC}/rubyspec && git clone git://github.com/rubyspec/mspec.git)
(cd ${WRKSRC}/rubyspec/rubyspec && env PATH=${WRKSRC}/rubyspec/mspec/bin:${PATH} mspec -t ${PREFIX}/bin/ruby${RUBY_SUFFIX})
+.if defined(WITH_PGO)
+pgo: pgo-pre-build pgo-build pgo-run pgo-post-run pgo-clean
+
+pgo-pre-build:
+ @${FIND} ${BUILD_WRKSRC} -type f -name Makefile -exec \
+ ${REINPLACE_CMD} -E \
+ -e 's,^(((C|LD)FLAGS|LDSHARED|ldflags)[[:space:]]*=.*)-fprofile-generate,\1,' \
+ -e 's,^(CFLAGS[[:space:]]*=.*)-fprofile-use,\1,' \
+ -e 's,^(((C|LD)FLAGS|LDSHARED|ldflags)[[:space:]]*=.*)$$,\1 -fprofile-generate,' \
+ {} \;
+
+pgo-build:
+ @(cd ${BUILD_WRKSRC}; ${SETENV} ${MAKE_ENV} ${MAKE} ${MAKE_FLAGS} ${MAKEFILE} ${MAKE_ARGS} ${ALL_TARGET})
+
+pgo-run: test
+# Check everything to generate profiling information.
+# We will ignore any errors if test target works
+ @-(cd ${BUILD_WRKSRC}; ${MAKE} check)
+
+pgo-post-run:
+ @${FIND} ${BUILD_WRKSRC} -type f -name Makefile -exec \
+ ${REINPLACE_CMD} -E \
+ -e 's,^(((C|LD)FLAGS|LDSHARED|ldflags)[[:space:]]*=.*)-fprofile-generate,\1,' \
+ -e 's,^(CFLAGS[[:space:]]*=.*)-fprofile-use,\1,' \
+ -e 's,^(CFLAGS[[:space:]]*=.*)$$,\1 -fprofile-use,' \
+ {} \;
+ @${REINPLACE_CMD} -E \
+ -e 's,-fprofile-generate,-fprofile-use,g' \
+ ${CONFIGURE_WRKSRC}/config.status
+
+pgo-clean:
+ @(cd ${BUILD_WRKSRC}; ${MAKE} clean)
+.endif # if defined(WITH_PGO)
+
.include <bsd.port.post.mk>
--- ruby+pgo-1.8.7.72_1,1.patch ends here ---
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-ports-bugs
mailing list