clang: warning: no such sysroot directory: '-mmacosx-version-min=10.5' on compiling LLVM (3.9.0)

你。 提交于 2020-07-19 18:54:30

问题


I am compiling LLVM (3.9.0) using CMake (3.6.2) on my Mac (OsX) using GCC, but somehow I am getting the following error with following GCC configuration

Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 7.3.0 (clang-703.0.31)
Target: x86_64-apple-darwin15.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

[50%] Building C object projects/compiler-rt/lib/builtins/CMakeFiles/clang_rt.eprintf.dir/eprintf.c.o
clang: warning: no such sysroot directory: '-mmacosx-version-min=10.5'
/Users/Ritzy/llvm_src/llvm-3.9.0.src/projects/compiler-rt/lib/builtins/eprintf.c:14:10: fatal error: 'stdio.h' file not found
#include <stdio.h>
         ^
1 error generated.
make[2]: *** [projects/compiler-rt/lib/builtins/CMakeFiles/clang_rt.eprintf.dir/eprintf.c.o] Error 1
make[1]: *** [projects/compiler-rt/lib/builtins/CMakeFiles/clang_rt.eprintf.dir/all] Error 2
make: *** [all] Error 2

I am using following CMake command:

cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR  ..
cmake --build .

I spent hours figuring out what was wrong. Even tried to using gcc6 and clang but in vain.


回答1:


Here's an example of what the command line flags supplied to a MacOS/X clang invocation might look like:

-pipe -stdlib=libc++ -std=c++11 -stdlib=libc++ -O2 -std=gnu++11 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -mmacosx-version-min=10.7 -Wall -W -fPIC $(DEFINES)

Note in particular this part:

-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -mmacosx-version-min=10.7

-isysroot tells the compiler where to look for header files, and then the next argument -mmacosx-version-min=10.7 tells it what minimum version of MacOS/X to maintain backwards compatibility with.

In your case, your CMake invocation probably isn't specifying a value for the -isysroot argument, instead it probably has something like this:

-isysroot   -mmacosx-version-min=10.5

... where the path that was intended to be supplied after the -isysroot flag has been left blank (i.e. an empty string) for some reason, and that is why "-mmacosx-version-min=10.5" is being interpreted as a path to look for header files in (which of course will not work).

As to why the path argument was left blank, that is something you'll have to investigate on your own.



来源:https://stackoverflow.com/questions/39438048/clang-warning-no-such-sysroot-directory-mmacosx-version-min-10-5-on-compil

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!