From patchwork Wed Jan 8 07:59:19 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Ye X-Patchwork-Id: 308081 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 861122C007A for ; Wed, 8 Jan 2014 18:59:48 +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:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=P1B5R3O/CDlJ5K9J EHPdU7MfQNCy/bB1gBPVYryrgplmiCFoESXFAweBorX6Ub1oOipH+JZoV0qTBpW0 458OdRZEHn/pIICUDIsAlAeAuwJS1yBz6m8zq+eBOKjio7I5QuKZLETlruBbqzsK 1+cmVoBgc/OHZzIwg4bwZjHlrI4= 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:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=default; bh=7tCqm96IdCawIRGsmqT6yz Wlys4=; b=RiYPncoW0eCDIW6niO9r4p79cYmuzIE7dUV11YTVrdo2AXPtsRDBqD Y9DHc9F4cFaKv84rv061+zLTA1VD6B4cMxdO6c8OQ0x9CysNrRw+w7yYbhHschwp 243G2hUnYKNz+PLrfbaTDg4+Ir9Ke2k44n75Z3LOxWD2pbns2umOA= Received: (qmail 3938 invoked by alias); 8 Jan 2014 07:59: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 3924 invoked by uid 89); 8 Jan 2014 07:59:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: service87.mimecast.com Received: from service87.mimecast.com (HELO service87.mimecast.com) (91.220.42.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 08 Jan 2014 07:59:38 +0000 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Wed, 08 Jan 2014 07:59:36 +0000 Received: from E103005 ([10.1.255.212]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 8 Jan 2014 07:59:33 +0000 From: "Joey Ye" To: Subject: [PATCH] [doc] Update plugin doc Date: Wed, 8 Jan 2014 15:59:19 +0800 Message-ID: <000001cf0c47$897a78f0$9c6f6ad0$@arm.com> MIME-Version: 1.0 X-MC-Unique: 114010807593600201 Update plugin document after switching to C++, also make it more friendly to cross-build. ChangeLog: 2014-01-08 Joey Ye doc/plugin.texi (Building GCC plugins): Update to C++. OK to trunk? diff --git a/gcc/doc/plugins.texi b/gcc/doc/plugins.texi index fc2d754..e668de6 100644 --- a/gcc/doc/plugins.texi +++ b/gcc/doc/plugins.texi @@ -465,18 +465,18 @@ integer numbers, so a plugin could ensure it is built for GCC 4.7 with The following GNU Makefile excerpt shows how to build a simple plugin: @smallexample -GCC=gcc -PLUGIN_SOURCE_FILES= plugin1.c plugin2.c -PLUGIN_OBJECT_FILES= $(patsubst %.c,%.o,$(PLUGIN_SOURCE_FILES)) -GCCPLUGINS_DIR:= $(shell $(GCC) -print-file-name=plugin) -CFLAGS+= -I$(GCCPLUGINS_DIR)/include -fPIC -O2 - -plugin.so: $(PLUGIN_OBJECT_FILES) - $(GCC) -shared $^ -o $@@ +HOST_GCC=g++ +TARGET_GCC=gcc +PLUGIN_SOURCE_FILES= plugin1.c plugin2.cc +GCCPLUGINS_DIR:= $(shell $(TARGET_GCC) -print-file-name=plugin) +CXXFLAGS+= -I$(GCCPLUGINS_DIR)/include -fPIC -fno-rtti -O2 + +plugin.so: $(PLUGIN_SOURCE_FILES) + $(HOST_GCC) -shared $(CXXFLAGS) $^ -o $@@ @end smallexample -A single source file plugin may be built with @code{gcc -I`gcc --print-file-name=plugin`/include -fPIC -shared -O2 plugin.c -o +A single source file plugin may be built with @code{g++ -I`gcc +-print-file-name=plugin`/include -fPIC -shared -fno-rtti -O2 plugin.c -o plugin.so}, using backquote shell syntax to query the @file{plugin} directory.