AdaCore / gnat-llvm

LLVM based GNAT compiler
179 stars 18 forks source link

Problem on macOS #2

Closed simonjwright closed 4 years ago

simonjwright commented 4 years ago

I’ve tried building LLVM from llvm-project; branch master with GCC 9.1.0, tag llvmorg-8.01 with GCC 9.1.0, GNAT CE 2019, and the standard CommandLineTools; all fail building gnat_llvm with

/volumes/miscellaneous/ll/llvm/bin/clang++ -c -x c++ -g -I/Volumes/Miscellaneous/ll/llvm/include -std=c++11 -fno-exceptions -fno-rtti -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -MMD -MF llvm_wrapper.d /Volumes/Miscellaneous/ll/gnat-llvm/llvm-interface/llvm_wrapper.cc
In file included from /Volumes/Miscellaneous/ll/gnat-llvm/llvm-interface/llvm_wrapper.cc:1:
In file included from /Volumes/Miscellaneous/ll/llvm/include/llvm/ADT/APFloat.h:20:
In file included from /Volumes/Miscellaneous/ll/llvm/include/llvm/ADT/APInt.h:19:
/Volumes/Miscellaneous/ll/llvm/include/llvm/Support/Compiler.h:20:10: fatal error: 'new' file not found
#include <new>
         ^~~~~
1 error generated.

   compilation of llvm_wrapper.cc failed

Any thoughts welcome (aside from using "brew", please)

ArnaudCharlet commented 4 years ago

"new" is a standard C++ include, I guess you need to e.g. setup the Apple SDK to point to the right place. This is really unrelated to building GNAT LLVM: you would have the same issue compiling any C++ file depending on the C++ "new" include and clang++.

simonjwright commented 4 years ago

Quite so. You’d’ve thought that, following the work here I’d’ve been more aware that most of the problems introduced by Apple’s SDK changes. But that’s not the whole story: it turns out, from looking at what Apple’s clang++ does, that the C++ headers are in /usr/include/c++/v1 (or the equivalent place under the SDK). I don’t know how to build clang to incorporate this knowledge, so I’ve modified llvm-interface/Makefile to add it:

--- a/llvm-interface/Makefile
+++ b/llvm-interface/Makefile
@@ -33,6 +33,7 @@ endif
 LDFLAGS=$(shell $(LLVM_CONFIG) --libs all --ldflags --system-libs) \
   -static-libstdc++
 CXXFLAGS=$(shell $(LLVM_CONFIG) --cxxflags)
+CXXFLAGS += -I/Library/Developer/CommandLineTools/usr/include/c++/v1

 ifeq ($(filter-out CYGWIN% MINGW%,$(uname)),)
   LN_S=cp -p
ArnaudCharlet commented 4 years ago

OK, glad to hear that you found a way forward, thank you for sharing the info! What we'll do is to allow overriding the CXXFLAGS make variable on the command line so that you can do: make CXXFLAGS="-I/Library/..." without having to modify the Makefile

simonjwright commented 4 years ago

Perhaps EXTRA_CXXFLAGS?

ArnaudCharlet commented 4 years ago

That was my initial thought as well, but CXXFLAGS is really intended for that, so I'll make CXXFLAGS empty by default and user overridable, and use ALL_CXXFLAGS internally instead, watch for the commit soon if you're curious :-)