From patchwork Mon Nov 4 13:15:19 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Senthil Kumar Selvaraj X-Patchwork-Id: 288178 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)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 9CB6A2C007B for ; Tue, 5 Nov 2013 00:15:50 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=o4PO7eU+3fhT7mvVoDMg9izPpATHG65iCB7Jpc2BJs5uBpF8Rb kifR99/oGazfRPX8g418aVfVD/cHjZfG0cEhPaMV0zwh9P4jbE/2E3uf7h1kv8s0 sJ3LoNHw0wah5ldpBEtgSOuLmz33i874uP1EtTbkn1dGN7PgX5KTFy5SE= 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:date :from:to:cc:subject:message-id:mime-version:content-type; s= default; bh=5VsCSOrKgMxbw2JtFp5hdqhTkUY=; b=AIxpoI9mRtSsBQdwsVwB TAcbdwrd2AKvV5DLyTj/jAIBEEtzH87DADL0dKZYI/4Z3nAa1gG9yw+WhTops0O2 CnLHCA5r+zbtwpUPxQ3e8IX7dcCmJd00VIS1gH0W3TWQgylwT70rRRZcZJiBINJl jAWFpJmzmwQcfr3u5vwGn14= Received: (qmail 14517 invoked by alias); 4 Nov 2013 13:15:41 -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 14501 invoked by uid 89); 4 Nov 2013 13:15:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.5 required=5.0 tests=AWL, BAYES_50, RDNS_NONE, SPF_PASS, URIBL_BLOCKED autolearn=no version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: DVREDG01.corp.atmel.com Received: from Unknown (HELO DVREDG01.corp.atmel.com) (192.199.1.245) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Mon, 04 Nov 2013 13:15:39 +0000 Received: from apsmtp01.atmel.com (10.168.254.30) by DVREDG01.corp.atmel.com (10.42.103.30) with Microsoft SMTP Server (TLS) id 14.2.347.0; Mon, 4 Nov 2013 06:15:22 -0700 Received: from PENCHT02.corp.atmel.com (10.168.5.162) by apsmtp01.corp.atmel.com (10.168.254.30) with Microsoft SMTP Server (TLS) id 14.2.347.0; Mon, 4 Nov 2013 21:19:30 +0800 Received: from atmel.com (10.168.5.13) by cas-ap.atmel.com (10.168.5.162) with Microsoft SMTP Server (TLS) id 14.2.342.3; Mon, 4 Nov 2013 21:15:20 +0800 Date: Mon, 4 Nov 2013 18:45:19 +0530 From: Senthil Kumar Selvaraj To: CC: , , , Subject: [Patch, avr] Emit diagnostics if -f{pic, PIC, pie, PIE} or -shared is passed Message-ID: <20131104131518.GA582@atmel.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.22 (2013-10-16) X-IsSubscribed: yes The AVR backend does not generate position independent code, yet it happily accepts -fpic, -fPIC, -fpie and -fPIE. The generated code doesn't change at all. Also, it accepts the -shared option to generate a shared library, without really doing anything with it. This causes one of the regression tests (gcc.dg/lto/pr54709 c_lto_pr54709_0.o-c_lto_pr54709_1.o link) to fail with an 'undefined reference to main' error, when the test is trying to build a shared object. The attached patch generates a warning if one of the -f{pic,PIC,pie,PIE} options is provided, and an error if -shared is provided ( config/mep/mep.c and config/s390/tpf.h already do something very similar). Regression tested with no new failures.Tests which exercise PIC now report as unsupported. If ok, could someone commit please? I don't have commit access. Regards Senthil gcc/ChangeLog 2013-11-04 Senthil Kumar Selvaraj * config/avr/avr.c (avr_option_override): Warn if asked to generate position independent code. * config/avr/avr.h: Modify LINK_SPEC to reject -shared. diff --git gcc/config/avr/avr.c gcc/config/avr/avr.c index e7e1c2f..cf4b8ca 100644 --- gcc/config/avr/avr.c +++ gcc/config/avr/avr.c @@ -310,6 +310,15 @@ avr_option_override (void) flag_omit_frame_pointer = 0; } + if (flag_pic == 1) + warning (OPT_fpic, "-fpic is not supported"); + if (flag_pic == 2) + warning (OPT_fPIC, "-fPIC is not supported"); + if (flag_pie == 1) + warning (OPT_fpie, "-fpie is not supported"); + if (flag_pie == 2) + warning (OPT_fPIE, "-fPIE is not supported"); + avr_current_device = &avr_mcu_types[avr_mcu_index]; avr_current_arch = &avr_arch_types[avr_current_device->arch]; diff --git gcc/config/avr/avr.h gcc/config/avr/avr.h index f223a61..1eff5be 100644 --- gcc/config/avr/avr.h +++ gcc/config/avr/avr.h @@ -522,7 +522,8 @@ extern const char *avr_device_to_sp8 (int argc, const char **argv); mmcu=at90can64*|\ mmcu=at90usb64*:--pmem-wrap-around=64k}}}\ %:device_to_ld(%{mmcu=*:%*})\ -%:device_to_data_start(%{mmcu=*:%*})" +%:device_to_data_start(%{mmcu=*:%*})\ +%{shared:%eshared is not supported}" #define LIB_SPEC \ "%{!mmcu=at90s1*:%{!mmcu=attiny11:%{!mmcu=attiny12:%{!mmcu=attiny15:%{!mmcu=attiny28: -lc }}}}}"