Skip to content

Fix clang vla warning #2736

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

Fix clang vla warning #2736

wants to merge 1 commit into from

Conversation

cyyever
Copy link
Contributor

@cyyever cyyever commented Jun 15, 2024

Fix the error

/var/lib/jenkins/workspace/third_party/fbgemm/src/FbgemmI8Spmdm.cc:188:41: error: variable length arrays in C++ are a Clang extension [-Werror,-Wvla-cxx-extension]

Copy link

netlify bot commented Jun 15, 2024

Deploy Preview for pytorch-fbgemm-docs ready!

Name Link
🔨 Latest commit f9846c5
🔍 Latest deploy log https://app.netlify.com/sites/pytorch-fbgemm-docs/deploys/67c9532d9db59a000886d02d
😎 Deploy Preview https://deploy-preview-2736--pytorch-fbgemm-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@cyyever cyyever changed the title Fix clang vla error Fix clang vla warning Oct 4, 2024
@jamesETsmith
Copy link

Thanks for working on this @cyyever. I'm still seeing the issue even when manually adding add the flags this PR implements (using clang/clang++ 18.1.8). Do you know if the fixs works for clang 18?

@cyyever
Copy link
Contributor Author

cyyever commented Feb 14, 2025

@jamesETsmith Can you help check compile_commands.json and make sure that the flag is indeed added to the problematic files' command lines?

@jamesETsmith
Copy link

@cyyever great idea, it looks like the flag is there (and in stdout during compilation):

From compile_commands.json:

{
  "directory": "/home/james.smith/apps/pytorch/build_qcog",
  "command": "/usr/bin/clang++ -DFBGEMM_STATIC -I/home/james.smith/apps/pytorch/third_party/cpuinfo/include -I/home/james.smith/apps/pytorch/third_party/fbgemm/third_party/asmjit/src -I/home/james.smith/apps/pytorch/third_party/fbgemm/include -I/home/james.smith/apps/pytorch/third_party/fbgemm -isystem /home/james.smith/apps/pytorch/third_party/protobuf/src -isystem /opt/intel/oneapi/mkl/latest/include -isystem /home/james.smith/apps/pytorch/third_party/XNNPACK/include -Wno-vla-cxx-extension -D_GLIBCXX_USE_CXX11_ABI=1 -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -fopenmp=libomp -Wall -Wextra -Werror -Wno-deprecated-declarations -Wimplicit-fallthrough -g -std=c++17 -fPIC -fvisibility=hidden -DMKL_HAS_SBGEMM -DMKL_HAS_SHGEMM -o third_party/fbgemm/CMakeFiles/fbgemm_generic.dir/src/EmbeddingSpMDM.cc.o -c /home/james.smith/apps/pytorch/third_party/fbgemm/src/EmbeddingSpMDM.cc",
  "file": "/home/james.smith/apps/pytorch/third_party/fbgemm/src/EmbeddingSpMDM.cc",
  "output": "third_party/fbgemm/CMakeFiles/fbgemm_generic.dir/src/EmbeddingSpMDM.cc.o"
}

From STDOUT:

[26/2892] Building CXX object third_party/fbgemm/CMakeFiles/fbgemm_generic.dir/src/FbgemmI8Spmdm.cc.o
FAILED: third_party/fbgemm/CMakeFiles/fbgemm_generic.dir/src/FbgemmI8Spmdm.cc.o 
/usr/bin/ccache /usr/bin/clang++ -DFBGEMM_STATIC -I/home/james.smith/apps/pytorch/third_party/cpuinfo/include -I/home/james.smith/apps/pytorch/third_party/fbgemm/third_party/asmjit/src -I/home/james.smith/apps/pytorch/third_party/fbgemm/include -I/home/james.smith/apps/pytorch/third_party/fbgemm -isystem /home/james.smith/apps/pytorch/third_party/protobuf/src -isystem /opt/intel/oneapi/mkl/latest/include -isystem /home/james.smith/apps/pytorch/third_party/XNNPACK/include -Wno-vla-cxx-extension -D_GLIBCXX_USE_CXX11_ABI=1 -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -fopenmp=libomp -Wall -Wextra -Werror -Wno-deprecated-declarations -Wimplicit-fallthrough -g -std=c++17 -fPIC -fvisibility=hidden -DMKL_HAS_SBGEMM -DMKL_HAS_SHGEMM -MD -MT third_party/fbgemm/CMakeFiles/fbgemm_generic.dir/src/FbgemmI8Spmdm.cc.o -MF third_party/fbgemm/CMakeFiles/fbgemm_generic.dir/src/FbgemmI8Spmdm.cc.o.d -o third_party/fbgemm/CMakeFiles/fbgemm_generic.dir/src/FbgemmI8Spmdm.cc.o -c /home/james.smith/apps/pytorch/third_party/fbgemm/src/FbgemmI8Spmdm.cc
/home/james.smith/apps/pytorch/third_party/fbgemm/src/FbgemmI8Spmdm.cc:86:32: error: variable length arrays in C++ are a Clang extension [-Werror,-Wvla-cxx-extension]
   86 |   alignas(64) uint8_t A_buffer[K * 32];

@cyyever
Copy link
Contributor Author

cyyever commented Feb 15, 2025

@jamesETsmith That flag is overwritten by '-Wall -Wextra -Werror' later. That means there is a flag order problem. Check where you added the flag and move it behind Wall

@jamesETsmith
Copy link

Thanks for the heads up @cyyever. I'm building FBGEMM through PyTorch and it doesn't seem like I can change the ordering of the CMAKE_CXX_FLAGS from the command line without modifying the cmake source like you have for FBGEMM or PyTorch. I replicated the changes from your pytorch PR and that seems to have worked.

Thanks for the work on this, I hope it gets merged.

@facebook-github-bot
Copy link
Contributor

@q10 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@cyyever
Copy link
Contributor Author

cyyever commented Mar 6, 2025

@q10 Any process towards landing?

@q10
Copy link
Contributor

q10 commented Mar 6, 2025

Hi @cyyever sorry for the delay, there have been some internal issues preventing the PR from being imported into our internal systems, but we are working to import and land this PR.

@facebook-github-bot
Copy link
Contributor

@q10 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@q10 merged this pull request in a1c8ab3.

@cyyever cyyever deleted the vla branch March 13, 2025 03:13
q10 pushed a commit to q10/FBGEMM that referenced this pull request Apr 10, 2025
Summary:
Pull Request resolved: facebookresearch/FBGEMM#860

Fix the error
```
/var/lib/jenkins/workspace/third_party/fbgemm/src/FbgemmI8Spmdm.cc:188:41: error: variable length arrays in C++ are a Clang extension [-Werror,-Wvla-cxx-extension]
```

X-link: pytorch#2736

Reviewed By: sryap

Differential Revision: D69761012

Pulled By: q10

fbshipit-source-id: 58ed28af37a399ef5385e62340968dabdd09f260
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants