building llvm-gcc4 with a different target name

Hello,

I've put together a macports version of llvm and llvm-gcc4, but I've run into a problem with how gcc on the mac works. llvm-gcc4 creates an executable named:

/opt/local/bin/powerpc-apple-darwin8-gcc-4.0.1

Which happens to be the same executable in /usr/bin. Because I have /opt/local before /usr/bin, gcc ends up using llvm-gcc4 to build all my code. Most of the time this isn't a problem, but since llvm-gcc4 doesn't yet support all the flags of gcc 4 (such as the -compatibility_version flag flac uses when compiling), it can error out. Anyone know how can I build llvm-gcc4 so that it has a different exe name, or suggest a better way to do this?

If this will help, these are the options I'm using to build llvm-gcc4. It's in tcl, but it hopefully is straight forward enough:

# create a build directory and run out of there
worksrcdir build

pre-configure {
  file mkdir ${workpath}/build
}

# ${prefix} is where we install llvm, normally /opt/local
configure.cmd ../llvm-gcc4-${version}.source/configure

configure.args-append --enable-llvm=${prefix}/lib/llvm/obj \
                        --enable-languages=c,c++,objc,obj-c++ \
                        --libdir=${prefix}/lib/${name} \
                        --libexecdir=${prefix}/libexec/${name} \
                        --includedir=${prefix}/include/${name} \
                        --infodir=${prefix}/share/info \
                        --mandir=${prefix}/share/man \
                        --with-local-prefix=${prefix} \
                        --program-prefix=llvm- \
                        --disable-nls

# like rpm, install into a destroot before finally installing
destroot.destdir prefix=${destroot}${prefix} \
                        libdir=${destroot}${prefix}/lib/${name} \
                        libexecdir=${destroot}${prefix}/libexec/${name} \
                        includedir=${destroot}${prefix}/include/${name} \
                        infodir=${destroot}${prefix}/share/info \
                        mandir=${destroot}${prefix}/share/man

# if we're on a mac, follow the install rules
variant darwin {
  post-extract {
    system "rm -rf ${workpath}/llvm-gcc4-${version}.source/libstdc++-v3"
  }

  configure.args-append --with-gxx-include-dir=/usr/include/c++/4.0.0
}

# use the powerpc triple if on a powerpc
variant powerpc {
  set triple powerpc-apple-darwin8

  configure.env-append TRIPLE=${triple}
  configure.post_args --build=${triple} --host=${triple} --target=${triple}
}

# use the intel triple if on an intel
variant x86 {
  set triple i686-apple-darwin8

  configure.env-append TRIPLE=${triple} \
                       TARGETOPTIONS="--with-arch=nocona --with-tune=generic"
  configure.post_args --build=${triple} --host=${triple} --target=${triple}
}

Thanks,
-e

Pass "--program-prefix=llvm-" to the llvm-gcc configuration. This will cause the produced executables to be "llvm-gcc" and "llvm-g++" respectively.

--Owen

Erick Tryzelaar wrote:

Hello,

I've put together a macports version of llvm and llvm-gcc4, but I've run into a problem with how gcc on the mac works. llvm-gcc4 creates an executable named:

/opt/local/bin/powerpc-apple-darwin8-gcc-4.0.1

Which happens to be the same executable in /usr/bin. Because I have /opt/local before /usr/bin, gcc ends up using llvm-gcc4 to build all my code. Most of the time this isn't a problem, but since llvm-gcc4 doesn't yet support all the flags of gcc 4 (such as the -compatibility_version flag flac uses when compiling), it can error out. Anyone know how can I build llvm-gcc4 so that it has a different exe name, or suggest a better way to do this?

Just a bump as I haven't figured out how to get gcc's build system to generate the darwin target compiler named something like this:

/opt/local/bin/powerpc-apple-darwin8-llvm-gcc-4.0.1

Is this possible? Thanks again,

-e