[llvm-commits] [dragonegg] r154994 - in /dragonegg/trunk: Makefile include/dragonegg/Internals.h include/x86/dragonegg/Target.h src/Aliasing.cpp src/Backend.cpp src/Cache.cpp src/Constants.cpp src/Convert.cpp src/Debug.cpp src/DefaultABI.cpp src/Trees.cpp src/Types.cpp src/arm/Target.cpp src/x86/ABIHack.inc src/x86/Target.cpp utils/empty.c utils/lang_plugin.c

Duncan Sands baldrick at free.fr
Wed Apr 18 01:50:57 PDT 2012


Author: baldrick
Date: Wed Apr 18 03:50:57 2012
New Revision: 154994

URL: http://llvm.org/viewvc/llvm-project?rev=154994&view=rev
Log:
Revert commit 154925: Pax Team told me about a better way of doing this.
Original commit message:

GCC-4.7 may be built with either a C or a C++ compiler.  If it was with a C
compiler then symbols we access in it need to be wrapped in "extern C",
otherwise they need to be mangled so must not be wrapped in "extern C".
Detect how gcc-4.7 was built via a horrible hack and build the plugin
appropriately.


Removed:
    dragonegg/trunk/utils/empty.c
    dragonegg/trunk/utils/lang_plugin.c
Modified:
    dragonegg/trunk/Makefile
    dragonegg/trunk/include/dragonegg/Internals.h
    dragonegg/trunk/include/x86/dragonegg/Target.h
    dragonegg/trunk/src/Aliasing.cpp
    dragonegg/trunk/src/Backend.cpp
    dragonegg/trunk/src/Cache.cpp
    dragonegg/trunk/src/Constants.cpp
    dragonegg/trunk/src/Convert.cpp
    dragonegg/trunk/src/Debug.cpp
    dragonegg/trunk/src/DefaultABI.cpp
    dragonegg/trunk/src/Trees.cpp
    dragonegg/trunk/src/Types.cpp
    dragonegg/trunk/src/arm/Target.cpp
    dragonegg/trunk/src/x86/ABIHack.inc
    dragonegg/trunk/src/x86/Target.cpp

Modified: dragonegg/trunk/Makefile
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/Makefile?rev=154994&r1=154993&r2=154994&view=diff
==============================================================================
--- dragonegg/trunk/Makefile (original)
+++ dragonegg/trunk/Makefile Wed Apr 18 03:50:57 2012
@@ -40,18 +40,16 @@
 LOADABLE_MODULE_OPTIONS=-shared -Wl,-O1 -Wl,--version-script=$(TOP_DIR)/exports.map
 endif
 
-LLVM_VERSION:=$(shell $(LLVM_CONFIG) --version)
-
-GCC_VERSION:=$(shell $(GCC) -dumpversion).0
-GCC_MAJOR:=$(word 1, $(subst ., ,$(GCC_VERSION)))
-GCC_MINOR:=$(word 2, $(subst ., ,$(GCC_VERSION)))
-GCC_MICRO:=$(word 3, $(subst ., ,$(GCC_VERSION)))
-
-GCC_LANGUAGES:=$(shell $(GCC) -v 2>&1 | grep '^Configured with:' | sed 's/^.*--enable-languages=\([^ ]*\).*/\1/')
 GCC_PLUGIN_DIR:=$(shell $(GCC) -print-file-name=plugin)
-
+GCC_VERSION:=$(shell $(GCC) -dumpversion).0
+GCC_MAJOR=$(word 1, $(subst ., ,$(GCC_VERSION)))
+GCC_MINOR=$(word 2, $(subst ., ,$(GCC_VERSION)))
+GCC_MICRO=$(word 3, $(subst ., ,$(GCC_VERSION)))
+GCC_LANGUAGES=$(shell $(GCC) -v 2>&1 | grep '^Configured with:' | sed 's/^.*--enable-languages=\([^ ]*\).*/\1/')
 TARGET_TRIPLE:=$(shell $(GCC) -dumpmachine)
 
+LLVM_VERSION:=$(shell $(LLVM_CONFIG) --version)
+
 PLUGIN=dragonegg.so
 PLUGIN_OBJECTS=Aliasing.o Backend.o Cache.o Constants.o Convert.o Debug.o \
 	       DefaultABI.o Trees.o Types.o bits_and_bobs.o
@@ -68,7 +66,7 @@
 	     -MD -MP \
 	     -DIN_GCC -DLLVM_VERSION=\"$(LLVM_VERSION)\" \
 	     -DGCC_MAJOR=$(GCC_MAJOR) -DGCC_MINOR=$(GCC_MINOR) \
-	     -DGCC_MICRO=$(GCC_MICRO) -DGCC_LANG=\"$(GCC_LANG)\" \
+	     -DGCC_MICRO=$(GCC_MICRO) \
 	     -I$(INCLUDE_DIR) -isystem$(GCC_PLUGIN_DIR)/include
 ifdef DISABLE_VERSION_CHECK
 CPP_OPTIONS+=-DDISABLE_VERSION_CHECK
@@ -93,49 +91,6 @@
 
 default: $(PLUGIN)
 
-
-# gcc-4.6 and earlier are built as C, gcc-4.8 and later are built as C++, while
-# gcc-4.7 may be built as C or as C++.  The plugin accesses symbols inside gcc
-# so needs to know if they are mangled or not.  Determine the gcc build language
-# and store it in GCC_LANG.
-
-GCC_LANG_PLUGIN:=lang_plugin.so
-GCC_LANG_TARGET:=
-ifeq ($(GCC_MAJOR),4)
-
-ifeq ($(GCC_MINOR),5)
-# gcc-4.5
-GCC_LANG:="C"
-else ifeq ($(GCC_MINOR),6)
-# gcc-4.6
-GCC_LANG:="C"
-else ifeq ($(GCC_MINOR),7)
-# gcc-4.7, may have been built as C or C++
-GCC_LANG_TARGET:=check_build_language
-
-$(GCC_LANG_PLUGIN): $(TOP_DIR)/utils/lang_plugin.c
-	@echo Compiling utils/$(<F)
-	$(QUIET)$(CC) -o $@ $< $(LOADABLE_MODULE_OPTIONS) \
-	  -I$(GCC_PLUGIN_DIR)/include
-
-# Try to load a simple plugin that attempts to use a non-mangled symbol
-# from gcc.  If it works then gcc was built as C.  Otherwise either gcc
-# was built as C++ (or something went wrong with the test).
-check_build_language:: $(GCC_LANG_PLUGIN)
-	$(eval GCC_LANG := $(shell $(GCC) -fplugin=./$(GCC_LANG_PLUGIN) -S \
-	  utils/empty.c 2> /dev/null && echo "C" || echo "C++"))
-	@echo "GCC was built as $(GCC_LANG)"
-else
-# gcc-4.8 and later
-GCC_LANG:="C++"
-endif
-
-else
-# gcc-5.0 and later
-GCC_LANG:="C++"
-endif
-
-
 $(TARGET_UTIL_OBJECTS): %.o : $(TOP_DIR)/utils/%.cpp
 	@echo Compiling utils/$*.cpp
 	$(QUIET)$(CXX) -c -DTARGET_TRIPLE=\"$(TARGET_TRIPLE)\" \
@@ -146,7 +101,7 @@
 	$(QUIET)$(CXX) -o $@ $^ $(shell $(LLVM_CONFIG) --libs support) \
 	$(LD_OPTIONS)
 
-%.o : $(SRC_DIR)/%.cpp $(GCC_LANG_TARGET) $(TARGET_UTIL)
+%.o : $(SRC_DIR)/%.cpp $(TARGET_UTIL)
 	@echo Compiling $*.cpp
 	$(QUIET)$(CXX) -c $(TARGET_HEADERS) $(CPP_OPTIONS) $(CXXFLAGS) $<
 
@@ -187,8 +142,7 @@
 check:: check-validator check-compilator
 
 clean::
-	$(QUIET)rm -f *.o *.d $(GCC_LANG_PLUGIN) $(PLUGIN) $(TARGET_UTIL) \
-	  $(LIT_SITE_CONFIG)
+	$(QUIET)rm -f *.o *.d $(PLUGIN) $(TARGET_UTIL) $(LIT_SITE_CONFIG)
 
 
 -include $(ALL_OBJECTS:.o=.d)

Modified: dragonegg/trunk/include/dragonegg/Internals.h
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/include/dragonegg/Internals.h?rev=154994&r1=154993&r2=154994&view=diff
==============================================================================
--- dragonegg/trunk/include/dragonegg/Internals.h (original)
+++ dragonegg/trunk/include/dragonegg/Internals.h Wed Apr 18 03:50:57 2012
@@ -37,8 +37,9 @@
 union gimple_statement_d;
 union tree_node;
 
-extern GCC_LANG {
+extern "C" {
 extern void debug_gimple_stmt(union gimple_statement_d *);
+extern void debug_tree(union tree_node *);
 }
 
 namespace llvm {

Modified: dragonegg/trunk/include/x86/dragonegg/Target.h
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/include/x86/dragonegg/Target.h?rev=154994&r1=154993&r2=154994&view=diff
==============================================================================
--- dragonegg/trunk/include/x86/dragonegg/Target.h (original)
+++ dragonegg/trunk/include/x86/dragonegg/Target.h Wed Apr 18 03:50:57 2012
@@ -46,7 +46,7 @@
    `inreg` parameter attribute */
 #define LLVM_TARGET_ENABLE_REGPARM
 
-extern GCC_LANG int ix86_regparm;
+extern "C" int ix86_regparm;
 
 #define LLVM_TARGET_INIT_REGPARM(local_regparm, local_fp_regparm, type) \
   {                                                             \

Modified: dragonegg/trunk/src/Aliasing.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Aliasing.cpp?rev=154994&r1=154993&r2=154994&view=diff
==============================================================================
--- dragonegg/trunk/src/Aliasing.cpp (original)
+++ dragonegg/trunk/src/Aliasing.cpp Wed Apr 18 03:50:57 2012
@@ -34,7 +34,7 @@
 #include <map>
 
 // GCC headers
-extern GCC_LANG {
+extern "C" {
 #include "config.h"
 // Stop GCC declaring 'getopt' as it can clash with the system's declaration.
 #undef HAVE_DECL_GETOPT

Modified: dragonegg/trunk/src/Backend.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Backend.cpp?rev=154994&r1=154993&r2=154994&view=diff
==============================================================================
--- dragonegg/trunk/src/Backend.cpp (original)
+++ dragonegg/trunk/src/Backend.cpp Wed Apr 18 03:50:57 2012
@@ -50,7 +50,7 @@
 #include <gmp.h>
 
 // GCC headers
-extern GCC_LANG {
+extern "C" {
 #include "config.h"
 // Stop GCC declaring 'getopt' as it can clash with the system's declaration.
 #undef HAVE_DECL_GETOPT
@@ -85,7 +85,7 @@
 #endif
 
 // TODO: In GCC, add targhooks.h to the list of plugin headers and remove this.
-extern GCC_LANG tree default_mangle_decl_assembler_name (tree, tree);
+extern "C" tree default_mangle_decl_assembler_name (tree, tree);
 
 // Non-zero if libcalls should not be simplified.
 int flag_no_simplify_libcalls;
@@ -2284,14 +2284,12 @@
     pass_info.pos_op = PASS_POS_REPLACE;
     register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &pass_info);
 
-#if (GCC_MINOR < 7)
     // Turn off pass_ipa_type_escape.
     pass_info.pass = &pass_simple_ipa_null.pass;
     pass_info.reference_pass_name = "type-escape-var";
     pass_info.ref_pass_instance_number = 0;
     pass_info.pos_op = PASS_POS_REPLACE;
     register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &pass_info);
-#endif
 
     // Turn off pass_ipa_pta.
     pass_info.pass = &pass_simple_ipa_null.pass;
@@ -2300,14 +2298,12 @@
     pass_info.pos_op = PASS_POS_REPLACE;
     register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &pass_info);
 
-#if (GCC_MINOR < 7)
     // Turn off pass_ipa_struct_reorg.
     pass_info.pass = &pass_simple_ipa_null.pass;
     pass_info.reference_pass_name = "ipa_struct_reorg";
     pass_info.ref_pass_instance_number = 0;
     pass_info.pos_op = PASS_POS_REPLACE;
     register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &pass_info);
-#endif
   }
 
   // Replace the LTO gimple pass with a pass that converts same-body aliases and

Modified: dragonegg/trunk/src/Cache.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Cache.cpp?rev=154994&r1=154993&r2=154994&view=diff
==============================================================================
--- dragonegg/trunk/src/Cache.cpp (original)
+++ dragonegg/trunk/src/Cache.cpp Wed Apr 18 03:50:57 2012
@@ -34,7 +34,7 @@
 #include <gmp.h>
 
 // GCC headers
-extern GCC_LANG {
+extern "C" {
 #include "config.h"
 // Stop GCC declaring 'getopt' as it can clash with the system's declaration.
 #undef HAVE_DECL_GETOPT
@@ -111,7 +111,7 @@
 
 
 // Include the garbage collector header.
-extern GCC_LANG {
+extern "C" {
 #if (GCC_MINOR > 5)
 #include "dragonegg/gt-cache-4.6.h"
 #else

Modified: dragonegg/trunk/src/Constants.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Constants.cpp?rev=154994&r1=154993&r2=154994&view=diff
==============================================================================
--- dragonegg/trunk/src/Constants.cpp (original)
+++ dragonegg/trunk/src/Constants.cpp Wed Apr 18 03:50:57 2012
@@ -38,7 +38,7 @@
 #include <gmp.h>
 
 // GCC headers
-extern GCC_LANG {
+extern "C" {
 #include "config.h"
 // Stop GCC declaring 'getopt' as it can clash with the system's declaration.
 #undef HAVE_DECL_GETOPT

Modified: dragonegg/trunk/src/Convert.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Convert.cpp?rev=154994&r1=154993&r2=154994&view=diff
==============================================================================
--- dragonegg/trunk/src/Convert.cpp (original)
+++ dragonegg/trunk/src/Convert.cpp Wed Apr 18 03:50:57 2012
@@ -40,7 +40,7 @@
 #include <gmp.h>
 
 // GCC headers
-extern GCC_LANG {
+extern "C" {
 #include "config.h"
 // Stop GCC declaring 'getopt' as it can clash with the system's declaration.
 #undef HAVE_DECL_GETOPT

Modified: dragonegg/trunk/src/Debug.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Debug.cpp?rev=154994&r1=154993&r2=154994&view=diff
==============================================================================
--- dragonegg/trunk/src/Debug.cpp (original)
+++ dragonegg/trunk/src/Debug.cpp Wed Apr 18 03:50:57 2012
@@ -30,7 +30,7 @@
 #include <gmp.h>
 
 // GCC headers
-extern GCC_LANG {
+extern "C" {
 #include "config.h"
 // Stop GCC declaring 'getopt' as it can clash with the system's declaration.
 #undef HAVE_DECL_GETOPT

Modified: dragonegg/trunk/src/DefaultABI.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/DefaultABI.cpp?rev=154994&r1=154993&r2=154994&view=diff
==============================================================================
--- dragonegg/trunk/src/DefaultABI.cpp (original)
+++ dragonegg/trunk/src/DefaultABI.cpp Wed Apr 18 03:50:57 2012
@@ -27,7 +27,7 @@
 #include <gmp.h>
 
 // GCC headers
-extern GCC_LANG {
+extern "C" {
 #include "config.h"
 // Stop GCC declaring 'getopt' as it can clash with the system's declaration.
 #undef HAVE_DECL_GETOPT

Modified: dragonegg/trunk/src/Trees.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Trees.cpp?rev=154994&r1=154993&r2=154994&view=diff
==============================================================================
--- dragonegg/trunk/src/Trees.cpp (original)
+++ dragonegg/trunk/src/Trees.cpp Wed Apr 18 03:50:57 2012
@@ -28,7 +28,7 @@
 #include <gmp.h>
 
 // GCC headers
-extern GCC_LANG {
+extern "C" {
 #include "config.h"
 // Stop GCC declaring 'getopt' as it can clash with the system's declaration.
 #undef HAVE_DECL_GETOPT

Modified: dragonegg/trunk/src/Types.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Types.cpp?rev=154994&r1=154993&r2=154994&view=diff
==============================================================================
--- dragonegg/trunk/src/Types.cpp (original)
+++ dragonegg/trunk/src/Types.cpp Wed Apr 18 03:50:57 2012
@@ -35,7 +35,7 @@
 #include <map>
 
 // GCC headers
-extern GCC_LANG {
+extern "C" {
 #include "config.h"
 // Stop GCC declaring 'getopt' as it can clash with the system's declaration.
 #undef HAVE_DECL_GETOPT

Modified: dragonegg/trunk/src/arm/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/arm/Target.cpp?rev=154994&r1=154993&r2=154994&view=diff
==============================================================================
--- dragonegg/trunk/src/arm/Target.cpp (original)
+++ dragonegg/trunk/src/arm/Target.cpp Wed Apr 18 03:50:57 2012
@@ -32,7 +32,7 @@
 #include <gmp.h>
 
 // GCC headers
-extern GCC_LANG {
+extern "C" {
 #include "config.h"
 // Stop GCC declaring 'getopt' as it can clash with the system's declaration.
 #undef HAVE_DECL_GETOPT

Modified: dragonegg/trunk/src/x86/ABIHack.inc
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/x86/ABIHack.inc?rev=154994&r1=154993&r2=154994&view=diff
==============================================================================
--- dragonegg/trunk/src/x86/ABIHack.inc (original)
+++ dragonegg/trunk/src/x86/ABIHack.inc Wed Apr 18 03:50:57 2012
@@ -25,7 +25,7 @@
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
-extern GCC_LANG {
+extern "C" {
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"

Modified: dragonegg/trunk/src/x86/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/x86/Target.cpp?rev=154994&r1=154993&r2=154994&view=diff
==============================================================================
--- dragonegg/trunk/src/x86/Target.cpp (original)
+++ dragonegg/trunk/src/x86/Target.cpp Wed Apr 18 03:50:57 2012
@@ -31,7 +31,7 @@
 #include <gmp.h>
 
 // GCC headers
-extern GCC_LANG {
+extern "C" {
 #include "config.h"
 // Stop GCC declaring 'getopt' as it can clash with the system's declaration.
 #undef HAVE_DECL_GETOPT

Removed: dragonegg/trunk/utils/empty.c
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/utils/empty.c?rev=154993&view=auto
==============================================================================
    (empty)

Removed: dragonegg/trunk/utils/lang_plugin.c
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/utils/lang_plugin.c?rev=154993&view=auto
==============================================================================
--- dragonegg/trunk/utils/lang_plugin.c (original)
+++ dragonegg/trunk/utils/lang_plugin.c (removed)
@@ -1,12 +0,0 @@
-#include "gcc-plugin.h"
-
-int plugin_is_GPL_compatible;
-
-/* Use a symbol defined inside gcc.  */
-extern int toplev_main (int argc, char **argv);
-int (*use) (int argc, char **argv) = toplev_main;
-
-int plugin_init(struct plugin_name_args *plugin_info,
-                struct plugin_gcc_version *version) {
-  return 0;
-}





More information about the llvm-commits mailing list