Bug 202624 - [PATCH] lang/go14: correct clang detection
Summary: [PATCH] lang/go14: correct clang detection
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Julien Laffaye
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2015-08-24 15:09 UTC by Sascha Holzleiter
Modified: 2015-09-28 22:15 UTC (History)
1 user (show)

See Also:
bugzilla: maintainer-feedback? (jlaffaye)


Attachments
go14 patch (514 bytes, patch)
2015-08-24 15:09 UTC, Sascha Holzleiter
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sascha Holzleiter 2015-08-24 15:09:35 UTC
Created attachment 160308 [details]
go14 patch

Building go14 on a FreeBSD 10.2 systme yields some -pthread warnings:


os/user/lookup_unix.go:58:31: warning: unknown attribute '__gcc_struct__' ignored [-Wattributes]
        } __attribute__((__packed__, __gcc_struct__)) *a = v;
                                     ^
os/user/lookup_unix.go:73:31: warning: unknown attribute '__gcc_struct__' ignored [-Wattributes]
        } __attribute__((__packed__, __gcc_struct__)) *a = v;
                                     ^
os/user/lookup_unix.go:92:31: warning: unknown attribute '__gcc_struct__' ignored [-Wattributes]
        } __attribute__((__packed__, __gcc_struct__)) *a = v;
                                     ^
os/user/lookup_unix.go:106:31: warning: unknown attribute '__gcc_struct__' ignored [-Wattributes]
        } __attribute__((__packed__, __gcc_struct__)) *a = v;
                                     ^
4 warnings generated.
# os/user
cc: warning: argument unused during compilation: '-pthread'
# net
net/cgo_unix.go:53:31: warning: unknown attribute '__gcc_struct__' ignored [-Wattributes]
        } __attribute__((__packed__, __gcc_struct__)) *a = v;
                                     ^
net/cgo_unix.go:66:31: warning: unknown attribute '__gcc_struct__' ignored [-Wattributes]
        } __attribute__((__packed__, __gcc_struct__)) *a = v;
                                     ^
net/cgo_unix.go:75:31: warning: unknown attribute '__gcc_struct__' ignored [-Wattributes]
        } __attribute__((__packed__, __gcc_struct__)) *a = v;
                                     ^
net/cgo_unix.go:86:31: warning: unknown attribute '__gcc_struct__' ignored [-Wattributes]
        } __attribute__((__packed__, __gcc_struct__)) *a = v;
                                     ^
net/cgo_unix.go:103:31: warning: unknown attribute '__gcc_struct__' ignored [-Wattributes]
        } __attribute__((__packed__, __gcc_struct__)) *a = v;
                                     ^
5 warnings generated.

It seems that go14 does not detect, that our cc is actually clang.
The attached patch explicitly sets CC to clang so the go toolchain knows about it. This fixes the above warnings.
It also replaces "type -t" in the shell script wiht "command -v" to remove these artifacts:

# Building C bootstrap tool.
cmd/dist
-t: not found
gcc: not found
-t: not found


lang/go seems to also suffer from not detecting our clang although it has code to detect it. So the CC patch should be applied there, too. Should i open an extra PR for that?
Comment 1 Julien Laffaye freebsd_committer freebsd_triage 2015-08-24 18:42:56 UTC
Well, we can not just overwrite CC.
This variable should be configurable by the user.
Comment 2 Sascha Holzleiter 2015-08-25 14:20:18 UTC
I can understand that but short of modifying the upstream code i don't see a way to fix this. Looking at the go code there are a lot of places which check the compiler name for "clang", there is no central compiler switch which would make this trivial.

We could do something like:
.if ${COMPILER_TYPE} == clang && ${CC} == cc
CC=clang
.endif

If anyone modifies CC the override will not take place and everything should work for them as they wanted while fixing the detection in go for the default case.
Comment 3 commit-hook freebsd_committer freebsd_triage 2015-09-27 19:55:14 UTC
A commit references this bug:

Author: jlaffaye
Date: Sun Sep 27 19:54:20 UTC 2015
New revision: 398046
URL: https://svnweb.freebsd.org/changeset/ports/398046

Log:
  - Update to 1.4.3, fix vulnerabilities
  - Improve clang detection [1]
  - Disable CGO, it is not needed to bootstrap 1.5

  PR:		202624 [1]

Changes:
  head/lang/go14/Makefile
  head/lang/go14/distinfo
  head/lang/go14/pkg-plist
Comment 4 commit-hook freebsd_committer freebsd_triage 2015-09-28 22:15:52 UTC
A commit references this bug:

Author: junovitch
Date: Mon Sep 28 22:15:20 UTC 2015
New revision: 398150
URL: https://svnweb.freebsd.org/changeset/ports/398150

Log:
  MFH: r398046 (partially)

  - Update to 1.4.3, fix vulnerabilities
  - Improve clang detection [1]

  PR:             202624 [1]
  Security:	CVE-2015-5739
  Security:	CVE-2015-5740
  Security:	CVE-2015-5741
  Security:	4464212e-4acd-11e5-934b-002590263bf5
  Approved by:	ports-secteam (feld)

Changes:
  branches/2015Q3/lang/go/Makefile
  branches/2015Q3/lang/go/distinfo
  branches/2015Q3/lang/go/pkg-plist