From patchwork Mon Feb 8 21:04:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 580500 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4827E140C4F for ; Tue, 9 Feb 2016 08:05:17 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=cOTVAy88; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type; q=dns; s=default; b=eDhvvbMivxp4qTn5y H9MOpOP7UgWfOkFZmR1LxwvQrReKb76LQ1fa0FX4r3DdBu+hQzIXfQSSIF6fy/fB TB4IDrdpf4KN8aZEesEj+eA59lJn70Y6Rb1w4uOLwuH5CCmGAYRLs+pbG0iMiv0O 7gwa8oHmSDAKQAeDm09E86xJCk= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type; s=default; bh=LlEIfLcga4ofJOclScJtNOV 2RyM=; b=cOTVAy88Qqbf1tGj5TuxqO7Ys9lDoKLXiETUYJms271/7RmYk8dEbp2 5nGEHXkSEQ5qt141vZ9NOWYexlNfbzxMxF3l5SS2oQjSp0Xh4SrhjrrikvE4OgXE mWXGwGOUj7R65NWXZIxdbarvTUuxN76MaDNr/+PEgHDTMx0CbPd0= Received: (qmail 57500 invoked by alias); 8 Feb 2016 21:05:09 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 57482 invoked by uid 89); 8 Feb 2016 21:05:08 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:5278, HX-detected-operating-system:Windows, bo X-HELO: fencepost.gnu.org Received: from fencepost.gnu.org (HELO fencepost.gnu.org) (208.118.235.10) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Mon, 08 Feb 2016 21:05:07 +0000 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54837) by fencepost.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1aSszY-0004G3-Sx for gcc-patches@gnu.org; Mon, 08 Feb 2016 16:05:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aSszT-0005pA-LD for gcc-patches@gnu.org; Mon, 08 Feb 2016 16:05:04 -0500 Received: from relay1.mentorg.com ([192.94.38.131]:45899) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aSszT-0005ox-CA for gcc-patches@gnu.org; Mon, 08 Feb 2016 16:04:59 -0500 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-FEM-01.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1aSszQ-0005Ii-W5 from Tom_deVries@mentor.com ; Mon, 08 Feb 2016 13:04:57 -0800 Received: from [127.0.0.1] (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.3.224.2; Mon, 8 Feb 2016 21:04:55 +0000 Subject: Re: [PATCH, PR69707] Handle -fdiagnostics-color in lto To: Jakub Jelinek References: <56B86F3F.3030201@mentor.com> <20160208104239.GC3017@tucnak.redhat.com> <56B89A49.3040700@mentor.com> <20160208135419.GF3017@tucnak.redhat.com> CC: "gcc-patches@gnu.org" From: Tom de Vries Message-ID: <56B902F0.1030201@mentor.com> Date: Mon, 8 Feb 2016 22:04:48 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: <20160208135419.GF3017@tucnak.redhat.com> X-detected-operating-system: by eggs.gnu.org: Windows NT kernel [generic] [fuzzy] X-Received-From: 192.94.38.131 On 08/02/16 14:54, Jakub Jelinek wrote: > On Mon, Feb 08, 2016 at 02:38:17PM +0100, Tom de Vries wrote: >> hmm, indeed removing the 'Driver' flag from the fdiagnostics-color= entry in >> common.opt breaks the functioning of fdiagnostics-color= in the gcc driver. >> >> This patch leaves the 'Driver' flag alone, and instead explicitly allows >> fdiagnostics-color= in lto_write_options. >> >> Is this approach ok? > > Doesn't that mean storing -fdiagnostics-color= into the LTO option section and > then using whatever was recorded from the first TU that recorded anything? Yes. > That doesn't look right for such diagnostics options either. > I mean, if I > $ gcc -fdiagnostics-color=always -c -flto a.c > on another terminal > $ gcc -fdiagnostics-color=never -c -flto b.c > on yet another terminal > $ gcc -flto -o a a.o b.o > then I'd expect the default setting for -fdiagnostics-color= for all > diagnostics while linking/LTO optimizing it, and for say > $ gcc -fdiagnostics-color=always -flto -o a a.o b.o > to have it always colorized, similarly for never. > IMHO we should just honor what has been specified on the linker command > line if anything. Agreed. > So, the question is, is -fdiagnostics-color=never passed > in the testsuite just to the compilation and not to linking (that would be > IMHO a testsuite bug), In libgomp.exp we have: ... # Disable color diagnostics lappend ALWAYS_CFLAGS "additional_flags=-fdiagnostics-color=never" ... The test setup looks ok to me. > or is it passed on the linking command line, but not > passed through to lto1? Yes. I've now realized this is specific to mkoffload. If we're doing lto, in lto-wrapper.c:run_gcc, we have: ... append_compiler_options (&argv_obstack, fdecoded_options, fdecoded_options_count); append_linker_options (&argv_obstack, decoded_options, decoded_options_count); ... And the last line will propagate the fdiagnostics-color setting. But for calling mkoffload, we just have this: ... /* Append options from offload_lto sections. */ append_compiler_options (&argv_obstack, compiler_opts, compiler_opt_count); ... Followed by this, which just filters the -foffload options: ... /* Append options specified by -foffload last. In case of conflicting options we expect offload compiler to choose the latest. */ append_offload_options (&argv_obstack, target, compiler_opts, compiler_opt_count); append_offload_options (&argv_obstack, target, linker_opts, linker_opt_count); ... Attached patch adds the diagnostics flags to mkoffload. Bootstrapped and reg-tested on x86_64. OK for trunk, stage1? Thanks, - Tom Handle -fdiagnostics-color in lto 2016-02-08 Tom de Vries PR lto/69707 * lto-wrapper.c (append_diag_options): New function. (compile_offload_image): Call append_diag_options. * testsuite/libgomp.oacc-c-c++-common/parallel-dims-2.c: New test. --- gcc/lto-wrapper.c | 31 ++++++++++++++++++++++ .../libgomp.oacc-c-c++-common/parallel-dims-2.c | 19 +++++++++++++ 2 files changed, 50 insertions(+) diff --git a/gcc/lto-wrapper.c b/gcc/lto-wrapper.c index ced6f2f..8cda1fa 100644 --- a/gcc/lto-wrapper.c +++ b/gcc/lto-wrapper.c @@ -542,6 +542,36 @@ append_compiler_options (obstack *argv_obstack, struct cl_decoded_option *opts, } } +/* Append diag options in OPTS with length COUNT to ARGV_OBSTACK. */ + +static void +append_diag_options (obstack *argv_obstack, struct cl_decoded_option *opts, + unsigned int count) +{ + /* Append compiler driver arguments as far as they were merged. */ + for (unsigned int j = 1; j < count; ++j) + { + struct cl_decoded_option *option = &opts[j]; + + switch (option->opt_index) + { + case OPT_fdiagnostics_color_: + case OPT_fdiagnostics_show_caret: + case OPT_fdiagnostics_show_option: + case OPT_fdiagnostics_show_location_: + case OPT_fshow_column: + break; + default: + continue; + } + + /* Pass the option on. */ + for (unsigned int i = 0; i < option->canonical_option_num_elements; ++i) + obstack_ptr_grow (argv_obstack, option->canonical_option[i]); + } +} + + /* Append linker options OPTS to ARGV_OBSTACK. */ static void @@ -724,6 +754,7 @@ compile_offload_image (const char *target, const char *compiler_path, /* Append options from offload_lto sections. */ append_compiler_options (&argv_obstack, compiler_opts, compiler_opt_count); + append_diag_options (&argv_obstack, linker_opts, linker_opt_count); /* Append options specified by -foffload last. In case of conflicting options we expect offload compiler to choose the latest. */ diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/parallel-dims-2.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/parallel-dims-2.c new file mode 100644 index 0000000..eea8c7e --- /dev/null +++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/parallel-dims-2.c @@ -0,0 +1,19 @@ +/* { dg-do run { target { openacc_nvidia_accel_selected && lto } } } */ +/* { dg-additional-options "-flto -fno-use-linker-plugin" } */ + +/* Worker and vector size checks. Picked an outrageously large + value. */ + +int main () +{ +#pragma acc parallel num_workers (2<<20) /* { dg-error "using num_workers" } */ + { + } + +#pragma acc parallel vector_length (2<<20) /* { dg-error "using vector_length" } */ + { + } + + return 0; +} +