Bug 272430

Summary: Building parts of build-tools appears to be broken
Product: Base System Reporter: Kenneth Raplee <kenrap>
Component: binAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me CC: herbert
Priority: ---    
Version: CURRENT   
Hardware: Any   
OS: Any   

Description Kenneth Raplee 2023-07-08 22:57:04 UTC
I don't know if this is because of having a broken toolchain in base but these kinds of errors have been persistent for me even after running `make clean` or `make cleanuniverse`.

# uname -aKU
FreeBSD freebsd 14.0-CURRENT FreeBSD 14.0-CURRENT #0 main-n264064-2596008a0bde: Sat Jul  8 13:37:22 PDT 2023     root@freebsd:/usr/obj/usr/src/amd64.amd64/sys/GENERIC-NODEBUG amd64 1400093 1400093

________________________________
--- curses.h ---
cat: stdout: Bad file descriptor
cat: stdout: Bad file descriptor
cat: stdout: Bad file descriptor
*** [curses.h] Error code 1

make[3]: stopped in /usr/src/lib/ncurses/tinfo
1 error

make[3]: stopped in /usr/src/lib/ncurses/tinfo
*** [build-tools_lib/ncurses/tinfo] Error code 2

make[2]: stopped in /usr/src
--- build-tools_usr.bin/awk ---
*** [build-tools_usr.bin/awk] Error code 6

make[2]: stopped in /usr/src
--- build-tools_bin/csh ---
*** [build-tools_bin/csh] Error code 6

make[2]: stopped in /usr/src
--- build-tools_rescue/rescue ---
*** [build-tools-bin/csh] Error code 6

make[3]: stopped in /usr/src/rescue/rescue
--- build-tools_usr.bin/vi/catalog ---
*** [build-tools_usr.bin/vi/catalog] Error code 6

make[2]: stopped in /usr/src
--- build-tools_bin/sh ---
*** [build-tools_bin/sh] Error code 6

make[2]: stopped in /usr/src
--- build-tools_rescue/rescue ---
--- build-tools-bin/sh ---
*** [build-tools-bin/sh] Error code 6

make[3]: stopped in /usr/src/rescue/rescue
2 errors

make[3]: stopped in /usr/src/rescue/rescue
*** [build-tools_rescue/rescue] Error code 2

make[2]: stopped in /usr/src
--- build-tools_lib/libpmc/pmu-events ---
*** [build-tools_lib/libpmc/pmu-events] Error code 6

make[2]: stopped in /usr/src
--- build-tools_lib/libmagic ---
*** [build-tools_lib/libmagic] Error code 6

make[2]: stopped in /usr/src
8 errors

make[2]: stopped in /usr/src
        1.13 real         2.52 user         0.46 sys

make[1]: stopped in /usr/src

make: stopped in /usr/src
Comment 1 Herbert J. Skuhra 2023-07-08 23:30:22 UTC
This seems to be fixed by:

commit 055f920ebe21b8e05235363bc11a83cc649cdc6a (HEAD -> main, freebsd/main, freebsd/HEAD)
Author: Martin Matuska
Date:   Sun Jul 9 01:04:25 2023 +0200

    cat: fallback on EBADF with copy_file_range(2)
    
    When stdout is opened with O_APPEND, copy_file_range(2) fails with EBADF.
Comment 2 Kenneth Raplee 2023-07-08 23:36:58 UTC
Unfortunately, (at least for me), that latest commit didn't do it for me, even with make clean*. Though I wouldn't be surprised if I'm doing something wrong.
Comment 3 Herbert J. Skuhra 2023-07-08 23:44:45 UTC
(In reply to Kenneth Raplee from comment #2)

Have you rebuilt and reinstalled cat first? 

If not, try:

# cd /usr/src/bin/cat
# make cleandir obj all install
Comment 4 Kenneth Raplee 2023-07-08 23:51:02 UTC
I haven't and wasn't aware of that approach. Thanks for sharing that.

I'm still stuck though unfortunately:

[Creating objdir /usr/obj/usr/src/amd64.amd64/bin/cat...]
===> tests (cleandir)
rm -f cat_test cat_test.tmp Kyuafile Kyuafile.tmp
rm -rf checkdir
rm -f .depend .depend.*
rm -f cat.o cat.bc cat.ll cat.full.bc cat.full.ll cat cat.bc cat.ll cat.full cat.debug cat.o cat.bc cat.ll cat.1.gz cat.1.cat.gz
rm -f .depend .depend.* GPATH GRTAGS GSYMS GTAGS
echo cat.full: /usr/lib/libc.a  >> .depend
cc  -O2 -pipe -fno-common   -fPIE -g -gz=zlib -MD  -MF.depend.cat.o -MTcat.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 -Wdate-time -Wmissing-variable-declarations -Wthread-safety -Wno-empty-body -Wno-string-plus-int -Wno-unused-const-variable -Wno-error=unused-but-set-parameter  -Qunused-arguments    -c /usr/src/bin/cat/cat.c -o cat.o
cc -O2 -pipe -fno-common -fPIE -g -gz=zlib -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 -Wdate-time -Wmissing-variable-declarations -Wthread-safety -Wno-empty-body -Wno-string-plus-int -Wno-unused-const-variable -Wno-error=unused-but-set-parameter -Qunused-arguments  -Wl,-zrelro -pie   -o cat.full cat.o  
objcopy --only-keep-debug cat.full cat.debug
objcopy --strip-debug --add-gnu-debuglink=cat.debug  cat.full cat
gzip -cn /usr/src/bin/cat/cat.1 > cat.1.gz
===> tests (all)
[Creating objdir /usr/obj/usr/src/amd64.amd64/bin/cat/tests...]
echo '#! /usr/libexec/atf-sh' > cat_test.tmp
cat /usr/src/contrib/netbsd-tests/bin/cat/t_cat.sh >>cat_test.tmp
cat: stdout: Bad file descriptor
*** Error code 1

Stop.
make[1]: stopped in /usr/src/bin/cat/tests
*** Error code 1

Stop.
make: stopped in /usr/src/bin/cat
_________________________________

# git log -n 1            
commit 055f920ebe21b8e05235363bc11a83cc649cdc6a (HEAD -> main, origin/main, origin/HEAD)
Author: Martin Matuska <mm@FreeBSD.org>
Date:   Sun Jul 9 01:04:25 2023 +0200

    cat: fallback on EBADF with copy_file_range(2)
    
    When stdout is opened with O_APPEND, copy_file_range(2) fails with EBADF.
Comment 5 Herbert J. Skuhra 2023-07-09 00:02:27 UTC
(In reply to Kenneth Raplee from comment #4)
Try instead:

# cd /usr/src/bin/cat
# make cleandir 
# make -DWITHOUT_TESTS obj all install
Comment 6 Kenneth Raplee 2023-07-09 00:31:24 UTC
(In reply to Herbert J. Skuhra from comment #5)
Thank you so much, that worked!

And I can also report that I was successfully able to build world again.

Should this issue be closed then?
Comment 7 Yuri Pankov freebsd_committer freebsd_triage 2023-07-09 06:44:29 UTC
Fixed in base 055f920ebe21b8e05235363bc11a83cc649cdc6a.