Skip to content

Incorrect LLVM system config directory when using clang-scan-deps #221782

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

Open
4 tasks done
tcbrindle opened this issue Apr 28, 2025 · 1 comment
Open
4 tasks done

Incorrect LLVM system config directory when using clang-scan-deps #221782

tcbrindle opened this issue Apr 28, 2025 · 1 comment

Comments

@tcbrindle
Copy link
Contributor

tcbrindle commented Apr 28, 2025

brew gist-logs <formula> link OR brew config AND brew doctor output

brew config:

HOMEBREW_VERSION: 4.4.32-77-g9eb0357
ORIGIN: https://github.com/Homebrew/brew
HEAD: 9eb0357716192fc4273613220ef0ee700d213c40
Last commit: 8 hours ago
Branch: master
Core tap HEAD: 6c2620ecb4d741efbff32295f0c2ef01ebd5dfca
Core tap last commit: 10 hours ago
Core tap JSON: 28 Apr 17:03 UTC
Core cask tap HEAD: ba3da943abc861c24d078b63560419d6981c4f32
Core cask tap last commit: 11 hours ago
Core cask tap JSON: 28 Apr 17:03 UTC
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CASK_OPTS: []
HOMEBREW_DISPLAY: /private/tmp/com.apple.launchd.d9VT5wDudZ/org.xquartz:0
HOMEBREW_MAKE_JOBS: 8
HOMEBREW_SORBET_RUNTIME: set
Homebrew Ruby: 3.4.3 => /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/3.4.3/bin/ruby
CPU: octa-core 64-bit kabylake
Clang: 17.0.0 build 1700
Git: 2.49.0 => /usr/local/bin/git
Curl: 8.7.1 => /usr/bin/curl
macOS: 15.4.1-x86_64
CLT: 16.3.0.0.1.1742442376
Xcode: 16.3

Brew Doctor:

Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!

Warning: Unbrewed dylibs were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae and may need to be deleted.

Unexpected dylibs:
  /usr/local/lib/libarena-4e7c5e5c.dylib
  /usr/local/lib/libflate-4e7c5e5c.dylib
  /usr/local/lib/libfmt_macros-4e7c5e5c.dylib
  /usr/local/lib/libgetopts-4e7c5e5c.dylib
  /usr/local/lib/libgraphviz-4e7c5e5c.dylib
  /usr/local/lib/liblog-4e7c5e5c.dylib
  /usr/local/lib/libodb-2.5.0-b.13.dylib
  /usr/local/lib/libodb-2.5.0-b.5.dylib
  /usr/local/lib/libodb-sqlite-2.5.0-b.13.dylib
  /usr/local/lib/libodb-sqlite-2.5.0-b.5.dylib
  /usr/local/lib/librbml-4e7c5e5c.dylib
  /usr/local/lib/libregex-4e7c5e5c.dylib
  /usr/local/lib/librustc-4e7c5e5c.dylib
  /usr/local/lib/librustc_back-4e7c5e5c.dylib
  /usr/local/lib/librustc_borrowck-4e7c5e5c.dylib
  /usr/local/lib/librustc_driver-4e7c5e5c.dylib
  /usr/local/lib/librustc_llvm-4e7c5e5c.dylib
  /usr/local/lib/librustc_resolve-4e7c5e5c.dylib
  /usr/local/lib/librustc_trans-4e7c5e5c.dylib
  /usr/local/lib/librustc_typeck-4e7c5e5c.dylib
  /usr/local/lib/librustdoc-4e7c5e5c.dylib
  /usr/local/lib/libserialize-4e7c5e5c.dylib
  /usr/local/lib/libstd-4e7c5e5c.dylib
  /usr/local/lib/libsyntax-4e7c5e5c.dylib
  /usr/local/lib/libterm-4e7c5e5c.dylib
  /usr/local/lib/libtest-4e7c5e5c.dylib

Warning: Homebrew's "sbin" was not found in your PATH but you have installed
formulae that put executables in /usr/local/sbin.
Consider setting your PATH for example like so:
  echo 'export PATH="/usr/local/sbin:$PATH"' >> /Users/tristan/.bash_profile

Verification

  • My brew doctor output says Your system is ready to brew. and am still able to reproduce my issue.
  • I ran brew update and am still able to reproduce my issue.
  • I have resolved all warnings from brew doctor and that did not fix my problem.
  • I searched for recent similar issues at https://github.com/Homebrew/homebrew-core/issues?q=is%3Aissue and found no duplicates.

What were you trying to do (and why)?

Use Homebrew-built clang-scan-deps (from the LLVM package) to scan the module dependencies of a C++ file

What happened (include all command output)?

test_file.cpp:

#include <vector>

int main() {}

Command line

/usr/local/opt/llvm/bin/clang-scan-deps -- /usr/local/opt/llvm/bin/clang++ test-file.cpp -o test-file -v

Output:

Homebrew clang version 20.1.3
Target: x86_64-apple-darwin24.4.0
Thread model: posix
InstalledDir: /usr/local/opt/llvm/bin
System configuration file directory: /usr/etc/clang
User configuration file directory: /Users/tristan/.config/clang
Homebrew clang version 20.1.3
Target: x86_64-apple-darwin24.4.0
Thread model: posix
InstalledDir: /usr/local/opt/llvm/bin
System configuration file directory: /usr/etc/clang
User configuration file directory: /Users/tristan/.config/clang
clang -cc1 version 20.1.3 based upon LLVM 20.1.3 default target x86_64-apple-darwin24.4.0
ignoring nonexistent directory "/usr/include"
ignoring nonexistent directory "/System/Library/SubFrameworks"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/opt/llvm/bin/../include/c++/v1
 /usr/local/include
 /usr/local/opt/llvm/lib/clang/20/include
 /System/Library/Frameworks (framework directory)
 /Library/Frameworks (framework directory)
End of search list.
Error while scanning dependencies for test-file.cpp:
In file included from test-file.cpp:2:
In file included from /usr/local/opt/llvm/bin/../include/c++/v1/vector:352:
In file included from /usr/local/opt/llvm/bin/../include/c++/v1/algorithm:1854:
In file included from /usr/local/opt/llvm/bin/../include/c++/v1/__algorithm/for_each.h:16:
In file included from /usr/local/opt/llvm/bin/../include/c++/v1/__ranges/movable_box.h:21:
In file included from /usr/local/opt/llvm/bin/../include/c++/v1/optional:1296:
In file included from /usr/local/opt/llvm/bin/../include/c++/v1/atomic:607:
In file included from /usr/local/opt/llvm/bin/../include/c++/v1/__atomic/atomic_flag.h:19:
In file included from /usr/local/opt/llvm/bin/../include/c++/v1/__thread/support.h:112:
/usr/local/opt/llvm/bin/../include/c++/v1/__thread/support/pthread.h:18:10: error: 'pthread.h' file not found with <angled> include; use "quotes" instead
/usr/local/opt/llvm/bin/../include/c++/v1/__thread/support/pthread.h:19:10: fatal error: 'sched.h' file not found

Note the "System configuration file directory" is set to /usr/etc/clang, which does not exist on my system -- it should be /usr/local/etc/clang for the Homebrew-provided config files

A workaround is to pass the correct directory explicitly using the --config-system-dir parameter:

/usr/local/opt/llvm/bin/clang-scan-deps -- /usr/local/opt/llvm/bin/clang++ test-file.cpp -o test-file --config-system-dir=/usr/local/etc/clang

What did you expect to happen?

clang-scan-deps would correctly report the dependencies of the C++ file

Step-by-step reproduction instructions (by running brew commands)

brew install llvm

then as above
@tcbrindle
Copy link
Contributor Author

Possibly related to #220757

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant