From 499e6764e6fbb2a1e9b107e5b30f45ec2b13046c Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Mon, 25 Oct 2021 15:02:17 -0400 Subject: Enabling slang-llvm for host-callable (#1975) * #include an absolute path didn't work - because paths were taken to always be relative. * First integration of slang-pack. * Use .os * Add optional dependency support. * Update github actions/scripts to update deps. aarch64 needs special handling. * Upgrade to latest slang-pack for ignore-deps support. * Fix linux build issues. * Copying slang-llvm from dependencies. * Add support for LLVM for host callable. Added CodeGenTransitionMap. * Remove hack to enable host callable for LLVM. * Small improvements around transitions/downstream compiler. * Fix typo in method name. * Fix comment. * Update visual studio project. * Updage slang-llvm to include initialization fix. * Fix handling extraction of clang version number. * Fix some formatting problems. * hack - to see if there is a version problem on CI. * Remove progress on github action linux. * Allow version lines to have text before 'prefix'. * Update slang-binaries to include centos-7 premake binaries. * Upgrade slang-binaries. * Upgrade slang-binaries. * Update slang binaries to have certificates. * Fix handling of dependency path. * Update README to include LLVM Update building to include --deps and --arch * Include slang-llvm in packages. * Update building docs. --- docs/building.md | 42 +++++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 17 deletions(-) (limited to 'docs') diff --git a/docs/building.md b/docs/building.md index 5e1658c14..c7c1ab3ea 100644 --- a/docs/building.md +++ b/docs/building.md @@ -12,10 +12,9 @@ The submodule update step is required to pull in dependencies used for testing i ## Windows Using Visual Studio -Building from source is really only well supported for Windows users with Visual Studio 2015 or later. -If you are on Windows, then you can just open `slang.sln` and build your desired platform/configuration. - -The Visual Studio solution in the project is actually just generated using [`premake5`](https://premake.github.io/). See instructions in premake section below for further explanation. +If you are using Visual Studio on Windows, then you can just open `slang.sln` and build your desired platform/configuration. `slang.sln` and associated project files are actually just generated using [`premake5`](https://premake.github.io/). See instructions in premake section below for further explanation. + +Whilst using the provided `slang.sln` solution is a fast and easy way to get a build to work, it does not make all binary dependencies available which can add features and improve performance (such as [slang-llvm](https://github.com/shader-slang/slang-llvm)). To get the binary dependencies create the solution using [`premake5`](https://premake.github.io/) described in a later section. ## Other Targets @@ -52,22 +51,31 @@ If you are on a unix-like operating system such as OSX/Linux, it may be necesary Alternatively you can download and install [`premake5`](https://premake.github.io/) on your build system. -You can run `premake5` with `--help` to see available command line options (assuming premake5 is in your `PATH`): +Run `premake5` with `--help` to in the root of the Slang project to see available command line options (assuming `premake5` is in your `PATH`): ``` % premake5 --help ``` +To download and use binaries for a particular architecture the [slang-pack](https://github.com/shader-slang/slang-binaries/tree/master/lua-modules) package manager can be invoked via the additional `--deps` and `--arch` options. If `--arch` isn't specified it defaults to `x64`. On Windows targets, the Visual Studio platform setting should be consistent with the `--arch` option such that the appropriate binary dependencies are available. The `--deps=true` option just indicates that on invoking premake it should make the binary dependencies for the `arch` available. + +Supported `--arch` options are + +* x64 +* x86 +* aarch64 +* arm + For Unix like targets that might have `clang` or `gcc` compilers available you can select which one via the `-cc` option. For example... ``` -% premake5 gmake --cc=clang +% premake5 gmake --cc=clang --deps=true --arch=x64 ``` or ``` -% premake5 gmake --cc=clang +% premake5 gmake --cc=gcc --deps=true --arch=x64 ``` If you want to build the [`glslang`](https://github.com/KhronosGroup/glslang) library that Slang uses, add the option `--build-glslang=true`. @@ -97,19 +105,19 @@ To check what compiler is being used/command line options you can add `verbose=1 First download and install [`premake5`](https://premake.github.io/) on your build system. Open up a command line and go to the root directory of the slang source tree (ie the directory containing `slang.h`). -Assuming premake5 is in your `PATH`, you can create a Visual Studio 2015 project for Slang with the following command line +Assuming premake5 is in your `PATH`, you can create a Visual Studio 2017 project for Slang with the following command line ``` -% premake5 vs2015 +% premake5 vs2017 --deps=true --arch=x64 ``` -For Visual Studio 2017 use +For Visual Studio 2019 use ``` -% premake5 vs2017 +% premake5 vs2019 --deps=true --arch=x64 ``` -These should create a slang.sln in the same directory and which you can then open in the appropriate Visual Studio. Building will build all of slang and it's test infrastructure. +These should create a slang.sln in the same directory and which you can then open in the appropriate Visual Studio. Building will build all of Slang, examples and it's test infrastructure. ### Linux @@ -118,7 +126,7 @@ On Linux we need to generate Makefiles using `premake`. Please read the `premake In the terminal go to the root directory of the slang source tree (ie the directory containing `slang.h`). Assuming `premake5` is in your `PATH` use ``` -% premake5 gmake +% premake5 gmake --deps=true --arch=x64 ``` To create a release build use @@ -136,13 +144,13 @@ Note that OSX isn't an official target. On Mac OSX to generate Makefiles or an XCode project we use `premake`. Please read the `premake` section for more details. ``` -% premake5 gmake +% premake5 gmake --deps=true --arch=x64 ``` If you want to build `glslang` (necessary for Slang to output SPIR-V for example), then the additional `--build-glslang` option should be used ``` -% premake5 gmake --build-glslang=true +% premake5 gmake --build-glslang=true --deps=true --arch=x64 ``` To build for release you can use... @@ -154,7 +162,7 @@ To build for release you can use... Slang can also be built within the Xcode IDE. Invoke `premake` as follows ``` -% premake5 xcode4 +% premake5 xcode4 --deps=true --arch=x64 ``` Then open the `slang.xcworkspace` project inside of Xcode and build. @@ -166,7 +174,7 @@ Note that Cygwin isn't an official target. One issue with building on [Cygwin](https://cygwin.com/), is that there isn't a binary version of `premake` currently available. It may be possible to make this work by building `premake` from source, and then just doing `premake5 gmake`. Here we use another approach - using the windows `premake` to create a Cygwin project. To do this use the command line... ``` -% premake5 --target-detail=cygwin gmake +% premake5 --target-detail=cygwin gmake --deps=true --arch=x64 ``` ## Testing -- cgit v1.2.3