patching config.guess or passing triplets

Jack Howarth howarth at
Sat Sep 12 18:06:26 PDT 2009

   I was until a couple days ago the maintainer of the gcc4x packages in
fink. Looking at your broken gcc44 package I noticed some major lapses in
logic that is fouling the build and the multilib. The current packaging
doesn't pass explicit --host,--target and --build triplets to configure
yet attempts to force the compiler to generate 64-bit code with -m64 on
the flags. This is never going to work even with config.guess is patched
because the operative decider of what the native code architecture is
should be the code generated by CC alone. Currently config.guess is broken
and misreports the architecture as i386-apple-darwin10 even when the
code execution and default code generation in gcc-4.2 is x86_64. I have
proposed a fixed config.guess to upstream...

which fixes this. This change has been added to the gcc44 ticket as a patch...

I am attempting to build this locally but am having some issues with this
Portfile not finding the build directory when used from my local ports directory.
Perhaps some else can test this. You will to add the patch...

and disable any attempt at forcing -m32 or -m64 onto the compiler...

# the generated compiler doesn't accept -arch
# if {[info exists build_arch] && ${os.platform} == "darwin"} {
#    if {(${os.arch} == "i386" && $build_arch == "i386") || (${os.arch} == "powerpc" && $build_arch == "ppc")} {
#        configure.env-append CFLAGS_FOR_TARGET="${configure.cflags}"
#    } elseif {(${os.arch} == "i386" && $build_arch == "x86_64") || (${os.arch} == "powerpc" && $build_arch == "ppc64")} {
#        configure.env-append CFLAGS_FOR_TARGET="${configure.cflags}"
#    } else {
#        pre-fetch {
#            return -code error "Cannot build $name for $build_arch"
#        }
#    }
#    configure.env-append CFLAGS_FOR_BUILD="${configure.cc_archflags} ${configure.cflags}"
#    configure.cc_archflags
#    configure.cxx_archflags
#    configure.objc_archflags

Alternatively you could do what I did in fink gcc44 with...

 darwinvers=`uname -r|cut -f1 -d.`
 if [ "%m" = "powerpc" ]; then
  ../gcc-%v/configure %c --build=%m-apple-darwin${darwinvers} --host=%m-apple-darwin${darwinvers} --target=%m-apple-darwin${darwinvers}
 elif [ "%m" = "i386" ]; then
  ../gcc-%v/configure %c --with-arch=nocona --with-tune=generic --build=i686-apple-darwin${darwinvers} --host=i686-apple-darwin${darwinvers} --target=i686-apple-darwin${darwinvers}
 elif [ "%m" = "x86_64" ]; then
  ../gcc-%v/configure %c --build=x86_64-apple-darwin${darwinvers} --host=x86_64-apple-darwin${darwinvers} --target=x86_64-apple-darwin${darwinvers}

and explicitly pass the triplets. However this shouldn't be necessary with the patched config.guess. Note
that this config.guess always tracks the code generation of CC so that...

[Macintosh-2:~/gcc-4.5-20090905] howarth% setenv CC gcc-4.2
[Macintosh-2:~/gcc-4.5-20090905] howarth% ./config.guess.proposed

[Macintosh-2:~/gcc-4.5-20090905] howarth% setenv CC gcc-4.0
[Macintosh-2:~/gcc-4.5-20090905] howarth% ./config.guess.proposed

[Macintosh-2:~/gcc-4.5-20090905] howarth% setenv CC "gcc-4.0 -m64"
[Macintosh-2:~/gcc-4.5-20090905] howarth% ./config.guess.proposed

[Macintosh-2:~/gcc-4.5-20090905] howarth% setenv CC "gcc-4.2 -m32"
[Macintosh-2:~/gcc-4.5-20090905] howarth% ./config.guess.proposed

Also it is essential to avoid decoupling the detected triplets in configure
from the code generation of the compiler. You risk attempting to compile
hard coded assembly language with the wrong architecture or simply have 
that code disabled unexpectedly. That applies to all packages.

More information about the macports-dev mailing list