From dennylin93@cnmc32.hs.ntnu.edu.tw Tue Nov 10 14:03:35 2009 Return-Path: Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4F0131065670 for ; Tue, 10 Nov 2009 14:03:35 +0000 (UTC) (envelope-from dennylin93@cnmc32.hs.ntnu.edu.tw) Received: from mx.hs.ntnu.edu.tw (mx.hs.ntnu.edu.tw [140.131.149.2]) by mx1.freebsd.org (Postfix) with ESMTP id DBC508FC08 for ; Tue, 10 Nov 2009 14:03:34 +0000 (UTC) Received: by mx.hs.ntnu.edu.tw (Postfix, from userid 1002) id 185386FC45D; Tue, 10 Nov 2009 22:03:34 +0800 (CST) Message-Id: <20091110140334.185386FC45D@mx.hs.ntnu.edu.tw> Date: Tue, 10 Nov 2009 22:03:34 +0800 (CST) From: Denny Lin Reply-To: Denny Lin To: FreeBSD-gnats-submit@freebsd.org Cc: Subject: [UPDATE] New Traditional Chinese translation of custom-gcc X-Send-Pr-Version: 3.113 X-GNATS-Notify: >Number: 140444 >Category: docs >Synopsis: [patch] New Traditional Chinese translation of custom-gcc >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-doc >State: open >Quarter: >Keywords: articles >Date-Required: >Class: update >Submitter-Id: current-users >Arrival-Date: Tue Nov 10 14:10:02 UTC 2009 >Closed-Date: >Last-Modified: Tue Aug 31 22:33:03 UTC 2010 >Originator: Denny Lin >Release: FreeBSD 7.2-RELEASE-p4 amd64 >Organization: >Environment: System: FreeBSD cnmc32.hs.ntnu.edu.tw 7.2-RELEASE-p4 FreeBSD 7.2-RELEASE-p4 #0: Mon Oct 26 19:41:45 CST 2009 root@cnmc32.hs.ntnu.edu.tw:/usr/obj/usr/src/sys/CNMC32 amd64 >Description: New Traditional Chinese translation of "Using newer version of GCC and binutils with the FreeBSD Ports Collection." Should be put in doc/zh_TW.Big5/articles/custom-gcc. The attached files are also available at http://security-hole.info/~dennylin93/doc/zh_TW.Big5/articles/custom-gcc/. >How-To-Repeat: >Fix: --- Makefile begins here --- # # $FreeBSD$ # # Article: Using newer version of GCC and binutils with the FreeBSD Ports Collection DOC?= article FORMATS?= html WITH_ARTICLE_TOC?= YES INSTALL_COMPRESSED?= gz INSTALL_ONLY_COMPRESSED?= SRCS= article.sgml URL_RELPREFIX?= ../../../.. DOC_PREFIX?= ${.CURDIR}/../../.. .include "${DOC_PREFIX}/share/mk/doc.project.mk" --- Makefile ends here --- --- article.sgml begins here --- %articles.ent; ]>
配合 &os; Ports Collection 使用新版本的 <application>GCC</application> 與 <application>binutils</application> Martin Matuska
mm@FreeBSD.org
$FreeBSD$ &tm-attrib.freebsd; &tm-attrib.general; 2009 The &os; Documentation Project 此篇文件說明了如何從 &os; ports tree 使用新版本的 GCC 編譯器與 binutils。 自訂的 GCC 設定也是本文件討論範圍。
簡介 在 &os; 8.0 裡,系統預設的編譯器為 GCC 版本 4.2.1。除此之外,系統本身也含有 binutils 版本 2.15。這些版本已經出幾年了,且不支援新的 CPU 指令集,如 SSSE3SSE4.1SSE4.2 等。礙於許可證的關係,這些程式較新的版本並不會被移植到系統內。幸好,仍然可以透過 &os; ports tree 使用新版本的 GCC 編譯器(如:版本 4.4)。 前提 從 ports 安裝 binutils 若要使用所有 GCC 新版本的功能,必須安裝最新版本的 binutils。 雖然安裝新版本的 binutils 非必要條件,但若沒有安裝,將無法使用新 CPU 的指令集。 若要從 &os; ports tree 安裝最新版本的 binutils,請下: &prompt.root; cd /usr/ports/devel/binutils && make install 從 ports 安裝 GCC &os; ports tree 提供了數種新版本的 GCC。下面的範例是使用穩定的 4.4 版本。但是,可以安裝之前或更新的版本(如: lang/gcc43lang/gcc45)。 若要安裝上面提到的 GCC ports 之一,請下: &prompt.root; cd /usr/ports/lang/gcc44 && make install 設定 ports 使用自訂版本的 <application>GCC</application> 使用從 &os; ports tree 安裝的 GCC 之前,必須先做一些額外的設定。 調整 <filename>make.conf</filename> 將下列幾行加入 /etc/make.conf 檔案(視情況調整): .if !empty(.CURDIR:M/usr/ports/*) && exists(/usr/local/bin/gcc44) CC=gcc44 CXX=g++44 CPP=cpp44 .endif 此外,可以手動設變數 ${CC}${CPP} 上面的範裡是給 GCC 版本 4.4。若要使用 gcc43「gcc44」 替換成 「gcc43」「4.4」 替換成 「4.3」,以此類推。 調整 <filename>libmap.conf</filename> 許多 ports 的執行檔與 libraries 會連結到 libgcc_s 或 libstdc++。系統已有內建這些 libraries,但是是 就版本的 GCC(版本 4.2.1)。 rtld(和 ldd)正確的版本,將下列幾行加入 /etc/libmap.conf 檔案(視情況調整): libgcc_s.so.1 gcc44/libgcc_s.so.1 libgomp.so.1 gcc44/libgomp.so.1 libobjc.so.3 gcc44/libobjc.so.2 libssp.so.0 gcc44/libssp.so.0 libstdc++.so.6 gcc44/libstdc++.so.6 上面的範例是針對 GCC 版本 4.4。若要使用 gcc43,將 「gcc44」 替換成 「gcc43」,以此類推。值得注意的是,這些 libraries 都與系統本身的 libraries 相容。 有些 C++ 若這些 libraries 沒有設定好,可以無法執行。 若沒有辦法將所有的 libraries 設定好,建議至少 libstdc++.so 要正確。 自訂 ports tree 使用的 <literal>CFLAGS</literal> 若要針對 ports tree 加自訂(系統內建不支援)的 CFLAGS,照著範例調整 /etc/make.conf .if !empty(.CURDIR:M/usr/ports/*) && exists(/usr/local/bin/gcc44) CC=gcc44 CXX=g++44 CPP=cpp44 CFLAGS+=-mssse3 .endif 可以完全取代 CFLAGS,也可以設定自訂的 CPUTYPE。我們建議設定自訂的 CPUTYPE 因為許多 ports 的優話參數以此變數為基礎。 排除無法用新版本的 <application>GCC</application> 編譯的 ports。 若要排除一些跟新版本的 GCC 有問題的 ports,依照範例調整 /etc/make.conf .if !empty(.CURDIR:M/usr/ports/*) && exists(/usr/local/bin/gcc44) .if empty(.CURDIR:M/usr/ports/net/openldap*) CC=gcc44 CXX=g++44 CPP=cpp44 .endif .endif 上面的範例安裝 net/openldap* ports 時,不會使用 gcc 4.4。另外,也可以在同一行上設更多 ports: .if empty(.CURDIR:M/usr/ports/net/openldap*) && empty(.CURDIR:M/usr/ports/xxx/yyy) && ... 對二進位執行檔之影響 使用 GCC 版本 4.4 且 SSSE3 指令集有用到(若 CPU 支援)平均來講,效能可能提高 10% 。在某些測試當中,結果顯示效能有提昇超過 20%(如:處理多媒體時)。 位於 的表格顯示了 &os; 系統內建的 GCC 版本與 GCC 版本 4.3、4.4 之比較。表格包含有各種 CFLAGS 的組合,使用的是 perlbench 的效能測試套件。
--- article.sgml ends here --- >Release-Note: >Audit-Trail: From: Denny Lin To: bug-followup@FreeBSD.org, dennylin93@cnmc32.hs.ntnu.edu.tw Cc: Subject: Re: docs/140444: [patch] New Traditional Chinese translation of custom-gcc Date: Thu, 19 Nov 2009 22:28:01 +0800 --fUYQa+Pmc3FrFX/N Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Forgot to add new article to doc/zh_TW.Big5/articles/Makefile. --=20 Denny Lin --fUYQa+Pmc3FrFX/N Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.13 (FreeBSD) iEYEARECAAYFAksFVfEACgkQtYH0ykp1KDwSTwCeJ9KPfJb4WFhbMS1NlaZx48dR dK4An2h4ojwjzuzDdcuPZsQlDP//p4SY =kZ27 -----END PGP SIGNATURE----- --fUYQa+Pmc3FrFX/N-- From: Denny Lin To: bug-followup@FreeBSD.org, dennylin93@cnmc32.hs.ntnu.edu.tw Cc: Subject: Re: docs/140444: [patch] New Traditional Chinese translation of custom-gcc Date: Thu, 19 Nov 2009 22:29:37 +0800 --ftEhullJWpWg/VHq Content-Type: multipart/mixed; boundary="KsGdsel6WgEHnImy" Content-Disposition: inline --KsGdsel6WgEHnImy Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Oops. Forgot to attach file. --=20 Denny Lin --KsGdsel6WgEHnImy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="zh_TW-articles-Makefile.patch" Content-Transfer-Encoding: quoted-printable --- doc/zh_TW.Big5/articles/Makefile.orig 2009-11-19 22:22:57.650325047 +08= 00 +++ doc/zh_TW.Big5/articles/Makefile 2009-11-19 22:23:33.914787810 +0800 @@ -2,6 +2,7 @@ =20 SUBDIR =3D SUBDIR+=3D contributing +SUBDIR+=3D custom-gcc SUBDIR+=3D cvs-freebsd SUBDIR+=3D freebsd-questions SUBDIR+=3D hubs --KsGdsel6WgEHnImy-- --ftEhullJWpWg/VHq Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.13 (FreeBSD) iEYEARECAAYFAksFVlEACgkQtYH0ykp1KDwMKgCgk+xrybLnKKXgiKhQDjUZGKSk RxcAn0r6/ylsUvhSK2bFgVwh/JYPFAW1 =UiKU -----END PGP SIGNATURE----- --ftEhullJWpWg/VHq-- >Unformatted: