📄 gcc.jam
字号:
# # lib a : a.cpp b ; # obj b : b.cpp ; # exe c : c.cpp a d ; # obj d : d.cpp ; # # This all is fine, except that 'd' will be compiled with -fPIC even though # it is not needed, as 'd' is used only in exe. However, it is hard to # detect where a target is going to be used. Alternatively, we can set -fPIC # only when main target type is LIB but than 'b' would be compiled without # -fPIC which would lead to link errors on x86-64. So, compile everything # with -fPIC. # # Yet another alternative would be to create a propagated <sharedable> # feature and set it when building shared libraries, but that would be hard # to implement and would increase the target path length even more. # On Windows, fPIC is default, specifying -fPIC explicitly leads to # a warning. if $(target) != cygwin && $(target) != windows { OPTIONS on $(targets) += -fPIC ; } }}# FIXME: this should not use os.name.if [ os.name ] != NT && [ os.name ] != OSF && [ os.name ] != HPUX && [ os.name ] != AIX{ # OSF does have an option called -soname but it does not seem to work as # expected, therefore it has been disabled. HAVE_SONAME = "" ; SONAME_OPTION = -h ;}toolset.flags gcc.compile USER_OPTIONS <cflags> ;toolset.flags gcc.compile.c++ USER_OPTIONS <cxxflags> ;toolset.flags gcc.compile DEFINES <define> ;toolset.flags gcc.compile INCLUDES <include> ;toolset.flags gcc.compile.c++ TEMPLATE_DEPTH <c++-template-depth> ;rule compile.c++.pch ( targets * : sources * : properties * ){ setup-fpic $(targets) : $(sources) : $(properties) ;}actions compile.c++.pch{ "$(CONFIG_COMMAND)" -x c++-header $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)"}rule compile.c.pch ( targets * : sources * : properties * ){ setup-fpic $(targets) : $(sources) : $(properties) ;}actions compile.c.pch{ "$(CONFIG_COMMAND)" -x c-header $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)"}rule compile.c++ ( targets * : sources * : properties * ){ setup-threading $(targets) : $(sources) : $(properties) ; setup-fpic $(targets) : $(sources) : $(properties) ; # Some extensions are compiled as C++ by default. For others, we need to # pass -x c++. We could always pass -x c++ but distcc does not work with it. if ! $(>:S) in .cc .cp .cxx .cpp .c++ .C { LANG on $(<) = "-x c++" ; } DEPENDS $(<) : [ on $(<) return $(PCH_FILE) ] ; # Here we want to raise the template-depth parameter value to something # higher than the default value of 17. Note that we could do this using the # feature.set-default rule but we do not want to set the default value for # all toolsets as well. # # TODO: This 'modified default' has been inherited from some 'older Boost # Build implementation' and has most likely been added to make some Boost # library parts compile correctly. We should see what exactly prompted this # and whether we can get around the problem more locally. local template-depth = [ on $(<) return $(TEMPLATE_DEPTH) ] ; if ! $(template-depth) { TEMPLATE_DEPTH on $(<) = 128 ; }}rule compile.c ( targets * : sources * : properties * ){ setup-threading $(targets) : $(sources) : $(properties) ; setup-fpic $(targets) : $(sources) : $(properties) ; # If we use the name g++ then default file suffix -> language mapping does # not work. So have to pass -x option. Maybe, we can work around this by # allowing the user to specify both C and C++ compiler names. #if $(>:S) != .c #{ LANG on $(<) = "-x c" ; #} DEPENDS $(<) : [ on $(<) return $(PCH_FILE) ] ;}actions compile.c++ bind PCH_FILE{ "$(CONFIG_COMMAND)" $(LANG) -ftemplate-depth-$(TEMPLATE_DEPTH) $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(PCH_FILE:D)" -I"$(INCLUDES)" -c -o "$(<:W)" "$(>:W)"}actions compile.c bind PCH_FILE{ "$(CONFIG_COMMAND)" $(LANG) $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(PCH_FILE:D)" -I"$(INCLUDES)" -c -o "$(<)" "$(>)"}rule compile.asm{ LANG on $(<) = "-x assembler-with-cpp" ;}actions compile.asm{ "$(CONFIG_COMMAND)" $(LANG) $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)"}# The class which check that we don't try to use the <runtime-link>static# property while creating or using shared library, since it's not supported by# gcc/libc.class gcc-linking-generator : unix-linking-generator{ rule run ( project name ? : property-set : sources + ) { # TODO: Replace this with the use of a target-os property. local no-static-link = ; if [ modules.peek : UNIX ] { switch [ modules.peek : JAMUNAME ] { case * : no-static-link = true ; } } local properties = [ $(property-set).raw ] ; local reason ; if $(no-static-link) && <runtime-link>static in $(properties) { if <link>shared in $(properties) { reason = "On gcc, DLL can't be build with '<runtime-link>static'." ; } else if [ type.is-derived $(self.target-types[1]) EXE ] { for local s in $(sources) { local type = [ $(s).type ] ; if $(type) && [ type.is-derived $(type) SHARED_LIB ] { reason = "On gcc, using DLLS together with the" "<runtime-link>static options is not possible " ; } } } } if $(reason) { ECHO warning: $(reason) ; ECHO warning: "It is suggested to use '<runtime-link>static' together" "with '<link>static'." ; return ; } else { local generated-targets = [ unix-linking-generator.run $(project) $(name) : $(property-set) : $(sources) ] ; return $(generated-targets) ; } }}.IMPLIB-COMMAND = ;if [ os.on-windows ]{ .IMPLIB-COMMAND = "-Wl,--out-implib," ; generators.register [ new gcc-linking-generator gcc.link : OBJ SEARCHED_LIB STATIC_LIB IMPORT_LIB : EXE : <toolset>gcc ] ; generators.register [ new gcc-linking-generator gcc.link.dll : OBJ SEARCHED_LIB STATIC_LIB IMPORT_LIB : IMPORT_LIB SHARED_LIB : <toolset>gcc ] ;}else{ generators.register [ new gcc-linking-generator gcc.link : LIB OBJ : EXE : <toolset>gcc ] ; generators.register [ new gcc-linking-generator gcc.link.dll : LIB OBJ : SHARED_LIB : <toolset>gcc ] ;}# Declare flags for linking.# First, the common flags.toolset.flags gcc.link OPTIONS <debug-symbols>on : -g ;toolset.flags gcc.link OPTIONS <profiling>on : -pg ;toolset.flags gcc.link USER_OPTIONS <linkflags> ;toolset.flags gcc.link LINKPATH <library-path> ;toolset.flags gcc.link FINDLIBS-ST <find-static-library> ;toolset.flags gcc.link FINDLIBS-SA <find-shared-library> ;toolset.flags gcc.link LIBRARIES <library-file> ;# For <runtime-link>static we made sure there are no dynamic libraries in the# link. On HP-UX not all system libraries exist as archived libraries (for# example, there is no libunwind.a), so, on this platform, the -static option# cannot be specified.if [ os.name ] != HPUX{ toolset.flags gcc.link OPTIONS <runtime-link>static : -static ;}# Now, the vendor specific flags.# The parameter linker can be either aix, darwin, gnu, hpux, osf or sun.rule init-link-flags ( toolset linker condition ){ switch $(linker) { case aix : { # # On AIX we *have* to use the native linker. # # Using -brtl, the AIX linker will look for libraries with both the .a # and .so extensions, such as libfoo.a and libfoo.so. Without -brtl, the # AIX linker looks only for libfoo.a. Note that libfoo.a is an archived # file that may contain shared objects and is different from static libs # as on Linux. # # The -bnoipath strips the prepending (relative) path of libraries from # the loader section in the target library or executable. Hence, during # load-time LIBPATH (identical to LD_LIBRARY_PATH) or a hard-coded # -blibpath (*similar* to -lrpath/-lrpath-link) is searched. Without # this option, the prepending (relative) path + library name is # hard-coded in the loader section, causing *only* this path to be # searched during load-time. Note that the AIX linker does not have an # -soname equivalent, this is as close as it gets. # # The above options are definately for AIX 5.x, and most likely also for # AIX 4.x and AIX 6.x. For details about the AIX linker see: # http://download.boulder.ibm.com/ibmdl/pub/software/dw/aix/es-aix_ll.pdf # toolset.flags $(toolset).link OPTIONS : -Wl,-brtl -Wl,-bnoipath : unchecked ; } case darwin : { # On Darwin, the -s option to ld does not work unless we pass -static, # and passing -static unconditionally is a bad idea. So, don't pass -s. # at all, darwin.jam will use separate 'strip' invocation. toolset.flags $(toolset).link RPATH $(condition) : <dll-path> : unchecked ; toolset.flags $(toolset).link RPATH_LINK $(condition) : <xdll-path> : unchecked ; } case gnu : { # Strip the binary when no debugging is needed. We use --strip-all flag # as opposed to -s since icc (intel's compiler) is generally # option-compatible with and inherits from the gcc toolset, but does not # support -s. toolset.flags $(toolset).link OPTIONS $(condition)/<debug-symbols>off : -Wl,--strip-all : unchecked ; toolset.flags $(toolset).link RPATH $(condition) : <dll-path> : unchecked ; toolset.flags $(toolset).link RPATH_LINK $(condition) : <xdll-path> : unchecked ; toolset.flags $(toolset).link START-GROUP $(condition) : -Wl,--start-group : unchecked ; toolset.flags $(toolset).link END-GROUP $(condition) : -Wl,--end-group : unchecked ; # gnu ld has the ability to change the search behaviour for libraries # referenced by -l switch. These modifiers are -Bstatic and -Bdynamic # and change search for -l switches that follow them. The following list # shows the tried variants. # The search stops at the first variant that has a match. # *nix: -Bstatic -lxxx # libxxx.a # # *nix: -Bdynamic -lxxx # libxxx.so # libxxx.a # # windows (mingw,cygwin) -Bstatic -lxxx # libxxx.a # xxx.lib # # windows (mingw,cygwin) -Bdynamic -lxxx # libxxx.dll.a # xxx.dll.a # libxxx.a # xxx.lib # cygxxx.dll (*) # libxxx.dll # xxx.dll # libxxx.a # # (*) This is for cygwin # Please note that -Bstatic and -Bdynamic are not a guarantee that a # static or dynamic lib indeed gets linked in. The switches only change # search patterns!
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -