Skip to content

Instantly share code, notes, and snippets.

@jperkin
Last active October 26, 2016 15:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jperkin/1e6c26cb605945cdc03402b61851c61b to your computer and use it in GitHub Desktop.
Save jperkin/1e6c26cb605945cdc03402b61851c61b to your computer and use it in GitHub Desktop.
diff --git a/mk/bsd.prefs.mk b/mk/bsd.prefs.mk
index 55516d1..f3f6662 100644
--- a/mk/bsd.prefs.mk
+++ b/mk/bsd.prefs.mk
@@ -712,8 +712,13 @@ _PKGSRC_USE_SSP= no
_PKGSRC_USE_SSP= yes
.endif
-# Enable cwrappers if requested unless we're building the wrappers themselves.
-.if ${USE_CWRAPPERS:tl} != "no" && empty(PKGPATH:Mpkgtools/cwrappers)
+# Enable cwrappers if not building the wrappers themselves, and if the user has
+# explicitly requested them, or if they haven't but the compiler/platform is
+# known to support them.
+.if empty(PKGPATH:Mpkgtools/cwrappers) && \
+ (${USE_CWRAPPERS:tl} == "yes" || \
+ (${USE_CWRAPPERS:tl} == "auto" && \
+ ${_OPSYS_SUPPORTS_CWRAPPERS:Uno} == "yes"))
_USE_CWRAPPERS= yes
.else
_USE_CWRAPPERS= no
diff --git a/mk/defaults/mk.conf b/mk/defaults/mk.conf
index 49c9d58..72d3086 100644
--- a/mk/defaults/mk.conf
+++ b/mk/defaults/mk.conf
@@ -12,11 +12,15 @@
# NOTE TO PEOPLE EDITING THIS FILE - USE LEADING SPACES, NOT LEADING TABS.
# ************************************************************************
-USE_CWRAPPERS?= no
-# build packages using the newer pkgtools/cwrappers infrastructure.
-# WARNING: Experimental!
-# Possible: yes, no
-# Default: no
+USE_CWRAPPERS?= auto
+# Build packages using the newer pkgtools/cwrappers infrastructure, which can
+# significantly speed up builds and use fewer resources. Some compiler and
+# platform combinations are not currently handled by cwrappers, so currently
+# the default is "auto" which enables cwrappers automatically if the platform
+# _OPSYS_SUPPORTS_CWRAPPERS variable is set to "yes".
+#
+# Possible: yes, no, auto
+# Default: auto (automatic detection, see above)
#ALLOW_VULNERABLE_PACKAGES=
# allow the user to build packages which are known to be vulnerable to
diff --git a/mk/platform/Darwin.mk b/mk/platform/Darwin.mk
index 5087a36..4e2d4f2 100644
--- a/mk/platform/Darwin.mk
+++ b/mk/platform/Darwin.mk
@@ -153,6 +153,8 @@ BUILDLINK_TRANSFORM+= rm:-Wl,--export-dynamic
BUILDLINK_TRANSFORM+= rm:-Wl,--gc-sections
BUILDLINK_TRANSFORM+= rm:-Wl,--no-undefined
+_OPSYS_SUPPORTS_CWRAPPERS= yes
+
_OPSYS_CAN_CHECK_SHLIBS= yes # check shared libraries using otool(1)
# OSX strip(1) tries to remove relocatable symbols and fails on certain
diff --git a/mk/platform/Linux.mk b/mk/platform/Linux.mk
index 3e1348f..09ae191 100644
--- a/mk/platform/Linux.mk
+++ b/mk/platform/Linux.mk
@@ -104,6 +104,8 @@ _USE_RPATH= yes # add rpath to LDFLAGS
_STRIPFLAG_CC?= ${_INSTALL_UNSTRIPPED:D:U-s} # cc(1) option to strip
_STRIPFLAG_INSTALL?= ${_INSTALL_UNSTRIPPED:D:U-s} # install(1) option to strip
+_OPSYS_SUPPORTS_CWRAPPERS= yes
+
_OPSYS_CAN_CHECK_SHLIBS= yes # use readelf in check/bsd.check-vars.mk
# check for maximum command line length and set it in configure's environment,
diff --git a/mk/platform/SunOS.mk b/mk/platform/SunOS.mk
index 5f5e159..d1863af 100644
--- a/mk/platform/SunOS.mk
+++ b/mk/platform/SunOS.mk
@@ -112,6 +112,11 @@ _OPSYS_SYSTEM_RPATH?= /lib${LIBABISUFFIX}:/usr/lib${LIBABISUFFIX}
_OPSYS_LIB_DIRS?= /lib${LIBABISUFFIX} /usr/lib${LIBABISUFFIX}
_OPSYS_INCLUDE_DIRS?= /usr/include
+# Sun Studio support is untested at this time, but would be strongly desired.
+.if ${PKGSRC_COMPILER} != "sunpro"
+_OPSYS_SUPPORTS_CWRAPPERS= yes
+.endif
+
# support FORTIFY (with GCC)
_OPSYS_SUPPORTS_FORTIFY=yes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment