From dcec7af445d2cf6c58816e1cf02028590be43a05 Mon Sep 17 00:00:00 2001 From: ruki Date: Fri, 14 Jun 2019 00:00:05 +0800 Subject: add add_culdflags api --- manual.md | 117 +++++++++++++++++++++++++++++++++-------------------------- zh/manual.md | 15 ++++++++ 2 files changed, 81 insertions(+), 51 deletions(-) diff --git a/manual.md b/manual.md index cd124e18..6e775f5c 100644 --- a/manual.md +++ b/manual.md @@ -908,6 +908,7 @@ target("test2") | [add_dcflags](#targetadd_dcflags) | Add dlang compilation flags | >= 2.1.1 | | [add_rcflags](#targetadd_rcflags) | Add rust compilation flags | >= 2.1.1 | | [add_cuflags](#targetadd_cuflags) | Add cuda compilation flags | >= 2.1.1 | +| [add_culdflags](#targetadd_culdflags) | Add cuda device-link flags | >= 2.2.7 | | [add_ldflags](#targetadd_ldflags) | Add static library link flags | >= 1.0.1 | | [add_arflags](#targetadd_arflags) | Add archive library flags | >= 1.0.1 | | [add_shflags](#targetadd_shflags) | Add dynamic library link flags | >= 1.0.1 | @@ -2581,6 +2582,19 @@ Add compilation options to cuda code add_cuflags("-gencode arch=compute_30,code=sm_30") ``` +##### target:add_culdflags + +###### Add cuda device link flags + +After v2.2.7, cuda default build will use device-link. If you want to set some link flags in this stage, you can set it through this interface. +The final program link will use ldflags, will not call nvcc, and directly link through c/c++ linker such as gcc/clang. + +For a description of device-link, please refer to: https://devblogs.nvidia.com/separate-compilation-linking-cuda-device-code/ + +```lua +add_culdflags("-gencode arch=compute_30,code=sm_30") +``` + ##### target:add_ldflags ###### Add static library link flags @@ -3223,57 +3237,58 @@ The `option` field can be repeatedly entered to implement separate settings. If

-| Interface | Description | Supported Versions | -| ----------------------------------------------------- | -------------------------------------------- | -------- | -| [option](#option) | Define Options | >= 2.0.1 | -| [option_end](#option_end) | End Definition Options | >= 2.1.1 | -| [add_deps](#optionadd_deps) | Add Options Dependencies | >= 2.1.5 | -| [before_check](#optionbefore_check) | Execute this script before option detection | >= 2.1.5 | -| [on_check](#optionon_check) | Custom Option Detection Script | >= 2.1.5 | -| [after_check](#optionafter_check) | Execute this script after option detection | >= 2.1.5 | -| [set_values](#optionset_values) | Setting the list of option values ​​| >= 2.1.9 | -| [set_default](#optionset_default) | Set Defaults | >= 2.0.1 | -| [set_showmenu](#optionset_showmenu) | Set whether to enable menu display | >= 1.0.1 | -| [set_category](#optionset_category) | Set option categories, only for menu display | >= 1.0.1 | -| [set_description](#optionset_description) | Settings Menu Display Description | >= 1.0.1 | -| [add_links](#optionadd_links) | Add Linked Library Detection | >= 1.0.1 | -| [add_linkdirs](#optionadd_linkdirs) | Add a search directory for link library detection | >= 1.0.1 | -| [add_rpathdirs](#optionadd_rpathdirs) | Add runtime dynamic link library search directory | >= 2.1.3 | -| [add_cincludes](#optionadd_cincludes) | Add c header file detection | >= 1.0.1 | -| [add_cxxincludes](#optionadd_cxxincludes) | Add c++ header file detection | >= 1.0.1 | -| [add_ctypes](#optionadd_ctypes) | Add c type detection | >= 1.0.1 | -| [add_cxxtypes](#optionadd_cxxtypes) | Add c++ type detection | >= 1.0.1 | -| [add_csnippet](#optionadd_csnippet) | Add c-code snippets detection | >= 2.1.5 | -| [add_cxxsnippet](#optionadd_cxxsnippet) | Add c++ code snippet detection | >= 2.1.5 | -| [set_warnings](#targetset_warnings) | Setting the warning level | >= 1.0.1 | -| [set_optimize](#targetset_optimize) | Setting the optimization level | >= 1.0.1 | -| [set_languages](#targetset_languages) | Setting the Code Language Standard | >= 1.0.1 | -| [add_includedirs](#targetadd_includedirs) | Add Header Search Directory | >= 1.0.1 | -| [add_defines](#targetadd_defines) | Add Macro Definition | >= 1.0.1 | -| [add_undefines](#targetadd_undefines) | Cancel Macro Definition | >= 1.0.1 | -| [add_defines_h](#targetadd_defines_h) | Add macro definitions to header files | >= 1.0.1 | -| [add_undefines_h](#targetadd_undefines_h) | Cancel macro definition to header file | >= 1.0.1 | -| [add_cflags](#targetadd_cflags) | Add c Compile Options | >= 1.0.1 | -| [add_cxflags](#targetadd_cxflags) | Add c/c++ Compile Options | >= 1.0.1 | -| [add_cxxflags](#targetadd_cxxflags) | Add c++ Compile Options | >= 1.0.1 | -| [add_mflags](#targetadd_mflags) | Add objc compile options | >= 2.0.1 | -| [add_mxflags](#targetadd_mxflags) | Add objc/objc++ Compile Options | >= 2.0.1 | -| [add_mxxflags](#targetadd_mxxflags) | Add objc++ Compile Options | >= 2.0.1 | -| [add_scflags](#targetadd_scflags) | Add swift compile options | >= 2.1.1 | -| [add_asflags](#targetadd_asflags) | Add assembly compile options | >= 2.1.1 | -| [add_gcflags](#targetadd_gcflags) | Add go compile options | >= 2.1.1 | -|[add_dcflags](#targetadd_dcflags) | Add dlang compile options | >= 2.1.1 | -| [add_rcflags](#targetadd_rcflags) | Add rust compile option | >= 2.1.1 | -| [add_cuflags](#targetadd_cuflags) | Add cuda compile options | >= 2.2.1 | -| [add_ldflags](#targetadd_ldflags) | Add Link Options | >= 2.1.1 | -| [add_arflags](#targetadd_arflags) | Add Static Library Archive Options | >= 2.1.1 | -| [add_shflags](#targetadd_shflags) | Add Dynamic Library Link Options | >= 2.0.1 | -| [add_cfuncs](#targetadd_cfuncs) | Add c library function detection | >= 1.0.1 | -| [add_cxxfuncs](#targetadd_cxxfuncs) | Add C++ Library Function Interface | >= 1.0.1 | -| [add_languages](#targetadd_languages) | Add Language Standards | >= 2.0.1 | -| [add_vectorexts](#targetadd_vectorexts) | Add Vector Extension Instructions | >= 2.0.1 | -| [add_frameworks](#targetadd_frameworks) | Add Linked Framework | >= 2.1.1 | -| [add_frameworkdirs](#targetadd_frameworkdirs) | Add Linked Framework | >= 2.1.5 | +| Interface | Description | Supported Versions | +| ----------------------------------------------------- | -------------------------------------------- | -------- | +| [option](#option) | Define Options | >= 2.0.1 | +| [option_end](#option_end) | End Definition Options | >= 2.1.1 | +| [add_deps](#optionadd_deps) | Add Options Dependencies | >= 2.1.5 | +| [before_check](#optionbefore_check) | Execute this script before option detection | >= 2.1.5 | +| [on_check](#optionon_check) | Custom Option Detection Script | >= 2.1.5 | +| [after_check](#optionafter_check) | Execute this script after option detection | >= 2.1.5 | +| [set_values](#optionset_values) | Setting the list of option values ​​ | >= 2.1.9 | +| [set_default](#optionset_default) | Set Defaults | >= 2.0.1 | +| [set_showmenu](#optionset_showmenu) | Set whether to enable menu display | >= 1.0.1 | +| [set_category](#optionset_category) | Set option categories, only for menu display | >= 1.0.1 | +| [set_description](#optionset_description) | Settings Menu Display Description | >= 1.0.1 | +| [add_links](#optionadd_links) | Add Linked Library Detection | >= 1.0.1 | +| [add_linkdirs](#optionadd_linkdirs) | Add a search directory for link library detection | >= 1.0.1 | +| [add_rpathdirs](#optionadd_rpathdirs) | Add runtime dynamic link library search directory | >= 2.1.3 | +| [add_cincludes](#optionadd_cincludes) | Add c header file detection | >= 1.0.1 | +| [add_cxxincludes](#optionadd_cxxincludes) | Add c++ header file detection | >= 1.0.1 | +| [add_ctypes](#optionadd_ctypes) | Add c type detection | >= 1.0.1 | +| [add_cxxtypes](#optionadd_cxxtypes) | Add c++ type detection | >= 1.0.1 | +| [add_csnippet](#optionadd_csnippet) | Add c-code snippets detection | >= 2.1.5 | +| [add_cxxsnippet](#optionadd_cxxsnippet) | Add c++ code snippet detection | >= 2.1.5 | +| [set_warnings](#targetset_warnings) | Setting the warning level | >= 1.0.1 | +| [set_optimize](#targetset_optimize) | Setting the optimization level | >= 1.0.1 | +| [set_languages](#targetset_languages) | Setting the Code Language Standard | >= 1.0.1 | +| [add_includedirs](#targetadd_includedirs) | Add Header Search Directory | >= 1.0.1 | +| [add_defines](#targetadd_defines) | Add Macro Definition | >= 1.0.1 | +| [add_undefines](#targetadd_undefines) | Cancel Macro Definition | >= 1.0.1 | +| [add_defines_h](#targetadd_defines_h) | Add macro definitions to header files | >= 1.0.1 | +| [add_undefines_h](#targetadd_undefines_h) | Cancel macro definition to header file | >= 1.0.1 | +| [add_cflags](#targetadd_cflags) | Add c Compile Options | >= 1.0.1 | +| [add_cxflags](#targetadd_cxflags) | Add c/c++ Compile Options | >= 1.0.1 | +| [add_cxxflags](#targetadd_cxxflags) | Add c++ Compile Options | >= 1.0.1 | +| [add_mflags](#targetadd_mflags) | Add objc compile options | >= 2.0.1 | +| [add_mxflags](#targetadd_mxflags) | Add objc/objc++ Compile Options | >= 2.0.1 | +| [add_mxxflags](#targetadd_mxxflags) | Add objc++ Compile Options | >= 2.0.1 | +| [add_scflags](#targetadd_scflags) | Add swift compile options | >= 2.1.1 | +| [add_asflags](#targetadd_asflags) | Add assembly compile options | >= 2.1.1 | +| [add_gcflags](#targetadd_gcflags) | Add go compile options | >= 2.1.1 | +| [add_dcflags](#targetadd_dcflags) | Add dlang compile options | >= 2.1.1 | +| [add_rcflags](#targetadd_rcflags) | Add rust compile option | >= 2.1.1 | +| [add_cuflags](#targetadd_cuflags) | Add cuda compile options | >= 2.2.1 | +| [add_culdflags](#targetadd_culdflags) | Add cuda device-link options | >= 2.2.7 | +| [add_ldflags](#targetadd_ldflags) | Add Link Options | >= 2.1.1 | +| [add_arflags](#targetadd_arflags) | Add Static Library Archive Options | >= 2.1.1 | +| [add_shflags](#targetadd_shflags) | Add Dynamic Library Link Options | >= 2.0.1 | +| [add_cfuncs](#targetadd_cfuncs) | Add c library function detection | >= 1.0.1 | +| [add_cxxfuncs](#targetadd_cxxfuncs) | Add C++ Library Function Interface | >= 1.0.1 | +| [add_languages](#targetadd_languages) | Add Language Standards | >= 2.0.1 | +| [add_vectorexts](#targetadd_vectorexts) | Add Vector Extension Instructions | >= 2.0.1 | +| [add_frameworks](#targetadd_frameworks) | Add Linked Framework | >= 2.1.1 | +| [add_frameworkdirs](#targetadd_frameworkdirs) | Add Linked Framework | >= 2.1.5 | | Obsolete Interface | Description | Supported Version | | ----------------------------------------------------- | -------------------------------------------- | ---------------- | diff --git a/zh/manual.md b/zh/manual.md index 93151dc5..38c718e4 100644 --- a/zh/manual.md +++ b/zh/manual.md @@ -936,6 +936,7 @@ target("test2") | [add_dcflags](#targetadd_dcflags) | 添加dlang编译选项 | >= 2.1.1 | | [add_rcflags](#targetadd_rcflags) | 添加rust编译选项 | >= 2.1.1 | | [add_cuflags](#targetadd_cuflags) | 添加cuda编译选项 | >= 2.2.1 | +| [add_culdflags](#targetadd_culdflags) | 添加cuda设备链接选项 | >= 2.2.7 | | [add_ldflags](#targetadd_ldflags) | 添加链接选项 | >= 1.0.1 | | [add_arflags](#targetadd_arflags) | 添加静态库归档选项 | >= 1.0.1 | | [add_shflags](#targetadd_shflags) | 添加动态库链接选项 | >= 1.0.1 | @@ -2602,6 +2603,19 @@ add_rcflags("xxx") add_cuflags("-gencode arch=compute_30,code=sm_30") ``` +##### target:add_culdflags + +###### 添加cuda设备链接选项 + +v2.2.7之后,cuda默认构建会使用device-link,这个阶段如果要设置一些链接flags,则可以通过这个接口来设置。 +而最终的程序链接,会使用ldflags,不会调用nvcc,直接通过gcc/clang等c/c++链接器来链接。 + +关于device-link的说明,可以参考:https://devblogs.nvidia.com/separate-compilation-linking-cuda-device-code/ + +```lua +add_culdflags("-gencode arch=compute_30,code=sm_30") +``` + ##### target:add_ldflags ###### 添加链接选项 @@ -3343,6 +3357,7 @@ option("test2") | [add_dcflags](#targetadd_dcflags) | 添加dlang编译选项 | >= 2.1.1 | | [add_rcflags](#targetadd_rcflags) | 添加rust编译选项 | >= 2.1.1 | | [add_cuflags](#targetadd_cuflags) | 添加cuda编译选项 | >= 2.2.1 | +| [add_culdflags](#targetadd_culdflags) | 添加cuda设备链接选项 | >= 2.2.7 | | [add_ldflags](#targetadd_ldflags) | 添加链接选项 | >= 2.1.1 | | [add_arflags](#targetadd_arflags) | 添加静态库归档选项 | >= 2.1.1 | | [add_shflags](#targetadd_shflags) | 添加动态库链接选项 | >= 2.0.1 | -- cgit v1.2.3