Update test scripts and Makefiles to allow testing with GCC:
authorDaniel Malea <daniel.malea@intel.com>
Fri, 25 Jan 2013 00:31:48 +0000 (00:31 +0000)
committerDaniel Malea <daniel.malea@intel.com>
Fri, 25 Jan 2013 00:31:48 +0000 (00:31 +0000)
- introduce new variable ARCHFLAG in make/Makefile.rules to switch between "-arch" on Mac and "-m" everywhere else
- update testcase makefiles to use LD_EXTRAS instead of LDFLAGS (the former interacts with Makefile.rules badly)
- special treatment for gcc 4.6: replace "-std=c++11" with "-std=c++0x" as the former is not handled correctly
- remove hardcoded "-arch" from test Makefile

This patch should not have any effect on lldb on Mac OS X.

llvm-svn: 173402

lldb/test/functionalities/stop-hook/multiple_threads/Makefile
lldb/test/functionalities/thread/Makefile
lldb/test/functionalities/watchpoint/watchpoint_set_command/Makefile
lldb/test/lang/c/const_variables/Makefile
lldb/test/lang/cpp/stl/TestSTL.py
lldb/test/make/Makefile.rules
lldb/test/plugins/builder_base.py
lldb/test/python_api/lldbutil/iter/Makefile
lldb/test/python_api/lldbutil/process/Makefile
lldb/test/python_api/module_section/Makefile
lldb/test/python_api/watchpoint/watchlocation/Makefile

index ecf078b..2af752b 100644 (file)
@@ -1,6 +1,6 @@
 LEVEL = ../../../make
 
-LDFLAGS := -lpthread
+LD_EXTRAS := -lpthread
 CXX_SOURCES := main.cpp
 
 include $(LEVEL)/Makefile.rules
index 24cb29f..2773c6d 100644 (file)
@@ -1,5 +1,5 @@
 LEVEL = ../../make
 
 C_SOURCES := main.c
-LDFLAGS := -lpthread
+LD_EXTRAS := -lpthread
 include $(LEVEL)/Makefile.rules
index ecf078b..2af752b 100644 (file)
@@ -1,6 +1,6 @@
 LEVEL = ../../../make
 
-LDFLAGS := -lpthread
+LD_EXTRAS := -lpthread
 CXX_SOURCES := main.cpp
 
 include $(LEVEL)/Makefile.rules
index 923a0d6..69dc250 100644 (file)
@@ -2,6 +2,6 @@ LEVEL = ../../../make
 
 C_SOURCES := main.c functions.c
 
-CFLAGS ?= -arch $(ARCH) -gdwarf-2 -O3
+CFLAGS ?= -gdwarf-2 -O3
 
 include $(LEVEL)/Makefile.rules
index 62f4332..d96c692 100644 (file)
@@ -36,6 +36,7 @@ class STLTestCase(TestBase):
         self.buildDsym()
         self.sbtype_template_apis()
 
+   @skipIfGcc # bugzilla 15036: crashes during DWARF parsing when built with GCC
     @python_api_test
     @dwarf_test
     def test_SBType_template_aspects_with_dwarf(self):
index aaae894..dd90341 100644 (file)
@@ -54,26 +54,49 @@ ifeq "$(CC)" "cc"
 endif
 
 #----------------------------------------------------------------------
+# ARCHFLAG is the flag used to tell the compiler which architecture
+# to compile for. The default is the flag that clang accepts.
+#----------------------------------------------------------------------
+ARCHFLAG ?= -arch 
+
+#----------------------------------------------------------------------
 # Change any build/tool options needed
 #----------------------------------------------------------------------
-CFLAGS ?= -gdwarf-2 -O0
-CFLAGS += $(FRAMEWORK_INCLUDES) $(CFLAGS_EXTRAS)
 ifeq "$(OS)" "Darwin"
-       CFLAGS += -arch $(ARCH)
        DS := dsymutil
        DSFLAGS =
        DSYM = $(EXE).dSYM
        AR := libtool
        ARFLAGS := -static -o
+else
+       # On non-Apple platforms, -arch becomes -m
+       ARCHFLAG := -m
+
+       # i386 becomes 32, and x86_64 becomes 64
+       ifeq "$(ARCH)" "x86_64"
+           override ARCH := $(subst x86_64,64,$(ARCH))
+       endif
+       ifeq "$(ARCH)" "i386"
+           override ARCH := $(subst i386,32,$(ARCH))
+       endif
 endif
 
+CFLAGS ?= -gdwarf-2 -O0
+CFLAGS += $(ARCHFLAG)$(ARCH) $(FRAMEWORK_INCLUDES) $(CFLAGS_EXTRAS)
+
 CXXFLAGS +=$(CFLAGS)
 LD = $(CC)
 LDFLAGS ?= $(CFLAGS)
-LDFLAGS += $(LD_EXTRAS) -arch $(ARCH)
+LDFLAGS += $(LD_EXTRAS)
 OBJECTS =
 EXE ?= a.out
 
+ifneq (,$(findstring g++,$(CXX)))
+       # GCC 4.6 cannot handle -std=c++11, so replace it with -std=c++0x
+       # instead. FIXME: remove once GCC version is upgraded.
+       override CXXFLAGS := $(subst -std=c++11,-std=c++0x,$(CXXFLAGS))
+endif
+
 ifneq "$(DYLIB_NAME)" ""
        ifeq "$(OS)" "Darwin"
                DYLIB_FILENAME = lib$(DYLIB_NAME).dylib
@@ -208,7 +231,7 @@ EXE = $(DYLIB_FILENAME)
 endif
 else
 $(EXE) : $(OBJECTS) $(ARCHIVE_NAME)
-       $(LD) $(LDFLAGS) $(OBJECTS) $(ARCHIVE_NAME) -o "$(EXE)"
+       $(LD) $(OBJECTS) $(LDFLAGS) $(ARCHIVE_NAME) -o "$(EXE)"
 endif
 
 #----------------------------------------------------------------------
index 78fc2f0..737276d 100644 (file)
@@ -23,6 +23,20 @@ def getCompiler():
     """Returns the compiler in effect the test suite is running with."""
     return os.environ["CC"] if "CC" in os.environ else "clang"
 
+def getArchFlag():
+    """Returns the flag required to specify the arch"""
+    compiler = getCompiler()
+    if compiler is None:
+      return ""
+    elif "gcc" in compiler:
+      archflag = "-m"
+    elif "clang" in compiler:
+      archflag = "-arch "
+    else:
+      archflag = None
+
+    return (" ARCHFLAG=" + archflag) if archflag else ""
+
 def getArchSpec(architecture):
     """
     Helper function to return the key-value string to specify the architecture
index 865b34b..190194e 100644 (file)
@@ -1,7 +1,7 @@
 LEVEL = ../../../make
 
 CFLAGS_EXTRAS := -D__STDC_LIMIT_MACROS
-LDFLAGS := -lpthread
+LD_EXTRAS := -lpthread
 CXX_SOURCES := main.cpp
 MAKE_DSYM :=NO
 
index 865b34b..190194e 100644 (file)
@@ -1,7 +1,7 @@
 LEVEL = ../../../make
 
 CFLAGS_EXTRAS := -D__STDC_LIMIT_MACROS
-LDFLAGS := -lpthread
+LD_EXTRAS := -lpthread
 CXX_SOURCES := main.cpp
 MAKE_DSYM :=NO
 
index 2e9a4de..7b5f111 100644 (file)
@@ -1,7 +1,7 @@
 LEVEL = ../../make
 
 CFLAGS_EXTRAS := -D__STDC_LIMIT_MACROS
-LDFLAGS := -lpthread
+LD_EXTRAS := -lpthread
 CXX_SOURCES := main.cpp b.cpp c.cpp
 MAKE_DSYM :=NO
 
index ecf078b..2af752b 100644 (file)
@@ -1,6 +1,6 @@
 LEVEL = ../../../make
 
-LDFLAGS := -lpthread
+LD_EXTRAS := -lpthread
 CXX_SOURCES := main.cpp
 
 include $(LEVEL)/Makefile.rules