6

So, for no apparent reason (I haven't installed a new version of clang, or changed any compiler configuration), clang suddenly can't find assert.h on my Mac.

In my development VM, running Ubuntu, both gcc and clang compile the project fine; on the host Mac OS X, gcc still compiles it fine, but clang spits out the following:

> make
clang -g -O0 -Wall -Wextra -pedantic -Wshadow -Wstrict-overflow -Wno-missing-field-initializers -std=c99 -m64 -Wno-unused-variable -Wno-unused-parameter -o csim csim.c cachelab.c -lm
csim.c:1:10: fatal error: 'assert.h' file not found
#include <assert.h>
         ^
1 error generated.
cachelab.c:5:10: fatal error: 'assert.h' file not found
#include <assert.h>
         ^
1 error generated.
make: *** [csim] Error 1

Here's some further relevant information:

> xcode-select --print-path
/Applications/Xcode-beta.app/Contents/Developer
> gcc -g -O0 -Wall -Wextra -pedantic -Wshadow -Wstrict-overflow -Wno-missing-field-initializers -std=c99 -m64 -Wno-unused-variable -Wno-unused-parameter -o csim csim.c cachelab.c -lm
> clang -std=c99 -o csim csim.c -v
clang version 3.8.1 (tags/RELEASE_381/final)
Target: x86_64-apple-darwin16.0.0
Thread model: posix
InstalledDir: /usr/local/opt/llvm/bin
 "/usr/local/Cellar/llvm/3.8.1/bin/clang-3.8" -cc1 -triple x86_64-apple-macosx10.12.0 -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name csim.c -mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version 273 -v -dwarf-column-info -debugger-tuning=lldb -resource-dir /usr/local/Cellar/llvm/3.8.1/bin/../lib/clang/3.8.1 -std=c99 -fdebug-compilation-dir /Users/ec/Dropbox/Documents/Homework/CS351/mps/04 -ferror-limit 19 -fmessage-length 211 -stack-protector 1 -fblocks -fobjc-runtime=macosx-10.12.0 -fencode-extended-block-signature -fmax-type-align=16 -fdiagnostics-show-option -fcolor-diagnostics -o /var/folders/xt/wm01x2h50nv993t_csb1t5qm0000gn/T/csim-9590db.o -x c csim.c
clang -cc1 version 3.8.1 based upon LLVM 3.8.1 default target x86_64-apple-darwin16.0.0
ignoring nonexistent directory "/usr/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /usr/local/Cellar/llvm/3.8.1/bin/../lib/clang/3.8.1/include
 /System/Library/Frameworks (framework directory)
 /Library/Frameworks (framework directory)
End of search list.
csim.c:1:10: fatal error: 'assert.h' file not found
#include <assert.h>
         ^
1 error generated.
ELLIOTTCABLE
  • 17,185
  • 12
  • 62
  • 78
  • So did you check if the files exist in the search dirs? "ignoring nonexistent directory "/usr/include"" - is that correct on OS-X? It definitively is uncommon on Unix/Linux. – too honest for this site Aug 15 '16 at 01:33
  • I'm checking with other OS X friends now, re: the former, yes, and `locate assert.h` doesn't report it existing in any of those directories: http://hastebin.com/aboyeqobih.txt – ELLIOTTCABLE Aug 15 '16 at 01:46
  • As a side-note: do you really use gcc or just the installed clang which is run with the `gcc` link? Also I'd check which path that "gcc" (whichever it is) uses. Sorry, I don't use Mac, just trying to help with common sense. – too honest for this site Aug 15 '16 at 02:00
  • Interestingly, you're right; that gcc is running through clang, too. (That's kinda nasty? wtf?). But that makes it *even weirder* that it works? – ELLIOTTCABLE Aug 15 '16 at 02:03
  • Not, it is actually "clang running as gcc". You don't know the history of OS-x, don't you? They replaced gcc by clang some years ago, but set the link for compatibility. No wtf, but somewhat logical. Yet it can casue trouble, as both a re not identical in all aspects (options, language extensions&features. I suppose for the majority it works, though. As I wrote, I don't use Apple, I'm happy with my Linux systems:-) – too honest for this site Aug 15 '16 at 02:08
  • I just posted an answer that should fix this problem too: http://stackoverflow.com/a/38966585/829116 – AlexDenisov Aug 16 '16 at 04:21

0 Answers0