bin/180985: clang 3.3 does not handle correctly -O option

Alexander Shikov alexander.shikoff at gmail.com
Thu Aug 1 13:30:00 UTC 2013


>Number:         180985
>Category:       bin
>Synopsis:       clang 3.3 does not handle correctly -O option
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Aug 01 13:30:00 UTC 2013
>Closed-Date:
>Last-Modified:
>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 at 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:
>Unformatted:


More information about the freebsd-bugs mailing list