Bug 267871

Summary: /usr/bin/rs compile fails after udate to c++
Product: Base System Reporter: rkoberman
Component: binAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Some People CC: dan.kotowski, devel, herbert, jhb, lwhsu, me, sjg, swills, wosch
Priority: ---    
Version: CURRENT   
Hardware: amd64   
OS: Any   

Description rkoberman 2022-11-19 23:53:49 UTC
buildwrld fails building rc. It attempts to compile rs.c, but it has been replaced by rc.cc.

--- rs.o ---
cc -target x86_64-unknown-freebsd14.0 --sysroot=/usr/obj/usr/src/amd64.amd64/tmp -B/usr/obj/usr/src/amd64.amd64/tmp/usr/bin  -O2 -pipe -fno-common   -fPIE -g -gz=zlib -MD  -MF.depend.rs.o -MTrs.o -std=gnu99 -Wno-format-zero-length -fstack-protector-strong -Wsystem-headers -Werror -Wall -Wno-format-y2k -W -Wno-unused-parameter -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow -Wunused-parameter -Wcast-align -Wchar-subscripts -Wnested-externs -Wold-style-definition -Wno-pointer-sign -Wmissing-variable-declarations -Wthread-safety -Wno-empty-body -Wno-string-plus-int -Wno-unused-const-variable -Wno-error=unused-but-set-variable  -Qunused-arguments    -c /usr/src/usr.bin/rs/rs.c -o rs.o
cc: error: no such file or directory: '/usr/src/usr.bin/rs/rs.c'
cc: error: no input files
*** [rs.o] Error code 1

# ls /usr/src/usr.bin/rs
Makefile		rs.1			tests/
Makefile.depend		rs.cc
Comment 1 Herbert J. Skuhra 2022-11-20 08:43:17 UTC
Is your src checkout in sync and clean? What's the output of 

git rev-parse HEAD
git status
git diff

in src? uname -a?
Comment 2 rkoberman 2022-11-20 14:31:49 UTC
(In reply to Herbert J. Skuhra from comment #1)
# git rev-parse HEAD
424bf1d5ca5bdba0597b546ec3931eb05bfabcab
# git status
On branch main
Your branch is up to date with 'origin/main'.

nothing to commit, working tree clean
# git diff
#
Comment 3 Herbert J. Skuhra 2022-11-20 16:01:02 UTC
Do you build with NO_CLEAN/WITHOUT_CLEAN?

Does it work if you run:

cd /usr/src/usr.bin/rs
make cleandir

or wipe /usr/obj?

Here it works:

--- rs.o ---
c++  -target x86_64-unknown-freebsd14.0 --sysroot=/usr/obj/usr/src/amd64.amd64/tmp -B/usr/obj/usr/src/amd64.amd64/tmp/usr/bin  -O2 -pipe -fno-common -fPIE -mretpoline -MD -MF.depend.rs.o -MTrs.o -Wno-format-zero-length -fstack-protector-strong -Wsystem-headers -Werror -Wall -Wno-format-y2k -W -Wno-unused-parameter -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow -Wunused-parameter -Wcast-align -Wchar-subscripts -Wmissing-variable-declarations -Wthread-safety -Wno-empty-body -Wno-string-plus-int -Wno-unused-const-variable -Wno-error=unused-but-set-variable -Qunused-arguments  -fPIE -mretpoline    -Wno-c++11-extensions   -c /usr/src/usr.bin/rs/rs.cc -o rs.o
Comment 4 rkoberman 2022-11-20 17:13:12 UTC
(In reply to Herbert J. Skuhra from comment #3)
Build was "nice make -j12 buildworld" Did not delete existing /usr/obj.

Since last update on 11/8, I just did:
# git pull --ff-only
# nice make -j12 buildworld

Today, after cleandir in usr.bin/rs, I did:
# make -j12 -DNO_CLEAN buildworld

This completed successfully. No idea what the cleandir did, bur some depend or config file must have survived the cleaning in the initial buildworld.

Unless there are additional reports in the next day or two, I'll close the ticket.
Comment 5 devel 2022-12-04 11:58:47 UTC
I saw the same bug yesterday.

1) Get the fresh tree to the new dir /usr/src:
git clone --branch main https://git.FreeBSD.org/src.git /usr/src
2) make buildworld 
3) stop at 
No such file or directory: '/usr/src/usr.bin/rs/rs.c
4) /usr/src/usr.bin/rs # make clean
===> tests (clean)
rm -f rs_test rs_test.tmp Kyuafile Kyuafile.tmp
rm -rf checkdir
rm -f rs.o rs.bc rs.ll rs.full.bc rs.full.ll rs rs.bc rs.ll rs.full rs.debug rs.o rs.bc rs.ll rs.1.gz rs.1.cat.gz
5) make -DNO_CLEAN buildworld
and world built successfully.

So it's no relation with old builds, because it was first build in fresh /usr/src.
Comment 6 John Baldwin freebsd_committer freebsd_triage 2022-12-09 18:50:10 UTC
(In reply to devel from comment #5)
Doing a fresh git clone doesn't ensure that /usr/obj is empty.  The only way make(1) could possibly know to look for rs.c is if it found a generated .depend file in /usr/obj that contained a reference to rs.c.

One question though is if you are using meta mode by chance?  I don't know if somehow the implicit SRCS breaks.  bsd.prog.mk has logic to assume <foo>.cc instead of <foo>.c for the default value of SRCS if PROG_CXX is used instead of PROG.  I see a somewhat dubious check for PROG_CXX (seems like it should be checking something else?) in local.dirdeps.mk, but aside from that I can't see any way that make would think the implicit source was rs.c instead of rs.cc.
Comment 7 Simon J. Gerraty freebsd_committer freebsd_triage 2022-12-10 22:06:35 UTC
(In reply to John Baldwin from comment #6)
Re meta mode; I don't think so, the build log would contain only

`Building ${OBJDIR}/rs.o`

all the detailed info would be in `rs.o.meta`
The errors would of course be repeated in the log too, but it would 
look quite different.

As for `local.dirdeps.mk` that is only relevant when using MK_DIRDEPS_BUILD=yes
which is not the case for targets like `buildworld`
Comment 8 Li-Wen Hsu freebsd_committer freebsd_triage 2022-12-18 14:58:35 UTC
*** Bug 268414 has been marked as a duplicate of this bug. ***
Comment 9 Wolfram Schneider freebsd_committer freebsd_triage 2022-12-19 09:10:13 UTC
I had the same problem when I upgraded an older FreeBSD 14-current machine from September. The solution was to remove /usr/obj
Comment 10 Alex.V 2022-12-27 14:55:42 UTC
cd /usr/src/usr.bin/rs
make cleandir
make 
cd /usr/src
make -DNO_CLEAN buildworld
--
Does the trick... however, "make install" did not finish yet : )
Comment 11 Alex.V 2022-12-27 15:56:39 UTC
[root@x /usr/src] cd /usr/src/usr.bin/rs
[root@x /usr/src] make cleandir
[root@x /usr/src] make 
[root@x /usr/src] cd /usr/src
[root@x /usr/src] make -DNO_CLEAN buildworld
[root@x /usr/src] # uname -a
FreeBSD x.y.z 14.0-CURRENT FreeBSD 14.0-CURRENT #34 main-n258976-93381ae06bb0: Wed Nov  2 11:30:41 MSK 2022 ...
[root@x /usr/src] # make buildkernel KERNCONF=CUSTOMx && make installkernel KERNCONF=CUSTOMx && make installworld && reboot 
...

(no mergemastering, cause UPDATING says nothing)

[root@x ~]# uname -a
FreeBSD x.y.z 14.0-CURRENT FreeBSD 14.0-CURRENT #35 main-n259865-b079ca8593ed: Tue Dec 27 18:32:34 MSK 2022     root@x.y.z:/usr/obj/usr/src/amd64.amd64/sys/CUSTOMx amd64
[root@x ~]#

----
It worked fine
Comment 12 Alex.V 2022-12-27 16:00:03 UTC
(In reply to Alex.V from comment #11)
dirty copy-paste, sorry
Comment 13 John Baldwin freebsd_committer freebsd_triage 2023-01-30 17:17:17 UTC
After more investigating, I think the case that was broken was doing a 'make buildworld' without NO_CLEAN=yes after a different commit I made to make MK_CXX conditional on bsd.compiler.mk.  The issue was kind of the inverse of b9cb80883bce6dc992cf05ae2e59089a60d311ec.  Same issue, but applied to the !NO_CLEAN case.  It has been rendered OBE though by the removal of the MK_CXX option in ac4c695ad61e81d00cff2a03202a4afe94a92513.
Comment 14 glassestax 2023-05-05 02:23:53 UTC
MARKED AS SPAM
Comment 15 eagerpython 2023-09-21 02:50:59 UTC
MARKED AS SPAM