From nobody@FreeBSD.org  Thu Aug  1 13:23:04 2013
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1])
	(using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by hub.freebsd.org (Postfix) with ESMTP id AFB8F85C
	for <freebsd-gnats-submit@FreeBSD.org>; Thu,  1 Aug 2013 13:23:04 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from oldred.freebsd.org (oldred.freebsd.org [8.8.178.121])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.freebsd.org (Postfix) with ESMTPS id 8539B2283
	for <freebsd-gnats-submit@FreeBSD.org>; Thu,  1 Aug 2013 13:23:04 +0000 (UTC)
Received: from oldred.freebsd.org ([127.0.1.6])
	by oldred.freebsd.org (8.14.5/8.14.7) with ESMTP id r71DN3pG006899
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 1 Aug 2013 13:23:03 GMT
	(envelope-from nobody@oldred.freebsd.org)
Received: (from nobody@localhost)
	by oldred.freebsd.org (8.14.5/8.14.5/Submit) id r71DN3Kx006896;
	Thu, 1 Aug 2013 13:23:03 GMT
	(envelope-from nobody)
Message-Id: <201308011323.r71DN3Kx006896@oldred.freebsd.org>
Date: Thu, 1 Aug 2013 13:23:03 GMT
From: Alexander Shikov <alexander.shikoff@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: clang 3.3 does not handle correctly -O option
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         180985
>Category:       bin
>Synopsis:       clang(1): clang 3.3 does not handle correctly -O option
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    dim
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Aug 01 13:30:00 UTC 2013
>Closed-Date:    Fri Aug 02 05:25:32 UTC 2013
>Last-Modified:  Fri Aug 02 05:25:32 UTC 2013
>Originator:     Alexander Shikov
>Release:        FreeBSD 10.0-CURRENT i386
>Organization:
>Environment:
FreeBSD crete.itcons.net.ua 10.0-CURRENT FreeBSD 10.0-CURRENT #1 r253613: Wed Jul 24 19:17:04 EEST 2013     root@crete.itcons.net.ua:/usr/obj/usr/src/sys/CRETE  i386
FreeBSD clang version 3.3 (tags/RELEASE_33/final 183502) 20130610
Target: i386-unknown-freebsd10.0
Thread model: posix

>Description:
clang 3.3 has a problem with handling -O option. This may lead to errors when compiling certain software from ports tree.

For example, because of these problem configure script of lang/python27 port incorrectly checks support of -OPT:Olevel compiler option:
# less www.freebsd.org/cgi/query-pr.cgi?pr=ports/174525
[...]
configure:6161: checking whether cc accepts -OPT:Olimit=0
configure:6179: cc -OPT:Olimit=0 -c -O2 -pipe -march=pentium4 -fno-strict-aliasing -I/usr/local/include/pth  conftest.c >&5
configure:6179: $? = 0
configure:6189: result: yes

Thus, check succeeds, and after python27 installation, 'python2.7-config --cflags' command output includes -OPT:Olimit=0. But actually neither gcc, nor clang do not support this option.

Among consequences of this issue there are problem with building some ports which depend on python with GCC compiler, for example configure script of editors/libreoffice with WITH_GCC=yes knob set fails with error:
configure:21136: checking Python.h usability
configure:21136: gcc46 -c -O2 -pipe -march=pentium4 -Wl,-rpath=/usr/local/lib/gcc46 -DLDAP_DEPRECATED -fno-strict-aliasing -I/usr/local/include -I/usr/local/include/python2.7 -I/usr/local/include/python2.7 -fno-strict-aliasing -OPT:Olimit=0 -O2 -pipe -march=pentium4 -fno-strict-aliasing -DNDEBUG -O2 -pipe -march=pentium4 -fno-strict-aliasing -I/usr/local/include/pth conftest.c >&5
cc1: error: argument to '-O' should be a non-negative integer

>How-To-Repeat:
# clang -OPT:Olevel=0 -c conftest.c || echo $?
error: invalid integral value 'PT:Olevel=0' in '-OPT:Olevel=0'
error: invalid integral value 'PT:Olevel=0' in '-OPT:Olevel=0'
1
- fails

# clang -O2 -OPT:Olevel=0 -c conftest.c || echo $?
error: invalid integral value 'PT:Olevel=0' in '-OPT:Olevel=0'
error: invalid integral value 'PT:Olevel=0' in '-OPT:Olevel=0'
1
- fails

# clang -OPT:Olevel=0 -O2 -c conftest.c && echo $?
0
- works, but should not.
>Fix:


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->dim 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Fri Aug 2 03:00:32 UTC 2013 
Responsible-Changed-Why:  
Over to maintainer. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=180985 
State-Changed-From-To: open->closed 
State-Changed-By: dim 
State-Changed-When: Fri Aug 2 05:22:21 UTC 2013 
State-Changed-Why:  
Please report this bug upstream instead: http://llvm.org/bugs/ 

The python problem should be fixed in the python port(s) for now, for 
example with this (almost two years old!) patch: 

http://www.andric.com/freebsd/ports/lang__python27-1.diff 

http://www.freebsd.org/cgi/query-pr.cgi?pr=180985 
>Unformatted:
