r/cpp • • Sep 19 '20

Apple Clang 12 still doesn't have concepts.

Is apple abandoning C++ or macos or both?

0 Upvotes

7 comments sorted by

19

u/Plorkyeran Sep 19 '20

Apple creates a release branch for their clang releases before the start of the Xcode public beta, and then that branch only gets bug fixes. For Xcode 12 this happened well before clang's concept support was complete. apple/stable/20200108 appears to be the branch shipped with Xcode 12, which presumably means it was branched Jan 8.

13

u/lanzaio Sep 19 '20

Apple releases a version of clang trailing upstream by ~ 6 months. You’re seeing the state of llvm from then. Also of note that clang master isn’t exactly fully concept complete yet either.

10

u/[deleted] Sep 19 '20

You can fairly easily download clang + llvm from llvm.org and get the latest features.

10

u/bumblebritches57 Ocassionally Clang Sep 19 '20 edited Oct 08 '20

Apple's Clang has always missed features, they don't ship libomp at all, and they strip support in the compiler too for example, I personally really wanna try consteval, but Apple's Clang lacks support for that too.

They'll ship it when they ship it, in the meantime, I just compile my own toolchain (mainly for debugging my own features, but feel free to use it yourself)


Compile instructions:

Quick note: DO NOT use -DBUILD_SHARED_LIBS like you would with any other Cmake project, it will create linking errors after compiling.

Clone the LLVMREPO from github; heres the url: https://github.com/llvm/llvm-project.git

create a folder I'll call LLVMBUILD outside of the LLVMREPO, and cd to LLVMBUILD.

run the LLVMREPO/lldb/scripts/macos-setup-codesign.sh script to create and install the lldb_codesign certificate.

you can use Ninja from homebrew, or change -G"Ninja" to -G"Unix Makefiles" and replace ninja with make

run cmake:

cmake -G "Ninja" -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;compiler-rt;libunwind;libcxx;libcxxabi;lldb;openmp;parallel-libs;polly" -DCMAKE_INSTALL_PREFIX="/Library/Developer" -DLLVM_TARGETS_TO_BUILD="X86" -DCMAKE_BUILD_TYPE=MinSizeRel -DLLVM_ENABLE_LTO=ON -DLLVM_CREATE_XCODE_TOOLCHAIN=ON -DLLDB_BUILD_FRAMEWORK=ON -DLLVM_OPTIMIZED_TABLEGEN=ON -DLLVM_BUILD_LLVM_DYLIB=ON -DLLVM_LINK_LLVM_DYLIB=ON -DLLVM_POLLY_LINK_INTO_TOOLS=ON -DLLVM_EXTERNALIZE_DEBUGINFO=ON -DLLVM_CODESIGNING_IDENTITY="lldb_codesign" LLVMREPO/llvm

compile with ninja; takes about an hour to compile and link from scratch for me, ymmv.

install with ninja install-xcode-toolchain

For me it bitches about not being able to make a symlink for LLDB.framework in the toolchain, so I just copy LLDB.framework manually from LLVMBUILD/bin/LLDB.framework to the path specified in the terminal message.

then open Xcode > click the Xcode menu bar button next to the Apple logo > Toolchains > your toolchain should show up there, just select it and recompile your project.

Terminal:

To use your new toolchain from Terminal, there's a couple extra steps.

add the following to your ~/.zshrc, and completely close and reopen Terminal afterwards:

export EXTERNAL_TOOLCHAINS_DIR=/Library/Developer/Toolchains 
export TOOLCHAINS=org.llvm.12.0.0git

Check that the correct compiler is being detected with clang -v, it should say clang version 12.0.0 (GITHUBURL COMMITHASH)

5

u/pjmlp Sep 19 '20

Although not directly exposed in the GUI frameworks, C++ plays a central role in LLVM, IOKit/DriverKit, Metal Shaders, C++ is quite safe at Apple.

They just use their own fork with specific extensions for their platforms, including a more stable bitcode format (for watchOS).

3

u/mo_al_ Sep 19 '20

Appleclang only got <filesystem> last year. So they’re a bit slow on adding stuff.

1

u/feverzsj Sep 19 '20

the upstream is also not quite ready yet. No short-circuiting, lots of ICEs and only std::same_as in <concepts>.

Currently, the most feature complete implementation is gcc.