The release of Xcode 4.2 for Snow Leopard presents fink with both a problem
and an opportunity. The Xcode 4.2 SL release defaults /usr/bin/gcc and 
/usr/bin/g++
to the llvm-gcc-4.2 and llvm-g++-4.2 compilers respectively. This exposes fink 
10.6
to a slew of llvm-gcc bugs (many yet unknown). Fortunately, the clang3.0svn in
Xcode 4.2 on SL appears to be quite good and allows us to leverage the current
path-prefix-clang support in fink. The attached patch does this whenever a 
symlink
for llvm-gcc-4.2 is found for /usr/bin/gcc on 10.6. This patch allows fink
0.31.3 to cleanly bootstrap using clang/clang++ on 10.6 with Xcode 4.2 
installed.
   I will admit that the Xcode 4.2 release on SL is problematic because new 
copies
are no longer sold from the App Store. On the otherhand, it is freely available
from the App Store for users who previously purchased Xcode 4.0. With this in 
mind,
I would suggest we assume all users with Xcode 4.0 have access to 4.2 and that 
they
should upgrade to this version (or revert to Xcode 3.2.6). This would allow us 
to
focus on supporting clang in the Xcode 4.x releases and encourage unification of
any clang specific changes to info files between the 10.4 and 10.6 trees. It 
also
will likely accelerate the elimination of the unstable tree in 10.4 as any clang
specific changes are backported into 10.4.
               Jack
--- fink-0.31.3/perlmod/Fink/PkgVersion.pm.orig 2011-10-20 14:46:20.000000000 
-0400
+++ fink-0.31.3/perlmod/Fink/PkgVersion.pm      2011-10-20 17:20:07.000000000 
-0400
@@ -4868,7 +4868,7 @@
 
 =item ensure_clang_prefix
 
-       my $prefix_path = ensure_clang_prefix;
+       my $prefix_path = ensure_clang_prefix $arch;
 
 Ensures that a path-prefix directory exists to use clang compilers
 Returns the path to the resulting directory.
@@ -4876,6 +4876,8 @@
 =cut
 
 sub ensure_clang_prefix {
+       my $arch = shift;
+
        my $dir = "$basepath/var/lib/fink/path-prefix-clang";
        unless (-d $dir) {
                mkdir_p $dir or die "Path-prefix dir $dir cannot be created!\n";
@@ -4904,7 +4906,7 @@
 if [ "\$compiler" = "c++" -o "\$compiler" = "g++" ]; then
   compiler="clang++"
 fi
-exec \$compiler "\$@"
+exec \$compiler "-arch" "$arch" "\$@"
 EOF
                close GPP;
                chmod 0755, $gpp or die "Path-prefix file $gpp cannot be made 
executable!\n";
@@ -5227,15 +5229,22 @@
                        }
                        $pathprefix = ensure_gpp_prefix($vers);
                }
-               if ($config->param("Distribution") eq "10.6" || 
$config->param("Architecture") eq "x86_64") {
-                       # Use single-architecture compiler-wrapper on 10.6. Also
-                       # override on older 10.x (gcc3.3 & 10.4T not supported)
-                       $pathprefix = 
ensure_gpp106_prefix($config->param("Architecture"));
+               if (($config->param("Distribution") eq "10.6") || 
($config->param("Architecture") eq "x86_64")) {
+                       my $link = readlink('/usr/bin/gcc');
+                       if (($config->param("Distribution") eq "10.6") && 
($link eq "llvm-gcc-4.2")) {
+                               # Use clang for gcc/g++ on darwin10 when Xcode 
4.2 or
+                               # later is installed.
+                               $pathprefix = 
ensure_clang_prefix($config->param("Architecture"));
+                       } else {
+                               # Use single-architecture compiler-wrapper on 
10.6. Also
+                               # override on older 10.x (gcc3.3 & 10.4T not 
supported)
+                               $pathprefix = 
ensure_gpp106_prefix($config->param("Architecture"));
+                       }
                }
                if  ($config->param("Distribution") gt "10.6") {
                        # Use clang for gcc/g++ on darwin11 and later. Only
                        # x86_64 supported so can override single-arch wrappers.
-                       $pathprefix = ensure_clang_prefix();
+                       $pathprefix = 
ensure_clang_prefix($config->param("Architecture"));
                }
                $script_env{'PATH'} = "$pathprefix:" . $script_env{'PATH'};
        }
------------------------------------------------------------------------------
The demand for IT networking professionals continues to grow, and the
demand for specialized networking skills is growing even more rapidly.
Take a complimentary Learning@Cisco Self-Assessment and learn 
about Cisco certifications, training, and career opportunities. 
http://p.sf.net/sfu/cisco-dev2dev
_______________________________________________
Fink-devel mailing list
Fink-devel@lists.sourceforge.net
List archive:
http://news.gmane.org/gmane.os.apple.fink.devel
Subscription management:
https://lists.sourceforge.net/lists/listinfo/fink-devel

Reply via email to