[Momonga-devel.ja:02888] cachecc1


tamo です。

gcc ビルドも高速化できるキャッシュ機構の
cachecc1 というものを見付けました。
svn 鯖が止まっているようなので diff を添付します。

-- 
tamo
Property changes on: pkgs/cachecc1
___________________________________________________________________
Name: svn:ignore
   + BUILD
RPMS
SRPMS
SOURCES
rpmrc
rpmmacros
OmoiKondara.log*


Index: pkgs/cachecc1/cachecc1.spec
===================================================================
--- pkgs/cachecc1/cachecc1.spec	(revision 0)
+++ pkgs/cachecc1/cachecc1.spec	(revision 0)
@@ -0,0 +1,47 @@
+%global momorel 1
+
+Name: cachecc1
+Version: 0.3
+Release: %{momorel}m
+License: GPL
+Group: Development/Languages
+%NoSource 0 http://aleron.dl.sourceforge.net/sourceforge/cachecc1/%{name}-%{version}.tar.gz ffe7a9391af62d4153673a4ee4dfde2f
+BuildRoot: %{_tmppath}/%{name}-%{version}-root
+Summary: cachecc1 - a gcc cache
+Url: http://cachecc1.sourceforge.net/
+
+%description
+cachecc1 is a gcc cache.
+It can be compared with the well known ccache. It has some unique features:
+* it uses a LD_PRELOADed shared object to catch invocations to cc1, cc1plus
+  and as.
+* consequently, it transparently supports all build methods.
+* it can cache gcc bootstraps.
+* it can be combined with distcc to transparently distribute compilations.
+
+%prep
+%setup -q
+
+%build
+%make
+
+%install
+rm -rf %{buildroot}
+mkdir -p %{buildroot}%{_libdir}
+mkdir -p %{buildroot}%{_libexecdir}
+install -m 755 bin/cachecc1.so %{buildroot}%{_libdir}/cachecc1.so
+install -m 755 bin/distccwrap %{buildroot}%{_libexecdir}/distccwrap
+
+%clean
+rm -rf %{buildroot}
+
+%files
+%defattr(-,root,root)
+%{_libdir}/cachecc1.so
+%{_libexecdir}/distccwrap
+%doc COPYING README.*
+
+%changelog
+* Thu Nov 11 2004 TAKAHASHI Tamotsu <tamo>
+- (0.3-1m)
+- cachecc1 builds gcc much faster than ccache
Index: pkgs/cachecc1/TO.Alter
===================================================================
Index: tools/ChangeLog
===================================================================
--- tools/ChangeLog	(revision 3645)
+++ tools/ChangeLog	(working copy)
@@ -1,3 +1,9 @@
+Fri Nov 12 18:50:00 2004  TAKAHASHI Tamotsu <tamo momonga-linux org>
+	* OmoiKondara: support cachecc1
+	* OmoiKondara: modify English messages
+	* OmoiKondara: print "not installed" if a BuildPreReq is missing
+	* example.OmoiKondara: add USE_CACHECC1 and CACHECC1_DISTCCDIR
+
 Fri Aug 20 22:38:19 2004  Kazuhiko  <kazuhiko@xxxxxxxxxx>
 	* OmoiKondara: exit if local source is missing. exit if 'rpm
 	--test' fails.
Index: tools/example.OmoiKondara
===================================================================
--- tools/example.OmoiKondara	(revision 3645)
+++ tools/example.OmoiKondara	(working copy)
@@ -79,3 +79,11 @@
 #         tmpfsファイルシステムのディレクトリを指定するのを推奨.
 #         コメントアウトしておけば,これまで通りの動きになる.
 #WORKDIR	/tmp/OmoiKondara
+
+# cachecc1 (default: off)
+#USE_CACHECC1
+
+# How to use distcc with cachecc1:
+#         mkdir CACHECC1_DISTCCDIR
+#         ln -s /usr/libexec/distccwrap CACHECC1_DISTCCDIR
+#CACHECC1_DISTCCDIR /tmp/cachecc1
Index: tools/OmoiKondara
===================================================================
--- tools/OmoiKondara	(revision 3645)
+++ tools/OmoiKondara	(working copy)
@@ -118,6 +118,8 @@
   $MIRROR_FIRST       = false
   $SCANPACKAGES       = false
   $GLOBAL_NOCCACHE    = false
+  $GLOBAL_CACHECC1    = false
+  $CACHECC1_DISTCCDIR = "/nonexistent"
   $ARCH_DEP_PKGS_ONLY = false
   $IGNORE_REMOVE      = false
   $FTP_CMD            = ""
@@ -493,7 +495,7 @@
 	end
         str.gsub!( /%\{\!?\?.+?\}/, res )
       else
-      	raise "Can not expand macros in line: `#{str}'"
+      	raise "Failed to expand macro(s): `#{str}'"
       end
     end
     str
@@ -753,6 +755,7 @@
     if $ENABLE_DISTCC then #and $DISTCC_HOSTS.length > 1 then
       ENV["DISTCC_VERBOSE"] = "1" if $DISTCC_VERBOSE
       ENV["DISTCC_HOSTS"] = $DISTCC_HOSTS.join(' ')
+      ENV["CACHECC1_DISTCCDIR"] = $CACHECC1_DISTCCDIR
     end
     if $DEBUG_FLAG then
       `grep -v macrofiles ../rpmrc.debug > rpmrc`
@@ -850,6 +853,16 @@
           $DISPLAY = s.join " "
         when "URL_ALIAS"
           $URL_ALIAS[Regexp.compile(s.first)] = s.last
+        when "USE_CACHECC1"
+          $GLOBAL_CACHECC1 = true
+        when "CACHECC1_DISTCCDIR"
+          $CACHECC1_DISTCCDIR = s.shift
+          if not File.directory?($CACHECC1_DISTCCDIR) then
+            $stderr.puts "WARNING: invalid CACHECC1_DISTCCDIR"
+          end
+          if not File.executable?("#{$CACHECC1_DISTCCDIR}/distccwrap") then
+            $stderr.puts "WARNING: invalid CACHECC1_DISTCCDIR: no distccwrap"
+          end
         when "DISTCC_HOST"
           $DISTCC_HOSTS.push s.last if not $DISTCC_HOSTS.include?(s.last)
         when "DISTCC_VERBOSE"
@@ -1015,7 +1028,7 @@
     brs = $DEPGRAPH.db.specs[name].buildRequires
     return  if brs.nil?
     brs.each do |req|
-      puts "#{name} is build requires #{req}:" if $VERBOSEOUT
+      puts "#{name} needs #{req} installed to build:" if $VERBOSEOUT
 
       flag = false
       if $SYSTEM_PROVIDES.has_name?(req.name) then
@@ -1023,24 +1036,27 @@
 
         provs.each do |prov|
           if $VERBOSEOUT then
-            print "    try check #{prov} ..."
+            print "    checking whether #{prov} is sufficient ..."
             STDOUT.flush
           end
           flag = resolved?(req, prov)
           break if flag
         end
+
+        if flag then
+          puts " YES" if $VERBOSEOUT
+          next
+        else
+          puts " NO" if $VERBOSEOUT
+        end
+      else
+          puts "    not installed" if $VERBOSEOUT
       end
 
-      if flag then
-        puts " YES" if $VERBOSEOUT
-        next
-      else
-        puts " NO" if $VERBOSEOUT
-        $DEPGRAPH.db.packages[req.name].each do |a|
-          spec = $DEPGRAPH.db.specs[a.spec]
-          if build_and_install(req.name, '-Uvh', spec.name) == 4 then
-            return 4
-          end
+      $DEPGRAPH.db.packages[req.name].each do |a|
+        spec = $DEPGRAPH.db.specs[a.spec]
+        if build_and_install(req.name, '-Uvh', spec.name) == 4 then
+          return 4
         end
       end
     end # brs.each do |req|
@@ -1192,6 +1208,19 @@
         ENV['PATH'] = ENV['PATH'].split(':').select{|a| a !~ %r!/usr/libexec/ccache!}.join(':')
       end
     end
+    if $GLOBAL_CACHECC1 then
+      if File.exist?("#{pkg}/NO.CACHECC1") or
+          File.exist?("#{pkg}/NO.CCACHE") then
+        ENV['LD_PRELOAD'] = ENV['LD_PRELOAD'].scan(/\w+/){|a| a !~ %r!^/usr/lib/cachecc1\.so$!}.join(' ')
+      else
+        if ENV['LD_PRELOAD'] !~ /cachecc1\.so/ && `rpm -q cachecc1 2>/dev/null` =~ /^cachecc1/ then
+          ENV['LD_PRELOAD'] = "/usr/lib/cachecc1.so #{ENV['LD_PRELOAD']}"
+        end
+        if !ENV['CACHECC1_DIR'] then
+          ENV['CACHECC1_DIR'] = "#{ENV['HOME']}/.cachecc1"
+        end
+      end
+    end
     if Dir.glob("#{pkg}/SRPM.ONLY").length != 0 then
       $SRPM_ONLY = true
       $RPMOPT = "-bs"
@@ -1407,6 +1436,7 @@
   ["-v", "--verbose",      GetoptLong::NO_ARGUMENT],
   ["-G", "--debug",        GetoptLong::NO_ARGUMENT],
   ["-C", "--noccache",     GetoptLong::NO_ARGUMENT],
+  ["-1", "--cachecc1",     GetoptLong::NO_ARGUMENT],
   ["-M", "--mirrorfirst",  GetoptLong::NO_ARGUMENT],
   ["-D", "--distcc",       GetoptLong::NO_ARGUMENT],
   ["-O", "--orphan",       GetoptLong::NO_ARGUMENT],
@@ -1434,6 +1464,7 @@
   -v, --verbose           verbose mode
   -G, --debug             enable debug flag
   -C, --noccache          no ccache
+  -1, --cachecc1          use cachecc1
   -M, --mirrorfirst       download from mirror first
   -D, --distcc            enable to use distcc
   -O, --orphan            build Orphan package, too
@@ -1481,6 +1512,8 @@
       $DEBUG_FLAG = true
     when "-C"
       $GLOBAL_NOCCACHE = true
+    when "-1"
+      $GLOBAL_CACHECC1 = true
     when "-M"
       $MIRROR_FIRST = true
     when "-D"
@@ -1526,7 +1559,7 @@
 end
 
 if not $NOSTRICT then
-  print "checking system provides ..."
+  print "reading RPM database to see what is installed ..."
   STDOUT.flush
   begin
     rpmdb = RPM::DB.open