Problem with building Clang and LLVM using Xcode


I'm trying to build clang and llvm using Xcode. I used the following
command to generate the Xcode project:

cmake -G Xcode -DDCMAKE_INSTALL_PREFIX="path to my llvm install
directory" "path to my llvm directory"

Then I opened LLVM.xcodeproj in Xcode, and chose "clang" as the only
build scheme and hit the Build. I ran into this error:
clang: error: no such file or directory: 'path to my build

/lib/Debug contains only one file - 'libPollyISL.a'. I got the same
error when I tried building from the command line:
clang: error: no such file or directory: 'my build
The following build commands failed: Ld
/Users/Firouzeh/dev/llvmbuild/Debug/bin/opt normal x86_64

I'm trying Xcode build, because I want to debug clang in Xcode. I'd
appreciate any help!

I'm using macOS 10.13.1, Xcode 9.1, Apple LLVM version 9.0.0
(clang-900.0.38), and trunk revision 318585 of the source code.

Firouzeh Soleymani

I don’t normally use Xcode – prefer command line – but thought this was interesting so I looked into it.

Not sure what the problem is with polly, but instead generating for xcode, try creating an External Build System project instead and point it to your ninja or make build.

You can follow these instructions, but note that I was unable to select clang in step 3, so I selected opt, then hand edited the .xschema file to use clang instead.


I tried what you said. I could run clangd in Xcode, but as you
mentioned it's not possible to choose clang to run. It seems that
Xcode doesn't see "clang-6.0" as an executable file. It assumes that
".0" at the end of the filename is the extension, so it is a
non-executable file. I removed ".0" from the name, then I could run
it. I don't know if this will cause problems along the way. I
haven't started to debug clang yet, but if I run into problems, I'll
report it here. Thanks!


Just edit the text file — it’s nothing magic.

Don, I edited .xschema and it worked fine, thanks! I added the driver
code (clang/tools/driver/driver.cpp) to start debugging and set a
breakpoint on main, but the program didn't stop at the breakpoint. Do
you know what else I need to do to debug? Thanks!


Don, I got it to debug. I set the breakpoint at
clang/lib/Driver/Driver.cpp and this time it worked. Please disregard
my previous email. Thank you so much for you help!


Great. Just have to remember to pass -cc1 since it’s a driver that forks.

Glad it worked for you, and thanks for bringing it up — l learned something too… :slight_smile: