summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2021-10-25 15:02:17 -0400
committerGitHub <noreply@github.com>2021-10-25 15:02:17 -0400
commit499e6764e6fbb2a1e9b107e5b30f45ec2b13046c (patch)
treecb814599487f95d9a8436da5ea67aaa5702038f1
parent8fb8459150efcb61bd65e6e83d94d12c821f6a4e (diff)
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.
-rw-r--r--.github/workflows/release-linux.yml4
-rw-r--r--.github/workflows/release-windows.yml3
-rw-r--r--README.md6
-rw-r--r--build/visual-studio/slang/slang.vcxproj18
-rw-r--r--deps/target-deps.json8
-rw-r--r--docs/building.md42
m---------external/slang-binaries0
-rw-r--r--github_build.sh2
-rw-r--r--premake5.lua16
-rw-r--r--source/compiler-core/slang-gcc-compiler-util.cpp86
10 files changed, 127 insertions, 58 deletions
diff --git a/.github/workflows/release-linux.yml b/.github/workflows/release-linux.yml
index 8f31dc510..db8879757 100644
--- a/.github/workflows/release-linux.yml
+++ b/.github/workflows/release-linux.yml
@@ -40,9 +40,9 @@ jobs:
export SLANG_BINARY_ARCHIVE=slang-${SLANG_TAG}-${SLANG_OS_NAME}-${SLANG_ARCH_NAME}.zip
export SLANG_BINARY_ARCHIVE_TAR=slang-${SLANG_TAG}-${SLANG_OS_NAME}-${SLANG_ARCH_NAME}.tar.gz
echo "creating zip"
- zip -r ${SLANG_BINARY_ARCHIVE} bin/*/*/slangc bin/*/*/libslang.so bin/*/*/libslang-glslang.so bin/*/*/libgfx.so docs/*.md README.md LICENSE slang.h slang-com-helper.h slang-com-ptr.h slang-tag-version.h slang-gfx.h prelude/*.h
+ zip -r ${SLANG_BINARY_ARCHIVE} bin/*/*/slangc bin/*/*/libslang.so bin/*/*/libslang-glslang.so bin/*/*/libgfx.so bin/*/*/libslang-llvm.so docs/*.md README.md LICENSE slang.h slang-com-helper.h slang-com-ptr.h slang-tag-version.h slang-gfx.h prelude/*.h
echo "creating tar"
- tar -czf ${SLANG_BINARY_ARCHIVE_TAR} bin/*/*/slangc bin/*/*/libslang.so bin/*/*/libslang-glslang.so bin/*/*/libgfx.so docs/*.md README.md LICENSE slang.h slang-com-helper.h slang-com-ptr.h slang-tag-version.h slang-gfx.h prelude/*.h
+ tar -czf ${SLANG_BINARY_ARCHIVE_TAR} bin/*/*/slangc bin/*/*/libslang.so bin/*/*/libslang-glslang.so bin/*/*/libgfx.so bin/*/*/libslang-llvm.so docs/*.md README.md LICENSE slang.h slang-com-helper.h slang-com-ptr.h slang-tag-version.h slang-gfx.h prelude/*.h
echo "::set-output name=SLANG_BINARY_ARCHIVE::${SLANG_BINARY_ARCHIVE}"
echo "::set-output name=SLANG_BINARY_ARCHIVE_TAR::${SLANG_BINARY_ARCHIVE_TAR}"
- name: UploadBinary
diff --git a/.github/workflows/release-windows.yml b/.github/workflows/release-windows.yml
index 8079b2519..95932b174 100644
--- a/.github/workflows/release-windows.yml
+++ b/.github/workflows/release-windows.yml
@@ -32,7 +32,7 @@ jobs:
# Do the premake for the actual target, downloading dependencies if necessary
- name: premake
run:
- .\premake.bat vs2017 --enable-embed-stdlib=true --arch=${{matrix.platform}} --deps=true
+ .\premake.bat vs2017 --enable-embed-stdlib=true --arch=${{matrix.platform}} --deps=true --no-progress=true
- name: msbuild
run:
MSBuild.exe slang.sln -v:m -m -property:Configuration=${{matrix.configuration}} -property:Platform=${{matrix.platform}} -property:WindowsTargetPlatformVersion=10.0.19041.0
@@ -68,6 +68,7 @@ jobs:
7z a "$binArchive" bin\*\*\slang.dll
7z a "$binArchive" bin\*\*\slang.lib
7z a "$binArchive" bin\*\*\slang-glslang.dll
+ 7z a "$binArchive" bin\*\*\slang-llvm.dll
7z a "$binArchive" bin\*\*\gfx.dll
7z a "$binArchive" bin\*\*\slangc.exe
7z a "$binArchive" docs\*.md
diff --git a/README.md b/README.md
index 8f3db5720..e943c0c00 100644
--- a/README.md
+++ b/README.md
@@ -75,7 +75,11 @@ Builds of the core Slang tools depend on the following projects, either automati
* [`spirv-headers`](https://github.com/KhronosGroup/SPIRV-Headers) (Modified MIT)
* [`spirv-tools`](https://github.com/KhronosGroup/SPIRV-Tools) (Apache 2.0)
-Some of the tests and example programs that build with Slang use the following projets, which may have their own licenses:
+Slang releases may include [slang-llvm](https://github.com/shader-slang/slang-llvm) which includes [LLVM](https://github.com/llvm/llvm-project) under the license:
+
+* [`llvm`](https://llvm.org/docs/DeveloperPolicy.html#new-llvm-project-license-framework) (Apache 2.0 License with LLVM exceptions)
+
+Some of the tests and example programs that build with Slang use the following projects, which may have their own licenses:
* [`glm`](https://github.com/g-truc/glm) (MIT)
* `stb_image` and `stb_image_write` from the [`stb`](https://github.com/nothings/stb) collection of single-file libraries (Public Domain)
diff --git a/build/visual-studio/slang/slang.vcxproj b/build/visual-studio/slang/slang.vcxproj
index 7af461800..6a7a3e54f 100644
--- a/build/visual-studio/slang/slang.vcxproj
+++ b/build/visual-studio/slang/slang.vcxproj
@@ -177,7 +177,8 @@
<TreatLinkerWarningAsErrors>true</TreatLinkerWarningAsErrors>
</Link>
<PostBuildEvent>
- <Command>IF EXIST ..\..\..\external\slang-binaries\bin\windows-x86\slang-glslang.dll\ (xcopy /Q /E /Y /I ..\..\..\external\slang-binaries\bin\windows-x86\slang-glslang.dll ..\..\..\bin\windows-x86\debug &gt; nul) ELSE (xcopy /Q /Y /I ..\..\..\external\slang-binaries\bin\windows-x86\slang-glslang.dll ..\..\..\bin\windows-x86\debug &gt; nul)</Command>
+ <Command>IF EXIST ..\..\..\external\slang-llvm\bin\windows-x86\release\slang-llvm.dll\ (xcopy /Q /E /Y /I ..\..\..\external\slang-llvm\bin\windows-x86\release\slang-llvm.dll ..\..\..\bin\windows-x86\debug &gt; nul) ELSE (xcopy /Q /Y /I ..\..\..\external\slang-llvm\bin\windows-x86\release\slang-llvm.dll ..\..\..\bin\windows-x86\debug &gt; nul)
+IF EXIST ..\..\..\external\slang-binaries\bin\windows-x86\slang-glslang.dll\ (xcopy /Q /E /Y /I ..\..\..\external\slang-binaries\bin\windows-x86\slang-glslang.dll ..\..\..\bin\windows-x86\debug &gt; nul) ELSE (xcopy /Q /Y /I ..\..\..\external\slang-binaries\bin\windows-x86\slang-glslang.dll ..\..\..\bin\windows-x86\debug &gt; nul)</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
@@ -198,7 +199,8 @@
<TreatLinkerWarningAsErrors>true</TreatLinkerWarningAsErrors>
</Link>
<PostBuildEvent>
- <Command>IF EXIST ..\..\..\external\slang-binaries\bin\windows-x64\slang-glslang.dll\ (xcopy /Q /E /Y /I ..\..\..\external\slang-binaries\bin\windows-x64\slang-glslang.dll ..\..\..\bin\windows-x64\debug &gt; nul) ELSE (xcopy /Q /Y /I ..\..\..\external\slang-binaries\bin\windows-x64\slang-glslang.dll ..\..\..\bin\windows-x64\debug &gt; nul)</Command>
+ <Command>IF EXIST ..\..\..\external\slang-llvm\bin\windows-x64\release\slang-llvm.dll\ (xcopy /Q /E /Y /I ..\..\..\external\slang-llvm\bin\windows-x64\release\slang-llvm.dll ..\..\..\bin\windows-x64\debug &gt; nul) ELSE (xcopy /Q /Y /I ..\..\..\external\slang-llvm\bin\windows-x64\release\slang-llvm.dll ..\..\..\bin\windows-x64\debug &gt; nul)
+IF EXIST ..\..\..\external\slang-binaries\bin\windows-x64\slang-glslang.dll\ (xcopy /Q /E /Y /I ..\..\..\external\slang-binaries\bin\windows-x64\slang-glslang.dll ..\..\..\bin\windows-x64\debug &gt; nul) ELSE (xcopy /Q /Y /I ..\..\..\external\slang-binaries\bin\windows-x64\slang-glslang.dll ..\..\..\bin\windows-x64\debug &gt; nul)</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug aarch64|ARM'">
@@ -219,7 +221,8 @@
<TreatLinkerWarningAsErrors>true</TreatLinkerWarningAsErrors>
</Link>
<PostBuildEvent>
- <Command>IF EXIST ..\..\..\external\slang-binaries\bin\windows-aarch64\slang-glslang.dll\ (xcopy /Q /E /Y /I ..\..\..\external\slang-binaries\bin\windows-aarch64\slang-glslang.dll ..\..\..\bin\windows-aarch64\debug &gt; nul) ELSE (xcopy /Q /Y /I ..\..\..\external\slang-binaries\bin\windows-aarch64\slang-glslang.dll ..\..\..\bin\windows-aarch64\debug &gt; nul)</Command>
+ <Command>IF EXIST ..\..\..\external\slang-llvm\bin\windows-aarch64\release\slang-llvm.dll\ (xcopy /Q /E /Y /I ..\..\..\external\slang-llvm\bin\windows-aarch64\release\slang-llvm.dll ..\..\..\bin\windows-aarch64\debug &gt; nul) ELSE (xcopy /Q /Y /I ..\..\..\external\slang-llvm\bin\windows-aarch64\release\slang-llvm.dll ..\..\..\bin\windows-aarch64\debug &gt; nul)
+IF EXIST ..\..\..\external\slang-binaries\bin\windows-aarch64\slang-glslang.dll\ (xcopy /Q /E /Y /I ..\..\..\external\slang-binaries\bin\windows-aarch64\slang-glslang.dll ..\..\..\bin\windows-aarch64\debug &gt; nul) ELSE (xcopy /Q /Y /I ..\..\..\external\slang-binaries\bin\windows-aarch64\slang-glslang.dll ..\..\..\bin\windows-aarch64\debug &gt; nul)</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@@ -244,7 +247,8 @@
<TreatLinkerWarningAsErrors>true</TreatLinkerWarningAsErrors>
</Link>
<PostBuildEvent>
- <Command>IF EXIST ..\..\..\external\slang-binaries\bin\windows-x86\slang-glslang.dll\ (xcopy /Q /E /Y /I ..\..\..\external\slang-binaries\bin\windows-x86\slang-glslang.dll ..\..\..\bin\windows-x86\release &gt; nul) ELSE (xcopy /Q /Y /I ..\..\..\external\slang-binaries\bin\windows-x86\slang-glslang.dll ..\..\..\bin\windows-x86\release &gt; nul)</Command>
+ <Command>IF EXIST ..\..\..\external\slang-llvm\bin\windows-x86\release\slang-llvm.dll\ (xcopy /Q /E /Y /I ..\..\..\external\slang-llvm\bin\windows-x86\release\slang-llvm.dll ..\..\..\bin\windows-x86\release &gt; nul) ELSE (xcopy /Q /Y /I ..\..\..\external\slang-llvm\bin\windows-x86\release\slang-llvm.dll ..\..\..\bin\windows-x86\release &gt; nul)
+IF EXIST ..\..\..\external\slang-binaries\bin\windows-x86\slang-glslang.dll\ (xcopy /Q /E /Y /I ..\..\..\external\slang-binaries\bin\windows-x86\slang-glslang.dll ..\..\..\bin\windows-x86\release &gt; nul) ELSE (xcopy /Q /Y /I ..\..\..\external\slang-binaries\bin\windows-x86\slang-glslang.dll ..\..\..\bin\windows-x86\release &gt; nul)</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@@ -269,7 +273,8 @@
<TreatLinkerWarningAsErrors>true</TreatLinkerWarningAsErrors>
</Link>
<PostBuildEvent>
- <Command>IF EXIST ..\..\..\external\slang-binaries\bin\windows-x64\slang-glslang.dll\ (xcopy /Q /E /Y /I ..\..\..\external\slang-binaries\bin\windows-x64\slang-glslang.dll ..\..\..\bin\windows-x64\release &gt; nul) ELSE (xcopy /Q /Y /I ..\..\..\external\slang-binaries\bin\windows-x64\slang-glslang.dll ..\..\..\bin\windows-x64\release &gt; nul)</Command>
+ <Command>IF EXIST ..\..\..\external\slang-llvm\bin\windows-x64\release\slang-llvm.dll\ (xcopy /Q /E /Y /I ..\..\..\external\slang-llvm\bin\windows-x64\release\slang-llvm.dll ..\..\..\bin\windows-x64\release &gt; nul) ELSE (xcopy /Q /Y /I ..\..\..\external\slang-llvm\bin\windows-x64\release\slang-llvm.dll ..\..\..\bin\windows-x64\release &gt; nul)
+IF EXIST ..\..\..\external\slang-binaries\bin\windows-x64\slang-glslang.dll\ (xcopy /Q /E /Y /I ..\..\..\external\slang-binaries\bin\windows-x64\slang-glslang.dll ..\..\..\bin\windows-x64\release &gt; nul) ELSE (xcopy /Q /Y /I ..\..\..\external\slang-binaries\bin\windows-x64\slang-glslang.dll ..\..\..\bin\windows-x64\release &gt; nul)</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release aarch64|ARM'">
@@ -294,7 +299,8 @@
<TreatLinkerWarningAsErrors>true</TreatLinkerWarningAsErrors>
</Link>
<PostBuildEvent>
- <Command>IF EXIST ..\..\..\external\slang-binaries\bin\windows-aarch64\slang-glslang.dll\ (xcopy /Q /E /Y /I ..\..\..\external\slang-binaries\bin\windows-aarch64\slang-glslang.dll ..\..\..\bin\windows-aarch64\release &gt; nul) ELSE (xcopy /Q /Y /I ..\..\..\external\slang-binaries\bin\windows-aarch64\slang-glslang.dll ..\..\..\bin\windows-aarch64\release &gt; nul)</Command>
+ <Command>IF EXIST ..\..\..\external\slang-llvm\bin\windows-aarch64\release\slang-llvm.dll\ (xcopy /Q /E /Y /I ..\..\..\external\slang-llvm\bin\windows-aarch64\release\slang-llvm.dll ..\..\..\bin\windows-aarch64\release &gt; nul) ELSE (xcopy /Q /Y /I ..\..\..\external\slang-llvm\bin\windows-aarch64\release\slang-llvm.dll ..\..\..\bin\windows-aarch64\release &gt; nul)
+IF EXIST ..\..\..\external\slang-binaries\bin\windows-aarch64\slang-glslang.dll\ (xcopy /Q /E /Y /I ..\..\..\external\slang-binaries\bin\windows-aarch64\slang-glslang.dll ..\..\..\bin\windows-aarch64\release &gt; nul) ELSE (xcopy /Q /Y /I ..\..\..\external\slang-binaries\bin\windows-aarch64\slang-glslang.dll ..\..\..\bin\windows-aarch64\release &gt; nul)</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
diff --git a/deps/target-deps.json b/deps/target-deps.json
index 987bbc6c3..6cefa7575 100644
--- a/deps/target-deps.json
+++ b/deps/target-deps.json
@@ -4,13 +4,13 @@
"dependencies" : [
{
"name" : "slang-llvm",
- "baseUrl" : "https://github.com/shader-slang/slang-llvm/releases/download/v13.x-18/",
+ "baseUrl" : "https://github.com/shader-slang/slang-llvm/releases/download/v13.x-19/",
"optional" : true,
"packages" :
{
- "windows-x86_64" : { "type" : "unavailable", "path" : "slang-llvm-13.x-18-win64.zip" },
- "windows-x86" : { "type": "unavailable", "path" : "slang-llvm-13.x-18-win32.zip" },
- "linux-x86_64" : { "type": "unavailable", "path" : "slang-llvm-v13.x-18-linux-x86_64-release.zip" }
+ "windows-x86_64" : { "type" : "url", "path" : "slang-llvm-13.x-19-win64.zip" },
+ "windows-x86" : { "type": "url", "path" : "slang-llvm-13.x-19-win32.zip" },
+ "linux-x86_64" : { "type": "url", "path" : "slang-llvm-v13.x-19-linux-x86_64-release.zip" }
}
},
{
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
diff --git a/external/slang-binaries b/external/slang-binaries
-Subproject d02ab808ba887ed59a16702aa4a2d67082ab191
+Subproject a1cfc4485fcfed4687afb99f51522fda7d3f24c
diff --git a/github_build.sh b/github_build.sh
index 8a0fd8b79..7e23294a6 100644
--- a/github_build.sh
+++ b/github_build.sh
@@ -8,7 +8,7 @@ git describe --tags | sed -e "s/\(.*\)/\#define SLANG_TAG_VERSION \"\1\"/" > sla
cat slang-tag-version.h
# Create the makefile
-./premake5 gmake --cc=${CC} --enable-embed-stdlib=true --arch=${ARCH} --deps=true
+./premake5 gmake --cc=${CC} --enable-embed-stdlib=true --arch=${ARCH} --deps=true --no-progress=true
# Build the configuration
make config=${CONFIGURATION}_x64 -j`nproc`
diff --git a/premake5.lua b/premake5.lua
index 57658d6d7..f83499ce2 100644
--- a/premake5.lua
+++ b/premake5.lua
@@ -1305,6 +1305,22 @@ end
dependson { "run-generators" }
+ -- If we have slang-llvm copy it
+ local slangLLVMPath = deps:getProjectRelativePath("slang-llvm", "../../..")
+
+ if slangLLVMPath then
+
+ filter { "system:windows" }
+ postbuildcommands {
+ "{COPY} " .. slangLLVMPath .."/bin/" .. targetName .. "/release/slang-llvm.dll %{cfg.targetdir}"
+ }
+
+ filter { "system:linux" }
+ postbuildcommands {
+ "{COPY} " .. slangLLVMPath .. "/bin/" .. targetName .. "/release/libslang-llvm.so %{cfg.targetdir}"
+ }
+ end
+
-- If we are not building glslang from source, then be
-- sure to copy a binary copy over to the output directory
if not buildGlslang then
diff --git a/source/compiler-core/slang-gcc-compiler-util.cpp b/source/compiler-core/slang-gcc-compiler-util.cpp
index 971416ddb..c897f5492 100644
--- a/source/compiler-core/slang-gcc-compiler-util.cpp
+++ b/source/compiler-core/slang-gcc-compiler-util.cpp
@@ -7,10 +7,37 @@
#include "../core/slang-io.h"
#include "../core/slang-shared-library.h"
+#include "../core/slang-char-util.h"
namespace Slang
{
+static Index _findVersionEnd(const UnownedStringSlice& in)
+{
+ Index numDots = 0;
+ const Index len = in.getLength();
+
+ for (Index i = 0; i < len; ++i)
+ {
+ const char c = in[i];
+ if (CharUtil::isDigit(c))
+ {
+ continue;
+ }
+ if (c == '.')
+ {
+ if (numDots >= 2)
+ {
+ return i;
+ }
+ numDots++;
+ continue;
+ }
+ return i;
+ }
+ return len;
+}
+
/* static */SlangResult GCCDownstreamCompilerUtil::parseVersion(const UnownedStringSlice& text, const UnownedStringSlice& prefix, DownstreamCompiler::Desc& outDesc)
{
List<UnownedStringSlice> lines;
@@ -18,38 +45,42 @@ namespace Slang
for (auto line : lines)
{
- if (line.startsWith(prefix))
+ Index prefixIndex = line.indexOf(prefix);
+ if (prefixIndex < 0)
{
- const UnownedStringSlice remainingSlice = UnownedStringSlice(line.begin() + prefix.getLength(), line.end()).trim();
- const Index versionEndIndex = remainingSlice.indexOf(' ');
- if (versionEndIndex < 0)
- {
- return SLANG_FAIL;
- }
+ continue;
+ }
- const UnownedStringSlice versionSlice(remainingSlice.begin(), remainingSlice.begin() + versionEndIndex);
+ const UnownedStringSlice remainingSlice = UnownedStringSlice(line.begin() + prefixIndex + prefix.getLength(), line.end()).trim();
- // Version is in format 0.0.0
- List<UnownedStringSlice> split;
- StringUtil::split(versionSlice, '.', split);
- List<Int> digits;
+ const Index versionEndIndex = _findVersionEnd(remainingSlice);
+ if (versionEndIndex < 0)
+ {
+ return SLANG_FAIL;
+ }
- for (auto v : split)
- {
- Int version;
- SLANG_RETURN_ON_FAIL(StringUtil::parseInt(v, version));
- digits.add(version);
- }
+ const UnownedStringSlice versionSlice(remainingSlice.begin(), remainingSlice.begin() + versionEndIndex);
- if (digits.getCount() < 2)
- {
- return SLANG_FAIL;
- }
+ // Version is in format 0.0.0
+ List<UnownedStringSlice> split;
+ StringUtil::split(versionSlice, '.', split);
+ List<Int> digits;
- outDesc.majorVersion = digits[0];
- outDesc.minorVersion = digits[1];
- return SLANG_OK;
+ for (auto v : split)
+ {
+ Int version;
+ SLANG_RETURN_ON_FAIL(StringUtil::parseInt(v, version));
+ digits.add(version);
+ }
+
+ if (digits.getCount() < 2)
+ {
+ return SLANG_FAIL;
}
+
+ outDesc.majorVersion = digits[0];
+ outDesc.minorVersion = digits[1];
+ return SLANG_OK;
}
return SLANG_FAIL;
@@ -64,6 +95,8 @@ SlangResult GCCDownstreamCompilerUtil::calcVersion(const String& exeName, Downst
ExecuteResult exeRes;
SLANG_RETURN_ON_FAIL(ProcessUtil::execute(cmdLine, exeRes));
+ // Note we now have builds that add other words in front of the version
+ // such as "Ubuntu clang version"
const UnownedStringSlice prefixes[] =
{
UnownedStringSlice::fromLiteral("clang version"),
@@ -89,6 +122,7 @@ SlangResult GCCDownstreamCompilerUtil::calcVersion(const String& exeName, Downst
return SLANG_OK;
}
}
+
return SLANG_FAIL;
}
@@ -594,7 +628,7 @@ static SlangResult _parseGCCFamilyLine(const UnownedStringSlice& line, LineParse
{
// Make STD libs available
cmdLine.addArg("-lstdc++");
- // Make maths lib available
+ // Make maths lib available
cmdLine.addArg("-lm");
}