0

The current clang version is 14 in my macOS 13.3.1 13.3.1 (a) (22E772610a):

> clang --version
Apple clang version 14.0.3 (clang-1403.0.22.14.1)
Target: arm64-apple-darwin22.4.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

I want to upgrade the clang to 16, then I tried like this followed https://ports.macports.org/port/clang-16/:

> sudo port install clang-16
Password:
--->  Computing dependencies for clang-16
--->  Cleaning clang-16
--->  Scanning binaries for linking errors
--->  No broken files found.
--->  No broken ports found.

but the clang version is still 14, what should I do to upgrade the clang to 16? I also tried like this:

> brew upgrade clang
==> Auto-updating Homebrew...
Adjust how often this is run with HOMEBREW_AUTO_UPDATE_SECS or disable with
HOMEBREW_NO_AUTO_UPDATE. Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
Warning: No remote 'origin' in /opt/homebrew/Library/Taps/homebrew/homebrew-services, skipping update!
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/cask).

You have 45 outdated formulae and 6 outdated casks installed.

Error: No available formula with the name "clang". Did you mean cln, cling, clean, vlang, clingo or clac?

what should I do to upgrade the clang? should I upgrade the macOS operation system to the newest version? This is the macPorts clang path /opt/local/bin:

> ls *clang*
clang++-mp-16                  clang-cpp-mp-16                clang-include-fixer-mp-16      clang-offload-packager-mp-16   clang-reorder-fields-mp-16     clangd-mp-16
clang-apply-replacements-mp-16 clang-doc-mp-16                clang-linker-wrapper-mp-16     clang-pseudo-mp-16             clang-repl-mp-16               clangd-xpc-test-client-mp-16
clang-change-namespace-mp-16   clang-extdef-mapping-mp-16     clang-move-mp-16               clang-query-mp-16              clang-scan-deps-mp-16          git-clang-format-mp-16
clang-check-mp-16              clang-format-mp-16             clang-mp-16                    clang-refactor-mp-16           clang-tblgen-mp-16             run-clang-tidy-mp-16
clang-cl-mp-16                 clang-include-cleaner-mp-16    clang-offload-bundler-mp-16    clang-rename-mp-16             clang-tidy-mp-16

there seems no clang. This is the current clang path:

> whereis clang
clang: /usr/bin/clang /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/share/man/man1/clang.1
8
  • Note that Apple's clang is not exactly the same as the open source release.
    – mmmmmm
    Commented Jun 9 at 14:04
  • how to upgrade the apple's clang? is it possible to ugprade the clange verison to 16? or should I upgrade my operation system version?
    – Dolphin
    Commented Jun 9 at 14:10
  • 1
    Apple's clang version is included in Xcode (and CLT), so in order to upgrade it you need to upgrade Xcode. Xcode 15.4 (which is the most recent version) includes clang 15.
    – nohillside
    Commented Jun 9 at 14:15
  • 2
    You might need ports.macports.org/port/clang_select and ports.macports.org/port/cctools as well, probably.
    – nohillside
    Commented Jun 9 at 14:19
  • I need at least clang 16.
    – Dolphin
    Commented Jun 9 at 14:34

1 Answer 1

2

clang --version is showing it using the macOS built in clang. Make sure your MacPorts installed tools are before the Xcode toolchain on your PATH per the MacPorts installation instructions.

5
  • I have tried to export the path like this: export PATH=/opt/local/bin:/opt/local/sbin:$PATH
    – Dolphin
    Commented Jun 9 at 12:11
  • This will affect use of clang in terminal but probably not in Xcode
    – mmmmmm
    Commented Jun 9 at 14:03
  • this did not change the clang version in terminal, it still use the old version, not the new version of clang.
    – Dolphin
    Commented Jun 9 at 14:09
  • @Dolphin it will - what does echo $PATH show?
    – mmmmmm
    Commented Jun 9 at 17:29
  • Assuming that you installed clang correctly, the following path will lead you to clang- /opt/local/libexec/llvm-16/bin .
    – fd0
    Commented Jun 9 at 21:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .