Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r71304 - trunk/tools/build/v2/tools
From: blelbach_at_[hidden]
Date: 2011-04-15 21:42:28


Author: wash
Date: 2011-04-15 21:42:28 EDT (Fri, 15 Apr 2011)
New Revision: 71304
URL: http://svn.boost.org/trac/boost/changeset/71304

Log:
Fix PCH support on clang-linux.

Text files modified:
   trunk/tools/build/v2/tools/clang-linux.jam | 218 +++++++++++++++++++++------------------
   1 files changed, 117 insertions(+), 101 deletions(-)

Modified: trunk/tools/build/v2/tools/clang-linux.jam
==============================================================================
--- trunk/tools/build/v2/tools/clang-linux.jam (original)
+++ trunk/tools/build/v2/tools/clang-linux.jam 2011-04-15 21:42:28 EDT (Fri, 15 Apr 2011)
@@ -1,5 +1,5 @@
-# Copyright (c) 2003 Michael Stevens
-# Copyright (c) 2011 Bryce Lelbach
+# Copyright (c) 2003 Michael Stevens
+# Copyright (c) 2010-2011 Bryce Lelbach (blelbach_at_[hidden], maintainer)
 #
 # Use, modification and distribution is subject to the Boost Software
 # License Version 1.0. (See accompanying file LICENSE_1_0.txt or
@@ -20,64 +20,60 @@
 feature.extend-subfeature toolset clang : platform : linux ;
 
 toolset.inherit-generators clang-linux
- <toolset>clang <toolset-clang:platform>linux : gcc
- : gcc.mingw.link gcc.mingw.link.dll gcc.cygwin.link gcc.cygwin.link.dll gcc.compile.c.pch gcc.compile.c++.pch ;
+ <toolset>clang <toolset-clang:platform>linux : gcc
+ : gcc.mingw.link gcc.mingw.link.dll gcc.cygwin.link gcc.cygwin.link.dll ;
 generators.override clang-linux.prebuilt : builtin.lib-generator ;
 generators.override clang-linux.prebuilt : builtin.prebuilt ;
 generators.override clang-linux.searched-lib-generator : searched-lib-generator ;
 
 # Override default do-nothing generators.
-# FIXME: disabled for now
-#generators.override clang-linux.compile.c.pch : pch.default-c-pch-generator ;
-#generators.override clang-linux.compile.c++.pch : pch.default-cpp-pch-generator ;
+generators.override clang-linux.compile.c.pch : pch.default-c-pch-generator ;
+generators.override clang-linux.compile.c++.pch : pch.default-cpp-pch-generator ;
  
-#type.set-generated-target-suffix PCH : <toolset>clang <toolset-clang:platform>linux : pchc ;
+type.set-generated-target-suffix PCH
+ : <toolset>clang <toolset-clang:platform>linux : pth ;
 
 toolset.inherit-rules clang-linux : gcc ;
 toolset.inherit-flags clang-linux : gcc
- : <inlining>off <inlining>on <inlining>full
- <optimization>space <optimization>speed
- <warnings>off <warnings>all <warnings>on
- ;
+ : <inlining>off <inlining>on <inlining>full
+ <optimization>space <optimization>speed
+ <warnings>off <warnings>all <warnings>on ;
         
-if [ MATCH (--debug-configuration) : [ modules.peek : ARGV ] ]
-{
- .debug-configuration = true ;
+if [ MATCH (--debug-configuration) : [ modules.peek : ARGV ] ] {
+ .debug-configuration = true ;
 }
                        
-# Initializes the clang-linux toolset
-# version in optional
-# name (default clang++) is used to invoke the specified clanglinux complier
-# compile and link options allow you to specify addition command line options for each version
-rule init ( version ? : command * : options * )
-{
- command = [ common.get-invocation-command clang-linux : clang++
- : $(command) ] ;
+rule init ( version ? : command * : options * ) {
+ command = [ common.get-invocation-command clang-linux : clang++
+ : $(command) ] ;
                 
- # Determine the version
- local command-string = $(command:J=" ") ;
- if $(command)
- {
- version ?= [ MATCH "^([0-9.]+)"
- : [ SHELL "$(command-string) -dumpversion" ] ] ;
- }
+ # Determine the version
+ local command-string = $(command:J=" ") ;
 
- local condition = [ common.check-init-parameters clang-linux
- : version $(version) ] ;
-
- common.handle-options clang-linux : $(condition) : $(command) : $(options) ;
+ if $(command) {
+ version ?= [ MATCH "version ([0-9.]+)"
+ : [ SHELL "$(command-string) --version" ] ] ;
+ }
 
- gcc.init-link-flags clang-linux gnu $(condition) ;
+ local condition = [ common.check-init-parameters clang-linux
+ : version $(version) ] ;
     
+ common.handle-options clang-linux : $(condition) : $(command) : $(options) ;
+
+ gcc.init-link-flags clang-linux gnu $(condition) ;
 }
 
-SPACE = " " ;
+###############################################################################
+# Flags
+
+toolset.flags clang-linux.compile OPTIONS <cflags> ;
+toolset.flags clang-linux.compile OPTIONS <cxxflags> ;
 
-# Declare flags and action for compilation.
 toolset.flags clang-linux.compile OPTIONS <optimization>off : ;
 toolset.flags clang-linux.compile OPTIONS <optimization>speed : -O3 ;
 toolset.flags clang-linux.compile OPTIONS <optimization>space : -Os ;
 
+# note: clang silently ignores some of these inlining options
 toolset.flags clang-linux.compile OPTIONS <inlining>off : -fno-inline ;
 toolset.flags clang-linux.compile OPTIONS <inlining>on : -Wno-inline ;
 toolset.flags clang-linux.compile OPTIONS <inlining>full : -finline-functions -Wno-inline ;
@@ -88,93 +84,113 @@
 toolset.flags clang-linux.compile OPTIONS <warnings-as-errors>on : -Werror ;
 
 toolset.flags clang-linux.compile OPTIONS <debug-symbols>on : -g ;
-toolset.flags clang-linux.compile OPTIONS <profiling>on : ;
+toolset.flags clang-linux.compile OPTIONS <profiling>on : -pg ;
 toolset.flags clang-linux.compile OPTIONS <rtti>off : -fno-rtti ;
 
-rule compile.c++ ( targets * : sources * : properties * )
-{
- gcc.setup-threading $(targets) : $(sources) : $(properties) ;
- gcc.setup-fpic $(targets) : $(sources) : $(properties) ;
- gcc.setup-address-model $(targets) : $(sources) : $(properties) ;
-# DEPENDS $(<) : [ on $(<) return $(PCH_FILE) ] ;
+###############################################################################
+# C and C++ compilation
+
+rule compile.c++ ( targets * : sources * : properties * ) {
+ gcc.setup-threading $(targets) : $(sources) : $(properties) ;
+ gcc.setup-fpic $(targets) : $(sources) : $(properties) ;
+ gcc.setup-address-model $(targets) : $(sources) : $(properties) ;
+
+ local pth-file = [ on $(<) return $(PCH_FILE) ] ;
+
+ if $(pth-file) {
+ DEPENDS $(<) : $(pth-file) ;
+ compile.c++.with-pch $(targets) : $(sources) ;
+ }
+ else {
+ compile.c++.without-pth $(targets) : $(sources) ;
+ }
 }
 
-#actions compile.c++ bind PCH_FILE
-actions compile.c++
+actions compile.c++.without-pth {
+ "$(CONFIG_COMMAND)" -c -x c++ $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -o "$(<)" "$(>)"
+}
+
+actions compile.c++.with-pch bind PCH_FILE
 {
-# "$(CONFIG_COMMAND)" -c -x c++ $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -Xclang -include-pch -Xclang "$(PCH_FILE)" -c -o "$(<)" "$(>)"
- "$(CONFIG_COMMAND)" -c -x c++ $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)"
+ "$(CONFIG_COMMAND)" -c -x c++ $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -Xclang -include-pth -Xclang "$(PCH_FILE)" -o "$(<)" "$(>)"
 }
 
 rule compile.c ( targets * : sources * : properties * )
 {
- gcc.setup-threading $(targets) : $(sources) : $(properties) ;
- gcc.setup-fpic $(targets) : $(sources) : $(properties) ;
- gcc.setup-address-model $(targets) : $(sources) : $(properties) ;
-# DEPENDS $(<) : [ on $(<) return $(PCH_FILE) ] ;
+ gcc.setup-threading $(targets) : $(sources) : $(properties) ;
+ gcc.setup-fpic $(targets) : $(sources) : $(properties) ;
+ gcc.setup-address-model $(targets) : $(sources) : $(properties) ;
+
+ local pth-file = [ on $(<) return $(PCH_FILE) ] ;
+
+ if $(pth-file) {
+ DEPENDS $(<) : $(pth-file) ;
+ compile.c.with-pch $(targets) : $(sources) ;
+ }
+ else {
+ compile.c.without-pth $(targets) : $(sources) ;
+ }
 }
 
-#actions compile.c bind PCH_FILE
-actions compile.c
+actions compile.c.without-pth
 {
-# "$(CONFIG_COMMAND)" -c -x c $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -Xclang -include-pch -Xclang "$(PCH_FILE)" -c -o "$(<)" "$(>)"
- "$(CONFIG_COMMAND)" -c -x c $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)"
+ "$(CONFIG_COMMAND)" -c -x c $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)"
 }
 
-#rule compile.c++.pch ( targets * : sources * : properties * )
-#{
-# gcc.setup-threading $(targets) : $(sources) : $(properties) ;
-# gcc.setup-fpic $(targets) : $(sources) : $(properties) ;
-# gcc.setup-address-model $(targets) : $(sources) : $(properties) ;
-#}
-
-# Compiling a pch first deletes any existing *.pchc file, as Clang's compiler
-# won't over-write an existing pch: instead it creates filename$1.pchc, filename$2.pchc
-# etc - which appear not to do anything except take up disk space :-(
-
-#actions compile.c++.pch
-#{
-# rm -f "$(<)" && "$(CONFIG_COMMAND)" -x c++-header $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -Xclang -emit-pch -o "$(<)" "$(>)"
-#}
-
-#rule compile.c.pch ( targets * : sources * : properties * )
-#{
-# gcc.setup-threading $(targets) : $(sources) : $(properties) ;
-# gcc.setup-fpic $(targets) : $(sources) : $(properties) ;
-# gcc.setup-address-model $(targets) : $(sources) : $(properties) ;
-#}
-
-#actions compile.c.pch
-#{
-# rm -f "$(<)" && "$(CONFIG_COMMAND)" -x c-header $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -Xclang -emit-pch -o "$(<)" "$(>)"
-#}
-
-rule link ( targets * : sources * : properties * )
+actions compile.c.with-pch bind PCH_FILE
 {
- gcc.setup-threading $(targets) : $(sources) : $(properties) ;
- gcc.setup-address-model $(targets) : $(sources) : $(properties) ;
- SPACE on $(targets) = " " ;
- JAM_SEMAPHORE on $(targets) = <s>gcc-link-semaphore ;
+ "$(CONFIG_COMMAND)" -c -x c $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -Xclang -include-pth -Xclang "$(PCH_FILE)" -c -o "$(<)" "$(>)"
 }
 
-actions link bind LIBRARIES
-{
- "$(CONFIG_COMMAND)" -L"$(LINKPATH)" -Wl,-R$(SPACE)-Wl,"$(RPATH)" -Wl,-rpath-link$(SPACE)-Wl,"$(RPATH_LINK)" -o "$(<)" "$(>)" "$(LIBRARIES)" -l$(FINDLIBS-SA) -l$(FINDLIBS-ST) $(OPTIONS) $(USER_OPTIONS)
+###############################################################################
+# PCH emission
+
+rule compile.c++.pch ( targets * : sources * : properties * ) {
+ gcc.setup-threading $(targets) : $(sources) : $(properties) ;
+ gcc.setup-fpic $(targets) : $(sources) : $(properties) ;
+ gcc.setup-address-model $(targets) : $(sources) : $(properties) ;
 }
 
-rule link.dll ( targets * : sources * : properties * )
-{
- gcc.setup-threading $(targets) : $(sources) : $(properties) ;
- gcc.setup-address-model $(targets) : $(sources) : $(properties) ;
- SPACE on $(targets) = " " ;
- JAM_SEMAPHORE on $(targets) = <s>gcc-link-semaphore ;
+actions compile.c++.pch {
+ rm -f "$(<)" && "$(CONFIG_COMMAND)" -x c++-header $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -Xclang -emit-pth -o "$(<)" "$(>)"
 }
 
-# Differ from 'link' above only by -shared.
-actions link.dll bind LIBRARIES
+rule compile.c.pch ( targets * : sources * : properties * ) {
+ gcc.setup-threading $(targets) : $(sources) : $(properties) ;
+ gcc.setup-fpic $(targets) : $(sources) : $(properties) ;
+ gcc.setup-address-model $(targets) : $(sources) : $(properties) ;
+}
+
+actions compile.c.pch
 {
- "$(CONFIG_COMMAND)" -L"$(LINKPATH)" -Wl,-R$(SPACE)-Wl,"$(RPATH)" -o "$(<)" -Wl,-soname$(SPACE)-Wl,$(<[1]:D=) -shared "$(>)" "$(LIBRARIES)" -l$(FINDLIBS-SA) -l$(FINDLIBS-ST) $(OPTIONS) $(USER_OPTIONS)
+ rm -f "$(<)" && "$(CONFIG_COMMAND)" -x c-header $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -Xclang -emit-pth -o "$(<)" "$(>)"
 }
 
+###############################################################################
+# Linking
 
+SPACE = " " ;
+
+rule link ( targets * : sources * : properties * ) {
+ gcc.setup-threading $(targets) : $(sources) : $(properties) ;
+ gcc.setup-address-model $(targets) : $(sources) : $(properties) ;
+ SPACE on $(targets) = " " ;
+ JAM_SEMAPHORE on $(targets) = <s>clang-linux-link-semaphore ;
+}
+
+actions link bind LIBRARIES {
+ "$(CONFIG_COMMAND)" -L"$(LINKPATH)" -Wl,-R$(SPACE)-Wl,"$(RPATH)" -Wl,-rpath-link$(SPACE)-Wl,"$(RPATH_LINK)" -o "$(<)" "$(>)" "$(LIBRARIES)" -l$(FINDLIBS-SA) -l$(FINDLIBS-ST) $(OPTIONS) $(USER_OPTIONS)
+}
+
+rule link.dll ( targets * : sources * : properties * ) {
+ gcc.setup-threading $(targets) : $(sources) : $(properties) ;
+ gcc.setup-address-model $(targets) : $(sources) : $(properties) ;
+ SPACE on $(targets) = " " ;
+ JAM_SEMAPHORE on $(targets) = <s>clang-linux-link-semaphore ;
+}
+
+# Differ from 'link' above only by -shared.
+actions link.dll bind LIBRARIES {
+ "$(CONFIG_COMMAND)" -L"$(LINKPATH)" -Wl,-R$(SPACE)-Wl,"$(RPATH)" -o "$(<)" -Wl,-soname$(SPACE)-Wl,$(<[1]:D=) -shared "$(>)" "$(LIBRARIES)" -l$(FINDLIBS-SA) -l$(FINDLIBS-ST) $(OPTIONS) $(USER_OPTIONS)
+}
 


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk