[llvm-dev] Building LLVM on Mac

583 views
Skip to first unread message

Abid Malik via llvm-dev

unread,
May 4, 2021, 4:11:13 AM5/4/21
to LLVM Developers Mailing List
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. 

----
I build with:

cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DLLVM_INCLUDE_TESTS=OFF ../llvm    -DLLVM_ENABLE_PROJECTS="mlir;clang;clang-tools-extra;libcxx;libcxxabi;lld;openmp"     -DLLVM_BUILD_EXAMPLES=ON  -DLLVM_TARGETS_TO_BUILD="X86;NVPTX;AMDGPU"    
-DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=ON -DCMAKE_C_FLAGS="-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk" -DCMAKE_CXX_FLAGS="-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk -I/Users/abidmalik/Programming/MLIR_target/llvm-project/libcxx/include" -DCMAKE_INSTALL_PREFIX=/Users/abidmalik/Programming/MLIR_target/llvm-project/INSTALL


I looked on Google as well for the solution. The closest one could find is


But unable to resolve the issue yet.
Any thoughts and suggestions? 

--
Abid M. Malik
******************************************************
"I have learned silence from the talkative, toleration from the intolerant, and kindness from the unkind"---Gibran
"Success is not for the chosen few, but for the few who choose" --- John Maxwell
"Being a good person does not depend on your religion or status in life, your race or skin color, political views or culture. IT DEPENDS ON HOW GOOD YOU TREAT OTHERS"--- Abid
"The Universe is talking to us, and the language of the Universe is mathematics."----Abid
 

Boris Boesler via llvm-dev

unread,
May 4, 2021, 5:06:57 AM5/4/21
to Abid Malik, LLVM Developers Mailing List
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

_______________________________________________
LLVM Developers mailing list
llvm...@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

Tobias Hieta via llvm-dev

unread,
May 4, 2021, 5:20:37 AM5/4/21
to Boris Boesler, LLVM Developers Mailing List
> > -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

Abid Malik via llvm-dev

unread,
May 4, 2021, 10:11:51 AM5/4/21
to Tobias Hieta, LLVM Developers Mailing List
Thanks, Boris and Tobias for the feedback.

The building always stuck at libcxxabi:
----
/Users/abidmalik/Programming/MLIR_target/llvm-project/libcxxabi/include/cxxabi.h:43:26: error: unknown type name 'size_t'
__cxa_allocate_exception(size_t thrown_size) throw();
                         ^
/Users/abidmalik/Programming/MLIR_target/llvm-project/libcxxabi/include/cxxabi.h:86:75: error: unknown type name 'uint64_t'
extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_ALWAYS_COLD int __cxa_guard_acquire(uint64_t *);
                                                                          ^
/Users/abidmalik/Programming/MLIR_target/llvm-project/libcxxabi/include/cxxabi.h:87:76: error: unknown type name 'uint64_t'
extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_ALWAYS_COLD void __cxa_guard_release(uint64_t *);

----
I tried with flag "-I/Users/abidmalik/Programming/MLIR_target/llvm-project/build/include/c++/v1" but I am getting:
 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/algorithm:641:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cstring:77:9: error: no member named 'strncmp' in the global namespace
using ::strncmp;
 
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cstring:78:9: error: no member named 'strcoll' in the global namespace
using ::strcoll;

I feel I am not setting flags for C++ libraries correctly for MacBook ( Ubuntu is doing fine).

Thanks 
                                                                           

On Tue, May 4, 2021 at 5:20 AM Tobias Hieta <tob...@plexapp.com> wrote:
> >  -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


mayuyu.io via llvm-dev

unread,
May 4, 2021, 9:17:34 PM5/4/21
to Abid Malik, llvm...@lists.llvm.org
The standalone Toolchain had always been troublesome and personally experience had always been installing the full Xcode suite, and use xcode-select -s to switch to it.

Other than that, You used the troublesome standalone toolchain initially so you might need to clear your build cache before switching to Xcode

Zhang

在 2021年5月4日,22:12,Abid Malik via llvm-dev <llvm...@lists.llvm.org> 写道:


Reply all
Reply to author
Forward
0 new messages