Skip to content

Commit

Permalink
Resolve compiler_flags to allow Mac build (#3478)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #3478

## `-Wglobal-constructors`

In ET-Vulkan, we use global constructors without global destructors.

Example: [`auto cls = VulkanBackend();`](https://github.com/pytorch/executorch/blob/3a253e96baa89e5a5434e91a236df63d54e0949e/backends/vulkan/runtime/VulkanBackend.cpp#L511-L513)
```
xplat/executorch/backends/vulkan/runtime/VulkanBackend.cpp:511:6: error: declaration requires a global destructor [-Werror,-Wglobal-constructors]
auto cls = VulkanBackend();
     ^
```

On Mac, this results in a `-Wglobal-constructors` warning, which is disabled in this change.

## `-Wmissing-prototypes`
## `-Wshadow`

Same as pytorch/pytorch#125361

Reviewed By: SS-JIA

Differential Revision: D56860764

fbshipit-source-id: 5e598a3774c04e9f4b4911cc7cbda14dbe703fd8
  • Loading branch information
jorgep31415 authored and facebook-github-bot committed May 2, 2024
1 parent 74538f8 commit 4bd45c3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 3 additions & 3 deletions backends/vulkan/runtime/api/Adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ PhysicalDevice::PhysicalDevice(VkPhysicalDevice physical_device_handle)
handle, &queue_family_count, queue_families.data());

// Find the total number of compute queues
for (const VkQueueFamilyProperties& properties : queue_families) {
for (const VkQueueFamilyProperties& p : queue_families) {
// Check if this family has compute capability
if (properties.queueFlags & VK_QUEUE_COMPUTE_BIT) {
num_compute_queues += properties.queueCount;
if (p.queueFlags & VK_QUEUE_COMPUTE_BIT) {
num_compute_queues += p.queueCount;
}
}
}
Expand Down
7 changes: 7 additions & 0 deletions backends/vulkan/targets.bzl
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")

def get_vulkan_compiler_flags():
return ["-Wno-missing-prototypes", "-Wno-global-constructors"]

def vulkan_spv_shader_lib(name, spv_filegroups, is_fbcode = False):
gen_vulkan_spv_target = "//executorch/backends/vulkan:gen_vulkan_spv_bin"
glslc_path = "//caffe2/fb/vulkan/dotslash:glslc"
Expand Down Expand Up @@ -36,6 +39,7 @@ def vulkan_spv_shader_lib(name, spv_filegroups, is_fbcode = False):
srcs = [
":{}[{}.cpp]".format(genrule_name, name),
],
compiler_flags = get_vulkan_compiler_flags(),
define_static_target = False,
# Static initialization is used to register shaders to the global shader registry,
# therefore link_whole must be True to make sure unused symbols are not discarded.
Expand Down Expand Up @@ -146,6 +150,7 @@ def define_common_targets(is_fbcode = False):

runtime.cxx_library(
name = "vulkan_compute_api",
compiler_flags = get_vulkan_compiler_flags(),
srcs = native.glob([
"runtime/api/*.cpp",
]),
Expand All @@ -165,6 +170,7 @@ def define_common_targets(is_fbcode = False):
srcs = native.glob([
"runtime/graph/**/*.cpp",
]),
compiler_flags = get_vulkan_compiler_flags(),
exported_headers = native.glob([
"runtime/graph/**/*.h",
]),
Expand All @@ -191,6 +197,7 @@ def define_common_targets(is_fbcode = False):
srcs = native.glob([
"runtime/*.cpp",
]),
compiler_flags = get_vulkan_compiler_flags(),
headers = native.glob([
"runtime/*.h",
]),
Expand Down

0 comments on commit 4bd45c3

Please sign in to comment.