From patchwork Tue Jun 12 20:33:26 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 164497 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]) by ozlabs.org (Postfix) with SMTP id A335DB6FAA for ; Wed, 13 Jun 2012 06:33:47 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1340138028; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:From:To:Subject:Date:Message-ID:User-Agent: MIME-Version:Content-Type:Mailing-List:Precedence:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=ALu24qyXQc4eospYzvmjBDRUnpE=; b=Tn5XcDULwjOQuEl Khx6vtdWBc/0st2vyn+H4cmJC8zXLz3tM8VDYpum2sowpwDxV76Zt9iNaic59ejR xJEK3qJWDieGMJMac4q6AgIWPM6oZ2HImThgCAN95AcXE3WiNIC843W64pXsUABf q1IUmiFNgTdwAltWvBZ+QwuIGCGo= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:X-Google-DKIM-Signature:Received:Received:Received:From:To:Subject:Date:Message-ID:User-Agent:MIME-Version:Content-Type:X-Gm-Message-State:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=yYocZiVJw0Hhh6W51p9hqPS+d403vJuHHbvUR28tov7glCfaVb9I3a4i8ADJYI E7csDkGasoto92FZ8qE17cy72UcRVmQtFUkb16HiyW4dnpTIItFBZhPN73y91vlH j0in5C+vqgJC7liw3gFUu5sislBGHTfsbKU1vMs+DWMDk=; Received: (qmail 10857 invoked by alias); 12 Jun 2012 20:33:43 -0000 Received: (qmail 10844 invoked by uid 22791); 12 Jun 2012 20:33:41 -0000 X-SWARE-Spam-Status: No, hits=-4.3 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, KHOP_RCVD_TRUST, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, TW_CC, T_RP_MATCHES_RCVD, T_TVD_MIME_NO_HEADERS X-Spam-Check-By: sourceware.org Received: from mail-pz0-f47.google.com (HELO mail-pz0-f47.google.com) (209.85.210.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 12 Jun 2012 20:33:28 +0000 Received: by dalh21 with SMTP id h21so7265950dal.20 for ; Tue, 12 Jun 2012 13:33:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:subject:date:message-id:user-agent:mime-version :content-type:x-gm-message-state; bh=LCiot4M02BrO1+i2NreKXZT7eJDlkbARducClwH6qAY=; b=HdMnUhUEY2npGuXQFv1BB4rpXmp19r6ng01kw9ydEgXI/CjUjtSisI+kTFX8zJMcjB RzYFYXnUWLrkoRwK365q63FBncPHoSQz3nbNOi3S4iqHcaw1MtsAx61EtHpjsudNFZSB v7wXW6gvOR9Wd5bJZZEzXadRjNSbLRSn5s3e/zQus3xwPQTU+fORdzK0QlPCADwsV3kx 7YsCM8oio16TKll072Vf1xnzmZGZWiUBLsF4O+Wox4KvvKkcJe4S95zNyLDlOy9DV+5s Zw4hkeOuhqYO6xOyvx1jLVTP1V64rxO/4MJHt47HrP+gp0GaIghrhC2UY5sHO86ZySZi xElQ== Received: by 10.68.228.136 with SMTP id si8mr42285549pbc.159.1339533208007; Tue, 12 Jun 2012 13:33:28 -0700 (PDT) Received: by 10.68.228.136 with SMTP id si8mr42285535pbc.159.1339533207914; Tue, 12 Jun 2012 13:33:27 -0700 (PDT) Received: from coign.google.com ([216.239.45.130]) by mx.google.com with ESMTPS id ua6sm3110864pbc.20.2012.06.12.13.33.26 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 12 Jun 2012 13:33:27 -0700 (PDT) From: Ian Lance Taylor To: gcc-patches@gcc.gnu.org, gofrontend-dev@googlegroups.com Subject: Go patch committed: Handle package path like gc compiler Date: Tue, 12 Jun 2012 13:33:26 -0700 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 X-Gm-Message-State: ALoCoQkrfbom9UBMfTe273TydbNrzPn4Edp+1f99gyNtQZw97YHC/WX8sxwXCup4Hq6ywcfNKn+Z3vw0CB/8U202n5lp0Yl9j+usB8bf/USXy6jpc/F2p1eB0H17LKvpd97bZbt4PWxD9bNKUvY2OE+fbK/xNr3Zsg== X-IsSubscribed: yes 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 This patch to the Go frontend and the runtime library handles the package path like the other Go compiler. Gccgo needs to canonicalize type names based on the reflection string, so that types defined in shared libraries work correctly. That means that it needs to include the package path in the reflection string. But the other Go compiler does not include the full path in the reflection string, only the package name. So this patch changes gccgo to store the package path in the reflection string within double quotes, and to strip out double quoted strings when the reflect.Type.String method is called. Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu. Committed to mainline. Ian diff -r 2ab3869bedd1 go/gogo.cc --- a/go/gogo.cc Thu Jun 07 01:05:45 2012 -0700 +++ b/go/gogo.cc Tue Jun 12 11:47:12 2012 -0700 @@ -339,9 +339,14 @@ // symbol names. if (!this->pkgpath_set_) { - if (!this->prefix_from_option_) - this->prefix_ = "go"; - this->pkgpath_ = this->prefix_ + '.' + package_name; + if (!this->prefix_from_option_ && package_name == "main") + this->pkgpath_ = package_name; + else + { + if (!this->prefix_from_option_) + this->prefix_ = "go"; + this->pkgpath_ = this->prefix_ + '.' + package_name; + } this->pkgpath_set_ = true; } diff -r 2ab3869bedd1 go/types.cc --- a/go/types.cc Thu Jun 07 01:05:45 2012 -0700 +++ b/go/types.cc Tue Jun 12 11:47:12 2012 -0700 @@ -8337,14 +8337,23 @@ { // We handle -fgo-prefix and -fgo-pkgpath differently here for // compatibility with how the compiler worked before - // -fgo-pkgpath was introduced. + // -fgo-pkgpath was introduced. When -fgo-pkgpath is specified, + // we use it to make a unique reflection string, so that the + // type canonicalization in the reflect package will work. In + // order to be compatible with the gc compiler, we quote the + // package path, so that the reflect methods can discard it. const Package* package = this->named_object_->package(); if (gogo->pkgpath_from_option()) - ret->append(package != NULL ? package->pkgpath() : gogo->pkgpath()); - else - ret->append(package != NULL - ? package->package_name() - : gogo->package_name()); + { + ret->push_back('"'); + ret->append(package != NULL + ? package->pkgpath_symbol() + : gogo->pkgpath_symbol()); + ret->push_back('"'); + } + ret->append(package != NULL + ? package->package_name() + : gogo->package_name()); ret->push_back('.'); } if (this->in_function_ != NULL) diff -r 2ab3869bedd1 libgo/go/encoding/xml/marshal_test.go --- a/libgo/go/encoding/xml/marshal_test.go Thu Jun 07 01:05:45 2012 -0700 +++ b/libgo/go/encoding/xml/marshal_test.go Tue Jun 12 11:47:12 2012 -0700 @@ -726,7 +726,7 @@ }, { Value: map[*Ship]bool{nil: false}, - Err: "xml: unsupported type: map[*encoding/xml.Ship]bool", + Err: "xml: unsupported type: map[*xml.Ship]bool", Kind: reflect.Map, }, { diff -r 2ab3869bedd1 libgo/go/html/template/escape_test.go --- a/libgo/go/html/template/escape_test.go Thu Jun 07 01:05:45 2012 -0700 +++ b/libgo/go/html/template/escape_test.go Tue Jun 12 11:47:12 2012 -0700 @@ -226,7 +226,7 @@ { "badMarshaler", `