How to call the compiler as if it were the linker

Ryan Schmidt ryandesign at macports.org
Wed Oct 1 23:11:09 PDT 2014


On Oct 2, 2014, at 12:59 AM, ryandesign at macports.org wrote:

> Revision
> 126021
> Author
> ryandesign at macports.org
> Date
> 2014-10-01 22:59:21 -0700 (Wed, 01 Oct 2014)
> Log Message
> 
> gr1c: new port, version 0.6.2 (#41653)
> Added Paths
> 
> 	• trunk/dports/math/gr1c/
> 	• trunk/dports/math/gr1c/Portfile
> 	• trunk/dports/math/gr1c/files/
> 	• trunk/dports/math/gr1c/files/patch-Makefile.diff
> 	• trunk/dports/math/gr1c/files/patch-tests-Makefile.diff

> +build.args          CC="${configure.cc} [get_canonical_archflags cc]" \
> +                    LD="${configure.cc} [get_canonical_archflags ld] -r" \

This port's Makefile sets:

> CC = gcc
> LD = ld -r

ld is designed to produce output in a single architecture only, so that doesn't work for universal builds. But when the compiler calls ld, it does so once for each architecture, then "lipo"s the results together.

I thought I would be clever and just replace "ld" with ${configure.cc} and that would work, and it did on Yosemite beta. On every previous system however it caused clang to experience an assertion failure, so I must not be doing this right.

What is the right way to invoke clang or gcc as if it were ld so that it does the multiple-ld-and-lipo dance for me?




More information about the macports-dev mailing list