<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/817f5a4fd9019a6c45a4dcf374d0d78b466f280c">https://github.com/macports/macports-base/commit/817f5a4fd9019a6c45a4dcf374d0d78b466f280c</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 817f5a4 Cache locations and versions of compilers
</span>817f5a4 is described below
<span style='display:block; white-space:pre;color:#808000;'>commit 817f5a4fd9019a6c45a4dcf374d0d78b466f280c
</span>Author: Joshua Root <jmr@macports.org>
AuthorDate: Sun May 5 14:55:14 2019 +1000
<span style='display:block; white-space:pre;color:#404040;'> Cache locations and versions of compilers
</span><span style='display:block; white-space:pre;color:#404040;'>
</span><span style='display:block; white-space:pre;color:#404040;'> This improves worst-case performance considerably. This is mainly
</span><span style='display:block; white-space:pre;color:#404040;'> because asking xcrun where a tool is takes a while when that tool is
</span><span style='display:block; white-space:pre;color:#404040;'> not present on the system, and we did this multiple times. In one test,
</span><span style='display:block; white-space:pre;color:#404040;'> parsing a single Portfile took 10 seconds, reduced to 0.5 by this
</span><span style='display:block; white-space:pre;color:#404040;'> change. The benefits are even greater when multiple Portfiles are
</span><span style='display:block; white-space:pre;color:#404040;'> parsed in a single invocation.
</span>---
src/macports1.0/macports.tcl | 67 +++++++++++++++++++++++++++++++++++++++++++
src/port1.0/portconfigure.tcl | 49 +++++++------------------------
2 files changed, 77 insertions(+), 39 deletions(-)
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/macports1.0/macports.tcl b/src/macports1.0/macports.tcl
</span><span style='display:block; white-space:pre;color:#808080;'>index d30a799..7ef9bf0 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/macports1.0/macports.tcl
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/macports1.0/macports.tcl
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -1470,6 +1470,11 @@ proc macports::worker_init {workername portpath porturl portbuildpath options va
</span> # archive_sites.conf handling
$workername alias get_archive_sites_conf_values macports::get_archive_sites_conf_values
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ # compiler version cache
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ $workername alias get_compiler_version macports::get_compiler_version
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # tool path cache
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ $workername alias get_tool_path macports::get_tool_path
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span> foreach opt $portinterp_options {
if {![info exists $opt]} {
global macports::$opt
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -5304,6 +5309,68 @@ proc macports::set_pingtime {host ms} {
</span> set ping_cache($host) [list $ms [clock seconds]]
}
<span style='display:block; white-space:pre;background:#e0ffe0;'>+# get the version of a compiler (memoized)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+proc macports::get_compiler_version {compiler} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ global macports::compiler_version_cache
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[info exists compiler_version_cache($compiler)]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return $compiler_version_cache($compiler)
</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;'>+ if {![file executable ${compiler}]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set compiler_version_cache($compiler) ""
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return ""
</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;'>+ switch [file tail ${compiler}] {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ clang {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set re {clang(?:_.*)?-([0-9.]+)}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ llvm-gcc-4.2 {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set re {LLVM build ([0-9.]+)}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ gcc-4.2 -
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ gcc-4.0 -
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ apple-gcc-4.2 {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set re {build ([0-9.]+)}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ default {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return -code error "don't know how to determine build number of compiler \"${compiler}\""
</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;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[catch {regexp ${re} [exec ${compiler} -v 2>@1] -> compiler_version}]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set compiler_version_cache($compiler) ""
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return ""
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {![info exists compiler_version]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return -code error "couldn't determine build number of compiler \"${compiler}\""
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set compiler_version_cache($compiler) $compiler_version
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return $compiler_version
</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;'>+# check availability and location of tool
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+proc macports::get_tool_path {tool} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ global macports::tool_path_cache
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[info exists tool_path_cache($tool)]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return $tool_path_cache($tool)
</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;'>+ # first try /usr/bin since this doesn't move around
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set toolpath "/usr/bin/${tool}"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {![file executable $toolpath]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # Use xcode's xcrun to find the named tool.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[catch {exec [findBinary xcrun $portutil::autoconf::xcrun_path] -find ${tool}} toolpath]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set toolpath ""
</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;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set tool_path_cache($tool) $toolpath
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return $toolpath
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span> # read and cache archive_sites.conf (called from port1.0 code)
proc macports::get_archive_sites_conf_values {} {
global macports::archive_sites_conf_values macports::autoconf::macports_conf_path
<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 4565edb..9628b97 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;'>@@ -972,31 +972,8 @@ proc portconfigure::get_mpi_wrapper {mpi compiler} {
</span> }
# utility procedure: get system compiler version by running it
proc compiler.command_line_tools_version {compiler} {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- switch ${compiler} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- clang {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set re {clang(?:_.*)?-([0-9.]+)}
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- llvm-gcc-4.2 {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set re {LLVM build ([0-9.]+)}
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- gcc-4.2 {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set re {build ([0-9.]+)}
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- gcc-4.0 -
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- apple-gcc-4.2 {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set re {build ([0-9.]+)}
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- default {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- return -code error "don't know how to determine build number of compiler \"${compiler}\""
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- }
</span> set cc [portconfigure::configure_get_compiler cc ${compiler}]
<span style='display:block; white-space:pre;background:#ffe0e0;'>- if {![file executable ${cc}]} return
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if {[catch {regexp ${re} [exec ${cc} -v 2>@1] -> compiler_version}]} return
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if {![info exists compiler_version]} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- return -code error "couldn't determine build number of compiler \"${compiler}\""
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- return ${compiler_version}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return [get_compiler_version ${cc}]
</span> }
# internal function to choose compiler fallback list based on platform
proc portconfigure::get_compiler_fallback {} {
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -1089,25 +1066,19 @@ proc portconfigure::get_fortran_fallback {} {
</span>
# Find a developer tool
proc portconfigure::find_developer_tool {name} {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- global developer_dir
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ global developer_dir
</span>
<span style='display:block; white-space:pre;background:#ffe0e0;'>- # first try /usr/bin since this doesn't move around
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set toolpath "/usr/bin/${name}"
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if {[file executable $toolpath]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set toolpath [get_tool_path $name]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {$toolpath ne ""} {
</span> return $toolpath
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- # Use xcode's xcrun to find the named tool.
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if {![catch {exec [findBinary xcrun $portutil::autoconf::xcrun_path] -find ${name}} toolpath]} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- return ${toolpath}
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- # If xcrun failed to find the tool, return a path from
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- # the developer_dir.
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- # The tool may not be there, but we'll leave it up to
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- # the invoking code to figure out that it doesn't have
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- # a valid compiler
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- return "${developer_dir}/usr/bin/${name}"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # If we failed to find the tool, return a path from
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # the developer_dir.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # The tool may not be there, but we'll leave it up to
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # the invoking code to figure out that it doesn't have
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # a valid compiler
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return "${developer_dir}/usr/bin/${name}"
</span> }
</pre><pre style='margin:0'>
</pre>