Bug 214173 - lang/gcc: gcc48 doesn't accept -march=nehalem
Summary: lang/gcc: gcc48 doesn't accept -march=nehalem
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: amd64 Any
: --- Affects Only Me
Assignee: Gerald Pfeifer
Keywords: patch
Depends on:
Reported: 2016-11-03 18:24 UTC by Ting-Wei Lan
Modified: 2016-11-20 21:49 UTC (History)
1 user (show)

See Also:

Patch to treat nehalem as corei7 (1.27 KB, patch)
2016-11-03 18:33 UTC, Jung-uk Kim
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ting-Wei Lan 2016-11-03 18:24:17 UTC
/usr/share/mk/bsd.cpu.mk in FreeBSD 11 unconditionally convert CPUTYPE=corei7 to CPUTYPE=nehalem. It can cause error in ports built with the default version of gcc, including gcc itself, ghc, and other ports with USE_GCC=yes.

A simple test:

$ echo 'int main(){}' > main.c
$ gcc48 -march=corei7 main.c && echo "OK"
$ gcc48 -march=nehalem main.c && echo "OK"
main.c:1:0: error: bad value (nehalem) for -march= switch
 int main(){}
Comment 1 Jung-uk Kim freebsd_committer 2016-11-03 18:33:50 UTC
Created attachment 176595 [details]
Patch to treat nehalem as corei7

This patch is for lang/gcc.
Comment 2 Jung-uk Kim freebsd_committer 2016-11-03 18:35:21 UTC
Gerald, please take a look.
Comment 3 Jung-uk Kim freebsd_committer 2016-11-03 19:16:33 UTC
FYI, the upstream replaced "corei7" with "nehalem" in 4.9:


Later, they did this:


Basically, my patch is the smallest hack to accept "-march=nehalem" instead of back-porting everything.
Comment 4 Ting-Wei Lan 2016-11-04 07:58:19 UTC
The patch works with ports using native FreeBSD gcc, but linux-* ports using CentOS gcc is still broken. CentOS 7 gcc, which is also gcc 4.8, doesn't know -march=nehalem, and CentOS 6 gcc know neither -march=nehalem nor -march=corei7.

# make -C audio/linux-skype_oss_wrapper
===>  Building for linux-skype_oss_wrapper-0.1.1
--- skype_oss ---
--- libpulse.o ---
--- skype_oss ---
echo "#!/bin/sh" > skype_oss && echo "LD_LIBRARY_PATH=/compat/linux/lib/skype_oss_wrapper:\$LD_LIBRARY_PATH skype" >> skype_oss && chmod +x skype_oss
--- libpulse.o ---
/compat/linux/usr/bin/gcc -O2 -pipe -march=nehalem  -fstack-protector -fno-strict-aliasing -m32 -fPIC -c libpulse.c -o libpulse.o
libpulse.c:1: error: bad value (nehalem) for -march= switch
libpulse.c:1: error: bad value (nehalem) for -mtune= switch
*** [libpulse.o] Error code 1
Comment 5 Jung-uk Kim freebsd_committer 2016-11-04 17:46:10 UTC
(In reply to Ting-Wei Lan from comment #4)
This is a separate issue, i.e., CFLAGS for FreeBSD/amd64 should never be used for Linux/i386.  In other words, audio/linux-skype_oss_wrapper must be fixed.
Comment 6 Ting-Wei Lan 2016-11-10 09:49:15 UTC
(In reply to Jung-uk Kim from comment #5)
OK, I think your patch is good enough, and I will open another bug for the linux-* issue.
Comment 7 Ting-Wei Lan 2016-11-14 18:41:31 UTC
I filed two bugs for Linux ports.

Bug 214512 - audio/linux-skype_oss_wrapper
Bug 214513 - devel/linux_libusb
Comment 8 Gerald Pfeifer freebsd_committer 2016-11-20 21:49:05 UTC
Thanks for your analysis, guys, and the suggested patch, Jung-uk!

Instead of patching lang/gcc in this direction, I continued my efforts
to finally upgrade lang/gcc to GCC 4.9 today which added support for -march=nehalem and others.  Which is even nicer! :-)

So, users of the canonical version of GCC in the Ports Collection will
now be fine (and I don't think we should keep patching compilers three
generations behind, so I suggest we leave lang/gcc48 as is).