From 59903ef7e4ddd8885f71567bf0fc85527a88fffc Mon Sep 17 00:00:00 2001 From: Yong He Date: Fri, 3 May 2024 18:02:31 -0700 Subject: Add host shared library target. (#4098) * Add host shared library target. * Attempt fix. * Fix warnings. * try fix. * Fix test. * Fix. --- source/compiler-core/slang-artifact-desc-util.cpp | 3 ++- source/compiler-core/slang-gcc-compiler-util.cpp | 4 +++- source/compiler-core/slang-visual-studio-compiler-util.cpp | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) (limited to 'source/compiler-core') diff --git a/source/compiler-core/slang-artifact-desc-util.cpp b/source/compiler-core/slang-artifact-desc-util.cpp index 7e3f61915..783833902 100644 --- a/source/compiler-core/slang-artifact-desc-util.cpp +++ b/source/compiler-core/slang-artifact-desc-util.cpp @@ -276,6 +276,7 @@ SLANG_HIERARCHICAL_ENUM(ArtifactStyle, SLANG_ARTIFACT_STYLE, SLANG_ARTIFACT_STYL case SLANG_HOST_CPP_SOURCE: return Desc::make(Kind::Source, Payload::Cpp, Style::Host, 0); case SLANG_CPP_PYTORCH_BINDING: return Desc::make(Kind::Source, Payload::Cpp, Style::Host, 0); case SLANG_HOST_EXECUTABLE: return Desc::make(Kind::Executable, Payload::HostCPU, Style::Host, 0); + case SLANG_HOST_SHARED_LIBRARY: return Desc::make(Kind::SharedLibrary, Payload::HostCPU, Style::Host, 0); case SLANG_SHADER_SHARED_LIBRARY: return Desc::make(Kind::SharedLibrary, Payload::HostCPU, Style::Kernel, 0); case SLANG_SHADER_HOST_CALLABLE: return Desc::make(Kind::HostCallable, Payload::HostCPU, Style::Kernel, 0); case SLANG_CUDA_SOURCE: return Desc::make(Kind::Source, Payload::CUDA, Style::Kernel, 0); @@ -357,7 +358,7 @@ SLANG_HIERARCHICAL_ENUM(ArtifactStyle, SLANG_ARTIFACT_STYLE, SLANG_ARTIFACT_STYL switch (desc.kind) { case Kind::Executable: return SLANG_HOST_EXECUTABLE; - case Kind::SharedLibrary: return SLANG_SHADER_SHARED_LIBRARY; + case Kind::SharedLibrary: return desc.style == ArtifactStyle::Host ? SLANG_HOST_SHARED_LIBRARY : SLANG_SHADER_SHARED_LIBRARY; case Kind::HostCallable: return desc.style == ArtifactStyle::Host ? SLANG_HOST_HOST_CALLABLE : SLANG_SHADER_HOST_CALLABLE; case Kind::ObjectCode: return SLANG_OBJECT_CODE; default: break; diff --git a/source/compiler-core/slang-gcc-compiler-util.cpp b/source/compiler-core/slang-gcc-compiler-util.cpp index 2bcdfcbfa..52d4a0c29 100644 --- a/source/compiler-core/slang-gcc-compiler-util.cpp +++ b/source/compiler-core/slang-gcc-compiler-util.cpp @@ -560,6 +560,7 @@ static SlangResult _parseGCCFamilyLine(SliceAllocator& allocator, const UnownedS switch (options.targetType) { case SLANG_SHADER_SHARED_LIBRARY: + case SLANG_HOST_SHARED_LIBRARY: { // Shared library cmdLine.addArg("-shared"); @@ -639,7 +640,8 @@ static SlangResult _parseGCCFamilyLine(SliceAllocator& allocator, const UnownedS // Add the library paths - if (options.libraryPaths.count && options.targetType == SLANG_HOST_EXECUTABLE) + if (options.libraryPaths.count && + (options.targetType == SLANG_HOST_EXECUTABLE)) { if(PlatformUtil::isFamily(PlatformFamily::Apple, platformKind)) cmdLine.addArg("-Wl,-rpath,@loader_path,-rpath,@loader_path/../lib"); diff --git a/source/compiler-core/slang-visual-studio-compiler-util.cpp b/source/compiler-core/slang-visual-studio-compiler-util.cpp index 14fad0aec..753d256a6 100644 --- a/source/compiler-core/slang-visual-studio-compiler-util.cpp +++ b/source/compiler-core/slang-visual-studio-compiler-util.cpp @@ -189,6 +189,7 @@ static void _addFile(const String& path, const ArtifactDesc& desc, IOSFileArtifa switch (options.targetType) { case SLANG_SHADER_SHARED_LIBRARY: + case SLANG_HOST_SHARED_LIBRARY: { // Create dynamic link library if (options.debugInfoType == DebugInfoType::None) -- cgit v1.2.3