Bug 96407

Summary: [PATCH] devel/avr-gcc-devel fails to build with -march in CFLAGS
Product: Ports & Packages Reporter: Alex Mogilnikov <alx>
Component: Individual Port(s)Assignee: Joerg Wunsch <joerg>
Status: Closed FIXED    
Severity: Affects Only Me CC: joerg
Priority: Normal    
Version: Latest   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
patch-march none

Description Alex Mogilnikov 2006-04-27 11:00:29 UTC
    Makefile in gcc-4.1.0 unconditionally adds host compiler flags
    containing in CFLAGS variable to CFLAGS_FOR_TARGET.
    If CFLAGS contains -march=... option, building of libgcc modules
    fails with the following error message:

	cc1: error: unrecognized command line option "-march=pentiumpro"

Fix: add the following patch to devel/avr-gcc-devel/files
How-To-Repeat:     echo CPUTYPE=i686 >>/etc/make.conf
    cd /usr/ports/devel/avr-gcc-devel && make
Comment 1 Edwin Groothuis freebsd_committer freebsd_triage 2006-04-27 11:04:12 UTC
Responsible Changed
From-To: freebsd-ports-bugs->joerg

Over to maintainer
Comment 2 Joerg Wunsch 2006-04-27 11:23:38 UTC
As Alex Mogilnikov wrote:

> --- patch-march begins here ---
> --- Makefile.in.orig	Thu Dec 15 19:02:02 2005
> +++ Makefile.in	Thu Apr 27 03:58:59 2006
> @@ -329,7 +329,7 @@
>  # CFLAGS will be just -g.  We want to ensure that TARGET libraries
>  # (which we know are built with gcc) are built with optimizations so
>  # prepend -O2 when setting CFLAGS_FOR_TARGET.
> -CFLAGS_FOR_TARGET = -O2 $(CFLAGS) $(SYSROOT_CFLAGS_FOR_TARGET)
> +CFLAGS_FOR_TARGET = -O2 $(filter-out -march=% -mcpu=%,$(CFLAGS)) $(SYSROOT_CFLAGS_FOR_TARGET)
>  SYSROOT_CFLAGS_FOR_TARGET = @SYSROOT_CFLAGS_FOR_TARGET@
>  CXXFLAGS_FOR_TARGET = $(CXXFLAGS) $(SYSROOT_CFLAGS_FOR_TARGET)
>  LIBCFLAGS_FOR_TARGET = $(CFLAGS_FOR_TARGET)
> --- patch-march ends here ---

I'm somewhat reluctant to add hacks like this as local patches.
I think it's basically a pilot error to first set CPU-specific
options in /etc/make.conf's CFLAGS, and then expect any kind of
cross-compilation still to work.

OTOH, it could be considered a general flaw in GCC's cross-compilation
setup, but then, I'd like to see it accompanied by a GCC bug report.
I'm don't think filtering -mcpu and -march is sufficient, as there
could be any number of other options that are incompatible with the
target CPU.  At least, all -m options need to be filtered.

-- 
cheers, J"org               .-.-.   --... ...--   -.. .  DL8DTL

http://www.sax.de/~joerg/                        NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)
Comment 3 Joerg Wunsch 2006-04-27 11:23:38 UTC
As Alex Mogilnikov wrote:

> --- patch-march begins here ---
> --- Makefile.in.orig	Thu Dec 15 19:02:02 2005
> +++ Makefile.in	Thu Apr 27 03:58:59 2006
> @@ -329,7 +329,7 @@
>  # CFLAGS will be just -g.  We want to ensure that TARGET libraries
>  # (which we know are built with gcc) are built with optimizations so
>  # prepend -O2 when setting CFLAGS_FOR_TARGET.
> -CFLAGS_FOR_TARGET = -O2 $(CFLAGS) $(SYSROOT_CFLAGS_FOR_TARGET)
> +CFLAGS_FOR_TARGET = -O2 $(filter-out -march=% -mcpu=%,$(CFLAGS)) $(SYSROOT_CFLAGS_FOR_TARGET)
>  SYSROOT_CFLAGS_FOR_TARGET = @SYSROOT_CFLAGS_FOR_TARGET@
>  CXXFLAGS_FOR_TARGET = $(CXXFLAGS) $(SYSROOT_CFLAGS_FOR_TARGET)
>  LIBCFLAGS_FOR_TARGET = $(CFLAGS_FOR_TARGET)
> --- patch-march ends here ---

I'm somewhat reluctant to add hacks like this as local patches.
I think it's basically a pilot error to first set CPU-specific
options in /etc/make.conf's CFLAGS, and then expect any kind of
cross-compilation still to work.

OTOH, it could be considered a general flaw in GCC's cross-compilation
setup, but then, I'd like to see it accompanied by a GCC bug report.
I'm don't think filtering -mcpu and -march is sufficient, as there
could be any number of other options that are incompatible with the
target CPU.  At least, all -m options need to be filtered.

-- 
cheers, J"org               .-.-.   --... ...--   -.. .  DL8DTL

http://www.sax.de/~joerg/                        NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)
Comment 4 Henrik Brix Andersen 2006-10-07 13:52:09 UTC
Another possible solution would be to set

CFLAGS=

in the devel/avr-gcc/Makefile, thus overriding all of the CFLAGS
specified in the environment.

Regards,
Brix
-- 
Henrik Brix Andersen <henrik@brixandersen.dk>
Comment 5 dfilter service freebsd_committer freebsd_triage 2006-10-10 11:24:59 UTC
joerg       2006-10-10 10:24:51 UTC

  FreeBSD ports repository

  Modified files:
    devel/avr-gcc        Makefile 
  Added files:
    devel/avr-gcc/files  patch-bug25672 
  Log:
  OK, I bite.  Implement the patch from PR ports/96407, to avoid the
  -mcpu=foobar braindeadness.
  
  There's a GCC bug open for this:
  http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25672
  so at least, the issue is being dealt with in its origin.
  
  Submitted by:   Alex Mogilnikov <alx@intellectronika.ru>
  PR:             ports/96407
  
  Revision  Changes    Path
  1.57      +1 -0      ports/devel/avr-gcc/Makefile
  1.1       +13 -0     ports/devel/avr-gcc/files/patch-bug25672 (new)
_______________________________________________
cvs-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/cvs-all
To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
Comment 6 Joerg Wunsch freebsd_committer freebsd_triage 2006-10-10 11:27:02 UTC
State Changed
From-To: open->closed

Suggested patch has been added, spasibo bolshoye! 

There's a GCC bug report for this: 
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25672 
so at least it is a known issue that is being dealt with. 

I eventually came to like the patch better than Brix' idea about 
blanking CFLAGS entirely, as that would leave us potentially with a 
non-optimized compiler which can cause a huge performance penalty in 
particular on RISC machines.