VirtualBox

Changeset 3278 in kBuild


Ignore:
Timestamp:
Jan 4, 2019 5:08:23 PM (6 years ago)
Author:
bird
Message:

kmk,footer-pass2-compiling-targets.kmk: Optimize def_target_source_rule and the associated kb-src-one function. This ditches the .obj aliases, so use .o instead.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/kBuild/footer-pass2-compiling-targets.kmk

    r3256 r3278  
    3737#
    3838
    39 ## wrapper the compile command dependency check.
     39ifndef NO_COMPILE_CMDS_DEPS
     40 ## Generates the rules for building a specific object and the aliases.
     41 # for building a source file.
     42 # @param    $(obj)    The object file.
     43 define def_target_source_rule_v3plus
     44$$(obj): .MUST_MAKE = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_CMDS_PREV_),$$(commands $$@),FORCE)
     45$$(obj) + $$(kbsrc_output) +| $$(kbsrc_output_maybe) : $$(kbsrc_depend) | $$(kbsrc_depord) $(target_intermediate_vars)
     46        %$$(call MSG_COMPILE,$(target),$(source),$$@,$(type))
     47  ifndef TOOL_$(tool)_COMPILE_$(type)_DONT_PURGE_OUTPUT
     48        $$(QUIET)$$(RM) -f -- $(dep) $(obj) $(kbsrc_output) $(kbsrc_output_maybe)
     49  endif
     50
     51$(kbsrc_cmds)
     52
     53        %$$(QUIET2)$$(APPEND) -in '$(dep)' '' 'define $(target)_$(subst :,_,$(source))_CMDS_PREV_' '--insert-command=$(obj)' 'endef'
     54$$(basename $$(notdir $$(obj))).o: $$(obj)
     55 endef # def_target_source_rule_v3plus
     56
     57 ## Generates the rules for building a specific object and the aliases, kObjCache variant.
     58 # for building a source file.
     59 # @param    $(obj)    The object file.
     60 define def_target_source_rule_v3plus_objcache
     61$$(obj): .MUST_MAKE = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_CMDS_PREV_),$$(commands $$@),FORCE)
     62_OUT_FILES += $(outbase).koc
     63$$(outbase).koc +| $$(obj) $$(kbsrc_output) $$(kbsrc_output_maybe) : $$(kbsrc_depend) | $$(kbsrc_depord) $(target_intermediate_vars)
     64        %$$(call MSG_COMPILE,$(target),$(source),$$@,$(type))
     65
     66$(kbsrc_cmds)
     67
     68        %$$(QUIET2)$$(APPEND) -in '$(dep)' '' 'define $(target)_$(subst :,_,$(source))_CMDS_PREV_' '--insert-command=$(obj)' 'endef'
     69$$(basename $$(notdir $$(obj))).o: $$(obj)
     70 endef # def_target_source_rule_v3plus_objcache
     71
     72else # NO_COMPILE_CMDS_DEPS
     73
     74 ## Generates the rules for building a specific object and the aliases.
     75 # for building a source file.
     76 # @param    $(obj)    The object file.
     77 define def_target_source_rule_v3plus
     78$$(obj) + $$(kbsrc_output) +| $$(kbsrc_output_maybe) : $$(kbsrc_depend) | $$(kbsrc_depord) $(target_intermediate_vars)
     79        %$$(call MSG_COMPILE,$(target),$(source),$$@,$(type))
     80  ifndef TOOL_$(tool)_COMPILE_$(type)_DONT_PURGE_OUTPUT
     81        $$(QUIET)$$(RM) -f -- $(dep) $(obj) $(kbsrc_output) $(kbsrc_output_maybe)
     82  endif
     83
     84$(kbsrc_cmds)
     85
     86$$(basename $$(notdir $$(obj))).o: $$(obj)
     87 endef # def_target_source_rule_v3plus
     88
     89 ## Generates the rules for building a specific object and the aliases, kObjCache variant.
     90 # for building a source file.
     91 # @param    $(obj)    The object file.
     92 define def_target_source_rule_v3plus_objcache
     93_OUT_FILES += $(outbase).koc
     94$(outbase).koc +| $(obj) $(kbsrc_output) $(kbsrc_output_maybe) : $(kbsrc_depend) | $(kbsrc_depord) $(target_intermediate_vars)
     95        %$$(call MSG_COMPILE,$(target),$(source),$$@,$(type))
     96
     97$(kbsrc_cmds)
     98
     99$$(basename $$(notdir $$(obj))).o: $$(obj)
     100 endef # def_target_source_rule_v3plus_objcache
     101
     102endif # NO_COMPILE_CMDS_DEPS
     103$(eval-opt-var def_target_source_rule_v3plus)
     104$(eval-opt-var def_target_source_rule_v3plus_objcache)
     105
     106
     107##
     108## Legacy legacy legacy - start
     109##
     110
     111## Wrapper
    40112ifndef NO_COMPILE_CMDS_DEPS
    41113 if1of ($(KMK_FEATURES),dot-must-make)
     
    49121endif
    50122
    51 
    52 ## Generates the rules for building a specific object, and the aliases
     123## Generates the rules for building a specific object, and the aliases - legacy version.
    53124# for building a source file.
    54125# @param    $(obj)    The object file.
     
    60131_OUT_FILES += $(outbase).koc
    61132$(outbase).koc +| $(obj) $($(target)_$(source)_OUTPUT_) $($(target)_$(source)_OUTPUT_MAYBE_) : \
    62                 $($(target)_$(source)_DEPEND_) \
    63                 $(value _DEP_COMPILE_CMDS) \
    64                 | \
    65                 $($(target)_$(source)_DEPORD_) \
    66                 $$$$($(target)_INTERMEDIATES) \
    67                 $$$$($(target)_INTERMEDIATES.$(bld_trg)) \
    68                 $$$$($(target)_INTERMEDIATES.$(bld_trg).$(bld_trg_arch)) \
    69                 $$$$($(target)_INTERMEDIATES.$(bld_trg_arch)) \
    70                 $$$$($(target)_INTERMEDIATES.$(bld_trg_cpu)) \
    71                 $$$$($(target)_INTERMEDIATES.$(bld_type))
     133                $($(target)_$(source)_DEPEND_) $(value _DEP_COMPILE_CMDS) \
     134                | $($(target)_$(source)_DEPORD_) $(target_intermediate_vars)
    72135        %$$(call MSG_COMPILE,$(target),$(source),$$@,$(type))
    73136else
    74137$(obj) + $($(target)_$(source)_OUTPUT_) +| $($(target)_$(source)_OUTPUT_MAYBE_) : \
    75                 $($(target)_$(source)_DEPEND_) \
    76                 $(value _DEP_COMPILE_CMDS) \
    77                 | \
    78                 $($(target)_$(source)_DEPORD_) \
    79                 $$$$($(target)_INTERMEDIATES) \
    80                 $$$$($(target)_INTERMEDIATES.$(bld_trg)) \
    81                 $$$$($(target)_INTERMEDIATES.$(bld_trg).$(bld_trg_arch)) \
    82                 $$$$($(target)_INTERMEDIATES.$(bld_trg_arch)) \
    83                 $$$$($(target)_INTERMEDIATES.$(bld_trg_cpu)) \
    84                 $$$$($(target)_INTERMEDIATES.$(bld_type))
     138                $($(target)_$(source)_DEPEND_) $(value _DEP_COMPILE_CMDS)
     139                | $($(target)_$(source)_DEPORD_) $(target_intermediate_vars)
    85140        %$$(call MSG_COMPILE,$(target),$(source),$$@,$(type))
    86141ifndef TOOL_$(tool)_COMPILE_$(type)_DONT_PURGE_OUTPUT
     
    106161
    107162$(basename $(notdir $(obj))).o: $(obj)
    108 $(basename $(notdir $(obj))).obj: $(obj)
    109163
    110164## @todo make this 'local cmds,output,output_maybe,depend and depord' in 0.2.x or when a new kb-src-one is added.
     
    116170endef # def_target_source_rule
    117171$(eval-opt-var def_target_source_rule)
     172##
     173## Legacy legacy legacy - end
     174
    118175
    119176
     
    213270define def_src_handler_c
    214271local type := C
    215  $(kb-src-one 2)
     272 $(kb-src-one 3)
    216273endef
    217274
    218275define def_src_handler_cxx
    219276local type := CXX
    220  $(kb-src-one 2)
     277 $(kb-src-one 3)
    221278endef
    222279
    223280define def_src_handler_objc
    224281local type := OBJC
    225  $(kb-src-one 2)
     282 $(kb-src-one 3)
    226283endef
    227284
    228285define def_src_handler_objcxx
    229286local type := OBJCXX
    230  $(kb-src-one 2)
     287 $(kb-src-one 3)
    231288endef
    232289
    233290define def_src_handler_asm
    234291local type := AS
    235  $(kb-src-one 2)
     292 $(kb-src-one 3)
    236293endef
    237294
    238295define def_src_handler_rc
    239296local type := RC
    240  $(kb-src-one 2)
     297 $(kb-src-one 3)
    241298endef
    242299
     
    490547$(target)_2_OBJS  :=
    491548
     549# kObjCache.
     550ifdef KBUILD_USE_KOBJCACHE
     551 ifneq ($($(target)_KOBJCACHE),)
     552local use_objcache := 1
     553 else
     554local use_objcache :=
     555 endif
     556local use_objcache :=
     557endif
     558
     559# target level intermediates
     560local target_intermediate_vars := $(foreach var, \
     561        $(target)_INTERMEDIATES \
     562        $(target)_INTERMEDIATES.$(bld_trg) \
     563        $(target)_INTERMEDIATES.$(bld_trg).$(bld_trg_arch) \
     564        $(target)_INTERMEDIATES.$(bld_trg_arch) \
     565        $(target)_INTERMEDIATES.$(bld_trg_cpu) \
     566        $(target)_INTERMEDIATES.$(bld_type) \
     567        ,$(if-expr defined($(var)),$$$$($(var)),))
     568#$(info target_intermediate_vars=$(target_intermediate_vars))
     569
    492570# Do units pre source callouts.
    493571local units       := \
     
    499577$(foreach unit,$(units),$(evalvalctx def_unit_$(unit)_target_pre))
    500578$(foreach unit,$(units),$(evalvalctx def_unit_$(unit)_target_pre_2))
    501 
    502 # kObjCache.
    503 ifdef KBUILD_USE_KOBJCACHE
    504  ifneq ($($(target)_KOBJCACHE),)
    505 local use_objcache := 1
    506  else
    507 local use_objcache :=
    508  endif
    509 local use_objcache :=
    510 endif
    511579
    512580# source -> object
     
    705773$(target)_2_OBJS  :=
    706774
     775# kObjCache.
     776ifdef KBUILD_USE_KOBJCACHE
     777 ifneq ($($(target)_KOBJCACHE),)
     778local use_objcache := 1
     779 else
     780local use_objcache :=
     781 endif
     782local use_objcache :=
     783endif
     784
     785# target level intermediates
     786local target_intermediate_vars := $(foreach var, \
     787        $(target)_INTERMEDIATES \
     788        $(target)_INTERMEDIATES.$(bld_trg) \
     789        $(target)_INTERMEDIATES.$(bld_trg).$(bld_trg_arch) \
     790        $(target)_INTERMEDIATES.$(bld_trg_arch) \
     791        $(target)_INTERMEDIATES.$(bld_trg_cpu) \
     792        $(target)_INTERMEDIATES.$(bld_type) \
     793        ,$(if-expr defined($(var)),$$$$($(var)),))
     794#$(info target_intermediate_vars=$(target_intermediate_vars))
     795
    707796# Do units pre source callouts.
    708797local units       := \
     
    714803$(foreach unit,$(units),$(evalvalctx def_unit_$(unit)_target_pre))
    715804$(foreach unit,$(units),$(evalvalctx def_unit_$(unit)_target_pre_2))
    716 
    717 # kObjCache.
    718 ifdef KBUILD_USE_KOBJCACHE
    719  ifneq ($($(target)_KOBJCACHE),)
    720 local use_objcache := 1
    721  else
    722 local use_objcache :=
    723  endif
    724 local use_objcache :=
    725 endif
    726805
    727806# source -> object
  • trunk/src/kmk/kbuild.c

    r3251 r3278  
    20072007#endif
    20082008    struct variable *pObj       = kbuild_set_object_name_and_dep_and_dirdep_and_PATH_target_source(pTarget, pSource, pOutBase, pObjSuff, "obj", &pDep, &pDirDep);
    2009     int fInstallOldVars = 0;
     2009    int fInstallOldObjsVar = 0;
    20102010    char *pszDstVar, *pszDst, *pszSrcVar, *pszSrc, *pszVal, *psz;
    20112011    char *pszSavedVarBuf;
     
    21232123    /** @todo Make all these local variables, if someone needs the info later it
    21242124     *        can be recalculated. (Ticket #80.) */
    2125     cch = sizeof("TOOL_") + pTool->value_length + sizeof("_COMPILE_") + pType->value_length + sizeof("_OUTPUT_MAYBE");
     2125    cch = sizeof("TOOL_") + pTool->value_length + sizeof("_COMPILE_") + pType->value_length + sizeof("_USES_KOBJCACHE");
    21262126    if (cch < pTarget->value_length + sizeof("$(_2_OBJS)"))
    21272127        cch = pTarget->value_length + sizeof("$(_2_OBJS)");
     
    21432143    memcpy(pszDst, "_CMDS_", sizeof("_CMDS_"));
    21442144    pVar = kbuild_get_recursive_variable(pszSrcVar);
    2145     do_variable_definition_2(NILF, pszDstVar, pVar->value, pVar->value_length,
    2146                              !pVar->recursive, 0, o_local, f_simple, 0 /* !target_var */);
     2145    if (iVer <= 2)
     2146        do_variable_definition_2(NILF, pszDstVar, pVar->value, pVar->value_length,
     2147                                 !pVar->recursive, 0, o_local, f_simple, 0 /* !target_var */);
    21472148    do_variable_definition_2(NILF, "kbsrc_cmds", pVar->value, pVar->value_length,
    21482149                             !pVar->recursive, 0, o_local, f_simple, 0 /* !target_var */);
     
    21512152    memcpy(pszDst, "_OUTPUT_", sizeof("_OUTPUT_"));
    21522153    pVar = kbuild_get_recursive_variable(pszSrcVar);
    2153     pOutput = do_variable_definition_2(NILF, pszDstVar, pVar->value, pVar->value_length,
    2154                                        !pVar->recursive, 0, o_local, f_simple, 0 /* !target_var */);
     2154    if (iVer <= 2)
     2155        pOutput = do_variable_definition_2(NILF, pszDstVar, pVar->value, pVar->value_length,
     2156                                           !pVar->recursive, 0, o_local, f_simple, 0 /* !target_var */);
    21552157    pOutput = do_variable_definition_2(NILF, "kbsrc_output", pVar->value, pVar->value_length,
    21562158                                       !pVar->recursive, 0, o_local, f_simple, 0 /* !target_var */);
     
    21612163    if (pVar)
    21622164    {
    2163         pOutputMaybe = do_variable_definition_2(NILF, pszDstVar, pVar->value, pVar->value_length,
    2164                                                 !pVar->recursive, 0, o_local, f_simple, 0 /* !target_var */);
     2165        if (iVer <= 2)
     2166            pOutputMaybe = do_variable_definition_2(NILF, pszDstVar, pVar->value, pVar->value_length,
     2167                                                    !pVar->recursive, 0, o_local, f_simple, 0 /* !target_var */);
    21652168        pOutputMaybe = do_variable_definition_2(NILF, "kbsrc_output_maybe", pVar->value, pVar->value_length,
    21662169                                                !pVar->recursive, 0, o_local, f_simple, 0 /* !target_var */);
     
    21682171    else
    21692172    {
    2170         pOutputMaybe = do_variable_definition_2(NILF, pszDstVar, "", 0, 1, 0, o_local, f_simple, 0 /* !target_var */);
     2173        if (iVer <= 2)
     2174            pOutputMaybe = do_variable_definition_2(NILF, pszDstVar, "", 0, 1, 0, o_local, f_simple, 0 /* !target_var */);
    21712175        pOutputMaybe = do_variable_definition_2(NILF, "kbsrc_output_maybe", "", 0, 1, 0, o_local, f_simple, 0 /* !target_var */);
    21722176    }
     
    21812185    *psz++ = ' ';
    21822186    memcpy(psz, pSource->value, pSource->value_length + 1);
    2183     do_variable_definition_2(NILF, pszDstVar, pszVal, pVar->value_length + 1 + pDeps->value_length + 1 + pSource->value_length,
    2184                              !pVar->recursive && !pDeps->recursive && !pSource->recursive,
    2185                              NULL, o_local, f_simple, 0 /* !target_var */);
     2187    if (iVer <= 2)
     2188        do_variable_definition_2(NILF, pszDstVar, pszVal, pVar->value_length + 1 + pDeps->value_length + 1 + pSource->value_length,
     2189                                 !pVar->recursive && !pDeps->recursive && !pSource->recursive,
     2190                                 NULL, o_local, f_simple, 0 /* !target_var */);
    21862191    do_variable_definition_2(NILF, "kbsrc_depend", pszVal, pVar->value_length + 1 + pDeps->value_length + 1 + pSource->value_length,
    21872192                             !pVar->recursive && !pDeps->recursive && !pSource->recursive,
     
    21972202    *psz++ = ' ';
    21982203    memcpy(psz, pOrderDeps->value, pOrderDeps->value_length + 1);
    2199     do_variable_definition_2(NILF, pszDstVar, pszVal,
    2200                              pVar->value_length + 1 + pDirDep->value_length + 1 + pOrderDeps->value_length,
    2201                              !pVar->recursive && !pDirDep->recursive && !pOrderDeps->recursive,
    2202                              NULL, o_local, f_simple, 0 /* !target_var */);
     2204    if (iVer <= 2)
     2205        do_variable_definition_2(NILF, pszDstVar, pszVal,
     2206                                 pVar->value_length + 1 + pDirDep->value_length + 1 + pOrderDeps->value_length,
     2207                                 !pVar->recursive && !pDirDep->recursive && !pOrderDeps->recursive,
     2208                                 NULL, o_local, f_simple, 0 /* !target_var */);
    22032209    do_variable_definition_2(NILF, "kbsrc_depord", pszVal,
    22042210                             pVar->value_length + 1 + pDirDep->value_length + 1 + pOrderDeps->value_length,
     
    22192225    memcpy(pszDstVar + pTarget->value_length, "_2_OBJS", sizeof("_2_OBJS"));
    22202226    pVar = kbuild_query_recursive_variable_n(pszDstVar, pTarget->value_length + sizeof("_2_OBJS") - 1);
    2221     fInstallOldVars |= iVer <= 2 && (!pVar || !pVar->value_length);
     2227    fInstallOldObjsVar |= iVer <= 2 && (!pVar || !pVar->value_length);
    22222228    if (pVar)
    22232229    {
     
    22352241
    22362242    /*
    2237      * Install legacy variables.
    2238      */
    2239     if (fInstallOldVars)
     2243     * Install legacy variable.
     2244     */
     2245    if (fInstallOldObjsVar)
    22402246    {
    22412247        /* $(target)_OBJS_ = $($(target)_2_OBJS)*/
     
    22592265    $(eval $(def_target_source_rule))
    22602266    */
    2261     pVar = kbuild_get_recursive_variable("def_target_source_rule");
    2262     pszVal = variable_expand_string_2 (o, pVar->value, pVar->value_length, &psz);
     2267    if (iVer > 2)
     2268    {
     2269        /*ifneq ($(TOOL_$(tool)_COMPILE_$(type)_USES_KOBJCACHE),)*/
     2270        int fUsesObjCache = 0;
     2271        memcpy(pszSrc, "_USES_KOBJCACHE", sizeof("_USES_KOBJCACHE"));
     2272        pVar = lookup_variable(pszSrcVar, pszSrc + sizeof("_USES_KOBJCACHE") - 1 - pszSrcVar);
     2273        if (pVar)
     2274        {
     2275            if (   !pVar->recursive
     2276                || IS_VARIABLE_RECURSIVE_WITHOUT_DOLLAR(pVar))
     2277                fUsesObjCache = pVar->value_length > 0;
     2278            else
     2279            {
     2280                unsigned int cchTmp = 0;
     2281                char *pszTmp = allocated_variable_expand_2(pVar->value, pVar->value_length, &cchTmp);
     2282                free(pszTmp);
     2283                fUsesObjCache = cchTmp > 0;
     2284            }
     2285        }
     2286        if (!fUsesObjCache)
     2287            pVar = kbuild_get_recursive_variable("def_target_source_rule_v3plus");
     2288        else
     2289            pVar = kbuild_get_recursive_variable("def_target_source_rule_v3plus_objcache");
     2290    }
     2291    else
     2292        pVar = kbuild_get_recursive_variable("def_target_source_rule");
     2293    pszVal = variable_expand_string_2(o, pVar->value, pVar->value_length, &psz);
    22632294    assert(!((size_t)pszVal & 3));
    22642295
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette