From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 122411 invoked by alias); 4 Oct 2016 20:25:23 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 122390 invoked by uid 89); 4 Oct 2016 20:25:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=c6x, Sharing, risk, night X-HELO: mail-qt0-f196.google.com Received: from mail-qt0-f196.google.com (HELO mail-qt0-f196.google.com) (209.85.216.196) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 04 Oct 2016 20:25:20 +0000 Received: by mail-qt0-f196.google.com with SMTP id 38so6299560qte.2 for ; Tue, 04 Oct 2016 13:25:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to; bh=QBEQ8IhSvPDOoHsgilfuSoIlvrfaJgoa4kihQ2mdQnw=; b=asXOgIxdnJVfaEkWpn8a6EtcPffp/lS1RIyFVFSQ0A3vXb+ekczkZ0cyq02SLvmKXK RQXeXQA1kMg7w1MxTRB+F3jCQfuki+dE4k66X0F/FPhvhu7YUBp0+uUVyVqmwUUUUHrL Fnm2BNQQgwnQcf+Te8H8+t/7DxQOPNbOcCvAkXG8qcvteADZigg1kZMYzHRD0CAIK1pp wrvTytEcHLfVrEnp27j+AylF0hMnQGiUHY98pA64KXq5qsASPSOWczEU5R2BAZ6ZVwRh ZblXoj8Dl/zGc1nrQxjSS4bnmp/v1/jKaud9Ay0RxPjAxCKniI4Pn5sN7V4GAdM0GCDB DAiA== X-Gm-Message-State: AA6/9RnBUB+h/USZ9IJ5qTIpTvd1VEoOv+cCOc/dBHbyJk64ZKREofTZM18uXiwNvj0xGg== X-Received: by 10.237.46.6 with SMTP id j6mr5571116qtd.10.1475612718491; Tue, 04 Oct 2016 13:25:18 -0700 (PDT) Received: from [192.168.0.26] (75-166-199-51.hlrn.qwest.net. [75.166.199.51]) by smtp.gmail.com with ESMTPSA id m201sm2161180qke.46.2016.10.04.13.25.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Oct 2016 13:25:18 -0700 (PDT) Subject: Re: [PATCH] add uClibc target hook (PR bootstrap/77819) To: Bernd Schmidt , Gcc Patch List References: <52a0ea48-cbfd-28c8-4711-22cea9481d1a@gmail.com> <7ab9d030-106e-1716-f495-94844e94f17f@gmail.com> <0098b7ae-b531-280c-ffbc-6636822f225c@redhat.com> From: Martin Sebor Message-ID: Date: Tue, 04 Oct 2016 20:25:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: <0098b7ae-b531-280c-ffbc-6636822f225c@redhat.com> Content-Type: multipart/mixed; boundary="------------81A78203B9E40303162F3A5D" X-IsSubscribed: yes X-SW-Source: 2016-10/txt/msg00188.txt.bz2 This is a multi-part message in MIME format. --------------81A78203B9E40303162F3A5D Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1316 On 10/04/2016 08:54 AM, Bernd Schmidt wrote: > On 10/04/2016 04:34 PM, Martin Sebor wrote: >> >> I copied the conditional from config/linux.h but I admit I don't >> fully understand when the macro is defined. > > AFAICT it's done in config.gcc, for a limited set of targets. > >> Should I still remove it from targhooks.c? > > That is compiled for all targets, not just for those which define the > macro, so yes. > >> Yes, the glibc and uclibc hooks are the same. I don't know what >> the convention is for these target hooks (i.e., whether they are >> expected to be duplicated across targets even if they are the >> same to reduce the risk of breaking one target as a result of >> changing another, or whether duplication should be avoided even >> at this risk). From your comment it sounds like it should be >> the latter and I'm okay with that. > > There's arguments for both. In this particular case I don't see a strong > reason not to have a general hook available. Sounds good. Attached is an updated patch reflecting these changes. Restested by building the powerpc64-linux and tic6x-uclinux cross toolchains. (Sharing the Glibc and uClibc implementation of the target hook and defining it in targhooks.c also obviates the patch I sent in for bug 77837 last night so it seems like a win-win.) Martin --------------81A78203B9E40303162F3A5D Content-Type: text/x-patch; name="gcc-77819.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="gcc-77819.diff" Content-length: 3466 PR bootstrap/77819 - undefined reference to gnu_libc_printf_pointer_format with uClibc gcc/ChangeLog: PR bootstrap/77819 * config/linux.h (TARGET_PRINTF_POINTER_FORMAT): Define macro. * config/linux.c (gnu_libc_printf_pointer_format): Remove. * targhooks.c [DEFAULT_LIBC == LIBC_UCLIBC) && SINGLE_LIBC] (default_printf_pointer_format): Define function. * targhooks.c (linux_printf_pointer_format): Define new function. * targhooks.h (linux_printf_pointer_format): Declare. (gnu_libc_printf_pointer_format): Remove declaration. diff --git a/gcc/config/linux.c b/gcc/config/linux.c index 9aac38b..a393d3b 100644 --- a/gcc/config/linux.c +++ b/gcc/config/linux.c @@ -24,9 +24,6 @@ along with GCC; see the file COPYING3. If not see #include "tree.h" #include "linux-protos.h" -#undef TARGET_PRINTF_POINTER_FORMAT -#define TARGET_PRINTF_POINTER_FORMAT gnu_libc_printf_pointer_format - bool linux_libc_has_function (enum function_class fn_class) { @@ -40,16 +37,3 @@ linux_libc_has_function (enum function_class fn_class) return false; } - -/* Glibc formats pointers as if by "%zx" except for the null pointer - which outputs "(nil)". It ignores the pound ('#') format flag but - interprets the space and plus flags the same as in the integer - directive. */ - -const char* -gnu_libc_printf_pointer_format (tree arg, const char **flags) -{ - *flags = " +"; - - return arg && integer_zerop (arg) ? "(nil)" : "%#zx"; -} diff --git a/gcc/config/linux.h b/gcc/config/linux.h index 3ff005b..7211da2 100644 --- a/gcc/config/linux.h +++ b/gcc/config/linux.h @@ -209,6 +209,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #endif -/* The format string to which "%p" corresponds. */ +/* The format string to which "%p" corresponds (same in Glibc and + uClibc. */ #undef TARGET_PRINTF_POINTER_FORMAT -#define TARGET_PRINTF_POINTER_FORMAT gnu_libc_printf_pointer_format +#define TARGET_PRINTF_POINTER_FORMAT linux_printf_pointer_format diff --git a/gcc/targhooks.c b/gcc/targhooks.c index d75650f..c7977be 100644 --- a/gcc/targhooks.c +++ b/gcc/targhooks.c @@ -1523,6 +1523,22 @@ default_printf_pointer_format (tree, const char **flags) return "%zx"; } +/* For Glibc and uClibc targets also define the hook here because + otherwise it would have to be duplicated in each target's .c file + (such as in bfin/bfin.c and c6x/c6x.c, etc.) + Glibc and uClibc format pointers as if by "%zx" except for the null + pointer which outputs "(nil)". It ignores the pound ('#') format + flag but interprets the space and plus flags the same as in the integer + directive. */ + +const char* +linux_printf_pointer_format (tree arg, const char **flags) +{ + *flags = " +"; + + return arg && integer_zerop (arg) ? "(nil)" : "%#zx"; +} + tree default_builtin_tm_load_store (tree ARG_UNUSED (type)) { diff --git a/gcc/targhooks.h b/gcc/targhooks.h index 3356f0a..afb1c00 100644 --- a/gcc/targhooks.h +++ b/gcc/targhooks.h @@ -192,7 +192,7 @@ extern bool no_c99_libc_has_function (enum function_class); extern bool gnu_libc_has_function (enum function_class); extern const char* default_printf_pointer_format (tree, const char **); -extern const char* gnu_libc_printf_pointer_format (tree, const char **); +extern const char* linux_printf_pointer_format (tree, const char **); extern const char* solaris_printf_pointer_format (tree, const char **); extern tree default_builtin_tm_load_store (tree); --------------81A78203B9E40303162F3A5D--