From owner-freebsd-ports@FreeBSD.ORG Mon Jan 9 18:23:00 2012 Return-Path: Delivered-To: freebsd-ports@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3700C106564A; Mon, 9 Jan 2012 18:23:00 +0000 (UTC) (envelope-from bf1783@googlemail.com) Received: from mail-we0-f182.google.com (mail-we0-f182.google.com [74.125.82.182]) by mx1.freebsd.org (Postfix) with ESMTP id 6EBE78FC12; Mon, 9 Jan 2012 18:22:59 +0000 (UTC) Received: by werb13 with SMTP id b13so4364221wer.13 for ; Mon, 09 Jan 2012 10:22:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=mime-version:reply-to:date:message-id:subject:from:to:content-type; bh=TCUBq5nXvkr8tbQELvDy6P6RMmibE6Jh/dN1jwoeCuk=; b=m0FO96owDSSY14CcghQDphrwijzdElaGUYPujPKvh6MyCvN7jHmQ7s97qvYXBo4gD9 jmmaCwiMiaZzsaDNDJMq8+nUcOHTlRJOK1a7iM84KXNvi+ESvk/Nqoi27wK8lfFRW4sn 4ReTepEfEQcASZLmcmXDWUQEicz1bk3jrG3iY= MIME-Version: 1.0 Received: by 10.216.136.132 with SMTP id w4mr7751861wei.53.1326133378327; Mon, 09 Jan 2012 10:22:58 -0800 (PST) Received: by 10.180.94.6 with HTTP; Mon, 9 Jan 2012 10:22:58 -0800 (PST) Date: Mon, 9 Jan 2012 18:22:58 +0000 Message-ID: From: "b. f." To: Wesley Shields , gerald@FreeBSD.org, freebsd-ports@FreeBSD.org Content-Type: text/plain; charset=ISO-8859-1 Cc: Subject: Re: USE_GCC and CC=clang X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: bf1783@gmail.com List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Jan 2012 18:23:00 -0000 > I'm trying to fix a port which absolutely will not build with clang, > since clang does not support the gcc extension used by this port. I set > USE_GCC=4.2+, which is the lowest version of GCC which will work, but it > doesn't properly override CC=clang. > > wxs at ack spamdyke % env CC=clang make test-gcc | grep -E "^(CC|USE_GCC)" > USE_GCC=4.2+ > CC=clang - CXX=c++ - CPP=cpp - CFLAGS="-O2 -pipe -fno-strict-aliasing" > wxs at ack spamdyke % > This problem only arises if the base compiler is gcc 4.2.x and USE_GCC=4.2+. Otherwise CC will be set to the appropriate gcc compiler. Since Gerald (who maintains ports/Mk/bsd.gcc.mk) is trying to retire lang/gcc42 anyway, it is not a good idea to set USE_GCC=4.2+ in a port. > I understand this is probably an acceptable behavior, since if the user > sets CC=clang they are explicitly asking to build with clang. However, > in the case of a port known to not work with clang, and more importantly > not able to be fixed, I was hoping there was a knob I could set that > would forcible override any compiler related environment variables which > may be set. I didn't find one, so I came up with this quick (and poorly > tested) patch to do so. The problem is due to a slight flaw in the implementation of the USE_GCC=4.2+ case, which will be obviated soon by the removal of this case. If in the meantime a change is made to bsd.gcc.mk, it should address this flaw directly -- by setting CC=gcc explicitly where needed, instead of relying upon the default setting of CC. Another knob is unnecessary. Note that changes to bsd.gcc.mk, good or bad, won't address the cases where a user sets CC on the command-line via "make .... CC= ...", or adds it to MAKE_ARGS, or sets CC in the environment, and then calls make with "-e" or "-E CC". So the right thing to do is to add something like: .if !empty(CC:M*clang*) IGNORE= : clang cannot be used to build this port .endif to the port Makefile, after the inclusion of bsd.port.options.mk or bsd.port.pre.mk (since a user may have set CC in Makefile.local, Makefile.inc, etc). Or, better yet, to patch the port so that it can be built with clang (which may have to be done anyway...). Regards, b.