Bug 242217

Summary: 'make buildworld' type upgrading to 12.1-RELEASE impossible
Product: Base System Reporter: oz42
Component: binAssignee: freebsd-bugs (Nobody) <bugs>
Status: New ---    
Severity: Affects Only Me CC: aurel, olaf, ports
Priority: ---    
Version: 12.0-RELEASE   
Hardware: amd64   
OS: Any   

Description oz42 2019-11-25 08:34:58 UTC
'make buildworld' error message is:

--- pkru.o ---
/usr/src/lib/libc/x86/sys/pkru.c:68:9: error: implicit declaration of function 'rdpkru' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
        pkru = rdpkru();
               ^
/usr/src/lib/libc/x86/sys/pkru.c:99:9: error: implicit declaration of function 'rdpkru' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
        pkru = rdpkru();
               ^
/usr/src/lib/libc/x86/sys/pkru.c:105:2: error: implicit declaration of function 'wrpkru' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
        wrpkru(pkru);
        ^
/usr/src/lib/libc/x86/sys/pkru.c:105:2: note: did you mean 'rdpkru'?
/usr/src/lib/libc/x86/sys/pkru.c:68:9: note: 'rdpkru' declared here
        pkru = rdpkru();
               ^
/usr/src/lib/libc/x86/sys/pkru.c:119:24: error: variable has incomplete type 'struct amd64_set_pkru'
        struct amd64_set_pkru a64pkru;
                              ^
/usr/src/lib/libc/x86/sys/pkru.c:119:9: note: forward declaration of 'struct amd64_set_pkru'
        struct amd64_set_pkru a64pkru;
               ^
/usr/src/lib/libc/x86/sys/pkru.c:126:18: error: use of undeclared identifier 'AMD64_SET_PKRU'
        return (sysarch(X86_SET_PKRU, &a64pkru));
                        ^
/usr/src/lib/libc/x86/sys/pkru.c:46:22: note: expanded from macro 'X86_SET_PKRU'
#define X86_SET_PKRU    AMD64_SET_PKRU
                        ^
/usr/src/lib/libc/x86/sys/pkru.c:132:24: error: variable has incomplete type 'struct amd64_set_pkru'
        struct amd64_set_pkru a64pkru;
                              ^
/usr/src/lib/libc/x86/sys/pkru.c:132:9: note: forward declaration of 'struct amd64_set_pkru'
        struct amd64_set_pkru a64pkru;
               ^
/usr/src/lib/libc/x86/sys/pkru.c:137:18: error: use of undeclared identifier 'AMD64_CLEAR_PKRU'
        return (sysarch(X86_CLEAR_PKRU, &a64pkru));
                        ^
/usr/src/lib/libc/x86/sys/pkru.c:47:24: note: expanded from macro 'X86_CLEAR_PKRU'
#define X86_CLEAR_PKRU  AMD64_CLEAR_PKRU
                        ^
7 errors generated.
*** [pkru.o] Error code 1

make[4]: stopped in /usr/src/lib/libc
1 error
Comment 1 oz42 2019-11-25 08:35:36 UTC
My /etc/make.conf:

KERNCONFDIR=/root
KERNCONF=FB12
MODULES_OVERRIDE=mac_ntpd filemon
#
OPTIONS_UNSET= NIS
OPTIONS_UNSET+= X11
OPTIONS_UNSET+= DOCS
OPTIONS_UNSET+= DEBUG
OPTIONS_UNSET+= WAYLAND
#
DEFAULT_VERSIONS+= ssl=libressl
Comment 2 oz42 2019-11-25 08:36:32 UTC
My /etc/src.conf:

WITH_CCACHE_BUILD=YES
WITH_LLD_BOOTSTRAP=YES  # is ignored, but just to make sure
Comment 3 oz42 2019-11-25 11:07:39 UTC
When I delete /etc/src.conf, I get a completely other error:

--- all_subdir_rescue ---
/usr/src/sbin/fsck_ffs/inode.c:72:9: error: no member named 'id_lballoc' in 'struct inodesc'
        idesc->id_lballoc = -1;
        ~~~~~  ^
/usr/src/sbin/fsck_ffs/inode.c:73:9: error: no member named 'id_level' in 'struct inodesc'
        idesc->id_level = 0;
        ~~~~~  ^
/usr/src/sbin/fsck_ffs/inode.c:107:15: error: too many arguments to function call, expected 0, have 1
                                        inodirty(dp);
                                        ~~~~~~~~ ^~
/usr/src/sbin/fsck_ffs/fsck.h:452:1: note: 'inodirty' declared here
void            inodirty(void);
^
/usr/src/sbin/fsck_ffs/inode.c:126:10: error: no member named 'id_level' in 'struct inodesc'
                idesc->id_level = i + 1;
                ~~~~~  ^
/usr/src/sbin/fsck_ffs/inode.c:148:15: error: too many arguments to function call, expected 0, have 1
                                        inodirty(dp);
                                        ~~~~~~~~ ^~
/usr/src/sbin/fsck_ffs/fsck.h:452:1: note: 'inodirty' declared here
void            inodirty(void);
^
/usr/src/sbin/fsck_ffs/inode.c:177:9: error: no member named 'id_level' in 'struct inodesc'
        idesc->id_level--;
        ~~~~~  ^
/usr/src/sbin/fsck_ffs/inode.c:178:51: error: no member named 'id_level' in 'struct inodesc'
        for (sizepb = sblock.fs_bsize, i = 0; i < idesc->id_level; i++)
                                                  ~~~~~  ^
/usr/src/sbin/fsck_ffs/inode.c:202:15: error: no member named 'id_level' in 'struct inodesc'
                        if (idesc->id_level == 0) {
                            ~~~~~  ^
/usr/src/sbin/fsck_ffs/inode.c:207:12: error: no member named 'id_level' in 'struct inodesc'
                                idesc->id_level++;
                                ~~~~~  ^
/usr/src/sbin/fsck_ffs/inode.c:229:15: error: too many arguments to function call, expected 0, have 1
                                        inodirty(dp);
                                        ~~~~~~~~ ^~
/usr/src/sbin/fsck_ffs/fsck.h:452:1: note: 'inodirty' declared here
void            inodirty(void);
^
/usr/src/sbin/fsck_ffs/inode.c:527:1: error: conflicting types for 'inodirty'
inodirty(union dinode *dp)
^
/usr/src/sbin/fsck_ffs/fsck.h:452:7: note: previous declaration is here
void            inodirty(void);
                ^
/usr/src/sbin/fsck_ffs/inode.c:552:13: error: too many arguments to function call, expected 0, have 1
                        inodirty(dp);
                        ~~~~~~~~ ^~
/usr/src/sbin/fsck_ffs/fsck.h:452:1: note: 'inodirty' declared here
void            inodirty(void);
^
/usr/src/sbin/fsck_ffs/inode.c:719:11: error: too many arguments to function call, expected 0, have 1
        inodirty(dp);
        ~~~~~~~~ ^~
/usr/src/sbin/fsck_ffs/fsck.h:452:1: note: 'inodirty' declared here
void            inodirty(void);
^
/usr/src/sbin/fsck_ffs/inode.c:740:11: error: too many arguments to function call, expected 0, have 1
        inodirty(dp);
        ~~~~~~~~ ^~
/usr/src/sbin/fsck_ffs/fsck.h:452:1: note: 'inodirty' declared here
void            inodirty(void);
^
14 errors generated.
*** [inode.o] Error code 1

make[6]: stopped in /usr/src/sbin/fsck_ffs
Comment 4 Krzysztof 2019-12-13 20:49:21 UTC
Hi,

Ithink I can attach to this bug. I've similiar problem with upgrading from 12.0-STABLE to 12.1-STABLE.

So Step by step. I;ve made svn update in /usr/src:
% svn info
Path: .
Working Copy Root Path: /usr/src
URL: http://svn.freebsd.org/base/stable/12
Relative URL: ^/stable/12
Repository Root: http://svn.freebsd.org/base
Repository UUID: ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Revision: 355646
Node Kind: directory
Schedule: normal
Last Changed Author: mav
Last Changed Rev: 355636
Last Changed Date: 2019-12-12 01:29:48 +0100 (Thu, 12 Dec 2019)

After that I've started make -j8 buildworld. So fisrt brake happened because of unknown CONSTANTS in some header files. I had to copy these files from /usr/src/sys/ to /usr/include:
/usr/include/sys/ata.h
/usr/include/sys/unistd.h
/usr/include/sys/sysctl.h

(and the error was:
--- all_subdir_sbin ---
/usr/src/sbin/camcontrol/modeedit.c:667:18: error: no member named 'flags' in 'struct scsi_mode_header_10'
                longlba = (mh->flags & SMH_LONGLBA) != 0;
                           ~~  ^
/usr/src/sbin/camcontrol/modeedit.c:667:26: error: use of undeclared identifier 'SMH_LONGLBA'
                longlba = (mh->flags & SMH_LONGLBA) != 0;
                                       ^
)

After copying some headers next "stopper" occured in cddl/usr.sbin/zpool:
ld: error: undefined symbol: zpool_sync_one
>>> referenced by zpool_main.c:2691 (/usr/src/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c:2691)
>>>               zpool_main.o:(zpool_do_sync)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
*** [zpool.full] Error code 1

but:
cd /usr/src/cddl/ && make
finished without errors.

OK, to I've continued buildworld. After some time I've got a problem with mount_nfs.c:
--- all_subdir_sbin ---
ld: error: undefined symbol: auth_destroy
>>> referenced by mount_nfs.c:834 (/usr/src/sbin/mount_nfs/mount_nfs.c:834)
>>>               mount_nfs.o:(main)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
*** [mount_nfs.full] Error code 1

And this error stops build process totally/ I'm not able to go on.

Yes, I've got my own src.conf, KERNCONF, but I'm using these configurations for long time (upgrading servers from 9, via 10, 11 and to 12.0). And I did not have any problems with compiling and installing my own binaries.

So I'm sure that 12.1-STABLE changed something, but I'm not able to findout what it is. I've checked man pages (like src.conf, build) and officiall handbook: I'm not able to find out what I'm doing wrong.

So I hope you can guide me to right direction.

Logfiles from building processes are quit big, so I can share them with my ownCloud if they are needed.
Comment 5 oz42 2020-02-05 19:15:58 UTC
(In reply to Krzysztof from comment #4)
I think we are coming close to two severe design bugs in the source tree that are related to each other.

1. 'make buildworld' relies on header files in /usr/include
2. 'make delete-old' removes these files in /usr/include

My workaround is: having another host just for the purpose to get a fresh copy of /usr/include and /usr/lib files if a 'make buildworld' fails on my productive system. I keep that one updated, and when 'make buildworld' fails I copy all header files from that machine to my productive one, and if it then fails also, I copy all /usr/lib also.

Unfortunately I have another account here with a password that I do not remember right now, but my browser at work does. So please look at bug 243727.
Comment 6 Krzysztof 2020-02-11 18:43:16 UTC
OK,

After some debugging I've found that problem was with some special CCFLAGS. I mean I was using make.conf settings form many, many years.

When I removed this CCFLAGS (optimalizations) everything went without problems.
Comment 7 olaf 2020-02-12 08:17:38 UTC
I do not have any CCFLAGS defined.
Comment 8 Aurel Bodenmann-Flury 2020-04-07 17:12:08 UTC
I've ran into the same problem on my 12.0-STABLE system. I'm guessing that oz42 is on to something regarding this being a problem due to bug 243727.

My workaround:

- Backup (or in my case a ZFS snapshot)
- Force a binary update (not a clean solution, I know): freebsd-update --debug -r 12.1-RELEASE --currently-running 12.0-RELEASE upgrade . This won't work without specifing 12.0-RELEASE as "currently-running" as we can't upgrade a -STABLE system with freebsd-update. In my case I had to merge quite a few config files by hand as prompted by freebsd-update, I'm guessing this is due to a version mismatch between the expected "12.0-RELEASE" and the actual "12.0-STABLE" my system was running on.
- Repeat "freebsd-update install" until all is updated
- Just to be sure I would rebuild the system from sources: make buildworld and make buildkernel etc. which ran just fine this time.