summaryrefslogtreecommitdiff
path: root/docs
AgeCommit message (Collapse)Author
2025-09-10Update SPIRV-{Tools,Headers} (#8415)Jay Kwak
This updates SPIRV submodules. Unfortunately we cannot use the latest because one of PRs in SPIRV-Tools causes VVL errors on our slang-tests. The issue is tracked in - https://github.com/KhronosGroup/SPIRV-Tools/issues/6316 - https://github.com/shader-slang/slang/issues/8414 This PR also updates/simplifies the document of updating SPIRV process.
2025-09-05Relax restriction on using link-time types for shader parameters. (#8387)Yong He
This change relaxes a previous restriction on link-time types and constants, so that we now allow them to be used to define shader parameters. Doing so will result in a parameter layout that is incomplete prior to linking. The PR added a test to call the reflection API on a fully linked program and ensure that we can report correct binding info.
2025-09-05Remove unnecessary check and adust server count etc. in CI (#8374)Gangzheng Tong
- This PR removes "wasm" check from the test job, since there is no test job for "wasm" yet. - Also, move the check for slang-rhi and slangpy test to the job level to skip the setup etc. if no run is needed. - Update the macos compiler version in building.md to match the clang compiler used in CI. - Reduce the server count in Linux and Mac when running slang-test to ease the machine load - Run slangpy test with `-n auto --maxprocesses=4` to speed up --------- Co-authored-by: slangbot <ellieh+slangbot@nvidia.com> Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
2025-09-01Remove ForceUnroll attribute from link-time specialization documentation (#8225)Copilot
The link-time specialization documentation contained an incorrect example that used `[ForceUnroll]` with a link-time type method call, which would cause a compilation error. The issue was that `[ForceUnroll]` requires loop bounds to be known at compile time, but `sampler.getSampleCount()` is a method call that returns a value at runtime. **Problem:** The documentation example showed: ```csharp Sampler sampler; [ForceUnroll] for (int i = 0; i < sampler.getSampleCount(); i++) output[tid] += sampler.sample(i); ``` This would fail with error: `loop does not terminate within the limited number of iterations, unrolling is aborted.` **Solution:** Removed the `[ForceUnroll]` attribute entirely, leaving a simple loop: ```csharp Sampler sampler; for (int i = 0; i < sampler.getSampleCount(); i++) output[tid] += sampler.sample(i); ``` Since the loop bounds come from a runtime method call, there's no way for the loop to be unrolled regardless of the directive used, so the simplest solution is to remove the unroll attribute completely. - [x] Remove ForceUnroll attribute from documentation example - [x] Remove explanatory note about unroll vs ForceUnroll - [x] Remove test cases for the removed functionality - [x] Fix missing closing backticks in code block Fixes #8161. <!-- START COPILOT CODING AGENT TIPS --> --- 💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more [Copilot coding agent tips](https://gh.io/copilot-coding-agent-tips) in the docs. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: bmillsNV <163073245+bmillsNV@users.noreply.github.com> Co-authored-by: expipiplus1 <857308+expipiplus1@users.noreply.github.com>
2025-08-29[CBP] Pointer frontend changes + groupshared pointer support (#7848)ArielG-NV
Resolves #7628 Resolves: #8197 Primary Goals: 1. Add `Access` to pointer 2. AddressSpace::GroupShared support for pointers (SPIR-V) 3. Add `__getAddress()` to replace `&` * `&` is not updated to `require(cpu)` since slangpy uses `&`. This means we must: (1) merge PR; (2) replace `&` with `__getAddress()`; (3) add `require(cpu)` to `&` Changes: * Added to `Ptr` the `Access` generic argument & logic (for `Access::Read`). * Moved the generic argument `AddressSpace` from `Ptr` to the end of the type. * Added pointer casting support between any `Ptr` as long as the `AddressSpace` is the same * Disallow globallycoherent T* and coherent T* * Disallow const T*, T const*, and const T* * Fixed .natvis display of `ConstantValue` `ValOperandNode` * Support generic resolution of type-casted integers * Added `VariablePointer` emitting for spirv + other minor logic needed for groupshared pointers Breaking Changes: * Anyone using the `AddressSpace` of `Ptr` will now have to account for the `Access` argument * we disallow various syntax paired with `Ptr` and `T*` --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
2025-08-28[Documentation] optix test coverage #463 (#8311)Harsh Aggarwal (NVIDIA)
Update docs/shader-execution-reordering.md with additional intrinsics Add correct capability `LoadLocalRootTableConstant`
2025-08-21Introduce CDataLayout & -fvk-use-c-layout (#8136)Julius Ikkala
Closes #8112. ~~The issue asks for a "C layout", but in this PR I use the term "CPU layout" because this naming was pre-existing in the codebase as `kCPULayoutRulesImpl_`. The primary purpose of this layout is to match CPU-side struct definitions with the shader side. I'm open to better naming suggestions, though.~~ Edit: switched back to using `CDataLayout` & `-fvk-use-c-layout`, as the CPU target depends on the object layout rules of existing CPU layout rules, but they're incompatible with actual shaders. So a new `kCLayoutRulesImpl_` was needed anyway. --------- Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
2025-08-21Implement SV_VulkanSamplePosition (#8236)davli-nv
-Adds semantic SV_VulkanSamplePosition that emits corresponding gl_SamplePosition and SpvBuiltinSamplePosition -Adds gl_SamplePosition property to glsl.meta.slang -Adds SPIRV and GLSL tests for the semantic and property -Plan is to later implement SV_SamplePosition that follows HLSL range of -0.5 to +0.5, and emits GetRenderTargetSamplePosition(SV_SampleIndex) which needs more complicated IR manipulation for HLSL and Metal Fixes #7906 --------- Co-authored-by: ArielG-NV <159081215+ArielG-NV@users.noreply.github.com>
2025-08-19Add multiple slang installations note to doc (#8231)Gangzheng Tong
Added a note section under the Installation section that warns users about potential conflicts when multiple Slang installations are present on the system. The note specifically addresses: * The scenario where Slang from Vulkan SDK might conflict with a standalone installation * How LD_LIBRARY_PATH on Linux overrides the RUNPATH in the slangc executable Closes https://github.com/shader-slang/slang/issues/7405
2025-08-17Update capability atoms reference page (#8138)Sam Estep
This file is automatically overwritten by the build: https://github.com/shader-slang/slang/blob/b7df3c7aa27301f88e31ed0a7bbf230688adab6a/source/slang/CMakeLists.txt#L68-L78 It is currently out of date (running the build gives rise to unstaged changes), so this PR updates it.
2025-08-08Error if super-type capabilities are a super-set of sub-type (#7452)ArielG-NV
Fixes: #7410 Changes: 1. super-type capabilities must be a super-set of sub-type capabilities (and support the same shader stages/targets) * InheritanceDecl visits super-type to inherit it's capabilities; validate InheritanceDecl capabilities against sub-type * visit all container decl's with a default case * clean up functionDeclBase visitor * Simplify `diagnoseUndeclaredCapability` by moving logic into capability checking (more correct*) 3. added changed behavior to documentation 4. fixed some incorrect capabilities 5. **we do not** diagnose capability errors on interface requirement-to-implementation if both lack explicit capability requirements. This change is to work around a slangpy regression (test case for the failing situation is in `tests\language-feature\capability\capability-interface-extension-1.slang`), Note: maybe for slang-2026 we don't do this? 6. requirement & implementation must support the same shader stage/target. This was changed because otherwise we can have cases where `X` inherits from `Y`, but `Y` is only expected to be used in `glsl` whilst `X` is expected to be used in `hlsl | glsl` 7. removed `tests/language-feature/capability/capabilitySimplification3.slang` because it tests nothing special (redundant) Note: not using rebase due to separate branches depending on this PR --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
2025-08-07Update LLVM from 13.0.1 to 14.0.6 (#8031)Sam Estep
Full set of mutually exclusive choices for upgrading LLVM: - #8031 (you are here) - #8035 - #8036 - #8034 - #8038 - #8039 - #8033 Alternative to #8028. Required some minor changes due to these upstream commits: - llvm/llvm-project@e463b69736da8b0a950ecd937cf990401bdfcdeb - llvm/llvm-project@89b57061f7b769e9ea9bf6ed686e284f3e55affe
2025-08-07Add a new option to use hash for release-note script (#8096)Jay Kwak
This commit adds a new command-line argument for `docs/script/release-note.sh`, which is `--previous-release-hash`. It will allow us to generate the release note at more finer granularity. The current help message is following, ``` Usage: ./docs/scripts/release-note.sh [--since DATE | --previous-release-hash HASH] --since DATE Generate notes since the given date (e.g., 2025-08-06) --previous-release-hash HASH Generate notes since the given commit hash Legacy usage (deprecated): ./docs/scripts/release-note.sh DATE ``` Fixes - https://github.com/shader-slang/slang/issues/5188 - https://github.com/shader-slang/slang/issues/6887 --------- Co-authored-by: slangbot <ellieh+slangbot@nvidia.com> Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
2025-08-05Implement SPV_EXT_fragment_invocation_density (SPV_NV_shading_rate) (#8037)davli-nv
* Implement SPV_EXT_fragment_invocation_density -Adds semantics SV_FragSize and SV_FragInvocationCount and implements them for SPIRV and GLSL using the appropriate target builtins from extensions. -Adds test case checking for expected target builtins from these semantics. -For future work, could implement SV_FragSize using pixel shader input SV_ShadingRate for HLSL, and SV_FragInvocationCount needs research. Fixes #7974 Generated with Claude Code * address review feedback https://github.com/shader-slang/slang/pull/8037#pullrequestreview-3084645845 * fixup format * review feedback https://github.com/shader-slang/slang/pull/8037#pullrequestreview-3086442819
2025-08-05Clarify downstream and direct compilation paths in design overview doc (#8021)aidanfnv
* Clarify downstream and direct compilation paths in design overview doc * Fix typo, add more examples
2025-08-01Omit "Invalid" capability from slangc -h output (#8020)aidanfnv
* Omit "Invalid" capability from slangc -h output * format code (#23) Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> --------- Co-authored-by: slangbot <ellieh+slangbot@nvidia.com> Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
2025-07-31msvc style bitfield packing (#7963)Ellie Hermaszewska
Closes https://github.com/shader-slang/slang/issues/3646 New tests rather than just adding another TEST line to existing tests so that we get the msvc- prefix in the output of slang-test
2025-07-27Fix broken links in User Guide (#7938)aidanfnv
* Fix broken links in User Guide * Fix link text with filename, use title
2025-07-25Fix metallib-asm target parsing by adding missing comma (#7902)Jay Kwak
* Fix metallib-asm target parsing by adding missing comma The metallib-asm target was not being recognized from command line because of a syntax error in the target string definition in slang-type-text-util.cpp. A missing comma after the first "metallib-asm" string caused C++ string literal concatenation to create a malformed string. Resolves #7774 Co-authored-by: Jay Kwak <jkwak-work@users.noreply.github.com> * format code (#7910) Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> * regenerate command line reference (#7911) Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> --------- Co-authored-by: Claude Code <claude@anthropic.com> Co-authored-by: Jay Kwak <jkwak-work@users.noreply.github.com> Co-authored-by: slangbot <ellieh+slangbot@nvidia.com> Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
2025-07-24Document how to use LLDB in the Slang codebase (#7809)Sam Estep
* Document how to use LLDB in the Slang codebase * Include `slang_lldb.py` in `.lldbinit` * Switch from GCC to Clang * Include a VS Code task to build before debugging * Fix clangd
2025-07-23Remove unnecessary processing in the release note script (#7884)Jay Kwak
The release note script was trying to retrieve additional label information from the "issue" but when parsing logic is not reliable. When the issue has a link to a repo other than Slang, it printed error message. An example is #7826 that has a link to an external repo, https://github.com/llvm/llvm-project/issues/79043
2025-07-23Update document to include lua build step (#7886)Jay Kwak
2025-07-23Added small section about default values of `struct` members (#7844)Å imon
* Added small section about default values of `struct` members * Added one more example and made `int a` to be brace initilised as well * Implemented suggested changes * Update docs/user-guide/02-conventional-features.md Co-authored-by: Yong He <yonghe@outlook.com> --------- Co-authored-by: Yong He <yonghe@outlook.com>
2025-07-22Fix capability generator to sort capabilities alphabetically within header ↵aidanfnv
groups (#7851) * Fix capability generator to sort capabilities alphabetically within header groups The slang-capability-generator now sorts capabilities alphabetically by name within each header group in the generated a3-02-reference-capability-atoms.md documentation file. This ensures consistent ordering for better readability and organization. Fixes #5030 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: aidanfnv <aidanfnv@users.noreply.github.com> * Regenerate capability atoms documentation with alphabetical sorting The capability generator now sorts capabilities alphabetically within each header group. This commit includes the regenerated documentation file to demonstrate the alphabetical sorting functionality implemented in the generator code. Generated with updated capability generator that sorts capabilities within groups: Targets, Stages, Versions, Extensions, Compound Capabilities, and Other. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * format code (#7853) Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: aidanfnv <aidanfnv@users.noreply.github.com> Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: slangbot <ellieh+slangbot@nvidia.com> Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
2025-07-17slang: Update ir-instruction-definition.md to reflect changes to operand ↵Sruthik P
specification (#7804) This change updates ir-instruction-definition.md to reflect changes to operand specification implemented in PR#7725 Auxiliary change meant for Issue #7185
2025-07-17mention adding new stable names manually (#7802)Ellie Hermaszewska
2025-07-17Document IR changes (#7781)Ellie Hermaszewska
* Document IR changes * Remove duplication
2025-07-16Correct help text for `-dump-intermediate-prefix` (#7768)Sam Estep
2025-07-14Let `flake.nix` users run `extras/formatting.sh` (#7682)Sam Estep
Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
2025-07-09Fix `slangc --help` text for `-reflection-json` (#7653)Sam Estep
2025-07-09Stable names and backwards compat for serialized IR modules (#7644)Ellie Hermaszewska
* stable names * tests, options and ci for stable names * Add back compat design document * fix warnings * formatting * comment * neaten * regenerate command line reference * consolidate ci scripts * faster ci * remove libreadline * Move new function to end of interface --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
2025-07-08Add <help-category> list and hint on usage in slangc -h (#7638)aidanfnv
* Add category list at end of slangc -h output * Use value category for categories * format code (#12) Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> * Regenerate cmdline reference --------- Co-authored-by: slangbot <ellieh+slangbot@nvidia.com> Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
2025-07-02add task shader alias (#7372)Sirox
* alias amplification shader as task shader and add mesh shader profile * add task shader stage alias to capabilities * regenerate command line reference --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
2025-07-01extend fiddle to allow custom lua splices in more places (#7559)Ellie Hermaszewska
* Add fkYAML submodule * Generate slang-ir-inst-defs.h from slang-ir-inst-defs.yaml * generate ir-inst-defs.h * neaten things * neaten inst def parser * add rapidyaml submodule * remove fkyaml * remove fkyaml submodule * remove use of ir-inst-defs.h * format and warnings * fix wasm build * tidy * remove rapidyaml * Extend fiddle to allow custom splices in more places * Use lua to describe ir insts * fix * neaten * neaten * neaten * spelling * neaten * comment comment out assert * merge
2025-07-01Add arguments for controlling floating point denormal mode (#7461)aidanfnv
* Implement -fp-denorm-mode slangc arg * Split fp-denorm-mode into 3 args for fp16/32/64 * Remove redundant option categories * Use emitInst for multiple of the same OpExecutionMode * Fix formatting * Remove -denorm any * Re-add option categories * emitinst for ftz * Use enums for type text * Remove extra categories again * Add tests for denorm mode * Move denorm mode to post linking * format code (#8) Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> * regenerate command line reference (#9) Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> * Clean up tests * Fix option text * format code (#10) Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> * Add tests for "any" mode * Return "any" enum if option not set * Simplify emission logic * Add support for generic entrypoints * Move denorm modes to end of CompilerOptionName enum * format code (#11) Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> * Move new enum members to before CountOf * Add not checks to tests, fix generic test, add functionality tests * Rename denorm to fpDenormal * Clean up functional test * Rename denorm test dir * Fix formatting, regenerate cmdline ref * Fold simple tests into functional tests, add more dxil checks * Remove no-op DX tests, make tests more consistent * Disable VK functionality tests that will fail on the CI configs * Fix formatting * Add comments to disabled tests explaining why --------- Co-authored-by: slangbot <ellieh+slangbot@nvidia.com> Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
2025-07-01Remove some cruft/complexity from IR serialization (#7483)Theresa Foley
* Remove some cruft/complexity from IR serialization This is a very simple cleanup to unnecessary code paths and remove some flexibility that isn't actually needed, to hopefully simplify the task of more completely overhauling the approach to IR serialization in a later change. The concrete feature that gets removed here is a debug-only feature (which thus shouldn't be affecting any users of Slang) that was added long ago in the life of the compiler as we were working to truly separate the front- and back-ends. At the time there was a lot of code in the compiler back-end that still made use of AST-level data structures, and thus got in the way of our goal to support separate compilation and linking (such that final code generation can only depend on the IR, and not the AST). The option was used to cause the Slang IR to be serialized out and then read back in as part of compilation, to try and enforce that only the wanted constructs could pass through that bottleneck. The idea was only ever half implemented, however, because it made use of a secondary implementation path in IR serialization that supported serializing the "raw" source locations (which are heavily dependent on AST-level information, even down to the number of bytes in source files). This change removes the feature entirely, since it is no longer useful for its intended purpose, and its presence causes there to be entire second code path for source locations in IR serialization that would need to have test coverage if we wanted to be sure it kept working. In addition, our pre-existing infrastructure for module serialization had various options that have either stopped being useful, or were not really useful at the time they were introduced. For example: there are no places in the code today where we attempt to serialize out a module without including both the serialized AST and IR. If that was a feature that we ever supported, the relevant code got removed at some preceding point without breaking any of our tests or (seemingly) upsetting users. Similarly, the options being passed into writing of a serialized module included both a flag to control whether source locations should be serialized *and* a pointer to the `SourceManager` to use in that case... but it was only ever meaningful to set both, or neither. The option has been changed to just be the `SourceManager` pointer, and the name has been updated to reflect its very narrow intended use case. * format code * fixup * regenerate command line reference --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> Co-authored-by: Yong He <yonghe@outlook.com>
2025-06-30Reset minimum cmake version to 3.22 (#7548)Gangzheng Tong
* Reset minimum cmake version to 3.22 * update slang-rhi
2025-06-29Support the GLSL/SPIR-V Built-in variable `DeviceIndex` (#7552)ArielG-NV
* Support DeviceIndex * format code * regenerate command line reference --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
2025-06-28Minimal optional constraints (#7422)Julius Ikkala
* Parse optional witness syntax * Allow failing optional constraint * Make `is` work with optional constraint * Allow using optional constraint in checked if statements * Fix tests * Make it work with structs * Fix MSVC build error * Disallow using `as` with optional constraints * Update test to match split is/as errors * Add tests * Fix uninitialized variables in tests * Add tests of incorrect uses & fix related bugs * Mention optional constraints in docs * format code * Fix type unification with NoneWitness * Fix formatting --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> Co-authored-by: Nathan V. Morrical <natemorrical@gmail.com>
2025-06-27Move separate-debug-info arg to target options (#7540)jarcherNV
* Move separate-debug-info arg to target options The separate-debug-info command line option is listed under debugging options, move this to the target options section which includes other similar flags like -g and -emit-spirv-directly. * regenerate command line reference --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
2025-06-24Document supported compiler versions in building.md (#7512)Ellie Hermaszewska
* Document supported compiler versions in building.md Closes https://github.com/shader-slang/slang/issues/7376 * multiple checked versions
2025-06-22Fix a small typo in CPU target docs (#7507)Mehmet Oguz Derin
Compiler word was missing after C/C++ in CPU target documentation. Thank you in advance!
2025-06-18Delete GFX User Guide (#7474)aidanfnv
Closes #6817 This change deletes the GFX User Guide, as GFX is being deprecated. It also removes the rebuild of its TOC from the TOC rebuilding scripts and replaces the link to the guide in the README with a note that it is being deprecated in favor of slang-rhi. Co-authored-by: Gangzheng Tong <tonggangzheng@gmail.com>
2025-06-16Require `override` keyword for overriding default interface methods. (#7458)Yong He
* Require `override` keyword for overriding default interface methods. * Update doc. * Fix test.
2025-06-13Allow interface methods to have default implementations. (#7439)Yong He
2025-06-13Add new capdef for lss intrinsics (#7427)Mukund Keshava
* Add new capdef for lss intrinsics Fixes #7426 Raygen shaders need to be supported for only hitobject APIs. So we need a special capability for that, instead of a common one. * regenerate command line reference --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
2025-06-10Fix IR layout of 3-element vectors in cbuffers for -fvk-use-dx-layout (#7282)James Helferty (NVIDIA)
* Better handling for 16-byte boundary of d3d cbuffer Fixes #6921 D3D cbuffers have slightly different packing rules that allow packing vectors into a 16-byte slot at element alignments, except when a field would cross a 16-byte boundary. In that case, we need to realign the field to the next 16-byte boundary. In particular, this impacts vec3s, which are not a power of two in size and thus require slightly different alignment logic, compared to std430 and std140. (Example: a float and float3 should fit together in that order in a single slot.) Adds test cases. Adds documentation page for GLSL target
2025-06-10Add optix support for coopvec (#7286)Mukund Keshava
* WiP: Add coopvec support for Optix * format code * fix minor issues * Fix review comments --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
2025-06-06Add command line option for separate debug info (#7178)jarcherNV
* Add command line option for separate debug info Add command line arg -separate-debug-info which, if provided, produces both a .spv and a .dbg.spv file. The .dbg.spv file contains full debug info and the .spv file has all debug info stripped out. Also add a DebugBuildIdentifier instruction to store a unique hash in both the output files, so they can be more easily matched together. A matching API is provided to allow using the Slang API to retrieve a base and debug SPIRV as well as the debug build identifier string.
2025-06-06Disable Link-Time-Optimization by default (#7345)Jay Kwak
* Disable Link-Time-Optimization by default LTO was requested for the release package a while ago. When we added it, LTO was enabled by default although it was needed only for the release packages. Later we found that the Release build cannot be incrementally recompiled when LTO is enabled. It sometimes works fine, but it required full recompilation when it doesn't work. We added a new CMake option, `SLANG_ENABLE_RELEASE_LTO`, to disable it for developers. But many Slang developers don't know the option exists. I was going to update the document, CONTRIBUTING.md, but I thought it will be better to change the default behavior. * Fix a compiler warning treated as an error on linux A padding variable was uninitialized, which is fine, but the compiler was complaining about it. * Fix other gcc error for uninitialized variable * Fix more compile warning treated as error * Fix compiler warning from gcc 11 It appears that this is a valid warning that the `delete this` is done on an offset 8 when the class uses multiple inheritance. The compiler warning is following: ``` In file included from /home/runner/work/slang/slang/source/core/slang-memory-file-system.h:5, from /home/runner/work/slang/slang/tools/slang-unit-test/unit-test-module-ptr.cpp:3: In destructor ‘virtual Slang::ComBaseObject::~ComBaseObject()’, inlined from ‘uint32_t Slang::ComBaseObject::_releaseImpl()’ at /home/runner/work/slang/slang/source/core/slang-com-object.h:49:16, inlined from ‘virtual uint32_t Slang::MemoryFileSystem::release()’ at /home/runner/work/slang/slang/source/core/slang-memory-file-system.h:34:5: /home/runner/work/slang/slang/source/core/slang-com-object.h:33:31: error: ‘void operator delete(void*, std::size_t)’ called on pointer ‘<unknown>’ with nonzero offset 8 [-Werror=free-nonheap-object] 33 | virtual ~ComBaseObject() {} | ^ In destructor ‘virtual Slang::ComBaseObject::~ComBaseObject()’, inlined from ‘uint32_t Slang::ComBaseObject::_releaseImpl()’ at /home/runner/work/slang/slang/source/core/slang-com-object.h:49:16, inlined from ‘virtual uint32_t Slang::MemoryFileSystem::release()’ at /home/runner/work/slang/slang/source/core/slang-memory-file-system.h:34:5, inlined from ‘Slang::ComPtr<T>::~ComPtr() [with T = ISlangMutableFileSystem]’ at /home/runner/work/slang/slang/include/slang-com-ptr.h:113:34, inlined from ‘void _modulePtr_impl(UnitTestContext*)’ at /home/runner/work/slang/slang/tools/slang-unit-test/unit-test-module-ptr.cpp:92:1: /home/runner/work/slang/slang/source/core/slang-com-object.h:33:31: error: ‘void operator delete(void*, std::size_t)’ called on pointer ‘<unknown>’ with nonzero offset 8 [-Werror=free-nonheap-object] 33 | virtual ~ComBaseObject() {} | ^ /home/runner/work/slang/slang/tools/slang-unit-test/unit-test-module-ptr.cpp: In function ‘void _modulePtr_impl(UnitTestContext*)’: /home/runner/work/slang/slang/tools/slang-unit-test/unit-test-module-ptr.cpp:36:69: note: returned from ‘void* operator new(std::size_t)’ 36 | ComPtr<ISlangMutableFileSystem>(new Slang::MemoryFileSystem()); | ^ ``` The problem is on the fact that `ComBaseObject` is not the first in the multiple inheritance: ``` class MemoryFileSystem : public ISlangMutableFileSystem, public ComBaseObject { public: // ISlangUnknown SLANG_COM_BASE_IUNKNOWN_ALL ``` It should be: ``` class MemoryFileSystem : public ComBaseObject, public ISlangMutableFileSystem ``` The chain of ComObject release is little complicated and it is easy to make a mistake. Here is summary with details, 1. `release()` is declared as a pure-virtual in ISlangUnknown, which is one of the base classes of `ISlangMutableFileSystem`. ``` struct ISlangUnknown { virtual SLANG_NO_THROW uint32_t SLANG_MCALL release() = 0; ``` 2. `release()` is implemented with the macro `SLANG_COM_BASE_IUNKNOWN_RELEASE`. ``` SLANG_NO_THROW uint32_t SLANG_MCALL release() SLANG_OVERRIDE \ { \ return _releaseImpl(); \ } inline uint32_t ComBaseObject::_releaseImpl() { // Check there is a ref count to avoid underflow SLANG_ASSERT(m_refCount != 0); const uint32_t count = --m_refCount; if (count == 0) { delete this; } return count; } ``` 3. The instance of `MemoryFileSystem` is handled by ComPtr. And `ComPtr::~ComPtr()` calls the `release()`. ``` ComPtr<ISlangMutableFileSystem> memoryFileSystem = ComPtr<ISlangMutableFileSystem>(new Slang::MemoryFileSystem()); SLANG_FORCE_INLINE ~ComPtr() { if (m_ptr) ((Ptr)m_ptr)->release(); } ``` 4. When `delete this` is called, because ComBaseObject is not the first in the multiple inheritance, `this` is 8 byte off from the actual instance address. A fix for this is to change the order of the inheritance and make ComBaseObject to be the first in the order.