Open thelukester92 opened 8 years ago
There is a line that checks for "colorgcc" and stores this in a variable named "COMPILER". Is that what you are referring to? In my testing on Linux, it seems to use it. (However, I think g++ uses color these days anyway, so I don't know what, if anything, colorgcc adds. Therefore, I think this feature should probably be removed for being superfluous complexity.)
I think using clang forces us to write better cross-compiler code. I suppose the advantage of going exclusively with g++ would be that we wouldn't have to worry about writing cross-compiler code. I'm conflicted on that issue, so I'll be happy with whatever direction you feel like pushing.
Perhaps it is worth keeping it cross-compiler compatible. In any case, it might be nice to be able to select a compiler to use more easily. Right now it is impossible for me on OS X to easily make sure Waffles still compiles using gcc.
I do think there is a problem with the Makefiles, though. We save which compiler we want in a variable named "COMPILER" then just use g++ down below when we are compiling. For example, in sparse/Makefile:
# If colorgcc is installed, use it, otherwise use g++
ifeq ($(wildcard /usr/bin/colorgcc),)
COMPILER=g++
else
COMPILER=colorgcc
endif
And down in the same file:
$(TARGET_PATH)/$(TARGET_NAME_OPT) : partialcleanopt $(OBJECTS_OPT) ../../lib/libGClasses.a
@if [ ! -d "$(TARGET_PATH)" ]; then mkdir -p "$(TARGET_PATH)"; fi
g++ -O3 -o $(TARGET_PATH)/$(TARGET_NAME_OPT) $(OBJECTS_OPT) $(OPT_LFLAGS)
Notice it uses g++ instead of $(COMPILER).
Committed a fix for this; still looking into an easy way to compile with a different compiler.
There are some platform problems -- I can select g++-5 as my compiler using:
make COMPILER=g++-5
However, it still sets -DDARWIN. This can be fixed like this:
make COMPILER=g++-5 UNAME=notDarwin
However, this does not appear to work because feenableexceptions is not declared. We may need OS X specific flags that are NOT clang specific flags...
Perhaps something like this:
# If colorgcc is installed, use it, otherwise use g++
ifeq ($(wildcard /usr/bin/colorgcc),)
COMPILER=g++
else
COMPILER=colorgcc
endif
# Detect compiler type
ifeq ($(shell $(COMPILER) 2>/dev/null --version | grep clang),)
CLANG=false
else
CLANG=true
endif
We also do have a CMake list, so another possibility would be to switch the creation of the makefiles entirely over to CMake. CMake is supposed to have really good cross compilation support, it could be easier to get it working on different OS's with CMake (Calling Jon Hammer for this one).
Thought I'd let you know. The Makefile build works on Mac OS X 10.12.5.
src:> g++ -v
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 8.0.0 (clang-800.0.42.1)
Target: x86_64-apple-darwin16.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
The Makefiles currently determine which compiler to use, then proceeds to use g++ regardless of what compiler was detected. This issue should be fixed. Additionally, it might be good to have the Makefiles attempt to use gcc instead of clang on Mac OS X (generally, if it is installed, it is available under the name g++-5). However, using g++-5 instead of clang on OS X would change the compiler flags on that platform, which potentially makes this a somewhat complicated change.