This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Don't build 32-bit libatomic with -march=i486 on x86-64
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Uros Bizjak <ubizjak at gmail dot com>
- Cc: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 19 Apr 2016 11:36:04 -0700
- Subject: Re: [PATCH] Don't build 32-bit libatomic with -march=i486 on x86-64
- Authentication-results: sourceware.org; auth=none
- References: <20160419150735 dot GA7668 at intel dot com> <CAFULd4ZV0jkjmgyH5HY_-BExB10YDtkXh4uL4_ObkVABU74PbA at mail dot gmail dot com> <CAMe9rOqZ1=kjTRqoxBJQkeowgo9U1Nqjs212=_1YVNQuWewRWg at mail dot gmail dot com> <CAFULd4YRzFzq96E8pDh4_iake6e-dXoF=aPJqKEeskx0VuoBnw at mail dot gmail dot com> <CAMe9rOpWiPAkMJrYz2fXYE95uUjmH7GTVS-fosn3oEx=-p_94w at mail dot gmail dot com> <CAFULd4bi3P3oGH1-KOHJ4uvPba9QR7t0sCd7Fu1-Yki4BZqs6w at mail dot gmail dot com>
On Tue, Apr 19, 2016 at 11:30 AM, Uros Bizjak <ubizjak@gmail.com> wrote:
> On Tue, Apr 19, 2016 at 8:24 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>> On Tue, Apr 19, 2016 at 11:18 AM, Uros Bizjak <ubizjak@gmail.com> wrote:
>>> On Tue, Apr 19, 2016 at 8:08 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>>>> On Tue, Apr 19, 2016 at 8:45 AM, Uros Bizjak <ubizjak@gmail.com> wrote:
>>>>> On Tue, Apr 19, 2016 at 5:07 PM, H.J. Lu <hongjiu.lu@intel.com> wrote:
>>>>>> Gcc uses the same -march= for both -m32 and -m64 on x86-64 unless
>>>>>> --with-arch-32= is used. There is no need for -march=i486 to compile
>>>>>> 32-bit libatomic on x86-64.
>>>>>>
>>>>>> Tested on x86-64. OK for trunk?
>>>>>>
>>>>>> H.J.
>>>>>> ---
>>>>>> PR target/70454
>>>>>> * configure.tgt (XCFLAGS): Don't add -march=i486 to compile
>>>>>> 32-bit x86 target library on x86-64.
>>>>>> ---
>>>>>> libatomic/configure.tgt | 10 ++--------
>>>>>> 1 file changed, 2 insertions(+), 8 deletions(-)
>>>>>>
>>>>>> diff --git a/libatomic/configure.tgt b/libatomic/configure.tgt
>>>>>> index c5470d7..bbb93fc 100644
>>>>>> --- a/libatomic/configure.tgt
>>>>>> +++ b/libatomic/configure.tgt
>>>>>> @@ -81,14 +81,8 @@ case "${target_cpu}" in
>>>>>> try_ifunc=yes
>>>>>> ;;
>>>>>> x86_64)
>>>>>> - case " ${CC} ${CFLAGS} " in
>>>>>> - *" -m32 "*)
>>>>>> - XCFLAGS="${XCFLAGS} -march=i486 -mtune=generic"
>>>>>> - XCFLAGS="${XCFLAGS} -fomit-frame-pointer"
>>>>>> - ;;
>>>>>> - *)
>>>>>> - ;;
>>>>>> - esac
>>>>>> + # Since 64-bit arch > i486, we can use the same -march= to build
>>>>>> + # both 32-bit and 64-bit target libraries.
>>>>>> ARCH=x86
>>>>>> # ??? Detect when -mcx16 is already enabled.
>>>>>> try_ifunc=yes
>>>>>> --
>>>>>> 2.5.5
>>>>>>
>>>>>
>>>>> No, this is wrong. My build with default options defaults to i386. So,
>>>>> the difference between
>>>>>
>>>>
>>>> How was your GCC configured? Did you use
>>>>
>>>> --with-arch_32=i386
>>>
>>> Nope, just:
>>>
>>> ~/gcc-svn/trunk/configure
>>>
>>
>> $ /ssd/uros/gcc-build/gcc/cc1 -E -dM -m32 hello.c > aaa
>>
>> I don't think cc1 is supposed to be used directly. Can you use gcc
>> driver instead, like
>>
>> $ /ssd/uros/gcc-build/gcc/xgcc -B/ssd/uros/gcc-build/gcc/ -E -dM -m32 hello.c
>
> This works, since the driver passes:
>
> COLLECT_GCC_OPTIONS='-B' '/ssd/uros/gcc-build/gcc/' '-E' '-dM' '-m32'
> '-mtune=generic' '-march=x86-64'
>
That is why I submitted my patches. Since -m32 passes -march=x86-64
to cc1 on x86-64, we shouldn't pass -march=i486 to cc1. It is undesirable
especially when --with-arch= is used. I noticed the issue when 32-bit
libatomic/libgomp/libitm weren't optimized with -march=haswell when GCC
was configured with --with-arch=haswell
--
H.J.