This release includes a number of major improvements to Cuda project builds and new support for lex/ yACC builds, as well as customization support for on_link, before_link and after_link phases for target.
I’d also like to thank @OpportunityLiu for his support of XMake, who contributed a lot of code to improve Cuda support in this release. In addition, he helped improve xmake’s entire unit testing framework, self-updating programs, command-line TAB completion, and CI scripts, making xmake’s update iterations more efficient and stable.
- Program source code
- The official documentation
New Features
Cuda project build improvements
Header dependency detection and incremental compilation
Prior to 2.2.6, CUDA compilation support was not perfect, at least not even header dependency detection. Therefore, if cudA code has a lot of code, all changes will be compiled, rather than detected and incrementally compiled like C/C ++ code.
In the new version, Xmake supports it, and now it can handle dependencies on different platforms, which will improve the efficiency of daily compilation and development.
Added genCodes setting related API
In the previous version, adding gencodes configuration was very tedious and not simple. Please take a look at the previous configuration:
target("cuda_console")
set_kind("binary")
add_files("src/*.cu")
add_cuflags("-gencode arch=compute_30,code=sm_30", "-gencode arch=compute_35,code=sm_35")
add_cuflags("-gencode arch=compute_37,code=sm_37", "-gencode arch=compute_50,code=sm_50")
add_cuflags("-gencode arch=compute_52,code=sm_52", "-gencode arch=compute_60,code=sm_60")
add_cuflags("-gencode arch=compute_61,code=sm_61", "-gencode arch=compute_70,code=sm_70")
add_cuflags("-gencode arch=compute_70,code=compute_70")
add_ldflags("-gencode arch=compute_30,code=sm_30", "-gencode arch=compute_35,code=sm_35")
add_ldflags("-gencode arch=compute_37,code=sm_37", "-gencode arch=compute_50,code=sm_50")
add_ldflags("-gencode arch=compute_52,code=sm_52", "-gencode arch=compute_60,code=sm_60")
add_ldflags("-gencode arch=compute_61,code=sm_61", "-gencode arch=compute_70,code=sm_70")
add_ldflags("-gencode arch=compute_70,code=compute_70")
Copy the code
Therefore, in order to simplify the configuration of xmake.lua, add_cugencodesAPI was added to cudA project to simplify the configuration as follows:
target("cuda_console")
set_kind("binary")
add_files("src/*.cu")
-- generate SASS code for each SM architecture
add_cugencodes("sm_30", "sm_35", "sm_37", "sm_50", "sm_52", "sm_60", "sm_61", "sm_70")
-- generate PTX code from the highest SM architecture to guarantee forward-compatibility
add_cugencodes("compute_70")
Copy the code
In addition, when configured as add_cugencodes(“native”), Xmake will automatically detect the gencodes supported by the current device and automatically add them, which will be more convenient and efficient.
This, too, thanks to OpportunityLiu for the detection code and the implementation of add_cugenCodes.
Device-link Device link support
In the new release, Xmake basically reconstructs the entire CUDA build process, separating cudA-related builds into a separate CUDA build rule and using device-link by default.
About the description of the device – the link and benefits, you can refer to relevant official introduction: https://devblogs.nvidia.com/separate-compilation-linking-cuda-device-code/
Devlink is also required when compiling calls to __global__ or __device__ functions that contain cross-build units, so devlink is currently turned on by default in Xmake.
There is no need to make any changes to xmake.lua for the user, although if the user wants to manually disable Devlink, they can:
Target ("test") set_kind("binary") add_files(" SRC /*.cu") add_values("cuda.devlink", false) -- Explicitly disables the default device-link behaviorCopy the code
Support for compiling CUDA projects with CLang
Clang currently supports *. Cu files, but the number of CUDA versions supported by clang is limited. Clang7 only supports CUDa7-9.2, 8 through 10, and 10.1 requires Clang9.
Xmake supports calls to NVCC to compile CUDA projects, and also directly to clang to compile cudA projects. For example:
xmake f --cu=clang
xmake
Copy the code
However, devLink seems to rely on NVCC, which Clang does not support.
You can configure to switch the c++ compiler used by NVCC
Xmake added –ccbin= parameter to enable switching, NVCC default c++ compiler and linker, use as follows:
xmake f --ccbin=clang++
xmake
Copy the code
This allows NVCC to internally call the clang++ compiler while compiling cuda code.
Customize the linking process
In the new version, we have added customization related to the link stage. Users can extend their customization process by implementing on_link, before_link, and after_link in target/rule.
For example, if we want to preprocess other things, such as *. O files, before the link phase of normal C/C ++ code, we can write our own Lua scripts in the before_link phase:
target("test")
before_link(function (target)
print("process objects", target:objectfiles())
end)
Copy the code
Or if we want to override the built-in linking process, we can use on_link:
target("test")
on_link(function (target)
print("link objects", target:objectfiles())
end)
Copy the code
After_link does some customization after the link is complete.
Lex/Yacc compilation support
Xmake already supports lex/ Flex, yacc/bison, etc. L /. Y files to be compiled and processed natively.
We only need to add lex and yacc rules to target, so that it can handle. L /. Y files, of course.
target("calc")
set_kind("binary")
add_rules("lex", "yacc")
add_files("src/*.l", "src/*.y")
Copy the code
Here is an example code for reference: lex_yacc_example
Operating environment Settings improved
Setting the Running directory
The set_rundir interface is used to set the current directory in which the target program is run by default. If this is not set, target is loaded and run in the directory in which the executable is run by default.
If the user wants to change the load directory, one option is to customize the run logic with on_run() to do the switch, but doing so just to cut the directory is too tedious.
This interface allows you to quickly switch Settings to default execution directory environments.
target("test")
set_kind("binary")
add_files("src/*.c")
set_rundir("$(projectdir)/xxx")
Copy the code
Add runtime environment variables
Another new interface, add_runenvs, can be used to add environment variables that set the target program to run by default.
target("test")
set_kind("binary")
add_files("src/*.c")
add_runenvs("PATH", "/tmp/bin", "xxx/bin")
add_runenvs("NAME", "value")
Copy the code
Command line TAB completion support
To improve user experience, the new version also supports TAB completion of xmake command parameters on the command line. Users can easily and quickly TAB out all command parameters of Xmake.
Currently supports ZSH /bash/sh and Powershell.
More convenient self-update command
In previous versions, xmake has provided the convenient self-update command xmake update to update its own version, and even to update specific branch versions, such as xmake update dev/master
However, there are still some shortcomings:
- Each update requires recompiling the core, so updates are slow, but in many cases, new releases just change the script, not the core
- The update specifies the dev/master branch, which is not implemented perfectly on Windows, lags behind and does not sync instantly to the online dev/ Master version.
So this OpportunityLiu helped with a lot of the improvements:
- provide
xmake update -s/--scriptonly
Parameters, only update lua scripts, no additional compilation of core, fast iterative updates - Improve CI script, realize CI automatic construction on Windows,
xmake update dev
Automatically pull prebuilt installation packages from CI to download updates - You can specify that Xmake is updated from other Github repOs, making it easier for contributors to update their own fork versions, and for users to switch mirrored repOs,
xmake update gitee:tboox/xmake
Update the content
New features
- # 440: Added for target/run
set_rundir()
andadd_runenvs()
Interface Settings - #443: Added command line TAB auto-completion support
- As a rule/target to add
on_link
.before_link
andafter_link
Stage custom script support - # 190Add:
add_rules("lex", "yacc")
Rules to support lex/ YACC projects
To improve the
- # 430Add:
add_cucodegens()
API sets codeGen for CUDA improvements - #432: Dependency analysis checks are supported for CUDA compilation
- # 437: Supports specifying update sources,
xmake update github:xmake-io/xmake#dev
- # 438: Supports script update only,
xmake update --scriptonly dev
- #433: Improved CUDA builds to support device-link device code linking
- #442: Improve the Tests framework