Building LLVM on Mac

Hello,

I am trying to build the framework on MacBook but getting errors while compilation; e.g., some are

/Users/abidmalik/Programming/MLIR_target/llvm-project/libcxx/include/wchar.h:137:77: error: use of undeclared identifier ‘wcschr’
wchar_t* __libcpp_wcschr(const wchar_t* __s, wchar_t __c) {return (wchar_t*)wcschr(__s, __c);}
^
/Users/abidmalik/Programming/MLIR_target/llvm-project/libcxx/include/wchar.h:144:87: error: use of undeclared identifier ‘wcspbrk’
wchar_t* __libcpp_wcspbrk(const wchar_t* __s1, const wchar_t* __s2) {return (wchar_t*)wcspbrk(__s1, __s2);}

Certainly, it has to do with the compiler flags related paths given to Cmake. I tried a couple of options but unable to solve the issue.

Hi.

I am trying to build the framework on MacBook but getting errors while compilation; e.g., some are

/Users/abidmalik/Programming/MLIR_target/llvm-project/libcxx/include/wchar.h:137:77: error: use of undeclared identifier 'wcschr'
wchar_t* __libcpp_wcschr(const wchar_t* __s, wchar_t __c) {return (wchar_t*)wcschr(__s, __c);}
                                                                            ^
/Users/abidmalik/Programming/MLIR_target/llvm-project/libcxx/include/wchar.h:144:87: error: use of undeclared identifier 'wcspbrk'
wchar_t* __libcpp_wcspbrk(const wchar_t* __s1, const wchar_t* __s2) {return (wchar_t*)wcspbrk(__s1, __s2);}

I'm building Clang/LLVM on a daily basis on Mac and I get these types of errors when I upgrade/update Xcode. Then I remove the build directory and build everything from scratch.

-DCMAKE_C_FLAGS="-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk" -DCMAKE_CXX_FLAGS="-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk

I do not use option -isysroot. Do these directories exist? I think you do not have to set it.

Boris

> -DCMAKE_C_FLAGS="-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk" -DCMAKE_CXX_FLAGS="-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk

I do not use option -isysroot. Do these directories exist? I think you do not have to set it.

The right way to do this is to set -DCMAKE_OSX_SYSROOT - not to pass
isysroot directly.

-- Tobias

Thanks, Boris and Tobias for the feedback.

The building always stuck at libcxxabi:

Hi! My problem seems similar.
I migrated to a M3 (arm64/Sequoia), installed Homebrew and llvm 19.1.3, reinstalled Xcode because of problems with breakpoints (lldb). And now I cannot compile because stdlib.h does not define some types ! I guess the problem would disappear if I could set the __cplusplus variable, but where and how?

We have kept the previous version of our apps on a MacBook x86_64 (also on Sequoia) and have not this problem.

– Xan
================ part of our Make trace =============
→ creerLiensSymboliques-INCL (sh), PWD = /Users/Shared/Dev_ex_PC_ou_Linux/Ariane-Y/ariane-y/Ariane-Y_prog_2013/INCL ←
clang++ -I/opt/homebrew/opt/llvm/include -w -g -O0 -std=c++17 -arch arm64 -DXY -DAVL -I…/INCL/ -I…/…/INCL -c Fichier.cpp
In file included from Fichier.cpp:29:
In file included from ./Fichier.hpp:25:
In file included from /opt/homebrew/Cellar/llvm/19.1.3/bin/…/include/c++/v1/string:591:
In file included from /opt/homebrew/Cellar/llvm/19.1.3/bin/…/include/c++/v1/__algorithm/remove.h:12:
In file included from /opt/homebrew/Cellar/llvm/19.1.3/bin/…/include/c++/v1/__algorithm/find.h:23:
In file included from /opt/homebrew/Cellar/llvm/19.1.3/bin/…/include/c++/v1/__string/constexpr_c_functions.h:14:
In file included from /opt/homebrew/Cellar/llvm/19.1.3/bin/…/include/c++/v1/__memory/construct_at.h:23:
In file included from /opt/homebrew/Cellar/llvm/19.1.3/bin/…/include/c++/v1/new:358:
In file included from /opt/homebrew/Cellar/llvm/19.1.3/bin/…/include/c++/v1/cstdlib:86:
/opt/homebrew/Cellar/llvm/19.1.3/bin/…/include/c++/v1/stdlib.h:143:30: error: unknown type name ‘ldiv_t’
143 | inline _LIBCPP_HIDE_FROM_ABI ldiv_t div(long __x, long __y) _NOEXCEPT { return ::ldiv(__x, __y); }

This is the first time I login to this forum, sorry about it!

My post has been in reply to the nearest topic I could see.

I would be interested to know how its author ( abidmalikwaterloo) has solved the problem.

I did not find how to create a new topic, or to aggregate 2 tags (here, llvm+clang).

Maybe I should modify or upgrade my llvm@19 installation (done with Homebrew)? Or is there a cmake+configure that would produce a usable installation of llvm?

Thanks in advance,

– Xan