[llvm-commits] [gcc-plugin] r82453 - in /gcc-plugin/trunk: Makefile darwin/ darwin/llvm-os.h linux/ linux/llvm-os.h llvm-backend.cpp

Duncan Sands baldrick at free.fr
Mon Sep 21 08:35:50 CDT 2009


Author: baldrick
Date: Mon Sep 21 08:35:50 2009
New Revision: 82453

URL: http://llvm.org/viewvc/llvm-project?rev=82453&view=rev
Log:
Add support for -fpic.

Added:
    gcc-plugin/trunk/darwin/
    gcc-plugin/trunk/darwin/llvm-os.h
    gcc-plugin/trunk/linux/
    gcc-plugin/trunk/linux/llvm-os.h
Modified:
    gcc-plugin/trunk/Makefile
    gcc-plugin/trunk/llvm-backend.cpp

Modified: gcc-plugin/trunk/Makefile
URL: http://llvm.org/viewvc/llvm-project/gcc-plugin/trunk/Makefile?rev=82453&r1=82452&r2=82453&view=diff

==============================================================================
--- gcc-plugin/trunk/Makefile (original)
+++ gcc-plugin/trunk/Makefile Mon Sep 21 08:35:50 2009
@@ -35,7 +35,8 @@
 PLUGIN_CFLAGS+=-I$(GCCOBJECT_DIR)/gcc -I$(GCCOBJECT_DIR)/gcc/include \
 	       -I$(GCCSOURCE_DIR)/gcc -I$(GCCSOURCE_DIR)/include \
 	       -I$(GCCSOURCE_DIR)/libcpp/include -I$(GCCSOURCE_DIR)/libdecnumber \
-	       -I$(GCCOBJECT_DIR)/libdecnumber -I$(shell $(TARGET_UTIL) -p)
+	       -I$(GCCOBJECT_DIR)/libdecnumber -I$(shell $(TARGET_UTIL) -p) \
+	       -I$(shell $(TARGET_UTIL) -o)
 PLUGIN_CXXFLAGS+=$(PLUGIN_CFLAGS)
 
 default: $(PLUGIN)

Added: gcc-plugin/trunk/darwin/llvm-os.h
URL: http://llvm.org/viewvc/llvm-project/gcc-plugin/trunk/darwin/llvm-os.h?rev=82453&view=auto

==============================================================================
--- gcc-plugin/trunk/darwin/llvm-os.h (added)
+++ gcc-plugin/trunk/darwin/llvm-os.h Mon Sep 21 08:35:50 2009
@@ -0,0 +1,45 @@
+/* Darwin specific definitions
+Copyright (C) 2009 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+02111-1307, USA.  */
+
+#ifndef LLVM_OS_H
+#define LLVM_OS_H
+
+/* Darwin X86-64 only supports PIC code generation. */
+#if defined (TARGET_386)
+#define LLVM_SET_TARGET_OPTIONS(argvec)              \
+  if ((TARGET_64BIT) || flag_pic)                    \
+    argvec.push_back ("--relocation-model=pic");     \
+  else if (!MACHO_DYNAMIC_NO_PIC_P)                  \
+    argvec.push_back ("--relocation-model=static")
+#elif defined (TARGET_ARM)
+#define LLVM_SET_TARGET_OPTIONS(argvec)              \
+  if (flag_pic)                                      \
+    argvec.push_back ("--relocation-model=pic");     \
+  else if (!MACHO_DYNAMIC_NO_PIC_P)                  \
+    argvec.push_back ("--relocation-model=static");  \
+#else /* !TARGET_386 && !TARGET_ARM */
+#define LLVM_SET_TARGET_OPTIONS(argvec)              \
+  if (flag_pic)                                      \
+    argvec.push_back ("--relocation-model=pic");     \
+  else if (!MACHO_DYNAMIC_NO_PIC_P)                  \
+    argvec.push_back ("--relocation-model=static")
+#endif /* !TARGET_386 && !TARGET_ARM */
+
+#endif /* LLVM_OS_H */

Added: gcc-plugin/trunk/linux/llvm-os.h
URL: http://llvm.org/viewvc/llvm-project/gcc-plugin/trunk/linux/llvm-os.h?rev=82453&view=auto

==============================================================================
--- gcc-plugin/trunk/linux/llvm-os.h (added)
+++ gcc-plugin/trunk/linux/llvm-os.h Mon Sep 21 08:35:50 2009
@@ -0,0 +1,31 @@
+/* Linux specific definitions
+Copyright (C) 2009 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+02111-1307, USA.  */
+
+#ifndef LLVM_OS_H
+#define LLVM_OS_H
+
+/* Yes, we support PIC codegen for linux targets! */
+#define LLVM_SET_TARGET_OPTIONS(argvec)              \
+  if (flag_pic)                                      \
+    argvec.push_back ("--relocation-model=pic");     \
+  else                                               \
+    argvec.push_back ("--relocation-model=static");
+
+#endif /* LLVM_OS_H */

Modified: gcc-plugin/trunk/llvm-backend.cpp
URL: http://llvm.org/viewvc/llvm-project/gcc-plugin/trunk/llvm-backend.cpp?rev=82453&r1=82452&r2=82453&view=diff

==============================================================================
--- gcc-plugin/trunk/llvm-backend.cpp (original)
+++ gcc-plugin/trunk/llvm-backend.cpp Mon Sep 21 08:35:50 2009
@@ -86,6 +86,7 @@
 #include "llvm-internal.h"
 #include "llvm-debug.h"
 #include "llvm-target.h"
+#include "llvm-os.h"
 #include "bits_and_bobs.h"
 extern "C" {
 #include "llvm-cache.h"
@@ -324,9 +325,9 @@
 //TODO#ifdef LLVM_SET_RED_ZONE_FLAG
 //TODO  LLVM_SET_RED_ZONE_FLAG(flag_disable_red_zone)
 //TODO#endif
-//TODO#ifdef LLVM_SET_TARGET_OPTIONS
-//TODO  LLVM_SET_TARGET_OPTIONS(Args);
-//TODO#endif
+#ifdef LLVM_SET_TARGET_OPTIONS
+  LLVM_SET_TARGET_OPTIONS(Args);
+#endif
 //TODO#ifdef LLVM_SET_MACHINE_OPTIONS
 //TODO  LLVM_SET_MACHINE_OPTIONS(Args);
 //TODO#endif





More information about the llvm-commits mailing list