Browse Source

intermediate changes
ref:f1a76bb520860c96f863dde2f5dfa5e45b9ea67b

arcadia-devtools 3 years ago
parent
commit
430ee01442
4 changed files with 150 additions and 12 deletions
  1. 6 0
      build/plugins/docs.py
  2. 46 6
      build/scripts/link_exe.py
  3. 97 5
      build/ymake.core.conf
  4. 1 1
      contrib/libs/openssl/crypto/ya.make

+ 6 - 0
build/plugins/docs.py

@@ -42,3 +42,9 @@ def onprocess_docs(unit, *args):
             unit.set(['_DOCS_VARS_FLAG', '--vars {}'.format(json.dumps(json.dumps(variables, sort_keys=True)))])
         else:
             assert False, 'Unexpected build_tool value: [{}]'.format(build_tool)
+
+
+def onprocess_mkdocs(unit, *args):
+    orig_variables = macro_calls_to_dict(unit, extract_macro_calls(unit, '_DOCS_VARS_VALUE'))
+    variables = {k: unit.get(k) or v for k, v in orig_variables.items()}
+    unit.set(['_DOCS_VARS_FLAG', ' '.join(['--var {}={}'.format(k, v) for k, v in variables.items()])])

+ 46 - 6
build/scripts/link_exe.py

@@ -15,11 +15,45 @@ def get_leaks_suppressions(cmd):
     return supp, newcmd
 
 
-musl_libs = '-lc', '-lcrypt', '-ldl', '-lm', '-lpthread', '-lrt', '-lutil'
-
-
-def fix_cmd(musl, c):
-    return [i for i in c if (not musl or i not in musl_libs) and not i.endswith('.ios.interface') and not i.endswith('.pkg.fake')]
+MUSL_LIBS = '-lc', '-lcrypt', '-ldl', '-lm', '-lpthread', '-lrt', '-lutil'
+
+
+CUDA_LIBRARIES = {
+    '-llapack_static': '-llapack',
+    '-lcublas_static': '-lcublas',
+    '-lcublasLt_static': '-lcublasLt',
+    '-lcudart_static': '-lcudart',
+    '-lcufft_static_nocallback': '-lcufft',
+    '-lcurand_static': '-lcurand',
+    '-lcusolver_static': '-lcusolver',
+    '-lcusparse_static': '-lcusparse',
+}
+
+
+def remove_excessive_flags(cmd):
+    flags = []
+    for flag in cmd:
+        if not flag.endswith('.ios.interface') and not flag.endswith('.pkg.fake'):
+            flags.append(flag)
+    return flags
+
+
+def fix_cmd_for_musl(cmd):
+    flags = []
+    for flag in cmd:
+        if flag not in MUSL_LIBS:
+            flags.append(flag)
+    return flags
+
+
+def fix_cmd_for_dynamic_cuda(cmd):
+    flags = []
+    for flag in cmd:
+        if flag in CUDA_LIBRARIES:
+            flags.append(CUDA_LIBRARIES[flag])
+        else:
+            flags.append(flag)
+    return flags
 
 
 def gen_default_suppressions(inputs, output, source_root):
@@ -50,6 +84,7 @@ def parse_args():
     parser.add_option('--custom-step')
     parser.add_option('--python')
     parser.add_option('--source-root')
+    parser.add_option('--dynamic-cuda', action='store_true')
     parser.add_option('--arch')
     parser.add_option('--linker-output')
     parser.add_option('--whole-archive-peers', action='append')
@@ -60,7 +95,12 @@ def parse_args():
 if __name__ == '__main__':
     opts, args = parse_args()
 
-    cmd = fix_cmd(opts.musl, args)
+    cmd = remove_excessive_flags(args)
+    if opts.musl:
+        cmd = fix_cmd_for_musl(cmd)
+    
+    if opts.dynamic_cuda:
+        cmd = fix_cmd_for_dynamic_cuda(cmd)
     cmd = ProcessWholeArchiveOption(opts.arch, opts.whole_archive_peers, opts.whole_archive_libs).construct_cmd(cmd)
 
     if opts.custom_step:

+ 97 - 5
build/ymake.core.conf

@@ -1671,6 +1671,10 @@ module _BASE_PROGRAM: _LINK_UNIT {
         }
     }
 
+    when ($USE_DYNAMIC_CUDA == "yes") {
+        LINK_SCRIPT_EXE_FLAGS += --dynamic-cuda
+    }
+
     DEFAULT(CPU_CHECK yes)
     when ($USE_SSE4 != "yes" || $NOUTIL == "yes" || $ALLOCATOR == "FAKE") {
         CPU_CHECK = no
@@ -1861,6 +1865,13 @@ macro EXPORT_ALL_DYNAMIC_SYMBOLS() {
     ENABLE(EXPORT_ALL_DYNAMIC_SYMBOLS)
 }
 
+### @usage: USE_DYNAMIC_CUDA()
+###
+### Enable linking of PROGRAM with dynamic CUDA. By default CUDA uses static linking
+macro USE_DYNAMIC_CUDA() {
+    ENABLE(USE_DYNAMIC_CUDA)
+}
+
 ### @usage: CUSTOM_LINK_STEP_SCRIPT(name)
 ###
 ### Specifies name of a script for custom link step. The scripts
@@ -3233,18 +3244,28 @@ _DOCS_MKDOCS_CMD=$_DOCS_MKDOCS_CMD_IMPL($_DOCS_CONFIG_VALUE INCLUDE_SRCS $_DOCS_
 _DOCS_YFM_DEFAULT_CONFIG=$MODDIR/.yfm
 _DOCS_MKDOCS_DEFAULT_CONFIG=$MODDIR/mkdocs.yml
 
-### FIXME(snermolaev)
-module _DOCS_BASE_UNIT: _BARE_UNIT {
+# tags:docs
+### This module is intended for internal use only. Common parts for DOCS and MKDOCS multimodules
+### should be defined here.
+module _DOCS_BARE_UNIT: _BARE_UNIT {
     .ALLOWED=DOCS_DIR DOCS_CONFIG DOCS_VARS
     .CMD=TOUCH_DOCS_MF
     .FINAL_TARGET=no
 
-    ENABLE(_DOCS_BASE_UNIT)
+    ENABLE(_DOCS_BARE_UNIT)
 
     SET(MODULE_SUFFIX .tar.gz)
     SET(MODULE_LANG DOCS)
-    DEFAULT(_DOCS_BUILDER_VALUE yfm)
     DEFAULT(_DOCS_DIR_VALUE ${MODDIR})
+}
+
+# tag:docs
+### This module is intended for internal use only. Common parts for submodules of DOCS multimodule
+### should be defined here.
+module _DOCS_BASE_UNIT: _DOCS_BARE_UNIT {
+    ENABLE(_DOCS_BASE_UNIT)
+
+    DEFAULT(_DOCS_BUILDER_VALUE yfm)
     select ($_DOCS_BUILDER) {
         "yfm" ? {
             PEERDIR+=build/platform/yfm
@@ -3295,7 +3316,7 @@ macro _DOCS_YFM_USE_PLANTUML() {
 ###
 ### Documentation project multimodule.
 ###
-### When built directly, via RECURSE, DEPENDS or BUNDLE the output artifact is docs.tar.gz with statically generated site (using mkdocs as builder).
+### When built directly, via RECURSE, DEPENDS or BUNDLE the output artifact is docs.tar.gz with statically generated site.
 ### When PEERDIRed from other DOCS() module behaves like a UNION (supplying own content and dependencies to build target).
 ### Peerdirs from modules other than DOCS are not accepted.
 ### Most usual macros are not accepted, only used with the macros DOCS_DIR(), DOCS_CONFIG(), DOCS_VARS(), DOCS_BUILDER().
@@ -3342,6 +3363,77 @@ multimodule DOCS {
     }
 }
 
+# tag:docs
+### This module is intended for internal use only. Common parts for submodules of MKDOCS multimodule
+### should be defined here.
+module _MKDOCS_BASE_UNIT: _DOCS_BARE_UNIT {
+    .RESTRICTED=DOCS_BUILDER
+
+    ENABLE(_MKDOCS_BASE_UNIT)
+
+    DOCS_CONFIG($_DOCS_MKDOCS_DEFAULT_CONFIG)
+}
+
+# tag:internal tag:docs
+### _MKDOCS_EPILOOGUE() # internal
+###
+### This macro executes macros which should be envoked after all user
+### specified macros in the ya.make file
+macro _MKDOCS_EPILOGUE() {
+    _LATE_GLOB(_DOCS_SRCS_GLOB ${pre=${ARCADIA_ROOT}/;suf=/**/*:_DOCS_DIR_VALUE})
+    SET(_DOCS_SRCS_VALUE \${input;hide:_DOCS_SRCS_GLOB})
+}
+
+# tag:docs
+### @usage: MKDOCS()
+###
+### Documentation project multimodule.
+###
+### When built directly, via RECURSE, DEPENDS or BUNDLE the output artifact is docs.tar.gz with statically generated site (using mkdocs as builder).
+### When PEERDIRed from other MKDOCS() module behaves like a UNION (supplying own content and dependencies to build target).
+### Peerdirs from modules other than MKDOCS are not accepted.
+### Most usual macros are not accepted, only used with the macros DOCS_DIR(), DOCS_CONFIG(), DOCS_VARS().
+###
+### @see: [DOCS_DIR()](#macro_DOCS_DIR), [DOCS_CONFIG()](#macro_DOCS_CONFIG), [DOCS_VARS()](#macro_DOCS_VARS).
+multimodule MKDOCS {
+    module MKDOCSBOOK: _MKDOCS_BASE_UNIT {
+        .CMD=_DOCS_MKDOCS_CMD
+        .EPILOGUE=_MKDOCS_EPILOGUE
+        .FINAL_TARGET=yes
+        .PEERDIR_POLICY=as_build_from
+
+        ENABLE(MKDOCSBOOK)
+
+        SET(MODULE_TYPE PROGRAM)
+        SET(PEERDIR_TAGS MKDOCSLIB)
+        SET(MODULE_TAG MKDOCSBOOK)
+
+        _DOCS_MKDOCS_CMDLINE_SUFFIX=$_DOCS_MKDOCS_BOOK_CMDLINE_SUFFIX
+        _DOCS_COMMON_PROCESS_DEPS=$_DOCS_MKDOCS_BOOK_PROCESS_DEPS
+
+        PROCESS_MKDOCS()
+    }
+
+    module MKDOCSLIB: _MKDOCS_BASE_UNIT {
+        .CMD=_DOCS_MKDOCS_CMD
+        .EPILOGUE=_MKDOCS_EPILOGUE
+        .PEERDIR_POLICY=as_include
+
+        ENABLE(MKDOCSLIB)
+
+        SET(MODULE_TYPE LIBRARY)
+        SET(PEERDIR_TAGS MKDOCSLIB)
+        SET(MODULE_TAG MKDOCSLIB)
+
+        REALPRJNAME=preprocessed
+
+        _DOCS_MKDOCS_CMDLINE_SUFFIX=$_DOCS_MKDOCS_LIB_CMDLINE_SUFFIX
+        _DOCS_COMMON_PROCESS_DEPS=$_DOCS_COMMON_LIB_PROCESS_DEPS
+
+        PROCESS_MKDOCS()
+    }
+}
+
 # tag:docs
 _DOCS_USE_PLANTUML=
 ### @usage: USE_PLANTUML()

+ 1 - 1
contrib/libs/openssl/crypto/ya.make

@@ -99,7 +99,7 @@ CFLAGS(
     -DZLIB
 )
 
-IF (NOT IOS_ARM64 AND NOT DARWIN_ARM64)
+IF (NOT OS_IOS AND NOT DARWIN_ARM64)
     CFLAGS(
         -DDSO_NONE
         -DAESNI_ASM