<feed xmlns='http://www.w3.org/2005/Atom'>
<title>slang.git/source/core/slang-shared-library.h, branch master</title>
<subtitle>Making it easier to work with shaders</subtitle>
<id>https://git.yummers.dev/slang.git/atom?h=master</id>
<link rel='self' href='https://git.yummers.dev/slang.git/atom?h=master'/>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/'/>
<updated>2025-06-06T17:48:06+00:00</updated>
<entry>
<title>Disable Link-Time-Optimization by default (#7345)</title>
<updated>2025-06-06T17:48:06+00:00</updated>
<author>
<name>Jay Kwak</name>
<email>82421531+jkwak-work@users.noreply.github.com</email>
</author>
<published>2025-06-06T17:48:06+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=7f04adbfb9dc0c39c372809ea02cc740d484b291'/>
<id>urn:sha1:7f04adbfb9dc0c39c372809ea02cc740d484b291</id>
<content type='text'>
* 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 ‘&lt;unknown&gt;’ 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&lt;T&gt;::~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 ‘&lt;unknown&gt;’ 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&lt;ISlangMutableFileSystem&gt;(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&lt;ISlangMutableFileSystem&gt; memoryFileSystem =
        ComPtr&lt;ISlangMutableFileSystem&gt;(new Slang::MemoryFileSystem());

    SLANG_FORCE_INLINE ~ComPtr()
    {
        if (m_ptr)
            ((Ptr)m_ptr)-&gt;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.</content>
</entry>
<entry>
<title>format</title>
<updated>2024-10-29T06:49:26+00:00</updated>
<author>
<name>Ellie Hermaszewska</name>
<email>ellieh@nvidia.com</email>
</author>
<published>2024-10-29T06:49:26+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=f65d756bff8d4c5cbc15bd0322a2ae8e6b896a21'/>
<id>urn:sha1:f65d756bff8d4c5cbc15bd0322a2ae8e6b896a21</id>
<content type='text'>
* format

* Minor test fixes

* enable checking cpp format in ci</content>
</entry>
<entry>
<title>preparation for clang format (#5422)</title>
<updated>2024-10-29T05:59:28+00:00</updated>
<author>
<name>Ellie Hermaszewska</name>
<email>ellieh@nvidia.com</email>
</author>
<published>2024-10-29T05:59:28+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=a729c15e9dce9f5116a38afc66329ab2ca4cea54'/>
<id>urn:sha1:a729c15e9dce9f5116a38afc66329ab2ca4cea54</id>
<content type='text'>
* Clang-format excludes

* Add .clang-format

* Don't clang-format in external

* Missing includes and forward declarations

* Replace wonky include-once macro name

* neaten include naming

* Add clang-format to formatting script

* Add xargs and diff to required binaries

* add clang-format to ci formatting check

* Add max version check to formatting script

* temporarily disable checking formatting for cpp files</content>
</entry>
<entry>
<title>Fix prelude generation by using relative paths for including `slang.h` (#4973)</title>
<updated>2024-08-30T23:58:07+00:00</updated>
<author>
<name>Sai Praveen Bangaru</name>
<email>31557731+saipraveenb25@users.noreply.github.com</email>
</author>
<published>2024-08-30T23:58:07+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=ca2317a28814c2ffe6427470be57df6d778b1358'/>
<id>urn:sha1:ca2317a28814c2ffe6427470be57df6d778b1358</id>
<content type='text'>
* Change `slang.h` path in `slang-common.h` to allow `slang-embed` to resolve correctly.

* Change `slang.h` path in all slang/core files

---------

Co-authored-by: Yong He &lt;yonghe@outlook.com&gt;</content>
</entry>
<entry>
<title>Move the file public header files to `include` dir (#4636)</title>
<updated>2024-07-17T17:53:19+00:00</updated>
<author>
<name>kaizhangNV</name>
<email>149626564+kaizhangNV@users.noreply.github.com</email>
</author>
<published>2024-07-17T17:53:19+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=2db15080085856ed9b5f20642dbb354aac59a888'/>
<id>urn:sha1:2db15080085856ed9b5f20642dbb354aac59a888</id>
<content type='text'>
* Move the file public header files to `include` dir

Close the issue (#4635).

Move the following headers files to a `include` dir
located at root dir of slang repo:

 slang-com-helper.h -&gt; include/slang-com-helper.h
 slang-com-ptr.h -&gt; include/slang-com-ptr.h
 slang-gfx.h -&gt; include/slang-gfx.h
 slang.h -&gt; include/slang.h

Change cmake/SlangTarget.cmake to add include path to
every target, and change the source file to use
"#include &lt;slang.h&gt;" to include the public headers.

The source code update is by the script like follow:

```
fileNames_slang=$(grep -r "\".*slang\.h\"" source/ -l)

for fileName in "${fileNames_slang[@]}"
do
    echo "$fileName"
    sed -i "s/\".*slang\.h\"/\"slang\.h\"/" $fileName
done
```

* Fix the test issues

* Fix cpu test issues by adding include seach path

* Update cmake to not add include path for every target

Also change "#include &lt;slang.h&gt;" to "include "slang.h" " to
make the coding style consistent with other slang code.

* Change public include to private include for unit-test and slang-glslang</content>
</entry>
<entry>
<title>Improvements around file tracking and Artifacts (#2379)</title>
<updated>2022-08-24T18:42:55+00:00</updated>
<author>
<name>jsmall-nvidia</name>
<email>jsmall@nvidia.com</email>
</author>
<published>2022-08-24T18:42:55+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=3746a47ce407b14c4afbfc5b625513cf81b5e890'/>
<id>urn:sha1:3746a47ce407b14c4afbfc5b625513cf81b5e890</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Assorted Artifact improvements (#2374)</title>
<updated>2022-08-24T13:25:51+00:00</updated>
<author>
<name>jsmall-nvidia</name>
<email>jsmall@nvidia.com</email>
</author>
<published>2022-08-24T13:25:51+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=f5755019246504ad4da4614d1e34a00d74970ea7'/>
<id>urn:sha1:f5755019246504ad4da4614d1e34a00d74970ea7</id>
<content type='text'>
* #include an absolute path didn't work - because paths were taken to always be relative.

* WIP replacing DownstreamCompileResult.

* First attempt at replacing DownstreamCompileResult with IArtifact and associated types.

* Small renaming around CharSlice.

* ICastable -&gt; ISlangCastable
Added IClonable
Fix issue with cloning in ArtifactDiagnostics.

* Only add the blob if one is defined in DXC.

* Guard adding blob representation.

* Make cloneInterface available across code base.
Set enums backing type for ArtifactDiagnostic.

* Added ::create for ArtifactDiagnostics.

* Use SemanticVersion for DownstreamCompilerDesc.
Set sizes for enum types.

* Depreciate old incompatible CompileOptions.
Change SemanticVersion use 32 bits for the patch.

* Split out CastableUtil.

* Change IDownstreamCompiler to use canConvert and convert to use artifact types.

* Fix typos.

* Fix typo bug.
Allow trafficing in PTX assembly/binaries

* struct DownstreamCompilerBaseUtil -&gt; struct DownstreamCompilerUtilBase

* Add other riff types.

* Small fix around artifact kind.

* Make using slices instead of strings explicit on atomic ref counted types. (not complete).
Added IArtifactList.
Use IArtifactList to hold the 'associated' files.
Use IUnknown for scoping for atomic ref counting.
Small naming improvements.

* Make artifact not use String in construction (so it owns contents).

* Calculate compile products as artifacts.

* Small improvements around ArtifactDesc.

* Use ICastableList for list of artifacts and remove IArtifactList.</content>
</entry>
<entry>
<title>Artifact closer to being able to replace CompileResult (#2354)</title>
<updated>2022-08-11T15:55:49+00:00</updated>
<author>
<name>jsmall-nvidia</name>
<email>jsmall@nvidia.com</email>
</author>
<published>2022-08-11T15:55:49+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=b5d84f60d36b81c7e8263048dda031a9be14a106'/>
<id>urn:sha1:b5d84f60d36b81c7e8263048dda031a9be14a106</id>
<content type='text'>
* #include an absolute path didn't work - because paths were taken to always be relative.

* WIP with hierarchical enums.

* Some small fixes and improvements around artifact desc related types.

* Improvements around hierarchical enum.

* Fixes to get Artifact types refactor to be able to execute tests.

* Attempt to better categorize PTX.

* Work around for potentially unused function warning.

* Typo fix.

* Simplify Artifact header.

* Small improvements around Artifact kind/payload/style.

* Added IDestroyable/ICastable

* Add IArtifactList.

* First impl of IArtifactUtil.

* Use the ICastable interface for IArtifactRepresentation.

* Added IArtifactRepresentation &amp; IArtifactAssociated.

* Add SLANG_OVERRIDE to avoid gcc/clang warning.

* Fix calling convention issue on win32.

* Fix missing SLANG_OVERRIDE.

* First attempt at file abstraction around Artifact.

* Added creation of lock file.

* Move functionality for determining file paths to the IArtifactUtil.
Add casting to ICastable.

* Added some casting/finding mechanisms.

* Simplify IArtifact interface, and use Items for file reps.

* Fix problem with libraries on DXIL.

* Split out ArtifactRepresentation.

* Move ArtifactDesc functionality to ArtifactDescUtil. ArtifactInfoUtil becomes ArtifactDescUtil.

* Split implementations from the interfaces for Artifact.

* Use TypeTextUtil for target name outputting.

* Add artifact impls.

* Add ICastableList

* Added UnknownCastableAdapter

* Make ISlangSharedLibrary derive from ICastable, and remain backwards compatible with slang-llvm.

* Refactor Representation on Artifact.

* Make our ISlangBlobs also derive from ICastable.
Make ISlangBlob atomic ref counted.

* Split out CastableList and related types, and placed in core.

* Small fixes around IArtifact.
Improve IArtifact docs.
First impl of getChildren for IArtifact.

* Documentation improvements for Artifact related types.

* Fix typo.

* Special case adding a ICastableList to a LazyCastableList.

* Small simplification of LazyCastableList, by adding State member.

* Removed the ILockFile interface because IFileArtifactRepresentation can be used.

* Implement DiagnosticsArtifactRepresentation.

* Added PostEmitMetadataArtifactRepresentation

* Add searching by predicate.
Added handling of accessing Artifact as ISharedLibrary

* Fix typo.

* Add find to IArtifacgtList.
Fix some missing SLANG_NO_THROW.

* Small improvements around ArtifactDesc types.

* Another small change around ArtifactKind.

* Some more shuffling of ArtifactDesc.

* Make IArtifact castable
Remove IArtifactList
Made IArtifactContainer derive from IArtifact
Made ModuleLibrary atomic ref counted/given IModuleLibrary interface.

* Must call _requireChildren before any children access.

* Fix missing SLANG_MCALL on castAs.

* Fix missing SLANG_OVERRIDE.

* Added IArtifactHandler

* Use ICastable for basis of scope/lookup.</content>
</entry>
<entry>
<title>Artifact and ICastable (#2351)</title>
<updated>2022-08-10T14:04:06+00:00</updated>
<author>
<name>jsmall-nvidia</name>
<email>jsmall@nvidia.com</email>
</author>
<published>2022-08-10T14:04:06+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=1378fffd9da094beb41b2db89b96f556c23ab6cb'/>
<id>urn:sha1:1378fffd9da094beb41b2db89b96f556c23ab6cb</id>
<content type='text'>
* #include an absolute path didn't work - because paths were taken to always be relative.

* WIP with hierarchical enums.

* Some small fixes and improvements around artifact desc related types.

* Improvements around hierarchical enum.

* Fixes to get Artifact types refactor to be able to execute tests.

* Attempt to better categorize PTX.

* Work around for potentially unused function warning.

* Typo fix.

* Simplify Artifact header.

* Small improvements around Artifact kind/payload/style.

* Added IDestroyable/ICastable

* Add IArtifactList.

* First impl of IArtifactUtil.

* Use the ICastable interface for IArtifactRepresentation.

* Added IArtifactRepresentation &amp; IArtifactAssociated.

* Add SLANG_OVERRIDE to avoid gcc/clang warning.

* Fix calling convention issue on win32.

* Fix missing SLANG_OVERRIDE.

* First attempt at file abstraction around Artifact.

* Added creation of lock file.

* Move functionality for determining file paths to the IArtifactUtil.
Add casting to ICastable.

* Added some casting/finding mechanisms.

* Simplify IArtifact interface, and use Items for file reps.

* Fix problem with libraries on DXIL.

* Split out ArtifactRepresentation.

* Move ArtifactDesc functionality to ArtifactDescUtil. ArtifactInfoUtil becomes ArtifactDescUtil.

* Split implementations from the interfaces for Artifact.

* Use TypeTextUtil for target name outputting.

* Add artifact impls.

* Add ICastableList

* Added UnknownCastableAdapter

* Make ISlangSharedLibrary derive from ICastable, and remain backwards compatible with slang-llvm.

* Refactor Representation on Artifact.

* Make our ISlangBlobs also derive from ICastable.
Make ISlangBlob atomic ref counted.

* Fix typo.</content>
</entry>
<entry>
<title>Atomic ref counting for ISlangSharedLibrary (#2332)</title>
<updated>2022-07-18T19:44:29+00:00</updated>
<author>
<name>jsmall-nvidia</name>
<email>jsmall@nvidia.com</email>
</author>
<published>2022-07-18T19:44:29+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=2e4b5770fa7e6dbf56845382706b33a22d6a025b'/>
<id>urn:sha1:2e4b5770fa7e6dbf56845382706b33a22d6a025b</id>
<content type='text'>
* #include an absolute path didn't work - because paths were taken to always be relative.

* Make ISlangSharedLibrary atomic ref counted.
Update docs to say most COM interfaces are *not* atomic ref counted.

* Upgrade slang-llvm to use version that atomic ref counts ISlangSharedLibrary.

* Fix some typos in docs.

* Fix ref count typo.

* Fix missing 'override'</content>
</entry>
</feed>
