<pre style='margin:0'>
Joshua Root (jmroot) pushed a commit to branch master
in repository macports-base.
</pre>
<p><a href="https://github.com/macports/macports-base/commit/a2b49dc8b28c9b37726e9833bbd67e62ae811089">https://github.com/macports/macports-base/commit/a2b49dc8b28c9b37726e9833bbd67e62ae811089</a></p>
<pre style="white-space: pre; background: #F8F8F8">The following commit(s) were added to refs/heads/master by this push:
<span style='display:block; white-space:pre;color:#404040;'> new a2b49dc Cache result of configure_get_default_compiler
</span>a2b49dc is described below
<span style='display:block; white-space:pre;color:#808000;'>commit a2b49dc8b28c9b37726e9833bbd67e62ae811089
</span>Author: Joshua Root <jmr@macports.org>
AuthorDate: Wed Jul 31 14:24:26 2019 +1000
<span style='display:block; white-space:pre;color:#404040;'> Cache result of configure_get_default_compiler
</span><span style='display:block; white-space:pre;color:#404040;'>
</span><span style='display:block; white-space:pre;color:#404040;'> This seems to give a modest performance improvement since it was getting
</span><span style='display:block; white-space:pre;color:#404040;'> evaluated over 10 times just to parse any portfile.
</span><span style='display:block; white-space:pre;color:#404040;'>
</span><span style='display:block; white-space:pre;color:#404040;'> Also remove some unneeded uses of subst.
</span>---
src/port1.0/portconfigure.tcl | 42 ++++++++++++++++++++++++++++++------------
1 file changed, 30 insertions(+), 12 deletions(-)
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/port1.0/portconfigure.tcl b/src/port1.0/portconfigure.tcl
</span><span style='display:block; white-space:pre;color:#808080;'>index de8be99..63d579a 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/port1.0/portconfigure.tcl
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/port1.0/portconfigure.tcl
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -606,8 +606,28 @@ proc portconfigure::compiler_is_port {compiler} {
</span> return [expr {[portconfigure::compiler_port_name ${compiler}] ne ""}]
}
<span style='display:block; white-space:pre;background:#e0ffe0;'>+# configure_get_default_compiler is fairly expensive, so cache the result
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+set ::portconfigure::recompute_default_compiler 1
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+set ::portconfigure::cached_default_compiler {}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+# changing these options will invalidate the cache
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+foreach varname {compiler.whitelist compiler.fallback compiler.blacklist
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ compiler.c_standard compiler.cxx_standard compiler.openmp_version
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ compiler.mpi compiler.thread_local_storage configure.cxx_stdlib} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ trace add variable $varname write portconfigure::recompute_default_compiler_proc
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+proc portconfigure::recompute_default_compiler_proc {varname unused op} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set ::portconfigure::recompute_default_compiler 1
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span> # internal function to determine the default compiler
proc portconfigure::configure_get_default_compiler {} {
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {!$::portconfigure::recompute_default_compiler} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return $::portconfigure::cached_default_compiler
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set ::portconfigure::recompute_default_compiler 0
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span> if {[option compiler.whitelist] ne ""} {
set search_list [option compiler.whitelist]
} else {
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -625,23 +645,23 @@ proc portconfigure::configure_get_default_compiler {} {
</span> ([file executable [configure_get_compiler cc $compiler]] ||
[compiler_is_port $compiler])
} then {
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ set ::portconfigure::cached_default_compiler $compiler
</span> return $compiler
}
}
ui_warn "All compilers are either blacklisted or unavailable; defaulting to first fallback option"
<span style='display:block; white-space:pre;background:#ffe0e0;'>- return [lindex [option compiler.fallback] 0]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set ::portconfigure::cached_default_compiler [lindex [option compiler.fallback] 0]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return $::portconfigure::cached_default_compiler
</span> }
# internal function to determine the Fortran compiler
proc portconfigure::configure_get_fortran_compiler {} {
global configure.compiler
<span style='display:block; white-space:pre;background:#ffe0e0;'>- set compiler [subst ${configure.compiler}]
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if {[portconfigure::configure_get_compiler fc ${compiler}] ne ""} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- return ${compiler}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[portconfigure::configure_get_compiler fc ${configure.compiler}] ne ""} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return ${configure.compiler}
</span> }
<span style='display:block; white-space:pre;background:#ffe0e0;'>- set search_list [option compiler.fortran_fallback]
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- foreach compiler $search_list {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ foreach compiler [option compiler.fortran_fallback] {
</span> set allowed yes
foreach pattern [option compiler.blacklist] {
if {[string match $pattern $compiler]} {
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -1272,14 +1292,12 @@ proc portconfigure::add_automatic_compiler_dependencies {} {
</span> return
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- # The default value requires substitution before use.
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set compiler [subst ${configure.compiler}]
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if {[compiler_is_port $compiler]} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- ui_debug "Chosen compiler ${compiler} is provided by a port, adding dependency"
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- portconfigure::add_compiler_port_dependencies ${compiler}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[compiler_is_port ${configure.compiler}]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ui_debug "Chosen compiler ${configure.compiler} is provided by a port, adding dependency"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ portconfigure::add_compiler_port_dependencies ${configure.compiler}
</span> }
<span style='display:block; white-space:pre;background:#ffe0e0;'>- if {[option compiler.require_fortran] && [portconfigure::configure_get_compiler fc ${compiler}] eq ""} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[option compiler.require_fortran] && [portconfigure::configure_get_compiler fc ${configure.compiler}] eq ""} {
</span> # Fortran is required, but compiler does not provide it
ui_debug "Adding Fortran compiler dependency"
portconfigure::add_compiler_port_dependencies [portconfigure::configure_get_fortran_compiler]
</pre><pre style='margin:0'>
</pre>