[GHC] #15848: ghc builds cbits with -fPIC even when -fPIC is not passed to ghc on linux

GHC ghc-devs at haskell.org
Fri Nov 2 18:35:05 UTC 2018


#15848: ghc builds cbits with -fPIC even when -fPIC is not passed to ghc on linux
-------------------------------------+-------------------------------------
        Reporter:  watashi           |                Owner:  watashi
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Driver            |              Version:  8.7
      Resolution:                    |             Keywords:
Operating System:  Linux             |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:  #15847, #12759    |  Differential Rev(s):  Phab:D5288
       Wiki Page:                    |
-------------------------------------+-------------------------------------
Changes (by watashi):

 * owner:  (none) => watashi
 * differential:   => Phab:D5288
 * related:  #15847 => #15847, #12759


Old description:

> ghc assumes that on linux, C compiler (e.g. gcc) will build non-PIC
> object code when no `-fPIC` is passed. But this is no longer true for
> recent gcc version on some distributions. e.g.
>
> {{{
> $ uname -a
> Linux watashi-arch32 4.18.5-arch1-1.0-ARCH #1 SMP PREEMPT Tue Aug 28
> 20:45:30 CEST 2018 i686 GNU/Linux
> $ gcc --version
> gcc (GCC) 7.3.1 20180312
> $ touch dummy.c
> $ gcc -Q -v dummy.c 2>&1 | grep PIC
> options enabled:  -fPIC -fPIE -faggressive-loop-optimizations
> }}}
>
> We need pass `-fno-PIC` explicitly just like `-no-pie`.
>
> In particular, this results in 300+ ext-interp related tests to fail on
> i386 when built with a gcc that has `-fPIC` on by default, as we don't
> support loading non-PIC .o built from .c on i386. (See #15847, fix this
> bug will mitigate #15847)

New description:

 ghc assumes that on linux, C compiler (e.g. gcc) will build non-PIC object
 code when no `-fPIC` is passed. But this is no longer true for recent gcc
 version on some distributions. e.g.

 {{{
 $ uname -a
 Linux watashi-arch32 4.18.5-arch1-1.0-ARCH #1 SMP PREEMPT Tue Aug 28
 20:45:30 CEST 2018 i686 GNU/Linux
 $ gcc --version
 gcc (GCC) 7.3.1 20180312
 $ touch dummy.c
 $ gcc -Q -v dummy.c 2>&1 | grep PIC
 options enabled:  -fPIC -fPIE -faggressive-loop-optimizations
 }}}

 We need pass `-fno-PIC` explicitly just like we have done for `-no-pie`
 (See #12759)

 In particular, this results in 300+ ext-interp related tests to fail on
 i386 when built with a gcc that has `-fPIC` on by default, as we don't
 support loading non-PIC .o built from .c on i386. (See #15847, fix this
 bug will mitigate #15847)

--

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15848#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list