This is the mail archive of the
ecos-devel@sources.redhat.com
mailing list for the eCos project.
Re: C vs C++ compilations
On Wed, 2003-10-15 at 07:57, Bart Veer wrote:
> >>>>> "Gary" == Gary Thomas <gary@mlbassoc.com> writes:
>
> Gary> I'm experimenting with GCC-3.3. This version is starting to be
> Gary> *really* picky about some things. In particular, the eCos Makefile(s)
> Gary> use XX-gcc to compile either C or C++ source files, often with
> Gary> some C++ only flags thrown in. This leads to warnings like this:
> Gary> cc1: warning: "-Woverloaded-virtual" is valid for C++ but not for C/ObjC
> Gary> cc1: warning: "-fno-rtti" is valid for C++ but not for C/ObjC
> Gary> cc1: warning: "-fvtable-gc" is valid for C++ but not for C/ObjC
>
> Gary> I'd like to get rid of these and the best way [I think] would be
> Gary> to change the rules so that C files are built using XXX-gcc using
> Gary> C flags and C++ files are built using XXX-g++ with C++ flags. I
> Gary> also think that over time, the compiler may decide that this is no
> Gary> longer just a warning, but an error, so thinking about this now will
> Gary> save us in the future.
>
> Gary> Is there any [good] way to handle this? Can the Makefile generator
> Gary> (CDL machine) be set up to handle both C and C++ (probably CXXFLAGS)?
>
> Gary> Thanks.
>
> Gary> Note: it works perfectly well, it's just noisy at the moment.
>
> See bugzilla 1000035. Andrew has already tried a patch which looked
> fine, but caused problems with arm builds.
>
That patch was slightly broken. The attached version works fine on my
PowerPC and ARM targets. There still are some warnings when there are
special rules.
What version (date) of ecosconfig has the support for the full flag set?
I realize that it will be some effort to split up the CDL and handle
these problems fully, but as I said I think it's something we should
address. The patch could be committed now as it doesn't conflict
with any other changes (e.g. using CXXFLAGS)
--
Gary Thomas <gary@mlbassoc.com>
MLB Associates
Index: pkgconf/rules.mak
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/pkgconf/rules.mak,v
retrieving revision 1.11
diff -u -5 -p -r1.11 rules.mak
--- pkgconf/rules.mak 23 May 2002 23:08:24 -0000 1.11
+++ pkgconf/rules.mak 15 Oct 2003 14:16:29 -0000
@@ -57,21 +57,26 @@ export HOST_CC := gcc
# include any dependency rules generated previously
ifneq ($(wildcard *.deps),)
include $(wildcard *.deps)
endif
+# Separate C++ flags out from C flags.
+ACTUAL_CFLAGS = $(CFLAGS)
+ACTUAL_CFLAGS := $(subst -fno-rtti,,$(ACTUAL_CFLAGS))
+ACTUAL_CFLAGS := $(subst -Woverloaded-virtual,,$(ACTUAL_CFLAGS))
+ACTUAL_CFLAGS := $(subst -fvtable-gc,,$(ACTUAL_CFLAGS))
# pattern matching rules to generate a library object from source code
# object filenames are prefixed to avoid name clashes
# a single dependency rule is generated (file extension = ".o.d")
%.o.d : %.c
ifeq ($(HOST),CYGWIN)
@mkdir -p `cygpath -w "$(dir $@)" | sed "s@\\\\\\\\@/@g"`
else
@mkdir -p $(dir $@)
endif
- $(CC) -c $(INCLUDE_PATH) -I$(dir $<) $(CFLAGS) -Wp,-MD,$(@:.o.d=.tmp) -o $(dir $@)$(OBJECT_PREFIX)_$(notdir $(@:.o.d=.o)) $<
+ $(CC) -c $(INCLUDE_PATH) -I$(dir $<) $(ACTUAL_CFLAGS) -Wp,-MD,$(@:.o.d=.tmp) -o $(dir $@)$(OBJECT_PREFIX)_$(notdir $(@:.o.d=.o)) $<
@sed -e '/^ *\\/d' -e "s#.*: #$@: #" $(@:.o.d=.tmp) > $@
@rm $(@:.o.d=.tmp)
%.o.d : %.cxx
ifeq ($(HOST),CYGWIN)
@@ -97,11 +102,11 @@ endif
ifeq ($(HOST),CYGWIN)
@mkdir -p `cygpath -w "$(dir $@)" | sed "s@\\\\\\\\@/@g"`
else
@mkdir -p $(dir $@)
endif
- $(CC) -c $(INCLUDE_PATH) -I$(dir $<) $(CFLAGS) -Wp,-MD,$(@:.o.d=.tmp) -o $(dir $@)$(OBJECT_PREFIX)_$(notdir $(@:.o.d=.o)) $<
+ $(CC) -c $(INCLUDE_PATH) -I$(dir $<) $(ACTUAL_CFLAGS) -Wp,-MD,$(@:.o.d=.tmp) -o $(dir $@)$(OBJECT_PREFIX)_$(notdir $(@:.o.d=.o)) $<
@sed -e '/^ *\\/d' -e "s#.*: #$@: #" $(@:.o.d=.tmp) > $@
@rm $(@:.o.d=.tmp)
# pattern matching rules to generate a test object from source code
# object filenames are not prefixed
@@ -110,11 +115,11 @@ endif
ifeq ($(HOST),CYGWIN)
@mkdir -p `cygpath -w "$(dir $@)" | sed "s@\\\\\\\\@/@g"`
else
@mkdir -p $(dir $@)
endif
- $(CC) -c $(INCLUDE_PATH) -I$(dir $<) $(CFLAGS) -Wp,-MD,$(@:.d=.tmp) -o $(@:.d=.o) $<
+ $(CC) -c $(INCLUDE_PATH) -I$(dir $<) $(ACTUAL_CFLAGS) -Wp,-MD,$(@:.d=.tmp) -o $(@:.d=.o) $<
@sed -e '/^ *\\/d' -e "s#.*: #$@: #" $(@:.d=.tmp) > $@
@rm $(@:.d=.tmp)
%.d : %.cxx
ifeq ($(HOST),CYGWIN)
@@ -140,11 +145,11 @@ endif
ifeq ($(HOST),CYGWIN)
@mkdir -p `cygpath -w "$(dir $@)" | sed "s@\\\\\\\\@/@g"`
else
@mkdir -p $(dir $@)
endif
- $(CC) -c $(INCLUDE_PATH) -I$(dir $<) $(CFLAGS) -Wp,-MD,$(@:.d=.tmp) -o $(@:.d=.o) $<
+ $(CC) -c $(INCLUDE_PATH) -I$(dir $<) $(ACTUAL_CFLAGS) -Wp,-MD,$(@:.d=.tmp) -o $(@:.d=.o) $<
@sed -e '/^ *\\/d' -e "s#.*: #$@: #" $(@:.d=.tmp) > $@
@rm $(@:.d=.tmp)
# rule to generate a test executable from object code
$(PREFIX)/tests/$(PACKAGE)/%$(EXEEXT): %.d $(wildcard $(PREFIX)/lib/target.ld) $(wildcard $(PREFIX)/lib/*.[ao])