我做了什么:
- 安装最小的 Debian-testing
- 安装 build-essential、dkms、linux-headers-$(uname -r)
- 安装 virtualbox,单击“设备”->“插入来宾添加 CD”
- 跑步
m-a prepare
- 安装
/dev/sr0
在某处、cd
那里和./VBoxLinuxAdditions.run
我得到了什么:
...
Building the modules for kernel 5.4.0-4-amd64.
Look at /var/log/vboxadd-setup.log to find out what went wrong.
modprobe vboxsf failed
...
日志中的内容:
...
test -e include/generated/autoconf.h -a -e include/config
/auto.conf || ( \
echo >&2; \
echo >&2 " ERROR: Kernel configuration is invalid."; \
echo >&2 " include/generated/autoconf.h or include/config/auto.conf are missing.";\
echo >&2 " Run 'make oldconfig && make prepare' on kernel src to fix it."; \
echo >&2 ; \
/bin/false)
...
我调查的内容:
$modprobe vboxsf
modprobe: FATAL: Module vboxsf not found in directory /lib/modules/5.4.0-4-amd
$lsmod | grep vboxsf
<no output>
$find /usr/src/linux-headers-5.4.0-4-amd64/ -name autoconf.h
/usr/src/linux-headers-5.4.0-4-amd64/include/generated/autoconf.h
主机操作系统是Ubuntu 18。
编辑:在 openbox 上,日志如下所示:
# less /var/log/vboxadd-setup.log
Building the main Guest Additions module for kernel 5.4.0-4-amd64.
Error building the module. Build output follows.
make V=1 CONFIG_MODULE_SIG= -C /lib/modules/5.4.0-4-amd64/build M=/tmp/vbox.0 SRCROOT=/tmp/vbox.0 -j1 modules
make -C /usr/src/linux-headers-5.4.0-4-amd64 -f /usr/src/linux-headers-5.4.0-4-common/Makefile modules
test -e include/generated/autoconf.h -a -e include/config/auto.conf || ( \
echo >&2; \
echo >&2 " ERROR: Kernel configuration is invalid."; \
echo >&2 " include/generated/autoconf.h or include/config/auto.conf are missing.";\
echo >&2 " Run 'make oldconfig && make prepare' on kernel src to fix it."; \
echo >&2 ; \
/bin/false)
make -f /usr/src/linux-headers-5.4.0-4-common/scripts/Makefile.build obj=/tmp/vbox.0 single-build= need-builtin=1 need-modorder=1
gcc-9 -Wp,-MD,/tmp/vbox.0/.VBoxGuest-linux.o.d -nostdinc -isystem /usr/lib/gcc/x86_64-linux-gnu/9/include -I/usr/src/linux-headers-5.4.0-4-common/arch/x86/include -I./arch/x86/include/generated -I/usr/src/linux-headers-5.4.0-4-common/include -I./include -I/usr/src/linux-headers-5.4.0-4-common/arch/x86/include/uapi -I./arch/x86/include/generated/uapi -I/usr/src/linux-headers-5.4.0-4-common/include/uapi -I./include/generated/uapi -include /usr/src/linux-headers-5.4.0-4-common/include/linux/kconfig.h -include /usr/src/linux-headers-5.4.0-4-common/include/linux/compiler_types.h -D__KERNEL__ -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE -Werror=implicit-function-declaration -Werror=implicit-int -Wno-format-security -std=gnu89 -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -m64 -falign-jumps=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mskip-rax-setup -mtune=generic -mno-red-zone -mcmodel=kernel -DCONFIG_X86_X32_ABI -DCONFIG_AS_CFI=1 -DCONFIG_AS_CFI_SIGNAL_FRAME=1 -DCONFIG_AS_CFI_SECTIONS=1 -DCONFIG_AS_SSSE3=1 -DCONFIG_AS_AVX=1 -DCONFIG_AS_AVX2=1 -DCONFIG_AS_AVX512=1 -DCONFIG_AS_SHA1_NI=1 -DCONFIG_AS_SHA256_NI=1 -Wno-sign-compare -fno-asynchronous-unwind-tables -mindirect-branch=thunk-extern -mindirect-branch-register -fno-jump-tables -fno-delete-null-pointer-checks -Wno-frame-address -Wno-format-truncation -Wno-format-overflow -Wno-address-of-packed-member -O2 --param=allow-store-data-races=0 -Wframe-larger-than=2048 -fstack-protector-strong -Wno-unused-but-set-variable -Wimplicit-fallthrough -Wno-unused-const-variable -fno-var-tracking-assignments -g -pg -mrecord-mcount -mfentry -DCC_USING_FENTRY -flive-patching=inline-clone -Wdeclaration-after-statement -Wvla -Wno-pointer-sign -Wno-stringop-truncation -fno-strict-overflow -fno-merge-all-constants -fmerge-constants -fno-stack-check -fconserve-stack -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -fmacro-prefix-map=/usr/src/linux-headers-5.4.0-4-common/= -fcf-protection=none -Wno-packed-not-aligned -Wno-declaration-after-statement -include /tmp/vbox.0/include/VBox/VBoxGuestMangling.h -fno-pie -I/usr/src/linux-headers-5.4.0-4-common/include -I/tmp/vbox.0/ -I/tmp/vbox.0/include -I/tmp/vbox.0/r0drv/linux -I/tmp/vbox.0/vboxguest/ -I/tmp/vbox.0/vboxguest/include -I/tmp/vbox.0/vboxguest/r0drv/linux -D__KERNEL__ -DMODULE -DVBOX -DRT_OS_LINUX -DIN_RING0 -DIN_RT_R0 -DIN_GUEST -DIN_GUEST_R0 -DIN_MODULE -DRT_WITH_VBOX -DVBGL_VBOXGUEST -DVBOX_WITH_HGCM -DRT_ARCH_AMD64 -DVBOX_WITH_64_BITS_GUESTS -DMODULE -DKBUILD_BASENAME='"VBoxGuest_linux"' -DKBUILD_MODNAME='"vboxguest"' -c -o /tmp/vbox.0/VBoxGuest-linux.o /tmp/vbox.0/VBoxGuest-linux.c
./tools/objtool/objtool orc generate --module --no-fp --retpoline --uaccess /tmp/vbox.0/VBoxGuest-linux.o
if objdump -h /tmp/vbox.0/VBoxGuest-linux.o | grep -q __ksymtab; then gcc-9 -E -D__GENKSYMS__ -Wp,-MD,/tmp/vbox.0/.VBoxGuest-linux.o.d -nostdinc -isystem /usr/lib/gcc/x86_64-linux-gnu/9/include -I/usr/src/linux-headers-5.4.0-4-common/arch/x86/include -I./arch/x86/include/generated -I/usr/src/linux-headers-5.4.0-4-common/include -I./include -I/usr/src/linux-headers-5.4.0-4-common/arch/x86/include/uapi -I./arch/x86/include/generated/uapi -I/usr/src/linux-headers-5.4.0-4-common/include/uapi -I./include/generated/uapi -include /usr/src/linux-headers-5.4.0-4-common/include/linux/kconfig.h -include /usr/src/linux-headers-5.4.0-4-common/include/linux/compiler_types.h -D__KERNEL__ -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE -Werror=implicit-function-declaration -Werror=implicit-int -Wno-format-security -std=gnu89 -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -m64 -falign-jumps=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mskip-rax-setup -mtune=generic -mno-red-zone -mcmodel=kernel -DCONFIG_X86_X32_ABI -DCONFIG_AS_CFI=1 -DCONFIG_AS_CFI_SIGNAL_FRAME=1 -DCONFIG_AS_CFI_SECTIONS=1 -DCONFIG_AS_SSSE3=1 -DCONFIG_AS_AVX=1 -DCONFIG_AS_AVX2=1 -DCONFIG_AS_AVX512=1 -DCONFIG_AS_SHA1_NI=1 -DCONFIG_AS_SHA256_NI=1 -Wno-sign-compare -fno-asynchronous-unwind-tables -mindirect-branch=thunk-extern -mindirect-branch-register -fno-jump-tables -fno-delete-null-pointer-checks -Wno-frame-address -Wno-format-truncation -Wno-format-overflow -Wno-address-of-packed-member -O2 --param=allow-store-data-races=0 -Wframe-larger-than=2048 -fstack-protector-strong -Wno-unused-but-set-variable -Wimplicit-fallthrough -Wno-unused-const-variable -fno-var-tracking-assignments -g -pg -mrecord-mcount -mfentry -DCC_USING_FENTRY -flive-patching=inline-clone -Wdeclaration-after-statement -Wvla -Wno-pointer-sign -Wno-stringop-truncation -fno-strict-overflow -fno-merge-all-constants -fmerge-constants -fno-stack-check -fconserve-stack -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -fmacro-prefix-map=/usr/src/linux-headers-5.4.0-4-common/= -fcf-protection=none -Wno-packed-not-aligned -Wno-declaration-after-statement -include /tmp/vbox.0/include/VBox/VBoxGuestMangling.h -fno-pie -I/usr/src/linux-headers-5.4.0-4-common/include -I/tmp/vbox.0/ -I/tmp/vbox.0/include -I/tmp/vbox.0/r0drv/linux -I/tmp/vbox.0/vboxguest/ -I/tmp/vbox.0/vboxguest/include -I/tmp/vbox.0/vboxguest/r0drv/linux -D__KERNEL__ -DMODULE -DVBOX -DRT_OS_LINUX -DIN_RING0 -DIN_RT_R0 -DIN_GUEST -DIN_GUEST_R0 -DIN_MODULE -DRT_WITH_VBOX -DVBGL_VBOXGUEST -DVBOX_WITH_HGCM -DRT_ARCH_AMD64 -DVBOX_WITH_64_BITS_GUESTS -DMODULE -DKBUILD_BASENAME='"VBoxGuest_linux"' -DKBUILD_MODNAME='"vboxguest"' /tmp/vbox.0/VBoxGuest-linux.c | scripts/genksyms/genksyms -r /dev/null > /tmp/vbox.0/.tmp_VBoxGuest-linux.ver; ld -m elf_x86_64 -z max-page-size=0x200000 -r -o /tmp/vbox.0/.tmp_VBoxGuest-linux.o /tmp/vbox.0/VBoxGuest-linux.o -T /tmp/vbox.0/.tmp_VBoxGuest-linux.ver; mv -f /tmp/vbox.0/.tmp_VBoxGuest-linux.o /tmp/vbox.0/VBoxGuest-linux.o; rm -f /tmp/vbox.0/.tmp_VBoxGuest-linux.ver; fi
gcc-9 -Wp,-MD,/tmp/vbox.0/.VBoxGuest.o.d -nostdinc -isystem /usr/lib/gcc/x86_64-linux-gnu/9/include -I/usr/src/linux-headers-5.4.0-4-common/arch/x86/include -I./arch/x86/include/generated -I/usr/src/linux-headers-5.4.0-4-common/include -I./include -I/usr/src/linux-headers-5.4.0-4-common/arch/x86/include/uapi -I./arch/x86/include/generated/uapi -I/usr/src/linux-headers-5.4.0-4-common/include/uapi -I./include/generated/uapi -include /usr/src/linux-headers-5.4.0-4-common/include/linux/kconfig.h -include /usr/src/linux-headers-5.4.0-4-common/include/linux/compiler_types.h -D__KERNEL__ -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE -Werror=implicit-function-declaration -Werror=implicit-int -Wno-format-security -std=gnu89 -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -m64 -falign-jumps=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mskip-rax-setup -mtune=generic -mno-red-zone -mcmodel=kernel -DCONFIG_X86_X32_ABI -DCONFIG_AS_CFI=1 -DCONFIG_AS_CFI_SIGNAL_FRAME=1 -DCONFIG_AS_CFI_SECTIONS=1 -DCONFIG_AS_SSSE3=1 -DCONFIG_AS_AVX=1 -DCONFIG_AS_AVX2=1 -DCONFIG_AS_AVX512=1 -DCONFIG_AS_SHA1_NI=1 -DCONFIG_AS_SHA256_NI=1 -Wno-sign-compare -fno-asynchronous-unwind-tables -mindirect-branch=thunk-extern -mindirect-branch-register -fno-jump-tables -fno-delete-null-pointer-checks -Wno-frame-address -Wno-format-truncation -Wno-format-overflow -Wno-address-of-packed-member -O2 --param=allow-store-data-races=0 -Wframe-larger-than=2048 -fstack-protector-strong -Wno-unused-but-set-variable -Wimplicit-fallthrough -Wno-unused-const-variable -fno-var-tracking-assignments -g -pg -mrecord-mcount -mfentry -DCC_USING_FENTRY -flive-patching=inline-clone -Wdeclaration-after-statement -Wvla -Wno-pointer-sign -Wno-stringop-truncation -fno-strict-overflow -fno-merge-all-constants -fmerge-constants -fno-stack-check -fconserve-stack -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -fmacro-prefix-map=/usr/src/linux-headers-5.4.0-4-common/= -fcf-protection=none -Wno-packed-not-aligned -Wno-declaration-after-statement -include /tmp/vbox.0/include/VBox/VBoxGuestMangling.h -fno-pie -I/usr/src/linux-headers-5.4.0-4-common/include -I/tmp/vbox.0/ -I/tmp/vbox.0/include -I/tmp/vbox.0/r0drv/linux -I/tmp/vbox.0/vboxguest/ -I/tmp/vbox.0/vboxguest/include -I/tmp/vbox.0/vboxguest/r0drv/linux -D__KERNEL__ -DMODULE -DVBOX -DRT_OS_LINUX -DIN_RING0 -DIN_RT_R0 -DIN_GUEST -DIN_GUEST_R0 -DIN_MODULE -DRT_WITH_VBOX -DVBGL_VBOXGUEST -DVBOX_WITH_HGCM -DRT_ARCH_AMD64 -DVBOX_WITH_64_BITS_GUESTS -DMODULE -DKBUILD_BASENAME='"VBoxGuest"' -DKBUILD_MODNAME='"vboxguest"' -c -o /tmp/vbox.0/VBoxGuest.o /tmp/vbox.0/VBoxGuest.c
/tmp/vbox.0/VBoxGuest.c: In function ‘vgdrvCheckIfVmmReqIsAllowed’:
/tmp/vbox.0/VBoxGuest.c:2060:16: warning: this statement may fall through [-Wimplicit-fallthrough=]
2060 | if (pSession->fUserSession)
| ^
/tmp/vbox.0/VBoxGuest.c:2062:9: note: here
2062 | case kLevel_AllUsers:
| ^~~~
./tools/objtool/objtool orc generate --module --no-fp --retpoline --uaccess /tmp/vbox.0/VBoxGuest.o
if objdump -h /tmp/vbox.0/VBoxGuest.o | grep -q __ksymtab; then gcc-9 <compile flags deleted to fit in 30 000 characters>fi
gcc-9 -Wp,-MD,/tmp/vbox.0/.VBoxGuestR0LibGenericRequest.o.d -nostdinc -isystem /usr/lib/gcc/x86_64-linux-gnu/9/include -I/usr/src/linux-headers-5.4.0-4-common/arch/x86/include -I./arch/x86/include/generated -I/usr/src/linux-headers-5.4.0-4-common/include -I./include -I/usr/src/linux-headers-5.4.0-4-common/arch/x86/include/uapi -I./arch/x86/include/generated/uapi -I/usr/src/linux-headers-5.4.0-4-common/include/uapi -I./include/generated/uapi -include /usr/src/linux-headers-5.4.0-4-common/include/linux/kconfig.h -include /usr/src/linux-headers-5.4.0-4-common/include/linux/compiler_types.h -D__KERNEL__ -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE -Werror=implicit-function-declaration -Werror=implicit-int -Wno-format-security -std=gnu89 -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -m64 -falign-jumps=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mskip-rax-setup -mtune=generic -mno-red-zone -mcmodel=kernel -DCONFIG_X86_X32_ABI -DCONFIG_AS_CFI=1 -DCONFIG_AS_CFI_SIGNAL_FRAME=1 -DCONFIG_AS_CFI_SECTIONS=1 -DCONFIG_AS_SSSE3=1 -DCONFIG_AS_AVX=1 -DCONFIG_AS_AVX2=1 -DCONFIG_AS_AVX512=1 -DCONFIG_AS_SHA1_NI=1 -DCONFIG_AS_SHA256_NI=1 -Wno-sign-compare -fno-asynchronous-unwind-tables -mindirect-branch=thunk-extern -mindirect-branch-register -fno-jump-tables -fno-delete-null-pointer-checks -Wno-frame-address -Wno-format-truncation -Wno-format-overflow -Wno-address-of-packed-member -O2 --param=allow-store-data-races=0 -Wframe-larger-than=2048 -fstack-protector-strong -Wno-unused-but-set-variable -Wimplicit-fallthrough -Wno-unused-const-variable -fno-var-tracking-assignments -g -pg -mrecord-mcount -mfentry -DCC_USING_FENTRY -flive-patching=inline-clone -Wdeclaration-after-statement -Wvla -Wno-pointer-sign -Wno-stringop-truncation -fno-strict-overflow -fno-merge-all-constants -fmerge-constants -fno-stack-check -fconserve-stack -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -fmacro-prefix-map=/usr/src/linux-headers-5.4.0-4-common/= -fcf-protection=none -Wno-packed-not-aligned -Wno-declaration-after-statement -include /tmp/vbox.0/include/VBox/VBoxGuestMangling.h -fno-pie -I/usr/src/linux-headers-5.4.0-4-common/include -I/tmp/vbox.0/ -I/tmp/vbox.0/include -I/tmp/vbox.0/r0drv/linux -I/tmp/vbox.0/vboxguest/ -I/tmp/vbox.0/vboxguest/include -I/tmp/vbox.0/vboxguest/r0drv/linux -D__KERNEL__ -DMODULE -DVBOX -DRT_OS_LINUX -DIN_RING0 -DIN_RT_R0 -DIN_GUEST -DIN_GUEST_R0 -DIN_MODULE -DRT_WITH_VBOX -DVBGL_VBOXGUEST -DVBOX_WITH_HGCM -DRT_ARCH_AMD64 -DVBOX_WITH_64_BITS_GUESTS -DMODULE -DKBUILD_BASENAME='"VBoxGuestR0LibGenericRequest"' -DKBUILD_MODNAME='"vboxguest"' -c -o /tmp/vbox.0/VBoxGuestR0LibGenericRequest.o /tmp/vbox.0/VBoxGuestR0LibGenericRequest.c
./tools/objtool/objtool orc generate --module --no-fp --retpoline --uaccess /tmp/vbox.0/VBoxGuestR0LibGenericRequest.o
if objdump -h /tmp/vbox.0/VBoxGuestR0LibGenericRequest.o | grep -q __ksymtab; then gcc-9 -E -D__GENKSYMS__ -Wp,-MD,/tmp/vbox.0/.VBoxGuestR0LibGenericRequest.o.d -nostdinc -isystem /usr/lib/gcc/x86_64-linux-gnu/9/include -I/usr/src/linux-headers-5.4.0-4-common/arch/x86/include -I./arch/x86/include/generated -I/usr/src/linux-headers-5.4.0-4-common/include -I./include -I/usr/src/linux-headers-5.4.0-4-common/arch/x86/include/uapi -I./arch/x86/include/generated/uapi -I/usr/src/linux-headers-5.4.0-4-common/include/uapi -I./include/generated/uapi -include /usr/src/linux-headers-5.4.0-4-common/include/linux/kconfig.h -include /usr/src/linux-headers-5.4.0-4-common/include/linux/compiler_types.h -D__KERNEL__ -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE -Werror=implicit-function-declaration -Werror=implicit-int -Wno-format-security -std=gnu89 -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -m64 -falign-jumps=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mskip-rax-setup -mtune=generic -mno-red-zone -mcmodel=kernel -DCONFIG_X86_X32_ABI -DCONFIG_AS_CFI=1 -DCONFIG_AS_CFI_SIGNAL_FRAME=1 -DCONFIG_AS_CFI_SECTIONS=1 -DCONFIG_AS_SSSE3=1 -DCONFIG_AS_AVX=1 -DCONFIG_AS_AVX2=1 -DCONFIG_AS_AVX512=1 -DCONFIG_AS_SHA1_NI=1 -DCONFIG_AS_SHA256_NI=1 -Wno-sign-compare -fno-asynchronous-unwind-tables -mindirect-<some flags removed to fit into 30 000 char> -DVBOX_WITH_64_BITS_GUESTS -DMODULE -DKBUILD_BASENAME='"VBoxGuestR0LibGenericRequest"' -DKBUILD_MODNAME='"vboxguest"' /tmp/vbox.0/VBoxGuestR0LibGenericRequest.c | scripts/genksyms/genksyms -r /dev/null > /tmp/vbox.0/.tmp_VBoxGuestR0LibGenericRequest.ver; ld -m elf_x86_64 -z max-page-size=0x200000 -r -o /tmp/vbox.0/.tmp_VBoxGuestR0LibGenericRequest.o /tmp/vbox.0/VBoxGuestR0LibGenericRequest.o -T /tmp/vbox.0/.tmp_VBoxGuestR0LibGenericRequest.ver; mv -f /tmp/vbox.0/.tmp_VBoxGuestR0LibGenericRequest.o /tmp/vbox.0/VBoxGuestR0LibGenericRequest.o; rm -f /tmp/vbox.0/.tmp_VBoxGuestR0LibGenericRequest.ver; fi
gcc-9 -Wp,-MD,/tmp/vbox.0/.VBoxGuestR0LibHGCMInternal.o.d -nostdinc -isystem /usr/lib/gcc/x86_64-linux-gnu/9/include -I/usr/src/linux-headers-5.4.0-4-common/arch/x86/include -I./arch/x86/include/generated -I/usr/src/linux-headers-5.4.0-4-common/include -I./include -I/usr/src/linux-headers-5.4.0-4-common/arch/x86/include/uapi -I./arch/x86/include/generated/uapi -I/usr/src/linux-headers-5.4.0-4-common/include/uapi -I./include/generated/uapi -include /usr/src/linux-headers-5.4.0-4-common/include/linux/kconfig.h -include /usr/src/linux-headers-5.4.0-4-common/include/linux/compiler_types.h -D__KERNEL__ -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE -Werror=implicit-function-declaration -Werror=implicit-int -Wno-format-security -std=gnu89 -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -m64 -falign-jumps=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mskip-rax-setup -mtune=generic -mno-red-zone -mcmodel=kernel -DCONFIG_X86_X32_ABI -DCONFIG_AS_CFI=1 -DCONFIG_AS_CFI_SIGNAL_FRAME=1 -DCONFIG_AS_CFI_SECTIONS=1 -DCONFIG_AS_SSSE3=1 -DCONFIG_AS_AVX=1 -DCONFIG_AS_AVX2=1 -DCONFIG_AS_AVX512=1 -DCONFIG_AS_SHA1_NI=1 -DCONFIG_AS_SHA256_NI=1 -Wno-sign-compare -fno-asynchronous-unwind-tables -mindirect-branch=thunk-extern -mindirect-branch-register -fno-jump-tables -fno-delete-null-pointer-checks -Wno-frame-address -Wno-format-truncation -Wno-format-overflow -Wno-address-of-packed-member -O2 --param=allow-store-data-races=0 -Wframe-larger-than=2048 -fstack-protector-strong -Wno-unused-but-set-variable -Wimplicit-fallthrough -Wno-unused-const-variable -fno-var-tracking-assignments -g -pg -mrecord-mcount -mfentry -DCC_USING_FENTRY -flive-patching=inline-clone -Wdeclaration-after-statement -Wvla -Wno-pointer-sign -Wno-stringop-truncation -fno-strict-overflow -fno-merge-all-constants -fmerge-constants -fno-stack-check -fconserve-stack -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -fmacro-prefix-map=/usr/src/linux-headers-5.4.0-4-common/= -fcf-protection=none -Wno-packed-not-aligned -Wno-declaration-after-statement -include /tmp/vbox.0/include/VBox/VBoxGuestMangling.h -fno-pie -I/usr/src/linux-headers-5.4.0-4-common/include -I/tmp/vbox.0/ -I/tmp/vbox.0/include -I/tmp/vbox.0/r0drv/linux -I/tmp/vbox.0/vboxguest/ -I/tmp/vbox.0/vboxguest/include -I/tmp/vbox.0/vboxguest/r0drv/linux -D__KERNEL__ -DMODULE -DVBOX -DRT_OS_LINUX -DIN_RING0 -DIN_RT_R0 -DIN_GUEST -DIN_GUEST_R0 -DIN_MODULE -DRT_WITH_VBOX -DVBGL_VBOXGUEST -DVBOX_WITH_HGCM -DRT_ARCH_AMD64 -DVBOX_WITH_64_BITS_GUESTS -DMODULE -DKBUILD_BASENAME='"VBoxGuestR0LibHGCMInternal"' -DKBUILD_MODNAME='"vboxguest"' -c -o /tmp/vbox.0/VBoxGuestR0LibHGCMInternal.o /tmp/vbox.0/VBoxGuestR0LibHGCMInternal.c
In file included from /usr/src/linux-headers-5.4.0-4-common/include/linux/compiler_types.h:59,
from <command-line>:
/tmp/vbox.0/VBoxGuestR0LibHGCMInternal.c: In function ‘vbglR0HGCMInternalPreprocessCall’:
/usr/src/linux-headers-5.4.0-4-common/include/linux/compiler_attributes.h:200:41: error: expected ‘)’ before ‘__attribute__’
200 | # define fallthrough __attribute__((__fallthrough__))
| ^~~~~~~~~~~~~
/tmp/vbox.0/include/iprt/cdefs.h:1116:48: note: in expansion of macro ‘fallthrough’
1116 | # define RT_FALL_THROUGH() __attribute__((fallthrough))
| ^~~~~~~~~~~
/tmp/vbox.0/include/iprt/cdefs.h:1123:33: note: in expansion of macro ‘RT_FALL_THROUGH’
1123 | #define RT_FALL_THRU() RT_FALL_THROUGH()
| ^~~~~~~~~~~~~~~
/tmp/vbox.0/VBoxGuestR0LibHGCMInternal.c:271:17: note: in expansion of macro ‘RT_FALL_THRU’
271 | RT_FALL_THRU();
| ^~~~~~~~~~~~
In file included from /tmp/vbox.0/include/iprt/types.h:29,
from /tmp/vbox.0/VBoxGuestR0LibInternal.h:33,
from /tmp/vbox.0/VBoxGuestR0LibHGCMInternal.c:33:
/tmp/vbox.0/include/iprt/cdefs.h:1116:60: error: expected identifier or ‘(’ before ‘)’ token
1116 | # define RT_FALL_THROUGH() __attribute__((fallthrough))
| ^
/tmp/vbox.0/include/iprt/cdefs.h:1123:33: note: in expansion of macro ‘RT_FALL_THROUGH’
1123 | #define RT_FALL_THRU() RT_FALL_THROUGH()
| ^~~~~~~~~~~~~~~
/tmp/vbox.0/VBoxGuestR0LibHGCMInternal.c:271:17: note: in expansion of macro ‘RT_FALL_THRU’
271 | RT_FALL_THRU();
| ^~~~~~~~~~~~
In file included from /usr/src/linux-headers-5.4.0-4-common/include/linux/compiler_types.h:59,
from <command-line>:
/tmp/vbox.0/VBoxGuestR0LibHGCMInternal.c: In function ‘vbglR0HGCMInternalInitCall’:
/usr/src/linux-headers-5.4.0-4-common/include/linux/compiler_attributes.h:200:41: error: expected ‘)’ before ‘__attribute__’
200 | # define fallthrough __attribute__((__fallthrough__))
| ^~~~~~~~~~~~~
/tmp/vbox.0/include/iprt/cdefs.h:1116:48: note: in expansion of macro ‘fallthrough’
1116 | # define RT_FALL_THROUGH() __attribute__((fallthrough))
| ^~~~~~~~~~~
/tmp/vbox.0/include/iprt/cdefs.h:1123:33: note: in expansion of macro ‘RT_FALL_THROUGH’
1123 | #define RT_FALL_THRU() RT_FALL_THROUGH()
| ^~~~~~~~~~~~~~~
/tmp/vbox.0/VBoxGuestR0LibHGCMInternal.c:545:17: note: in expansion of macro ‘RT_FALL_THRU’
545 | RT_FALL_THRU();
| ^~~~~~~~~~~~
In file included from /tmp/vbox.0/include/iprt/types.h:29,
from /tmp/vbox.0/VBoxGuestR0LibInternal.h:33,
from /tmp/vbox.0/VBoxGuestR0LibHGCMInternal.c:33:
/tmp/vbox.0/include/iprt/cdefs.h:1116:60: error: expected identifier or ‘(’ before ‘)’ token
1116 | # define RT_FALL_THROUGH() __attribute__((fallthrough))
| ^
/tmp/vbox.0/include/iprt/cdefs.h:1123:33: note: in expansion of macro ‘RT_FALL_THROUGH’
1123 | #define RT_FALL_THRU() RT_FALL_THROUGH()
| ^~~~~~~~~~~~~~~
/tmp/vbox.0/VBoxGuestR0LibHGCMInternal.c:545:17: note: in expansion of macro ‘RT_FALL_THRU’
545 | RT_FALL_THRU();
| ^~~~~~~~~~~~
In file included from /usr/src/linux-headers-5.4.0-4-common/include/linux/compiler_types.h:59,
from <command-line>:
/tmp/vbox.0/VBoxGuestR0LibHGCMInternal.c: In function ‘vbglR0HGCMInternalCopyBackResult’:
/usr/src/linux-headers-5.4.0-4-common/include/linux/compiler_attributes.h:200:41: error: expected ‘)’ before ‘__attribute__’
200 | # define fallthrough __attribute__((__fallthrough__))
| ^~~~~~~~~~~~~
/tmp/vbox.0/include/iprt/cdefs.h:1116:48: note: in expansion of macro ‘fallthrough’
1116 | # define RT_FALL_THROUGH() __attribute__((fallthrough))
| ^~~~~~~~~~~
/tmp/vbox.0/include/iprt/cdefs.h:1123:33: note: in expansion of macro ‘RT_FALL_THROUGH’
1123 | #define RT_FALL_THRU() RT_FALL_THROUGH()
| ^~~~~~~~~~~~~~~
/tmp/vbox.0/VBoxGuestR0LibHGCMInternal.c:812:17: note: in expansion of macro ‘RT_FALL_THRU’
812 | RT_FALL_THRU();
| ^~~~~~~~~~~~
In file included from /tmp/vbox.0/include/iprt/types.h:29,
from /tmp/vbox.0/VBoxGuestR0LibInternal.h:33,
from /tmp/vbox.0/VBoxGuestR0LibHGCMInternal.c:33:
/tmp/vbox.0/include/iprt/cdefs.h:1116:60: error: expected identifier or ‘(’ before ‘)’ token
1116 | # define RT_FALL_THROUGH() __attribute__((fallthrough))
| ^
/tmp/vbox.0/include/iprt/cdefs.h:1123:33: note: in expansion of macro ‘RT_FALL_THROUGH’
1123 | #define RT_FALL_THRU() RT_FALL_THROUGH()
| ^~~~~~~~~~~~~~~
/tmp/vbox.0/VBoxGuestR0LibHGCMInternal.c:812:17: note: in expansion of macro ‘RT_FALL_THRU’
812 | RT_FALL_THRU();
| ^~~~~~~~~~~~
/tmp/vbox.0/VBoxGuestR0LibHGCMInternal.c: In function ‘vbglR0HGCMInternalPreprocessCall’:
/tmp/vbox.0/VBoxGuestR0LibHGCMInternal.c:259:20: warning: this statement may fall through [-Wimplicit-fallthrough=]
259 | if (!VBGLR0_CAN_USE_PHYS_PAGE_LIST(/*a_fLocked =*/ true))
| ^
/tmp/vbox.0/VBoxGuestR0LibHGCMInternal.c:273:13: note: here
273 | case VMMDevHGCMParmType_LinAddr_In:
| ^~~~
/tmp/vbox.0/VBoxGuestR0LibHGCMInternal.c: In function ‘vbglR0HGCMInternalInitCall’:
/tmp/vbox.0/VBoxGuestR0LibHGCMInternal.c:539:20: warning: this statement may fall through [-Wimplicit-fallthrough=]
539 | if (!VBGLR0_CAN_USE_PHYS_PAGE_LIST(/*a_fLocked =*/ true))
| ^
/tmp/vbox.0/VBoxGuestR0LibHGCMInternal.c:547:13: note: here
547 | case VMMDevHGCMParmType_LinAddr_In:
| ^~~~
/tmp/vbox.0/VBoxGuestR0LibHGCMInternal.c: In function ‘vbglR0HGCMInternalCopyBackResult’:
/tmp/vbox.0/VBoxGuestR0LibHGCMInternal.c:807:20: warning: this statement may fall through [-Wimplicit-fallthrough=]
807 | if (!VBGLR0_CAN_USE_PHYS_PAGE_LIST(/*a_fLocked =*/ true))
| ^
/tmp/vbox.0/VBoxGuestR0LibHGCMInternal.c:814:13: note: here
814 | case VMMDevHGCMParmType_LinAddr_Out:
| ^~~~
make[3]: *** [/usr/src/linux-headers-5.4.0-4-common/scripts/Makefile.build:271: /tmp/vbox.0/VBoxGuestR0LibHGCMInternal.o] Error 1
make[2]: *** [/usr/src/linux-headers-5.4.0-4-common/Makefile:1665: /tmp/vbox.0] Error 2
make[1]: *** [/usr/src/linux-headers-5.4.0-4-common/Makefile:179: sub-make] Error 2
make: *** [/tmp/vbox.0/Makefile.include.footer:100: vboxguest] Error 2
我的编译器是:
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:hsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 9.2.1-30' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,gm2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-9 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-mutex
Thread model: posix
gcc version 9.2.1 20200224 (Debian 9.2.1-30)
答案1
问题似乎出在 virtualbox 安装附带的来宾添加 iso 上。最好的选择是从存储库下载来宾添加项。
- 运行
sudo apt install virtualbox-guest-additions-iso
以获取最新的存储库 - 访客 iso 将在里面下载
/usr/share/virtualbox/VBoxGuestAdditions.iso
- 创建挂载点并挂载iso:
sudo mkdir -p /mnt/cdrom && sudo mount /usr/share/virtualbox/VBoxGuestAdditions.iso /mnt/cdrom
- 导航到 iso 并安装:
cd /mnt/cdrom && sudo sh ./VBoxLinuxAdditions.run --nox11
答案2
fallthrough
虚拟机来宾添加驱动程序中与 gcc 属性相关的宏与 Linux 内核头文件之间似乎存在冲突。
具体来说,虚拟盒驱动程序定义了几个这样的宏:
root@vdebtest:/usr/src/vboxguest-5.1.38$ grep fallthrough -R
vboxvideo/include/iprt/cdefs.h:# define RT_FALL_THROUGH() __attribute__((fallthrough))
vboxguest/include/iprt/cdefs.h:# define RT_FALL_THROUGH() __attribute__((fallthrough))
vboxsf/include/iprt/cdefs.h:# define RT_FALL_THROUGH() __attribute__((fallthrough))
但在 Linux 内核中包含/linux/compiler_attributes.h,有这样的事情:
/*
* Add the pseudo keyword 'fallthrough' so case statement blocks
* must end with any of these keywords:
* break;
* fallthrough;
* goto <label>;
* return [expression];
*
* gcc: https://gcc.gnu.org/onlinedocs/gcc/Statement-Attributes.html#Statement-Attributes
*/
#if __has_attribute(__fallthrough__)
# define fallthrough __attribute__((__fallthrough__))
#else
# define fallthrough do {} while (0) /* fallthrough */
#endif
现在,如果我正确理解你的构建日志,我认为这些RT_FALL_THROUGH
s 实际上最终会变成__attribute__((__attribute__((__fallthrough__))))
,弄乱代码。
您可以尝试进入您的/usr/src/vboxguest-x.y.z
目录并将所有__attribute__((fallthrough))
(它们只是我的设置中的其中 3 个)替换为__attribute__((__fallthrough__))
吗? (falthrough
我想普通也应该有效)...
然后通过 重建所有这些./build_in_tmp
。
答案3
我终于解决了,花了1天时间尝试了多种解决方案。 VBoxLinuxAdditions.run 6.1.22 中存在错误,从您的主机升级到 Virtualbox 6.1.30,然后重复与许多其他帖子相同的步骤。