Bug 25179 - precedence of -fpie over -fpic
Summary: precedence of -fpie over -fpic
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: driver (show other bugs)
Version: 3.4.4
: P3 minor
Target Milestone: 4.8.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-11-30 10:13 UTC by Ralf Wildenhues
Modified: 2013-11-09 22:48 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2012-01-11 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ralf Wildenhues 2005-11-30 10:13:59 UTC
When both -fpie and -fpic are given on the command line, -fpie wins,
independent on the order of the arguments.  This is unfortunate, as
PIC objects are more widely usable.  It would be more useful to either
let the last one win, or let -fpic win over -fpie, from a usability
standpoint: for example, if -fpie were added to overall CFLAGS, and
those were used for both program objects and shared library objects,
current build rules for many packages would most likely still work.
It would've also made this patch unnecessary, as an aside:
http://lists.gnu.org/archive/html/libtool/2005-11/msg00093.html

Observed with gcc-3.4.4 and CVS HEAD as of before the switch to SVN.

Cheers, and keep up the good work,
Ralf
Comment 1 Richard Biener 2012-01-11 15:04:49 UTC
Hmm, I think they "combine" now:

  if (!opts->x_flag_opts_finished)
    {
      if (opts->x_flag_pie)
        opts->x_flag_pic = opts->x_flag_pie;
      if (opts->x_flag_pic && !opts->x_flag_pie)
        opts->x_flag_shlib = 1;
      opts->x_flag_opts_finished = true;
    }

So, is your issue fixed?
Comment 2 Andrew Pinski 2013-11-09 22:48:06 UTC
This has been fixed by:
2012-11-13  Ian Lance Taylor  <iant@google.com>

        * common.opt (fPIC, fPIE, fpic, fpie): Create a Negative loop such
        that any of these options disables the others.