From patchwork Wed Aug 18 04:37:38 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Objective C/C++ Compiler Drivers Date: Tue, 17 Aug 2010 18:37:38 -0000 From: Philip Herron X-Patchwork-Id: 61985 Message-Id: <4C6B6392.8080108@gcc.gnu.org> To: gcc-patches@gcc.gnu.org Cc: Ian Lance Taylor , tom.browder@gmail.com Hey Following up this thread on gcc-help: http://gcc.gnu.org/ml/gcc-help/2010-08/msg00087.html I added a objc and objcp compiler drivers, the objc one works so far as much as i can tell i tested a hello world program with gccobjc hello.m and the resulting a.out worked. The compiler driver code i added for both is a vanilla driver, which could fail though, since i don't tell anything to explicitly link their respective runtime libraries though i would doubt the objc front-end i just tested would generate working code without doing that so i may be fine as is. I am having problems with the objcp one so far it doesn't seem to get installed so i need to look into this though i would like to get a review on the patch as it stands so as i know i am on the right track. --Phil >From 8b24db0dc92ba9fb1b91955fd0e358d89a2c462e Mon Sep 17 00:00:00 2001 From: redbrain Date: Wed, 18 Aug 2010 04:35:41 +0100 Subject: [PATCH 1/2] add obj-c front-ends with compiler drivers --- gcc/objc/Make-lang.in | 39 ++++++++++++++++++++++++++++----------- gcc/objc/objc-spec.c | 38 ++++++++++++++++++++++++++++++++++++++ gcc/objcp/Make-lang.in | 45 +++++++++++++++++++++++++++++++++------------ gcc/objcp/objcp-spec.c | 38 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 137 insertions(+), 23 deletions(-) create mode 100644 gcc/objc/objc-spec.c create mode 100644 gcc/objcp/objcp-spec.c diff --git a/gcc/objc/Make-lang.in b/gcc/objc/Make-lang.in index 67644bb..645a809 100644 --- a/gcc/objc/Make-lang.in +++ b/gcc/objc/Make-lang.in @@ -36,13 +36,17 @@ # - the compiler proper (eg: cc1plus) # - define the names for selecting the language in LANGUAGES. -# -# Define the names for selecting Objective-C in LANGUAGES. -objc: cc1obj$(exeext) +OBJC_EXECS = objc # Tell GNU make to ignore these if they exist. .PHONY: objc +GCCOBJC_INSTALL_NAME := $(shell echo gccobjc|sed '$(program_transform_name)') +GCCOBJC_TARGET_INSTALL_NAME := $(target_noncanonical)-$(shell echo gccobjc|sed '$(program_transform_name)') + +# Define the names for selecting Objective-C in LANGUAGES. +objc: gccobjc$(exeext) cc1obj$(exeext) + # Use maximal warnings for this front end. objc-warn = $(STRICT_WARN) @@ -80,9 +84,18 @@ objc/objc-act.o : objc/objc-act.c \ $(LANGHOOKS_DEF_H) $(HASHTAB_H) $(C_PRAGMA_H) gt-objc-objc-act.h \ $(GIMPLE_H) c-lang.h +objc-spec.o: $(srcdir)/objc/objc-spec.c $(CONFIG_H) $(SYSTEM_H) \ + coretypes.h $(DIAGNOSTIC_H) $(TREE_H) $(FLAGS_H) toplev.h langhooks.h $(TM_H) + $(CC) $(GPY_CFLAGS) $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(DRIVER_DEFINES) \ + $(INCLUDES) $(LDFLAGS) -c -o $@ $(srcdir)/objc/objc-spec.c + +GCCOBJC_D_OBJS = $(GCC_OBJS) objc-spec.o version.o prefix.o intl.o +gccobjc$(exeext): $(GCCOBJC_D_OBJS) $(EXTRA_GCC_OBJS) $(LIBDEPS) + $(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \ + $(GCCOBJC_D_OBJS) $(EXTRA_GCC_OBJS) $(LIBS) + objc.srcextra: -# # Build hooks: objc.all.cross: @@ -99,6 +112,7 @@ objc.man: objc.srcinfo: objc.srcman: objc.install-plugin: +objc.install-man: objc.tags: force cd $(srcdir)/objc; etags -o TAGS.sub *.c *.h; \ @@ -106,16 +120,17 @@ objc.tags: force lang_checks += check-objc -# # Install hooks: -# cc1obj is installed elsewhere as part of $(COMPILERS). - -objc.install-common: +objc.install-common: installdirs + -rm -f $(DESTDIR)$(bindir)/$(GCCOBJC_INSTALL_NAME)$(exeext) + -$(INSTALL_PROGRAM) gccobjc$(exeext) $(DESTDIR)$(bindir)/$(GCCOBJC_INSTALL_NAME)$(exeext) + -chmod a+x $(DESTDIR)$(bindir)/$(GCCOBJC_INSTALL_NAME)$(exeext) -objc.install-man: +objc.install-plugin: objc.uninstall: -# + -rm -rf $(DESTDIR)/$(bindir)/$(GCCOBJC_INSTALL_NAME)$(exeext) + # Clean hooks: # A lot of the ancillary files are deleted by the main makefile. # We just have to delete files specific to us. @@ -129,7 +144,7 @@ objc.distclean: -rm -f objc/config.status objc/config.cache objc.maintainer-clean: -# + # Stage hooks: objc.stage1: stage1-start @@ -144,3 +159,5 @@ objc.stageprofile: stageprofile-start -mv objc/*$(objext) stageprofile/objc objc.stagefeedback: stagefeedback-start -mv objc/*$(objext) stagefeedback/objc + +config.status: objc/config-lang.in \ No newline at end of file diff --git a/gcc/objc/objc-spec.c b/gcc/objc/objc-spec.c new file mode 100644 index 0000000..8a44180 --- /dev/null +++ b/gcc/objc/objc-spec.c @@ -0,0 +1,38 @@ +/* This file is part of GCC. + +GNU CC 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 3, or (at your option) +any later version. + +GNU CC 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 COPYING3. If not see +. */ + +#include "config.h" +#include "system.h" +#include "gcc.h" + +#include "coretypes.h" +#include "tm.h" + +void lang_specific_driver( int *in_argc ATTRIBUTE_UNUSED, + const char *const **in_argv ATTRIBUTE_UNUSED, + int *in_added_libraries ATTRIBUTE_UNUSED ) +{ + return; +} + +/* Called before linking. Returns 0 on success and -1 on failure. */ +int lang_specific_pre_link( void ) +{ + return 0; +} + +/* Number of extra output files that lang_specific_pre_link may generate. */ +int lang_specific_extra_outfiles = 0; diff --git a/gcc/objcp/Make-lang.in b/gcc/objcp/Make-lang.in index 22dc30f..64ef647 100644 --- a/gcc/objcp/Make-lang.in +++ b/gcc/objcp/Make-lang.in @@ -37,12 +37,16 @@ # - the compiler proper (eg: cc1plus) # - define the names for selecting the language in LANGUAGES. -# -# Define the names for selecting Objective-C++ in LANGUAGES. -obj-c++: cc1objplus$(exeext) +OBJC_EXECS = objc-c++ # Tell GNU make to ignore these if they exist. -.PHONY: obj-c++ +.PHONY: gccobjcp obj-c++ + +GCCOBJCP_INSTALL_NAME := $(shell echo gccobjcp|sed '$(program_transform_name)') +GCCOBJCP_TARGET_INSTALL_NAME := $(target_noncanonical)-$(shell echo gccobjcp|sed '$(program_transform_name)') + +# Define the names for selecting Objective-C++ in LANGUAGES. +obj-c++: gccobjcp$(exeext) cc1objplus$(exeext) # Use maximal warnings for this front end. Also, make ObjC and C++ # headers accessible. @@ -90,9 +94,19 @@ objcp/objcp-act.o : objc/objc-act.c \ $(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $< \ $(OUTPUT_OPTION) +objcp-spec.o: $(srcdir)/objcp/objcp-spec.c $(CONFIG_H) $(SYSTEM_H) \ + coretypes.h $(DIAGNOSTIC_H) $(TREE_H) $(FLAGS_H) toplev.h langhooks.h $(TM_H) + $(CC) $(GPY_CFLAGS) $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(DRIVER_DEFINES) \ + $(INCLUDES) $(LDFLAGS) -c -o $@ $(srcdir)/objcp/objcp-spec.c + +GCCOBJCP_D_OBJS = $(GCC_OBJS) objcp-spec.o version.o prefix.o intl.o +gccobjcp$(exeext): $(GCCOBJCP_D_OBJS) $(EXTRA_GCC_OBJS) $(LIBDEPS) + $(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \ + $(GCCOBJC_D_OBJS) $(EXTRA_GCC_OBJS) $(LIBS) + po-generated: -# + # Build hooks: obj-c++.all.cross: @@ -108,36 +122,41 @@ obj-c++.install-html: obj-c++.srcinfo: obj-c++.srcextra: obj-c++.man: -obj-c++.install-plugin: +obj-c++.install-man: obj-c++.tags: force - cd $(srcdir)/objcp; etags -o TAGS.sub *.y *.c *.h; \ + cd $(srcdir)/obj-c++p; etags -o TAGS.sub *.y *.c *.h; \ etags --include TAGS.sub --include ../TAGS.sub lang_checks += check-obj-c++ -# # Install hooks: # cc1objplus is installed elsewhere as part of $(COMPILERS). -obj-c++.install-common: +obj-c++.install-common: installdirs + -rm -f $(DESTDIR)$(bindir)/$(GCCOBJCP_INSTALL_NAME)$(exeext) + -$(INSTALL_PROGRAM) gccobjp$(exeext) $(DESTDIR)$(bindir)/$(GCCOBJCP_INSTALL_NAME)$(exeext) + -chmod a+x $(DESTDIR)$(bindir)/$(GCCOBJCP_INSTALL_NAME)$(exeext) -obj-c++.install-man: +obj-c++.install-plugin: obj-c++.uninstall: -# + -rm -rf $(DESTDIR)/$(bindir)/$(GCCOBJ-C++_INSTALL_NAME)$(exeext) + # Clean hooks: # A lot of the ancillary files are deleted by the main makefile. # We just have to delete files specific to us. obj-c++.mostlyclean: -rm -f objcp/*$(objext) -rm -f objcp/*$(coverageexts) + obj-c++.clean: obj-c++.mostlyclean + obj-c++.distclean: -rm -f objcp/config.status objcp/Makefile + obj-c++.maintainer-clean: -# # Stage hooks: obj-c++.stage1: stage1-start @@ -152,3 +171,5 @@ obj-c++.stageprofile: stageprofile-start -mv objcp/*$(objext) stageprofile/objcp obj-c++.stagefeedback: stagefeedback-start -mv objcp/*$(objext) stagefeedback/objcp + +config.status: objcp/config-lang.in diff --git a/gcc/objcp/objcp-spec.c b/gcc/objcp/objcp-spec.c new file mode 100644 index 0000000..8a44180 --- /dev/null +++ b/gcc/objcp/objcp-spec.c @@ -0,0 +1,38 @@ +/* This file is part of GCC. + +GNU CC 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 3, or (at your option) +any later version. + +GNU CC 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 COPYING3. If not see +. */ + +#include "config.h" +#include "system.h" +#include "gcc.h" + +#include "coretypes.h" +#include "tm.h" + +void lang_specific_driver( int *in_argc ATTRIBUTE_UNUSED, + const char *const **in_argv ATTRIBUTE_UNUSED, + int *in_added_libraries ATTRIBUTE_UNUSED ) +{ + return; +} + +/* Called before linking. Returns 0 on success and -1 on failure. */ +int lang_specific_pre_link( void ) +{ + return 0; +} + +/* Number of extra output files that lang_specific_pre_link may generate. */ +int lang_specific_extra_outfiles = 0; -- 1.7.2.1 >From f7f2e04d83902f8f41f9917cfde54b4918ec3cbc Mon Sep 17 00:00:00 2001 From: redbrain Date: Wed, 18 Aug 2010 05:29:12 +0100 Subject: [PATCH 2/2] fix spelling error in the objcp-unisntall make rule --- gcc/objcp/Make-lang.in | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/gcc/objcp/Make-lang.in b/gcc/objcp/Make-lang.in index 64ef647..993efad 100644 --- a/gcc/objcp/Make-lang.in +++ b/gcc/objcp/Make-lang.in @@ -141,7 +141,7 @@ obj-c++.install-common: installdirs obj-c++.install-plugin: obj-c++.uninstall: - -rm -rf $(DESTDIR)/$(bindir)/$(GCCOBJ-C++_INSTALL_NAME)$(exeext) + -rm -rf $(DESTDIR)/$(bindir)/$(GCCOBJCP_INSTALL_NAME)$(exeext) # Clean hooks: # A lot of the ancillary files are deleted by the main makefile.