虽然无法重新安装 cc1,但由于缺少 cc1,amdgpu-dkms 无法构建?

虽然无法重新安装 cc1,但由于缺少 cc1,amdgpu-dkms 无法构建?

我目前正在尝试更新 Ubuntu 上的 AMD 驱动程序/还下载用于 blender 循环渲染的 HIP 驱动程序。问题是,当我使用最新的 amdgpu-install 脚本(带有配置:)安装它时,sudo amdgpu-install --usecase=graphics,hip我收到以下错误:

cpp: fatal error: cannot execute 'cc1': execvp: No such file or directory
compilation terminated.
configure: error: *** Cannot determine kernel version.
ERROR: Cannot create report: [Errno 17] File exists: '/var/crash/amdgpu-dkms.0.crash'
Error! Bad return status for module build on kernel: 5.15.0-76-generic (x86_64)
Consult /var/lib/dkms/amdgpu/6.1.5-1609671.22.04/build/make.log for more information.
dpkg: error processing package amdgpu-dkms (--configure):
 installed amdgpu-dkms package post-installation script subprocess returned error exit status 10
Errors were encountered while processing:
 amdgpu-dkms
E: Sub-process /usr/bin/dpkg returned an error code (1)

在网上搜索,这个 cc1 错误似乎相当常见,可以通过在你的安装中找到 cc1(如果它存在于你的安装中)并在你的 gcc 文件夹中创建指向它的符号链接来修复,而我无法做到这一点,因为 cc1 只是在我的系统上找不到。

或者重新安装 build-essential(apt 上的一个安装 gcc、g++、cmake 等的包)。但是我也无法做到这一点,因为每当我使用任何与 apt 相关的命令时,它都会尝试构建 amdgpu-dkms,但显然无法构建,这反过来又导致整个 apt 命令失败如图所示。

如果有帮助的话,这里是/var/lib/dkms/amdgpu/6.1.5-1609671.22.04/build/make.log

DKMS make.log for amdgpu-6.1.5-1609671.22.04 for kernel 5.15.0-76-generic (x86_64)
Mon 10 Jul 2023 00:26:58 AEST
make: Entering directory '/usr/src/linux-headers-5.15.0-76-generic'
warning: the compiler differs from the one used to build the kernel
  The kernel was built by: gcc (Ubuntu 11.3.0-1ubuntu1~22.04.1) 11.3.0
  You are using:           gcc (Ubuntu 12.1.0-2ubuntu1~22.04) 12.1.0
/var/lib/dkms/amdgpu/6.1.5-1609671.22.04/build/Makefile:17: "Local GCC version 120100 does not match kernel compiler GCC version 110300"
/var/lib/dkms/amdgpu/6.1.5-1609671.22.04/build/Makefile:18: "This may cause unexpected and hard-to-isolate compiler-related issues"
/var/lib/dkms/amdgpu/6.1.5-1609671.22.04/build/Makefile:219: "The local C standard(gnu89) doesn't match kernel default C standard(gnu11/gnu99)"
  CC [M]  /var/lib/dkms/amdgpu/6.1.5-1609671.22.04/build/drm_gem_ttm_helper.o
  CC [M]  /var/lib/dkms/amdgpu/6.1.5-1609671.22.04/build/drm_buddy.o
  CC [M]  /var/lib/dkms/amdgpu/6.1.5-1609671.22.04/build/scheduler/sched_main.o
  CC [M]  /var/lib/dkms/amdgpu/6.1.5-1609671.22.04/build/scheduler/sched_fence.o
  CC [M]  /var/lib/dkms/amdgpu/6.1.5-1609671.22.04/build/scheduler/sched_entity.o
  CC [M]  /var/lib/dkms/amdgpu/6.1.5-1609671.22.04/build/ttm/ttm_tt.o
  CC [M]  /var/lib/dkms/amdgpu/6.1.5-1609671.22.04/build/amd/amdkcl/main.o
  CC [M]  /var/lib/dkms/amdgpu/6.1.5-1609671.22.04/build/amd/amdgpu/amdgpu_drv.o
  CC [M]  /var/lib/dkms/amdgpu/6.1.5-1609671.22.04/build/amd/amdkcl/symbols.o
  CC [M]  /var/lib/dkms/amdgpu/6.1.5-1609671.22.04/build/amd/amdkcl/kcl_common.o
In file included from /var/lib/dkms/amdgpu/6.1.5-1609671.22.04/build/include/kcl/kcl_iosys-map.h:10,
                 from /var/lib/dkms/amdgpu/6.1.5-1609671.22.04/build/ttm/backport/backport.h:10,
                 from <command-line>:
/var/lib/dkms/amdgpu/6.1.5-1609671.22.04/build/include/kcl/header/linux/iosys-map.h:5:15: fatal error: linux/iosys-map.h: No such file or directory
    5 | #include_next <linux/iosys-map.h>
      |               ^~~~~~~~~~~~~~~~~~~
compilation terminated.
make[1]: *** [scripts/Makefile.build:297: /var/lib/dkms/amdgpu/6.1.5-1609671.22.04/build/drm_gem_ttm_helper.o] Error 1
make[1]: *** Waiting for unfinished jobs....
  CC [M]  /var/lib/dkms/amdgpu/6.1.5-1609671.22.04/build/amd/amdgpu/amdgpu_device.o
In file included from /var/lib/dkms/amdgpu/6.1.5-1609671.22.04/build/include/kcl/kcl_iosys-map.h:10,
                 from /var/lib/dkms/amdgpu/6.1.5-1609671.22.04/build/amd/backport/backport.h:14,
                 from <command-line>:
/var/lib/dkms/amdgpu/6.1.5-1609671.22.04/build/include/kcl/header/linux/iosys-map.h:5:15: fatal error: linux/iosys-map.h: No such file or directory
    5 | #include_next <linux/iosys-map.h>
      |               ^~~~~~~~~~~~~~~~~~~
compilation terminated.
In file included from /var/lib/dkms/amdgpu/6.1.5-1609671.22.04/build/include/kcl/kcl_iosys-map.h:10,
                 from /var/lib/dkms/amdgpu/6.1.5-1609671.22.04/build/ttm/backport/backport.h:10,
                 from <command-line>:
/var/lib/dkms/amdgpu/6.1.5-1609671.22.04/build/include/kcl/header/linux/iosys-map.h:5:15: fatal error: linux/iosys-map.h: No such file or directory
    5 | #include_next <linux/iosys-map.h>
      |               ^~~~~~~~~~~~~~~~~~~
compilation terminated.
In file included from /var/lib/dkms/amdgpu/6.1.5-1609671.22.04/build/scheduler/sched_main.c:51:
/var/lib/dkms/amdgpu/6.1.5-1609671.22.04/build/include/linux/dma-resv.h: In function ‘dma_resv_trylock’:
/var/lib/dkms/amdgpu/6.1.5-1609671.22.04/build/include/linux/dma-resv.h:330:16: error: too many arguments to function ‘ww_mutex_trylock’
  330 |         return ww_mutex_trylock(&obj->lock, NULL);
      |                ^~~~~~~~~~~~~~~~
In file included from ./include/linux/seqlock.h:20,
                 from ./include/linux/hrtimer.h:20,
                 from ./include/linux/sched.h:19,
                 from /var/lib/dkms/amdgpu/6.1.5-1609671.22.04/build/include/kcl/backport/kcl_kthread_backport.h:4,
                 from /var/lib/dkms/amdgpu/6.1.5-1609671.22.04/build/scheduler/backport/backport.h:7,
                 from <command-line>:
./include/linux/ww_mutex.h:349:32: note: declared here
  349 | static inline int __must_check ww_mutex_trylock(struct ww_mutex *lock)
      |                                ^~~~~~~~~~~~~~~~
make[2]: *** [scripts/Makefile.build:297: /var/lib/dkms/amdgpu/6.1.5-1609671.22.04/build/amd/amdgpu/amdgpu_drv.o] Error 1
make[2]: *** [scripts/Makefile.build:297: /var/lib/dkms/amdgpu/6.1.5-1609671.22.04/build/ttm/ttm_tt.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [scripts/Makefile.build:560: /var/lib/dkms/amdgpu/6.1.5-1609671.22.04/build/ttm] Error 2
  CC [M]  /var/lib/dkms/amdgpu/6.1.5-1609671.22.04/build/amd/amdkcl/kcl_kernel_params.o
  CC [M]  /var/lib/dkms/amdgpu/6.1.5-1609671.22.04/build/amd/amdkcl/dma-buf/dma-resv.o
make[2]: *** [scripts/Makefile.build:297: /var/lib/dkms/amdgpu/6.1.5-1609671.22.04/build/scheduler/sched_main.o] Error 1
make[2]: *** Waiting for unfinished jobs....
  CC [M]  /var/lib/dkms/amdgpu/6.1.5-1609671.22.04/build/amd/amdkcl/kcl_backlight.o
  CC [M]  /var/lib/dkms/amdgpu/6.1.5-1609671.22.04/build/amd/amdkcl/kcl_ioctl.o
In file included from /var/lib/dkms/amdgpu/6.1.5-1609671.22.04/build/amd/amdkcl/dma-buf/dma-resv.c:36:
/var/lib/dkms/amdgpu/6.1.5-1609671.22.04/build/include/linux/dma-resv.h: In function ‘dma_resv_trylock’:
/var/lib/dkms/amdgpu/6.1.5-1609671.22.04/build/include/linux/dma-resv.h:330:16: error: too many arguments to function ‘ww_mutex_trylock’
  330 |         return ww_mutex_trylock(&obj->lock, NULL);
      |                ^~~~~~~~~~~~~~~~
In file included from /var/lib/dkms/amdgpu/6.1.5-1609671.22.04/build/include/linux/dma-resv.h:42:
./include/linux/ww_mutex.h:349:32: note: declared here
  349 | static inline int __must_check ww_mutex_trylock(struct ww_mutex *lock)
      |                                ^~~~~~~~~~~~~~~~
In file included from /var/lib/dkms/amdgpu/6.1.5-1609671.22.04/build/include/kcl/kcl_iosys-map.h:10,
                 from /var/lib/dkms/amdgpu/6.1.5-1609671.22.04/build/amd/backport/backport.h:14,
                 from <command-line>:
/var/lib/dkms/amdgpu/6.1.5-1609671.22.04/build/include/kcl/header/linux/iosys-map.h:5:15: fatal error: linux/iosys-map.h: No such file or directory
    5 | #include_next <linux/iosys-map.h>
      |               ^~~~~~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [scripts/Makefile.build:297: /var/lib/dkms/amdgpu/6.1.5-1609671.22.04/build/amd/amdgpu/amdgpu_device.o] Error 1
make[1]: *** [scripts/Makefile.build:560: /var/lib/dkms/amdgpu/6.1.5-1609671.22.04/build/amd/amdgpu] Error 2
  CC [M]  /var/lib/dkms/amdgpu/6.1.5-1609671.22.04/build/amd/amdkcl/kcl_kthread.o
  CC [M]  /var/lib/dkms/amdgpu/6.1.5-1609671.22.04/build/amd/amdkcl/kcl_io.o
In file included from ./arch/x86/include/asm/bug.h:86,
                 from ./include/linux/bug.h:5,
                 from ./include/linux/cpumask.h:14,
                 from ./include/linux/smp.h:13,
                 from ./include/linux/lockdep.h:14,
                 from ./include/linux/mutex.h:17,
                 from ./include/linux/ww_mutex.h:20:
/var/lib/dkms/amdgpu/6.1.5-1609671.22.04/build/amd/amdkcl/dma-buf/dma-resv.c: In function ‘amddma_resv_add_fence’:
/var/lib/dkms/amdgpu/6.1.5-1609671.22.04/build/amd/amdkcl/dma-buf/dma-resv.c:287:17: error: implicit declaration of function ‘dma_fence_is_container’; did you mean ‘dma_fence_is_later’? [-Werror=implicit-function-declaration]
  287 |         WARN_ON(dma_fence_is_container(fence));
      |                 ^~~~~~~~~~~~~~~~~~~~~~
./include/asm-generic/bug.h:121:32: note: in definition of macro ‘WARN_ON’
  121 |         int __ret_warn_on = !!(condition);                              \
      |                                ^~~~~~~~~
  CC [M]  /var/lib/dkms/amdgpu/6.1.5-1609671.22.04/build/amd/amdkcl/kcl_seq_file.o
/var/lib/dkms/amdgpu/6.1.5-1609671.22.04/build/amd/amdkcl/dma-buf/dma-resv.c: In function ‘amddma_resv_describe’:
/var/lib/dkms/amdgpu/6.1.5-1609671.22.04/build/amd/amdkcl/dma-buf/dma-resv.c:726:17: error: implicit declaration of function ‘dma_fence_describe’; did you mean ‘dma_resv_describe’? [-Werror=implicit-function-declaration]
  726 |                 dma_fence_describe(fence, seq);
      |                 ^~~~~~~~~~~~~~~~~~
      |                 dma_resv_describe
cc1: some warnings being treated as errors
make[2]: *** [scripts/Makefile.build:297: /var/lib/dkms/amdgpu/6.1.5-1609671.22.04/build/amd/amdkcl/dma-buf/dma-resv.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [scripts/Makefile.build:560: /var/lib/dkms/amdgpu/6.1.5-1609671.22.04/build/scheduler] Error 2
make[1]: *** [scripts/Makefile.build:560: /var/lib/dkms/amdgpu/6.1.5-1609671.22.04/build/amd/amdkcl] Error 2
make: *** [Makefile:1914: /var/lib/dkms/amdgpu/6.1.5-1609671.22.04/build] Error 2
make: Leaving directory '/usr/src/linux-headers-5.15.0-76-generic'

我从中得到的结论是,我的 gcc/g++ 版本与我的内核版本不同,所以我尝试通过 update-alternatives 将默认的 gcc/g++ 版本改回 gcc-11/g++-12(我之前手动将它们更新到版本 12),但这没有帮助。

我还发现了它提到的另一个日志,config.log:

This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.

It was created by amdgpu-dkms configure 6.1.5, which was
generated by GNU Autoconf 2.71.  Invocation command line was

  $ ./configure

## --------- ##
## Platform. ##
## --------- ##

hostname = rahul-B550M-H
uname -m = x86_64
uname -r = 5.15.0-76-generic
uname -s = Linux
uname -v = #83-Ubuntu SMP Thu Jun 15 19:16:32 UTC 2023

/usr/bin/uname -p = x86_64
/bin/uname -X     = unknown

/bin/arch              = x86_64
/usr/bin/arch -k       = unknown
/usr/convex/getsysinfo = unknown
/usr/bin/hostinfo      = unknown
/bin/machine           = unknown
/usr/bin/oslevel       = unknown
/bin/universe          = unknown

PATH: /bin/
PATH: /sbin/
PATH: /usr/bin/
PATH: /usr/sbin/
PATH: /usr/lib/dkms/


## ----------- ##
## Core tests. ##
## ----------- ##

configure:2131: looking for aux files: install-sh
configure:2144:  trying ./config/
configure:2155:   ./config/install-sh found
configure:2310: checking for a BSD-compatible install
configure:2383: result: /bin/install -c
configure:2456: checking for gcc
configure:2488: result: gcc
configure:2841: checking for C compiler version
configure:2850: gcc --version >&5
gcc (Ubuntu 11.3.0-1ubuntu1~22.04.1) 11.3.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

configure:2861: $? = 0
configure:2850: gcc -v >&5
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/11/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 11.3.0-1ubuntu1~22.04.1' --with-bugurl=file:///usr/share/doc/gcc-11/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-11 --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 --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --enable-cet --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-11-aYxV0E/gcc-11-11.3.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-11-aYxV0E/gcc-11-11.3.0/debian/tmp-gcn/usr --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-serialization=2
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.3.0 (Ubuntu 11.3.0-1ubuntu1~22.04.1) 
... rest of stderr output deleted ...
configure:2861: $? = 0
configure:2850: gcc -V >&5
gcc: error: unrecognized command-line option '-V'
gcc: fatal error: no input files
compilation terminated.
configure:2861: $? = 1
configure:2850: gcc -qversion >&5
gcc: error: unrecognized command-line option '-qversion'; did you mean '--version'?
gcc: fatal error: no input files
compilation terminated.
configure:2861: $? = 1
configure:2850: gcc -version >&5
gcc: error: unrecognized command-line option '-version'
gcc: fatal error: no input files
compilation terminated.
configure:2861: $? = 1
configure:2881: checking whether the C compiler works
configure:2903: gcc    conftest.c  >&5
gcc: fatal error: cannot execute 'cc1': execvp: No such file or directory
compilation terminated.
configure:2907: $? = 1
configure:2947: result: no
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "amdgpu-dkms"
| #define PACKAGE_TARNAME "amdgpu-dkms"
| #define PACKAGE_VERSION "6.1.5"
| #define PACKAGE_STRING "amdgpu-dkms 6.1.5"
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL ""
| /* end confdefs.h.  */
| 
| int
| main (void)
| {
| 
|   ;
|   return 0;
| }
configure:2952: error: in `/var/lib/dkms/amdgpu/6.1.5-1609671.22.04/build/amd/dkms':
configure:2954: error: C compiler cannot create executables
See `config.log' for more details

## ---------------- ##
## Cache variables. ##
## ---------------- ##

ac_cv_env_CC_set=set
ac_cv_env_CC_value=gcc
ac_cv_env_CFLAGS_set=
ac_cv_env_CFLAGS_value=
ac_cv_env_CPPFLAGS_set=
ac_cv_env_CPPFLAGS_value=
ac_cv_env_CPP_set=
ac_cv_env_CPP_value=
ac_cv_env_LDFLAGS_set=
ac_cv_env_LDFLAGS_value=
ac_cv_env_LIBS_set=
ac_cv_env_LIBS_value=
ac_cv_env_build_alias_set=
ac_cv_env_build_alias_value=
ac_cv_env_host_alias_set=
ac_cv_env_host_alias_value=
ac_cv_env_target_alias_set=
ac_cv_env_target_alias_value=
ac_cv_path_install='/bin/install -c'
ac_cv_prog_ac_ct_CC=gcc

## ----------------- ##
## Output variables. ##
## ----------------- ##

CC='gcc'
CFLAGS=''
CPP=''
CPPFLAGS=''
DEFS=''
ECHO_C=''
ECHO_N='-n'
ECHO_T=''
EXEEXT=''
INSTALL_DATA='${INSTALL} -m 644'
INSTALL_PROGRAM='${INSTALL}'
INSTALL_SCRIPT='${INSTALL}'
KERNEL_MAKE=''
LDFLAGS=''
LIBOBJS=''
LIBS=''
LINUX=''
LINUX_OBJ=''
LINUX_SYMBOLS=''
LINUX_VERSION=''
LTLIBOBJS=''
NPROC=''
OBJEXT=''
PACKAGE_BUGREPORT=''
PACKAGE_NAME='amdgpu-dkms'
PACKAGE_STRING='amdgpu-dkms 6.1.5'
PACKAGE_TARNAME='amdgpu-dkms'
PACKAGE_URL=''
PACKAGE_VERSION='6.1.5'
PATH_SEPARATOR=':'
SHELL='/bin/bash'
ac_ct_CC='gcc'
bindir='${exec_prefix}/bin'
build_alias=''
datadir='${datarootdir}'
datarootdir='${prefix}/share'
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
dvidir='${docdir}'
exec_prefix='NONE'
host_alias=''
htmldir='${docdir}'
includedir='${prefix}/include'
infodir='${datarootdir}/info'
libdir='${exec_prefix}/lib'
libexecdir='${exec_prefix}/libexec'
localedir='${datarootdir}/locale'
localstatedir='${prefix}/var'
mandir='${datarootdir}/man'
oldincludedir='/usr/include'
pdfdir='${docdir}'
prefix='NONE'
program_transform_name='s,x,x,'
psdir='${docdir}'
runstatedir='${localstatedir}/run'
sbindir='${exec_prefix}/sbin'
sharedstatedir='${prefix}/com'
sysconfdir='${prefix}/etc'
target_alias=''

## ----------- ##
## confdefs.h. ##
## ----------- ##

/* confdefs.h */
#define PACKAGE_NAME "amdgpu-dkms"
#define PACKAGE_TARNAME "amdgpu-dkms"
#define PACKAGE_VERSION "6.1.5"
#define PACKAGE_STRING "amdgpu-dkms 6.1.5"
#define PACKAGE_BUGREPORT ""
#define PACKAGE_URL ""

configure: exit 77

从那以后,在我看来,当测试 gcc 是否工作时,它会尝试编译某个名为 conftest.c 的文件,但由于缺少 cc1 而失败。但我自己仍然无法使用它来解决问题。

我对 Linux 还很陌生,所以任何帮助我都会很感激,无论是修复问题还是仅仅能够重新安装 build-essential 而不触发 amdgpu-dkms 进行构建。提前谢谢!

顺便说一下,我的系统信息是:

OS: Kubuntu 22.04.2 LTS x86_64 
Host: B550M H 
Kernel: 5.15.0-76-generic 
CPU: AMD Ryzen 3 3300X (8) @ 3.792GHz 
GPU: AMD ATI Radeon RX 6600

相关内容