当前位置: 首页 > 工具软件 > FUSE for OS X > 使用案例 >

在OS X 10.9.2安装gcc-4.9.0——关于gcc对go语言的支持

凌意
2023-12-01

2014-05-01 wcdj


最近将gcc-4.8.1升级为gcc-4.9.0,安装方法类似之前文章《OS X Lion 10.8.4 x86_64平台搭建C++11发环》总结的方法。


gcc主页:http://gcc.gnu.org/

GCC 4.9.0 (changes) (docs)
Status: 2014-04-22 (regression fixes and docs only).
Serious regressions. All regressions.


GCC 4.9.0新版的变化主要包括 :

  • Solaris 9架构被宣布废弃,如果无人活跃开发,下一个版本将彻底移除;
  • ARM架构支持AddressSanitizer,改进链接时优化,过程间优化和反馈向优化;
  • C和C++编译器支持OpenMP 4.0规格;
  • 改进C++11和C++1y支持;
  • 完整支持Go 1.2.1;
  • 支持Power ISA 2.07及硬件事务性内存;
  • 支持英特尔AVX-512、Silvermont和 Broadwell架构、AMD Excavator架构等等。 
详细信息,可参阅 GCC 4.9.0发布注记

或者:

http://www.infoq.com/cn/news/2014/04/gcc4.9_release

0 gcc-4.9.0安装后的注意事项

----------------------------------------------------------------------
Libraries have been installed in:
   /Users/gerryyang/LAMP/gcc/install/gcc-4.9.0/lib

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `DYLD_LIBRARY_PATH' environment variable
     during execution

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------

gerryyang@mba:bin$./g++ -v
使用内建 specs。
COLLECT_GCC=./g++
COLLECT_LTO_WRAPPER=/Users/gerryyang/LAMP/gcc/install/gcc-4.9.0/libexec/gcc/x86_64-apple-darwin13.1.0/4.9.0/lto-wrapper
目标:x86_64-apple-darwin13.1.0
配置为:/Users/gerryyang/LAMP/gcc/objdir/../gcc-4.9.0/configure --prefix=/Users/gerryyang/LAMP/gcc/install/gcc-4.9.0
线程模型:posix
gcc 版本 4.9.0 (GCC)


1 关于gcc对go语言的支持

GCC 4.9 provides a complete implementation of the Go 1.2.1 release(2014-03-02).

gcc490 manual:

As of the GCC 4.7.1 release(2012-06-14), GCC supports the Go 1 language standard, described athttp://golang.org/doc/go1.html.


问题:compile go source using gcc 4.7 on Mac —— Go compiler not installed on this system

http://www.infoq.com/cn/news/2014/04/gcc4.9_release


2 GCC Command Options

See [Option Index], page 807, for an index to GCC's options.

Option Summary

Here is a summary of all the options, grouped by type. Explanations are in the following sections.

(1) Overall Options

See Section 3.2 [Options Controlling the Kind of Output], page 25.

-c -S -E -o file -no-canonical-prefixes

-pipe -pass-exit-codes

-x language -v -### --help[=class[,...]] --target-help

--version -wrapper @file -fplugin=file -fplugin-arg-name=arg

-fdump-ada-spec[-slim] -fada-spec-parent=unit -fdump-go-spec=file


(2) C Language Options

See Section 3.4 [Options Controlling C Dialect], page 31.

-ansi -std=standard -fgnu89-inline

-aux-info filename -fallow-parameterless-variadic-functions

-fno-asm -fno-builtin -fno-builtin-function

-fhosted -ffreestanding -fopenmp -fopenmp-simd -fms-extensions

-fplan9-extensions -trigraphs -traditional -traditional-cpp

-fallow-single-precision -fcond-mismatch -flax-vector-conversions

-fsigned-bitfields -fsigned-char

-funsigned-bitfields -funsigned-char


(3) C++ Language Options

See Section 3.5 [Options Controlling C++ Dialect], page 37.

-fabi-version=n -fno-access-control -fcheck-new

-fconstexpr-depth=n -ffriend-injection

-fno-elide-constructors

-fno-enforce-eh-specs

-ffor-scope -fno-for-scope -fno-gnu-keywords

-fno-implicit-templates

-fno-implicit-inline-templates

-fno-implement-inlines -fms-extensions

-fno-nonansi-builtins -fnothrow-opt -fno-operator-names

-fno-optional-diags -fpermissive

-fno-pretty-templates

-frepo -fno-rtti -fstats -ftemplate-backtrace-limit=n

-ftemplate-depth=n

-fno-threadsafe-statics -fuse-cxa-atexit -fno-weak -nostdinc++

-fvisibility-inlines-hidden

-fvtable-verify=std|preinit|none

-fvtv-counts -fvtv-debug

-fvisibility-ms-compat

-fext-numeric-literals

-Wabi -Wconversion-null -Wctor-dtor-privacy

-Wdelete-non-virtual-dtor -Wliteral-suffix -Wnarrowing

-Wnoexcept -Wnon-virtual-dtor -Wreorder

-Wno-non-template-friend -Wold-style-cast

-Woverloaded-virtual -Wno-pmf-conversions

-Wsign-promo


(4) Objective-C and Objective-C++ Language Options

See Section 3.6 [Options Controlling Objective-C and Objective-C++ Dialects]


(5) Language Independent Options

See Section 3.7 [Options to Control Diagnostic Messages Formatting], page 52.

-fmessage-length=n

-fdiagnostics-show-location=[once|every-line]

-fdiagnostics-color=[auto|never|always]

-fno-diagnostics-show-option -fno-diagnostics-show-caret


(6) Warning Options

See Section 3.8 [Options to Request or Suppress Warnings], page 53.

-fsyntax-only -fmax-errors=n -Wpedantic

-pedantic-errors

-w -Wextra -Wall -Waddress -Waggregate-return

-Waggressive-loop-optimizations -Warray-bounds

-Wno-attributes -Wno-builtin-macro-redefined

...


(7) C and Objective-C-only Warning Options

-Wbad-function-cast -Wmissing-declarations

-Wmissing-parameter-type -Wmissing-prototypes -Wnested-externs

-Wold-style-declaration -Wold-styple-definition

...


(8) Debugging Options

See Section 3.9 [Options for Debugging Your Program or GCC], page 78.

-dletters -dumpspecs -dumpmachine -dumpversion

-fsanitize=style

-fdbg-cnt-list -fdbg-cnt=counter-value-list

...


(9) Optimization Options

See Section 3.10 [Options that Control Optimization], page 101.

-faggressive-loop-optimizations - falign-functions[=n]

-falign-jumps[=n]

...


(10) Preprocessor Options

See Section 3.11 [Options Controlling the Preprocessor], page 155.

-Aquestion=answer

-A-question[=answer]

-C -dD -dI -dM -dN

-Dmacro[=defn] -E -H

-M -MM -MF -MG -MP -MQ -MT -nostdinc

...


(11) Assembler Option

See Section 3.12 [Passing Options to the Assembler], page 166.

-Wa, option -Xassembler option


(12) Linker Options

See Section 3.13 [Options for Linking], page 166.

object-file-name -llibrary

-nostartfiles -nodefaultlibs -nostdlib -pie -rdynamic

-s -static -static-libgcc -static-libstdc++

-shared -shared-libgcc -symbolic

...


(13) Directory Options

See Section 3.14 [Options for Directory Search], page 170.

-Bprefix -Idir -iplugindir=dir

-iquotedir -Ldir -specs=file -I-

--sysroot=dir --no-sysroot-suffix


(14) Machine Dependent Options

See Section 3.17 [Hardware Models and Configurations], page 180.

...


(15) Code Generation Options

See Section 3.18 [Options for Code Generation Conventions], page 323.

-fcall-saved-reg -fcall-used-reg

-ffixed-reg -fexceptions

-fnon-call-exceptions -fdelete-dead-exceptions -funwind-tables

...


3 Options Controlling the Kind of Output

Compilation can involve up to four stages: preprocessing, compilation proper, assembly and linking, always in that order. GCC is capable of preprocessing and compiling several files either into several assembler input files, or into one assembler input file; then each assembler input file produces an object file, and linking combines all the object files (those newly compiled, and thos specified as input) into an executable file.


For any given input file, the file name suffix determines what kind of compilation is done.

例如:

file.c  —— C source code that must be preprocessed.

file.cc/file.cp/file.cxx/file.cpp/file.CPP/file.c++/file.C —— C++ source code that must be preprocessed. Note that in '.cxx', the last two letters must both be literally 'x'. Likewise, '.C' refers to a literal capital C.

file.m —— Objective-C source code. Note that you must link with the 'libobjc' library to make an Objective-C program work.

file.mm/file.M —— Objective-C++ source code. Note that you must link with the 'libobjc' library to make an Objective-C++ program work. Note that '.M' refers to a literal capital M.

file.h —— C, C++, Objective-C or Objective-C++ header file to be turned into a precompiled header (default), or C, C++ header file to be turned into an Ada spec (via the '-fdump-ada-spec' switch).

file.go —— Go source code.


You can specify the input language explicitly with the '-x' option:

-x language

Specify explicitly the language for the following input files (rather than letting the compiler choose a default based on the file name suffix). This option applies to all following input files until the next '-x' option. Possible values for language are:

      c  c-header  cpp-output
      c++  c++-header  c++-cpp-output
      objective-c  objective-c-header  objective-c-cpp-output
      objective-c++ objective-c++-header objective-c++-cpp-output
      assembler  assembler-with-cpp
      ada
      f77  f77-cpp-input f95  f95-cpp-input
      go
      java

-x none

Turn off any specification of a language, so that subsequent files are handled according to their file name suffixes (as they are if '-x' has not been used at all).







 类似资料: