Skip to content

Commit

Permalink
Use -dumpversion instead of -dumpfullversion and handle simple gcc ve…
Browse files Browse the repository at this point in the history
…rsions correctly. i.e. gcc-8 instead of gcc 8.3.1. Fixes #410.
  • Loading branch information
swatanabe committed Apr 1, 2019
1 parent ae68202 commit 5fbba3a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 28 deletions.
2 changes: 1 addition & 1 deletion src/tools/common.jam
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,7 @@ local rule toolset-tag ( name : type ? : property-set )
case tru64cxx* : tag += tru ;
case vacpp* : tag += xlc ;
}
local version = [ MATCH "<toolset.*version>([0123456789]+)[.]([0123456789]*)"
local version = [ MATCH "<toolset.*version>([0123456789]+)[.]?([0123456789]*)"
: $(properties) ] ;
# For historical reasons, vc6.0 and vc7.0 use different naming.
if $(tag) = vc
Expand Down
59 changes: 32 additions & 27 deletions src/tools/gcc.jam
Original file line number Diff line number Diff line change
Expand Up @@ -181,31 +181,27 @@ rule init ( version ? : command * : options * : requirement * )
tool-command-string = $(tool-command-string:J=" ") ;
local tool-version = [ dump-full-version
$(tool-command-string) ] ;
if $(tool-version) != $(version)
# Permit a match between a two-digit version specified by the
# user (e.g. 4.4) and a 3-digit version reported by gcc.
# Since only two digits are present in the binary name
# anyway, insisting that user specify the 3-digit version
# when configuring Boost.Build, while it is not required on
# the command line, would be strange.
local versionl = [ regex.split $(version) "[.]" ] ;
local tool-versionl = [ regex.split $(tool-version) "[.]" ] ;
if ! ( $(versionl[1]) = $(tool-versionl[1]) &&
$(versionl[2]:E=$(tool-versionl[2])) = $(tool-versionl[2]) &&
$(versionl[3]:E=$(tool-versionl[3])) = $(tool-versionl[3]) )
{
# Permit a match between a two-digit version specified by the
# user (e.g. 4.4) and a 3-digit version reported by gcc.
# Since only two digits are present in the binary name
# anyway, insisting that user specify the 3-digit version
# when configuring Boost.Build, while it is not required on
# the command line, would be strange.
local stripped = [ MATCH "^([0-9]+\.[0-9]+).*" :
$(tool-version) ] ;
if $(stripped) != $(version)
{
import errors ;
errors.error toolset gcc "initialization:"
: version '$(version)' requested but
'g++-$(version)' not found and version
'$(tool-version)' of default '$(tool-command)'
does not match
: initialized from [ errors.nearest-user-location ]
;
tool-command = ;
}
# Use full 3-digit version to be compatible with the
# 'using gcc ;' case
version = $(tool-version) ;
import errors ;
errors.error toolset gcc "initialization:"
: version '$(version)' requested but
'g++-$(version)' not found and version
'$(tool-version)' of default '$(tool-command)'
does not match
: initialized from [ errors.nearest-user-location ]
;
tool-command = ;
}
}
else
Expand Down Expand Up @@ -263,7 +259,7 @@ rule init ( version ? : command * : options * : requirement * )
{
local machine = [ MATCH "^([^ ]+)" :
[ SHELL "$(command-string) -dumpmachine" ] ] ;
version ?= [ dump-full-version $(command-string) ] ;
version ?= [ dump-version $(command-string) ] ;
switch $(machine:L)
{
case *mingw* : flavor ?= mingw ;
Expand Down Expand Up @@ -376,6 +372,15 @@ local rule dump-full-version ( command-string )
[ SHELL "$(command-string) -dumpfullversion -dumpversion" ] ] ;
}

local rule dump-version ( command-string )
{
# -dumpfullversion is only supported for gcc 7+.
# Passing both options works, as the first one that's
# recognized will be used.
return [ MATCH "^([0-9.]+)" :
[ SHELL "$(command-string) -dumpversion" ] ] ;
}

# Uses -print-prog-name to get the name of the tool.
# Converts the path to native form if using cygwin.
rule .get-prog-name ( command-string : tool : flavor ? )
Expand Down Expand Up @@ -494,8 +499,8 @@ local rule compile-link-flags ( * )
local rule init-cxxstd-flags ( condition * : version )
{
local std ;
if [ version-ge $(version) : 8.0 ] { std = 2a ; }
else if [ version-ge $(version) : 5.1 ] { std = 1z ; }
if [ version-ge $(version) : 8 ] { std = 2a ; }
else if [ version-ge $(version) : 5 ] { std = 1z ; }
else if [ version-ge $(version) : 4.8 ] { std = 1y ; }
else if [ version-ge $(version) : 4.7 ] { std = 11 ; }
else if [ version-ge $(version) : 3.3 ] { std = 98 ; }
Expand Down

0 comments on commit 5fbba3a

Please sign in to comment.