You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bugs@apr.apache.org by bu...@apache.org on 2009/09/13 06:47:08 UTC

DO NOT REPLY [Bug 47829] New: apr-config: CFLAGS should not include "-O2"

https://issues.apache.org/bugzilla/show_bug.cgi?id=47829

           Summary: apr-config: CFLAGS should not include "-O2"
           Product: APR
           Version: HEAD
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: minor
          Priority: P2
         Component: APR
        AssignedTo: bugs@apr.apache.org
        ReportedBy: nrc@cs.berkeley.edu


When I build apr 1.3.8 on OSX or Linux, "apr-1-config --cflags" yields:

% ./apr-1-config --cflags
 -g -O2

Why are either of these flags useful? "apr-config --help" notes that

"An application should use the results of --cflags, --cppflags, --includes, and
--ldflags in their build process."

Why should an application that links against apr-config include "-O2" in its
build process, just because apr was compiled that way?

This is an issue in practice, because "-O2" makes debugging harder (and
increases compile times, etc.). If an application that links against apr wants
to have a "debug" build mode, there are 3 options:

(1) Don't include "apr-1-config --cflags" in the application's CFLAGS, which is
potentially non-portable
(2) Manually strip "-O2" from apr's CFLAGS by text search, which is error-prone
and hacky

I think it would be better to limit "--cflags" to only include flags that
application programs should add to their CFLAGS in order to safely build
against APR.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@apr.apache.org
For additional commands, e-mail: bugs-help@apr.apache.org


DO NOT REPLY [Bug 47829] apr-config: CFLAGS should not include "-O2"

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47829

Joe Orton <jo...@redhat.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID

--- Comment #1 from Joe Orton <jo...@redhat.com> 2010-01-31 05:31:27 UTC ---
APR simply exports all the CFLAGS used during the build.  I think this is
reasonable and follows the principle of least surprise - apps built against APR
will be built using exactly the same CFLAGS as APR.  Sure, if you want your app
to be explicitly built without debugging symbols even if APR is, you will have
to manually strip out -g or whatever from CFLAGS.

It is generally hard/impossible for APR to know what CFLAGS are "safe" to
strip;  e.g. if any CFLAGS affected an ABI/API choice.   Stripping simply -g
and -O2 alone would not necessarily be correct, either; any compiler-specific
debugging-related flags might still pass through, e.g. -gdwarf-* etc.  It seems
possible that stripping -g alone might even break the build if a combination of
flags remained that the compiler fails for.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@apr.apache.org
For additional commands, e-mail: bugs-help@apr.apache.org