Bug 258291 - lang/go{-devel}: Respect CC
Summary: lang/go{-devel}: Respect CC
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Guangyuan Yang
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-09-05 16:39 UTC by Ghost
Modified: 2021-11-15 21:57 UTC (History)
2 users (show)

See Also:
ygy: maintainer-feedback+


Attachments
v1 (use "git am") (1.22 KB, patch)
2021-09-05 16:39 UTC, Ghost
no flags Details | Diff
v1.1 (use "git am") (1.23 KB, patch)
2021-09-25 11:24 UTC, Ghost
2khramtsov: maintainer-approval?
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ghost 2021-09-05 16:39:37 UTC
Created attachment 227687 [details]
v1 (use "git am")

lang/go(-devel) does not respect CC per https://docs.freebsd.org/en/books/porters-handbook/porting-dads/#dads-cc

Reproduce by deleting 'cc' from jail and overriding CC to another value.

Package contents did change; PORTREVISION is bumped for lang/go(-devel):

11.4/amd64: https://codeberg.org/ei/misc/commit/b7f9d4e30f1
11.4/i386:  https://codeberg.org/ei/misc/commit/f3b9c5ec157
12.2/amd64: https://codeberg.org/ei/misc/commit/040234ee1e6
12.2/i386:  https://codeberg.org/ei/misc/commit/9897cb3af0a
13.0/amd64: https://codeberg.org/ei/misc/commit/33deb678794

My 'misc' repository also contains bulk and testport logs for this change,
not adding URL links to specific commits because codeberg did not generate
log diff this time for some reason, diff between logs can also be observed
by cloning the 'misc' repository and viewing with git if needed.
Comment 1 Kubilay Kocak freebsd_committer freebsd_triage 2021-09-06 02:51:04 UTC
Are environment/user CFLAGS and other flags (LDFLAGS, etc) honoured? Honoured meaning 'appended', not just included
Comment 2 Ghost 2021-09-06 11:57:01 UTC
(In reply to Kubilay Kocak from comment #1)

> Are environment/user CFLAGS and other flags (LDFLAGS, etc) honoured?

This is not easily verifiable as lang/go build log is not verbose by default,
and I am not familiar with Go build system to verbose build log. I added
"CFLAGS" and "LDFLAGS" to Makefile to check, and it seems that Go can't
build with these passed:

=======================<phase: build          >============================
===== env: NO_DEPENDS=yes
===>  Building for go-1.17_3,1
cd /wrkdirs/usr/ports/lang/go/work/go/src ; /usr/bin/env  XDG_CACHE_HOME=/wrkdirs/usr/ports/lang/go/work  GOROOT_BOOTSTRAP=/wrkdirs/usr/ports/lang/go/work/go-freebsd-amd64-bootstrap  GOROOT=/wrkdirs/usr/ports/lang/go/work/go  GOROOT_FINAL=/usr/local/go  GOBIN=  GOOS=freebsd  GOARCH=amd64  GO386=  GOARM=  CC=cc  CFLAGS=-O2 -pipe -fstack-protector-foo  -fstack-protector-strong -fno-strict-aliasing   LDFLAGS= -fstack-protector-strong   /bin/sh make.bash -v
env: -pipe: No such file or directory
*** Error code 127

Also, this seems PR scope creep to me.
Comment 3 Ghost 2021-09-25 11:24:19 UTC
Created attachment 228168 [details]
v1.1 (use "git am")

Update to the latest ports.
Comment 4 Ghost 2021-10-23 17:03:21 UTC
ping
Comment 5 commit-hook freebsd_committer freebsd_triage 2021-11-08 06:21:45 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=f55607ce7b906bd7886b857f568956880f4281ff

commit f55607ce7b906bd7886b857f568956880f4281ff
Author:     Evgeniy Khramtsov <evgeniy@khramtsov.org>
AuthorDate: 2021-11-08 06:19:59 +0000
Commit:     Guangyuan Yang <ygy@FreeBSD.org>
CommitDate: 2021-11-08 06:19:59 +0000

    lang/go, lang/go-devel: Respect CC

    PR:             258291

 lang/go-devel/Makefile | 2 +-
 lang/go/Makefile       | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)
Comment 6 Guangyuan Yang freebsd_committer freebsd_triage 2021-11-08 06:24:05 UTC
Fixed, thanks!
Comment 7 Ghost 2021-11-13 05:48:56 UTC
(In reply to Guangyuan Yang from comment #6)

See context in v1.1:

@@ -90,6 +90,7 @@ do-build:
 		GOARCH=${GOARCH_${ARCH}} \
 		GO386=${GO386} \
 		GOARM=${GOARM_${ARCH}} \
+		CC=${CC} \
 		${SH} make.bash -v

vs ports f55607ce7:

@@ -106,6 +106,7 @@ do-test:
 		GOARCH=${GOARCH_${ARCH}} \
 		GO386=${GO386} \
 		GOARM=${GOARM_${ARCH}} \
+		CC=${CC} \
 		${SH} run.bash -no-rebuild

The result is that CC is still not respected for "do-build" target:

Building Go cmd/dist using /wrkdirs/usr/ports/lang/go/work/go-freebsd-amd64-bootstrap. (go1.14 freebsd/amd64)
cmd/dist

go tool dist: cannot invoke C compiler "clang": exec: "clang": executable file not found in $PATH

Go needs a system C compiler for use with cgo.
To set a C compiler, set CC=the-compiler.
To disable cgo, set CGO_ENABLED=0.

*** Error code 2

Stop.
make: stopped in /usr/ports/lang/go

Passing CC in do-build as in v1.1 unbreaks the build.
Comment 8 Guangyuan Yang freebsd_committer freebsd_triage 2021-11-13 06:05:10 UTC
(In reply to Evgeniy Khramtsov from comment #7)

Sorry - I manually edited the wrong place of the Makefile. Will fix it soon.
Comment 9 commit-hook freebsd_committer freebsd_triage 2021-11-15 21:53:13 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=2309e28d9e4f185b5de56f0b4e5b0bde857a3c3a

commit 2309e28d9e4f185b5de56f0b4e5b0bde857a3c3a
Author:     Guangyuan Yang <ygy@FreeBSD.org>
AuthorDate: 2021-11-15 21:52:27 +0000
Commit:     Guangyuan Yang <ygy@FreeBSD.org>
CommitDate: 2021-11-15 21:52:27 +0000

    lang/go, lang/go-devel: Respect CC

    PR:             258291
    Fixes:          f55607ce7b906bd7886b857f568956880f4281ff
    Reported by:    Evgeniy Khramtsov <evgeniy@khramtsov.org>

 lang/go-devel/Makefile | 2 +-
 lang/go/Makefile       | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)