Merge pull request #1490 from billhollings/strip-promoted-static-vulkan-symbols

Optionally hide additional static Vulkan linkage symbols.
diff --git a/Docs/Whats_New.md b/Docs/Whats_New.md
index 47a6ff2..234f9c6 100644
--- a/Docs/Whats_New.md
+++ b/Docs/Whats_New.md
@@ -22,6 +22,7 @@
 - Do not use `MTLEvent` for `VkSemaphore` under *Rosetta2*.
 - Support compiling *MSL 2.4* in runtime pipelines and `MoltenVKShaderConverterTool`.
 - Fix issue where *MSL 2.3* only available on *Apple Silicon*, even on *macOS*.
+- Fix Metal object retain-release errors in assignment operators.
 - Update to latest SPIRV-Cross:
 	- MSL: Add 64 bit support for `OpSwitch`.
 	- MSL: Don't output depth and stencil values with explicit early fragment tests.
diff --git a/MoltenVK/MoltenVK/GPUObjects/MVKShaderModule.mm b/MoltenVK/MoltenVK/GPUObjects/MVKShaderModule.mm
index 7da3dca..e53aeb6 100644
--- a/MoltenVK/MoltenVK/GPUObjects/MVKShaderModule.mm
+++ b/MoltenVK/MoltenVK/GPUObjects/MVKShaderModule.mm
@@ -37,8 +37,10 @@
 }
 
 MVKMTLFunction& MVKMTLFunction::operator=(const MVKMTLFunction& other) {
-	[_mtlFunction release];
-	_mtlFunction = [other._mtlFunction retain];		// retained
+	if (_mtlFunction != other._mtlFunction) {
+		[_mtlFunction release];
+		_mtlFunction = [other._mtlFunction retain];		// retained
+	}
 	shaderConversionResults = other.shaderConversionResults;
 	threadGroupSize = other.threadGroupSize;
 	return *this;
@@ -179,9 +181,11 @@
 }
 
 MVKShaderLibrary& MVKShaderLibrary::operator=(const MVKShaderLibrary& other) {
-	[_mtlLibrary release];
+	if (_mtlLibrary != other._mtlLibrary) {
+		[_mtlLibrary release];
+		_mtlLibrary = [other._mtlLibrary retain];
+	}
 	_owner = other._owner;
-	_mtlLibrary = [other._mtlLibrary retain];
 	_shaderConversionResults = other._shaderConversionResults;
 	_msl = other._msl;
 	return *this;
diff --git a/MoltenVK/MoltenVK/GPUObjects/MVKVulkanAPIObject.mm b/MoltenVK/MoltenVK/GPUObjects/MVKVulkanAPIObject.mm
index 64556b3..d3af052 100644
--- a/MoltenVK/MoltenVK/GPUObjects/MVKVulkanAPIObject.mm
+++ b/MoltenVK/MoltenVK/GPUObjects/MVKVulkanAPIObject.mm
@@ -66,8 +66,10 @@
 }
 
 MVKVulkanAPIObject& MVKVulkanAPIObject::operator=(const MVKVulkanAPIObject& other) {
-	[_debugName release];
-	_debugName = [other._debugName retain];
+	if (_debugName != other._debugName) {
+		[_debugName release];
+		_debugName = [other._debugName retain];
+	}
 	return *this;
 }