This version is mainly for building projects Cuda done a lot of improvements and adds support for lex / yacc compiler support, but also for a new target on_link
, before_link
and after_link
customization support the link stage.
Here, I would also like to thank Under @ OpportunityLiu support for xmake of this version OpportunityLiu contributed a lot of code to improve the support Cuda. In addition, he is also helping to improve the overall unit testing framework xmake, the self-update, tab completion and command-line ci script, making updating iteration xmake more efficient and stable.
New features introduced
Cuda project to build improvements
Header files rely detection and incremental compilation
Previous 2.2.6 version, build support for the cuda's not perfect, at least with his head files depend detection is not available, so if cuda code is more than one, each change will compile all, and not like c / c ++ code is as It does detect changes, incremental compilation.
In the new version, xmake its support, it is now well under different platforms, handle dependencies, and this will have a lot of improvement daily compilation and development efficiency.
New gencodes settings related to api
The previous version, add gencodes configuration is very complicated, not simple, before you can configure the look:
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")
Therefore, in order to streamline xmake.lua configuration for cuda project to increase the add_cugencodes
api to simplify configuration, the improvements are 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")
In addition, when configured to add_cugencodes("native")
time, xmake automatically detects current device supports gencodes, added automatically, will be more convenient and efficient.
This, thanks also to the next OpportunityLiu detection code provided as well as add_cugencodes
implementation.
device-link devices support link
The new version, xmake basically reconstruct the entire build process cuda will cuda related to a separate building detached building rule in cuda to maintain, and defaults to the device-link link way.
About device-link description and benefits that can refer to the relevant official description: https: //devblogs.nvidia.com/separate-compilation-linking-cuda-device-code/
We include cross-compilation unit at compile __global__
or __device__
call a function of time is required devlink, so in xmake, the current is turned on by default devlink.
For the user does not need to make any changes xmake.lua, of course, if you want to manually disable devlink, are possible:
target("test")
set_kind("binary")
add_files("src/*.cu")
add_values("cuda.devlink", false) -- 显式禁用默认的device-link行为
Support projects with a clang compiler cuda
clang compiler is also support for * .cu file, but a different version of clang cuda version is supported by certain restrictions, clang7 only support cuda7-9.2,8 support to 10, to support the need to get 10.1 clang9.
In addition to supporting and xmake call cuda nvcc to compile the project, you can cut directly to the clang compiled, for example:
xmake f --cu=clang
xmake
But on devlink, it seems to rely nvcc, clang is not supported.
Configurable switch c ++ compiler used nvcc
xmake added --ccbin=
parameters can be configured to switch, nvcc default c ++ compiler and linker used, are used as follows:
xmake f --ccbin=clang++
xmake
It can make nvcc cuda compiled code, internal call clang ++ compiler.
Customized linking process
In the new version, we added custom processing associated with the link linking phase, the user can be implemented in target / rule by on_link
, before_link
and after_link
to expand customize their linking process.
For example, we want to link stage before the normal c / c ++ code, pretreatment some other things, such as what to do to deal with * .o files, then you can write some of their own lua script before_link stage on the line:
target("test")
before_link(function (target)
print("process objects", target:objectfiles())
end)
Or we want to rewrite the built-linking process, you can use on_link
:
target("test")
on_link(function (target)
print("link objects", target:objectfiles())
end)
There after_link
is, after the completion of the link, do some customization tasks.
Lex / Yacc compiler support
Current xmake already native support lex / flex, yacc / bison and so on .l / compilation process .y file to quickly develop some with compiler-related projects.
We only need to add lex, yacc rules to the target in two, so that it can be processed .L / .y file, of course .ll / .yy also supported.
target("calc")
set_kind("binary")
add_rules("lex", "yacc")
add_files("src/*.l", "src/*.y")
Here is an example of code, for reference: lex_yacc_example
Improved operating environment settings
Setting the run directory
We can set_rundir
set the default interface is used to run the target program currently run directory, if not set by default, target directory is loaded to run the executable file.
If the user wants to modify the load directory, one is by on_run()
way of custom logic operation, which switches do, but just to cut a directory to do so, too cumbersome.
So you can quickly perform the default directory environment is set up to do this by switching interfaces.
target("test")
set_kind("binary")
add_files("src/*.c")
set_rundir("$(projectdir)/xxx")
Add runtime environment variables
Another new interfaces add_runenvs
can be used to add an environment variable to set the default run target program.
target("test")
set_kind("binary")
add_files("src/*.c")
add_runenvs("PATH", "/tmp/bin", "xxx/bin")
add_runenvs("NAME", "value")
Command line support tab completion
In order to improve the user experience, the new version of the command line xmake command parameters tab completion has done a support, users can easily and quickly tab xmake of all command parameters.
Currently supported zsh / bash / sh and powershell.
More convenient self-refresh command
The previous version, xmake has provided a convenient self-update command xmake update
to update xmake own version, and even update the specified branch version, for example:xmake update dev/master
However, there is some lack of places:
- Each update will need to be recompiled core, so the update is slow, however, in many cases, the new version with only script changes, core does not become
- Updates the specified dev / master branch, implemented on the windows is not perfect, a little lag, and can not immediately synchronized to the line dev / master version.
Therefore, this OpportunityLiu help make a lot of improvements:
- Provide
xmake update -s/--scriptonly
parameters, only update lua script, not additional compiler core, fast iterative update - Improved script ci, ci achieve automation built on windows,
xmake update dev
automatic pulling on ci good pre-built installation package to download the update - You can specify update xmake from other github repo, convenient fork contributors to update their version, but also facilitate the user to switch mirror repo,
xmake update gitee:tboox/xmake
update content
New features
- 440. # : / RUN add target
set_rundir()
andadd_runenvs()
interface settings - # 443 : added command-line tab auto-complete support
- As a rule / target to add
on_link
,before_link
andafter_link
stage custom scripts Support - # 190 : Adding
add_rules("lex", "yacc")
rules to support lex / yacc project
Improve
- # 430 : Add
add_cucodegens()
api set codegen to improve cuda - # 432 : cuda compiler support for dependency analysis to detect
- # 437 : Support for specified update source,
xmake update github:xmake-io/xmake#dev
- # 438 : Support only update the script,
xmake update --scriptonly dev
- # 433 : Improving cuda build support device-link device code link
- # 442 : Improving tests Testing Framework