Skip to content

Commit

Permalink
[ANGLE] Add target for metal_translator_fuzzer
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=268201
<rdar://98947215>

Reviewed by Kimmo Kinnunen.

* Source/ThirdParty/ANGLE/ANGLE.xcodeproj/project.pbxproj:
- Add BaseTarget.xcconfig and metal_translator_fuzzer.xcconfig.
(metal_translator_fuzzer): Add target.
- Add translator_fuzzer.cpp to the project.
* Source/ThirdParty/ANGLE/Configurations/ANGLE-dynamic.xcconfig:
- Add copyright header.
(ANGLE_ALLOWABLE_CLIENTS): Add.
- Disable -allowable_client switches when libFuzzer is enabled.
(GCC_SYMBOLS_PRIVATE_EXTERN): Add.
- Disable private extern symbols when libFuzzer is enabled.
* Source/ThirdParty/ANGLE/Configurations/BaseTarget.xcconfig: Add.
- Extract common settings from ANGLE-dynamic.xcconfig.
(ANGLE_HEADER_PATH_PREFIX): Add.
- Add variable for header include path prefix so it may be overridden.
* Source/ThirdParty/ANGLE/Configurations/metal_translator_fuzzer.xcconfig: Add.
* Source/ThirdParty/ANGLE/src/compiler/fuzz/translator_fuzzer.cpp:
(LLVMFuzzerTestOneInput):
- Add a way to disable non-Metal outputs at build time.
- Add SH_MSL_METAL_OUTPUT as a valid output.
- Call sh::Finalize() after each test case since sh::Initialize is
  called at the start of every test case.

Canonical link: https://commits.webkit.org/273682@main
  • Loading branch information
David Kilzer authored and ddkilzer committed Jan 29, 2024
1 parent 868bb52 commit 704290f
Show file tree
Hide file tree
Showing 5 changed files with 203 additions and 10 deletions.
101 changes: 101 additions & 0 deletions Source/ThirdParty/ANGLE/ANGLE.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,8 @@
3A7AA54E28E1319D009E09C2 /* PixelLocalStorage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3A7AA54C28E1319D009E09C2 /* PixelLocalStorage.cpp */; };
3AD0D2242988C96D0080D728 /* renderermtl_utils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3AD0D2222988C96D0080D728 /* renderermtl_utils.cpp */; };
3AD0D2252988C96D0080D728 /* renderermtl_utils.h in Headers */ = {isa = PBXBuildFile; fileRef = 3AD0D2232988C96D0080D728 /* renderermtl_utils.h */; };
4458D1242B635DDB00B64F47 /* libANGLE-shared.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 31CDFDF42491819E00486F27 /* libANGLE-shared.dylib */; };
4458D1272B635E1000B64F47 /* translator_fuzzer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4458D1172B63500B00B64F47 /* translator_fuzzer.cpp */; };
6E27925927EA43F500B1BA86 /* BaseTypes.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6E27925827EA43F500B1BA86 /* BaseTypes.cpp */; };
7B19599326C3C22000C09322 /* android_util.h in Headers */ = {isa = PBXBuildFile; fileRef = A303079F230625C6002DA972 /* android_util.h */; };
7B19599426C3C22000C09322 /* android_util.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A303079E230625C6002DA972 /* android_util.cpp */; };
Expand Down Expand Up @@ -884,6 +886,13 @@
remoteGlobalIDString = 31CDFDF32491819E00486F27;
remoteInfo = "ANGLE (dynamic)";
};
4458D1252B635E0000B64F47 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = FB39D0701200ED9200088E69 /* Project object */;
proxyType = 1;
remoteGlobalIDString = 31DB794F2491C33300982878;
remoteInfo = ANGLE;
};
FF194FF52744331A006A97A3 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = FB39D0701200ED9200088E69 /* Project object */;
Expand Down Expand Up @@ -1071,6 +1080,10 @@
3A7AA54C28E1319D009E09C2 /* PixelLocalStorage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PixelLocalStorage.cpp; path = src/libANGLE/PixelLocalStorage.cpp; sourceTree = SOURCE_ROOT; };
3AD0D2222988C96D0080D728 /* renderermtl_utils.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = renderermtl_utils.cpp; sourceTree = "<group>"; };
3AD0D2232988C96D0080D728 /* renderermtl_utils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = renderermtl_utils.h; sourceTree = "<group>"; };
4458D1142B634F4200B64F47 /* metal_translator_fuzzer.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = metal_translator_fuzzer.xcconfig; sourceTree = "<group>"; };
4458D1152B634F4200B64F47 /* BaseTarget.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = BaseTarget.xcconfig; sourceTree = "<group>"; };
4458D1172B63500B00B64F47 /* translator_fuzzer.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = translator_fuzzer.cpp; sourceTree = "<group>"; };
4458D11C2B635DCC00B64F47 /* metal_translator_fuzzer */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = metal_translator_fuzzer; sourceTree = BUILT_PRODUCTS_DIR; };
5C1BAA961DFB60FF002906BB /* gl3.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = gl3.h; path = include/GLES3/gl3.h; sourceTree = "<group>"; };
5C1BAA971DFB60FF002906BB /* gl3platform.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = gl3platform.h; path = include/GLES3/gl3platform.h; sourceTree = "<group>"; };
5C1BAA981DFB60FF002906BB /* gl31.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = gl31.h; path = include/GLES3/gl31.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1881,6 +1894,14 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
4458D1192B635DCC00B64F47 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
4458D1242B635DDB00B64F47 /* libANGLE-shared.dylib in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
Expand Down Expand Up @@ -2102,6 +2123,14 @@
path = containers;
sourceTree = "<group>";
};
4458D1162B634FC200B64F47 /* fuzz */ = {
isa = PBXGroup;
children = (
4458D1172B63500B00B64F47 /* translator_fuzzer.cpp */,
);
path = fuzz;
sourceTree = "<group>";
};
5C1BAA931DFB60E2002906BB /* EGL */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -2797,7 +2826,9 @@
31CDFDEE24917F8900486F27 /* ANGLE-dynamic.xcconfig */,
FFE0D91526A0B4E80071ADAE /* AngleMetalLib.xcconfig */,
5D7C59C61208C68B001C873E /* Base.xcconfig */,
4458D1152B634F4200B64F47 /* BaseTarget.xcconfig */,
5D7C59C71208C68B001C873E /* DebugRelease.xcconfig */,
4458D1142B634F4200B64F47 /* metal_translator_fuzzer.xcconfig */,
);
path = Configurations;
sourceTree = "<group>";
Expand Down Expand Up @@ -3048,13 +3079,15 @@
isa = PBXGroup;
children = (
31CDFDF42491819E00486F27 /* libANGLE-shared.dylib */,
4458D11C2B635DCC00B64F47 /* metal_translator_fuzzer */,
);
name = Products;
sourceTree = "<group>";
};
FB39D2201200F35A00088E69 /* compiler */ = {
isa = PBXGroup;
children = (
4458D1162B634FC200B64F47 /* fuzz */,
FB39D2441200F35A00088E69 /* preprocessor */,
31012D9F18B97B9B0039062F /* translator */,
);
Expand Down Expand Up @@ -3733,6 +3766,23 @@
productReference = 31CDFDF42491819E00486F27 /* libANGLE-shared.dylib */;
productType = "com.apple.product-type.library.dynamic";
};
4458D11B2B635DCC00B64F47 /* metal_translator_fuzzer */ = {
isa = PBXNativeTarget;
buildConfigurationList = 4458D1202B635DCC00B64F47 /* Build configuration list for PBXNativeTarget "metal_translator_fuzzer" */;
buildPhases = (
4458D1182B635DCC00B64F47 /* Sources */,
4458D1192B635DCC00B64F47 /* Frameworks */,
);
buildRules = (
);
dependencies = (
4458D1262B635E0000B64F47 /* PBXTargetDependency */,
);
name = metal_translator_fuzzer;
productName = metal_translator_fuzzer;
productReference = 4458D11C2B635DCC00B64F47 /* metal_translator_fuzzer */;
productType = "com.apple.product-type.tool";
};
FFDA50C4269F845100AE11E2 /* ANGLEMetalLib */ = {
isa = PBXNativeTarget;
buildConfigurationList = FFDA50CB269F845100AE11E2 /* Build configuration list for PBXNativeTarget "ANGLEMetalLib" */;
Expand Down Expand Up @@ -3764,6 +3814,9 @@
CreatedOnToolsVersion = 12.0;
ProvisioningStyle = Automatic;
};
4458D11B2B635DCC00B64F47 = {
CreatedOnToolsVersion = 15.2;
};
FFDA50C4269F845100AE11E2 = {
CreatedOnToolsVersion = 13.0;
ProvisioningStyle = Automatic;
Expand All @@ -3785,6 +3838,7 @@
31DB794F2491C33300982878 /* ANGLE */,
31CDFDF32491819E00486F27 /* ANGLE (dynamic) */,
FFDA50C4269F845100AE11E2 /* ANGLEMetalLib */,
4458D11B2B635DCC00B64F47 /* metal_translator_fuzzer */,
);
};
/* End PBXProject section */
Expand Down Expand Up @@ -4203,6 +4257,14 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
4458D1182B635DCC00B64F47 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
4458D1272B635E1000B64F47 /* translator_fuzzer.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
FFDA50C3269F845100AE11E2 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
Expand All @@ -4219,6 +4281,11 @@
target = 31CDFDF32491819E00486F27 /* ANGLE (dynamic) */;
targetProxy = 31DB79562491C35400982878 /* PBXContainerItemProxy */;
};
4458D1262B635E0000B64F47 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 31DB794F2491C33300982878 /* ANGLE */;
targetProxy = 4458D1252B635E0000B64F47 /* PBXContainerItemProxy */;
};
FF194FF62744331A006A97A3 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = FFDA50C4269F845100AE11E2 /* ANGLEMetalLib */;
Expand Down Expand Up @@ -4269,6 +4336,30 @@
};
name = Production;
};
4458D1212B635DCC00B64F47 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 4458D1142B634F4200B64F47 /* metal_translator_fuzzer.xcconfig */;
buildSettings = {
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
};
4458D1222B635DCC00B64F47 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 4458D1142B634F4200B64F47 /* metal_translator_fuzzer.xcconfig */;
buildSettings = {
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
};
4458D1232B635DCC00B64F47 /* Production */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 4458D1142B634F4200B64F47 /* metal_translator_fuzzer.xcconfig */;
buildSettings = {
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Production;
};
5D7C59DB1208C6C3001C873E /* Production */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 5D7C59C61208C68B001C873E /* Base.xcconfig */;
Expand Down Expand Up @@ -4336,6 +4427,16 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Production;
};
4458D1202B635DCC00B64F47 /* Build configuration list for PBXNativeTarget "metal_translator_fuzzer" */ = {
isa = XCConfigurationList;
buildConfigurations = (
4458D1212B635DCC00B64F47 /* Debug */,
4458D1222B635DCC00B64F47 /* Release */,
4458D1232B635DCC00B64F47 /* Production */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Production;
};
FB39D0731200ED9200088E69 /* Build configuration list for PBXProject "ANGLE" */ = {
isa = XCConfigurationList;
buildConfigurations = (
Expand Down
43 changes: 33 additions & 10 deletions Source/ThirdParty/ANGLE/Configurations/ANGLE-dynamic.xcconfig
Original file line number Diff line number Diff line change
@@ -1,9 +1,33 @@
#include "../../../../Configurations/Version.xcconfig"
// Copyright (C) 2010-2024 Apple Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#include "../../../../Configurations/SDKVariant.xcconfig"
#include "BaseTarget.xcconfig"

PRODUCT_NAME = ANGLE-shared;
EXECUTABLE_PREFIX = lib;

ANGLE_OTHER_LDFLAGS = -allowable_client WebCore -allowable_client WebCoreTestSupport -framework QuartzCore -framework CoreGraphics -framework Foundation -framework IOSurface -framework Metal $(ANGLE_OTHER_LDFLAGS_$(WK_PLATFORM_NAME)) -Wl;
ANGLE_OTHER_LDFLAGS = $(ANGLE_ALLOWABLE_CLIENTS) -framework QuartzCore -framework CoreGraphics -framework Foundation -framework IOSurface -framework Metal $(ANGLE_OTHER_LDFLAGS_$(WK_PLATFORM_NAME)) -Wl;
ANGLE_OTHER_LDFLAGS_iphoneos = -lz;
ANGLE_OTHER_LDFLAGS_iphonesimulator = $(ANGLE_OTHER_LDFLAGS_iphoneos);
ANGLE_OTHER_LDFLAGS_watchos = $(ANGLE_OTHER_LDFLAGS_iphoneos);
Expand All @@ -13,33 +37,32 @@ ANGLE_OTHER_LDFLAGS_appletvsimulator = $(ANGLE_OTHER_LDFLAGS_iphonesimulator);
ANGLE_OTHER_LDFLAGS_maccatalyst = -framework IOKit -lz;
ANGLE_OTHER_LDFLAGS_macosx = -framework IOKit -lz;

// Allow fuzzers to link to libANGLE-shared.dylib.
ANGLE_ALLOWABLE_CLIENTS = $(ANGLE_ALLOWABLE_CLIENTS_$(WK_NOT_$(ENABLE_LIBFUZZER)));
ANGLE_ALLOWABLE_CLIENTS_YES = -allowable_client WebCore -allowable_client WebCoreTestSupport;

// Allow fuzzers to link to any symbol in libANGLE-shared.dylib.
GCC_SYMBOLS_PRIVATE_EXTERN = $(WK_NOT_$(ENABLE_LIBFUZZER));

INSTALL_PATH = $(WEBCORE_LIBRARY_DIR);

DYLIB_INSTALL_NAME_BASE = $(NORMAL_UMBRELLA_FRAMEWORKS_DIR)/WebCore.framework/Frameworks;
DYLIB_INSTALL_NAME_BASE[sdk=macosx*] = $(DYLIB_INSTALL_NAME_BASE_WK_RELOCATABLE_FRAMEWORKS_$(WK_RELOCATABLE_FRAMEWORKS));
DYLIB_INSTALL_NAME_BASE_WK_RELOCATABLE_FRAMEWORKS_ = $(NORMAL_UMBRELLA_FRAMEWORKS_DIR)/WebCore.framework/Versions/A/Frameworks;
DYLIB_INSTALL_NAME_BASE_WK_RELOCATABLE_FRAMEWORKS_YES = @loader_path/../../../;

HEADER_SEARCH_PATHS = ${DERIVED_FILES_DIR} WebKit include src src/common/base src/common/third_party/xxhash third_party/zlib/google;

ANGLE_HEADERS_FOLDER_PATH = $(WK_LIBRARY_HEADERS_FOLDER_PATH)/ANGLE;

PUBLIC_HEADERS_FOLDER_PATH = $(ANGLE_HEADERS_FOLDER_PATH);
PUBLIC_HEADERS_FOLDER_PATH[sdk=macosx*] = $(PUBLIC_HEADERS_FOLDER_PATH_$(WK_PLATFORM_NAME));
PUBLIC_HEADERS_FOLDER_PATH_macosx = $(ANGLE_HEADERS_FOLDER_PATH);
PUBLIC_HEADERS_FOLDER_PATH_maccatalyst = $(WK_ALTERNATE_FRAMEWORKS_DIR)/$(ANGLE_HEADERS_FOLDER_PATH);

GCC_PREPROCESSOR_DEFINITIONS = $(DEBUG_DEFINES) LIBGLESV2_IMPLEMENTATION LIBANGLE_IMPLEMENTATION ANGLE_CAPTURE_ENABLED=0 ANGLE_ENABLE_METAL ANGLE_METAL_XCODE_BUILDS_SHADERS ANGLE_ENABLE_METAL_OWNERSHIP_IDENTITY $(GCC_PREPROCESSOR_DEFINITIONS_$(WK_PLATFORM_NAME));
GCC_PREPROCESSOR_DEFINITIONS_macosx = ANGLE_ENABLE_GLSL ANGLE_ENABLE_ESSL ANGLE_ENABLE_OPENGL ANGLE_ENABLE_GL_DESKTOP_BACKEND ANGLE_ENABLE_APPLE_WORKAROUNDS ANGLE_ENABLE_CGL GL_SILENCE_DEPRECATION
GCC_PREPROCESSOR_DEFINITIONS_maccatalyst = $(GCC_PREPROCESSOR_DEFINITIONS_macosx)
GCC_PREPROCESSOR_DEFINITIONS_maccatalyst[arch=arm*] = $(GCC_PREPROCESSOR_DEFINITIONS_macosx) ANGLE_ENABLE_EAGL GLES_SILENCE_DEPRECATION ANGLE_CPU_ARM64

DEAD_CODE_STRIPPING = YES;
DEAD_CODE_STRIPPING[config=Debug] = NO;

STRIP_INSTALLED_PRODUCT = YES;
STRIP_INSTALLED_PRODUCT[config=Debug] = NO;

INSTALLHDRS_SCRIPT_PHASE = YES;
USE_HEADERMAP = NO;
APPLY_RULES_IN_COPY_HEADERS = YES;
35 changes: 35 additions & 0 deletions Source/ThirdParty/ANGLE/Configurations/BaseTarget.xcconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright (C) 2024 Apple Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#include "../../../../Configurations/Version.xcconfig"

ANGLE_HEADER_PATH_PREFIX = .;

HEADER_SEARCH_PATHS = ${DERIVED_FILES_DIR} $(ANGLE_HEADER_PATH_PREFIX)/WebKit $(ANGLE_HEADER_PATH_PREFIX)/include $(ANGLE_HEADER_PATH_PREFIX)/src $(ANGLE_HEADER_PATH_PREFIX)/src/common/base $(ANGLE_HEADER_PATH_PREFIX)/src/common/third_party/xxhash $(ANGLE_HEADER_PATH_PREFIX)/third_party/zlib/google;

USE_HEADERMAP = NO;

GCC_PREPROCESSOR_DEFINITIONS = $(DEBUG_DEFINES) LIBGLESV2_IMPLEMENTATION LIBANGLE_IMPLEMENTATION ANGLE_CAPTURE_ENABLED=0 ANGLE_ENABLE_METAL ANGLE_METAL_XCODE_BUILDS_SHADERS ANGLE_ENABLE_METAL_OWNERSHIP_IDENTITY $(GCC_PREPROCESSOR_DEFINITIONS_$(WK_PLATFORM_NAME));
GCC_PREPROCESSOR_DEFINITIONS_macosx = ANGLE_ENABLE_GLSL ANGLE_ENABLE_ESSL ANGLE_ENABLE_OPENGL ANGLE_ENABLE_GL_DESKTOP_BACKEND ANGLE_ENABLE_APPLE_WORKAROUNDS ANGLE_ENABLE_CGL GL_SILENCE_DEPRECATION;
GCC_PREPROCESSOR_DEFINITIONS_maccatalyst = $(GCC_PREPROCESSOR_DEFINITIONS_macosx);
GCC_PREPROCESSOR_DEFINITIONS_maccatalyst[arch=arm*] = $(GCC_PREPROCESSOR_DEFINITIONS_macosx) ANGLE_ENABLE_EAGL GLES_SILENCE_DEPRECATION ANGLE_CPU_ARM64;
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright (C) 2024 Apple Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#include "BaseTarget.xcconfig"

OTHER_CFLAGS = $(inherited) -DANGLE_TRANSLATOR_FUZZER_METAL_ONLY;
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
static_cast<uint32_t>(ShFragmentSynchronizationType::InvalidEnum));

std::vector<uint32_t> validOutputs;
#ifndef ANGLE_TRANSLATOR_FUZZER_METAL_ONLY
validOutputs.push_back(SH_ESSL_OUTPUT);
validOutputs.push_back(SH_GLSL_COMPATIBILITY_OUTPUT);
validOutputs.push_back(SH_GLSL_130_OUTPUT);
Expand All @@ -155,6 +156,10 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
validOutputs.push_back(SH_HLSL_3_0_OUTPUT);
validOutputs.push_back(SH_HLSL_4_1_OUTPUT);
validOutputs.push_back(SH_HLSL_4_0_FL9_3_OUTPUT);
#endif
#ifdef ANGLE_ENABLE_METAL
validOutputs.push_back(SH_MSL_METAL_OUTPUT);
#endif
bool found = false;
for (auto valid : validOutputs)
{
Expand Down Expand Up @@ -186,6 +191,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)

if (translator == nullptr)
{
sh::Finalize();
return 0;
}

Expand Down Expand Up @@ -219,6 +225,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)

if (!translator->Init(resources))
{
sh::Finalize();
return 0;
}

Expand All @@ -230,5 +237,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
const char *shaderStrings[] = {reinterpret_cast<const char *>(data)};
translator->compile(shaderStrings, 1, options);

sh::Finalize();
return 0;
}

0 comments on commit 704290f

Please sign in to comment.