public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "H.J. Lu" <hjl.tools@gmail.com>
To: Richard Biener <richard.guenther@gmail.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] PR middle-end/67220: GCC fails to properly handle libcall symbol visibility of built functions
Date: Thu, 15 Oct 2015 10:38:00 -0000	[thread overview]
Message-ID: <CAMe9rOo_=_8BTjsQTuAMOQ0w1Td+9f52AyS-SF1kJNdLP5=Xsw@mail.gmail.com> (raw)
In-Reply-To: <CAFiYyc1xY4DSo69+Yn91V-FHsmN94BX4FtY+CHScHiDqGwTs9g@mail.gmail.com>

On Thu, Oct 15, 2015 at 1:44 AM, Richard Biener
<richard.guenther@gmail.com> wrote:
> On Wed, Oct 14, 2015 at 6:21 PM, H.J. Lu <hongjiu.lu@intel.com> wrote:
>> By default, there is no visibility on builtin functions.  When there is
>> explicitly declared visibility on the C library function which a builtin
>> function fall back on, we should honor the explicit visibility on the
>> the C library function.
>>
>> There are 2 issues:
>>
>> 1. We never update visibility of the fall back C library function.
>> 2. init_block_move_fn and init_block_clear_fn used to implement builtin
>> memcpy and memset generate the library call to memcpy and memset
>> directly without checking if there is explicitly declared visibility on
>> them.
>>
>> This patch updates builtin function with explicit visibility and checks
>> visibility on builtin memcpy/memset when generating library call.
>>
>> Tested on Linux/x86-64 without regressions.  OK for trunk?
>
> Doesn't the C++ FE have the same issue?
>

Unlike gcc, visibility triggers a warning in g++:

[hjl@gnu-tools-1 pr67220]$ cat memcpy.i
typedef unsigned long size_t;
extern void *memcpy(void *dest, const void *src, size_t n)
  __attribute__ ((visibility ("hidden")));

void
bar (void *d, void *s, size_t n)
{
  memcpy (d, s, n);
}
[hjl@gnu-tools-1 pr67220]$ make memcpy.s
/export/build/gnu/gcc/build-x86_64-linux/gcc/xg++
-B/export/build/gnu/gcc/build-x86_64-linux/gcc/ -O2 -fPIC -S memcpy.i
memcpy.i:2:14: warning: ‘void* memcpy(void*, const void*, size_t)’:
visibility attribute ignored because it conflicts with previous
declaration [-Wattributes]
 extern void *memcpy(void *dest, const void *src, size_t n)
              ^
<built-in>: note: previous declaration of ‘void* memcpy(void*, const
void*, size_t)’
[hjl@gnu-tools-1 pr67220]$

Since those fallback functions are in the C library, it is very
unlikely they can be hidden in C++.  They are mostly likely
to happen inside of the C library.

-- 
H.J.

  reply	other threads:[~2015-10-15 10:38 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-14 16:21 H.J. Lu
2015-10-14 16:46 ` Ramana Radhakrishnan
2015-10-14 16:51   ` H.J. Lu
2015-10-14 17:17     ` Ramana Radhakrishnan
2015-10-15  8:44 ` Richard Biener
2015-10-15 10:38   ` H.J. Lu [this message]
2015-10-20 23:43     ` Bernd Schmidt
2015-10-21  3:42       ` H.J. Lu
2016-01-15 18:44       ` H.J. Lu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAMe9rOo_=_8BTjsQTuAMOQ0w1Td+9f52AyS-SF1kJNdLP5=Xsw@mail.gmail.com' \
    --to=hjl.tools@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=richard.guenther@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).