Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 843053 - media-video/v4l2loopback-0.12.5-r1: forces gcc even when kernel built with clang
Summary: media-video/v4l2loopback-0.12.5-r1: forces gcc even when kernel built with clang
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Aaron W. Swenson
URL:
Whiteboard:
Keywords:
: 907552 (view as bug list)
Depends on:
Blocks:
 
Reported: 2022-05-07 04:11 UTC by Logan Perkins
Modified: 2023-06-21 12:23 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Logan Perkins 2022-05-07 04:11:01 UTC
The ebuild for v4l2loopback overrides CC, LD, and related environment variables to point at gcc (and related tools).  This leads to compile time errors if the kernel used a different compiler (obvious example is clang, but a non-systemwide gcc may have the same issue).  

Reproducible: Always

Steps to Reproduce:
1. Build the kernel with CC=clang + LD=ld.lld
2. Invoke CC=clang LD=ld.lld emerge media-video/v4l2loopback
3. Observe error
Actual Results:  
The relevant section of the build log is:

warning: the compiler differs from the one used to build the kernel
  The kernel was built by: clang version 13.0.1
  You are using:           x86_64-pc-linux-gnu-gcc (Gentoo 11.2.1_p20220115 p4) 11.2.1 20220115
  CC [M]  /var/tmp/portage/media-video/v4l2loopback-0.12.5-r1/work/v4l2loopback-0.12.5/v4l2loopback.o
x86_64-pc-linux-gnu-gcc: error: unrecognized command-line option ‘-Qunused-arguments’
...

Expected Results:  
Package merges cleanly

The reason it can give the warning is because the built kernel sources record what compiler was used (and what options it was given).  Instead of guessing, the ebuild should pull this information.  It already does for the options to pass to the compiler, but not for the compiler executable itself.
Comment 1 ston jia 2023-03-22 15:21:19 UTC
I can confirm the bug too

```
>>> Verifying ebuild manifests

>>> Emerging (1 of 1) media-video/v4l2loopback-0.12.5-r1::gentoo
 * v4l2loopback-0.12.5.tar.gz BLAKE2B SHA512 size ;-) ...                                       [ ok ]
 * Determining the location of the kernel source code
 * Found kernel source directory:
 *     /usr/src/linux
 * Found sources for kernel version:
 *     6.2.7-gentoo
 * Checking for suitable kernel configuration options ...                                       [ ok ]
>>> Unpacking source...
>>> Unpacking v4l2loopback-0.12.5.tar.gz to /var/tmp/portage/media-video/v4l2loopback-0.12.5-r1/work
>>> Source unpacked in /var/tmp/portage/media-video/v4l2loopback-0.12.5-r1/work
>>> Preparing source in /var/tmp/portage/media-video/v4l2loopback-0.12.5-r1/work/v4l2loopback-0.12.5 ...
>>> Source prepared.
>>> Configuring source in /var/tmp/portage/media-video/v4l2loopback-0.12.5-r1/work/v4l2loopback-0.12.5 ...
>>> Source configured.
>>> Compiling source in /var/tmp/portage/media-video/v4l2loopback-0.12.5-r1/work/v4l2loopback-0.12.5 ...
ln: failed to create symbolic link 'Module.symvers': File exists
 * Preparing v4l2loopback module
make -j16 HOSTCC=x86_64-pc-linux-gnu-gcc 'LDFLAGS=-m elf_x86_64' all 
Building v4l2-loopback driver...
make -C /lib/modules/6.2.7-gentoo/build M=/var/tmp/portage/media-video/v4l2loopback-0.12.5-r1/work/v4l2loopback-0.12.5 modules
warning: the compiler differs from the one used to build the kernel
  The kernel was built by: clang version 15.0.7
  You are using:           x86_64-pc-linux-gnu-gcc (Gentoo 12.2.1_p20230304 p13) 12.2.1 20230304
  CC [M]  /var/tmp/portage/media-video/v4l2loopback-0.12.5-r1/work/v4l2loopback-0.12.5/v4l2loopback.o
x86_64-pc-linux-gnu-gcc: error: unrecognized command-line option ‘-Qunused-arguments’
x86_64-pc-linux-gnu-gcc: error: unrecognized command-line option ‘-mretpoline-external-thunk’
x86_64-pc-linux-gnu-gcc: error: unrecognized command-line option ‘-fsplit-lto-unit’
x86_64-pc-linux-gnu-gcc: error: unrecognized command-line option ‘-Wformat-invalid-specifier’
x86_64-pc-linux-gnu-gcc: error: unrecognized command-line option ‘-Wformat-insufficient-args’
make[2]: *** [scripts/Makefile.build:252: /var/tmp/portage/media-video/v4l2loopback-0.12.5-r1/work/v4l2loopback-0.12.5/v4l2loopback.o] Error 1
make[1]: *** [Makefile:2021: /var/tmp/portage/media-video/v4l2loopback-0.12.5-r1/work/v4l2loopback-0.12.5] Error 2
make: *** [Makefile:43: v4l2loopback.ko] Error 2
 * ERROR: media-video/v4l2loopback-0.12.5-r1::gentoo failed (compile phase):
 *   emake failed
 * 
 * If you need support, post the output of `emerge --info '=media-video/v4l2loopback-0.12.5-r1::gentoo'`,
 * the complete build log and the output of `emerge -pqv '=media-video/v4l2loopback-0.12.5-r1::gentoo'`.
 * The complete build log is located at '/var/tmp/portage/media-video/v4l2loopback-0.12.5-r1/temp/build.log'.
 * The ebuild environment file is located at '/var/tmp/portage/media-video/v4l2loopback-0.12.5-r1/temp/environment'.
 * Working directory: '/var/tmp/portage/media-video/v4l2loopback-0.12.5-r1/work/v4l2loopback-0.12.5'
 * S: '/var/tmp/portage/media-video/v4l2loopback-0.12.5-r1/work/v4l2loopback-0.12.5'

```
Comment 2 Ionen Wolkens gentoo-dev 2023-06-01 04:57:59 UTC
*** Bug 907552 has been marked as a duplicate of this bug. ***
Comment 3 Larry the Git Cow gentoo-dev 2023-06-21 08:29:54 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=032d9f3e8f89b760dc4d179a79128ae0490387b7

commit 032d9f3e8f89b760dc4d179a79128ae0490387b7
Author:     Andrew Ammerlaan <andrewammerlaan@gentoo.org>
AuthorDate: 2023-06-21 08:25:15 +0000
Commit:     Andrew Ammerlaan <andrewammerlaan@gentoo.org>
CommitDate: 2023-06-21 08:29:43 +0000

    media-video/v4l2loopback: migrate to linux-mod-r1.eclass, EAPI bump
    
    This should also fix Bug 843053 (please confirm that it works now)
    
    Should also fix the open CVE-2022-2652, the mentioned patch is in this release
    
    Bug: https://bugs.gentoo.org/864442
    Bug: https://bugs.gentoo.org/843053
    Closes: https://bugs.gentoo.org/888649
    Closes: https://bugs.gentoo.org/908723
    Signed-off-by: Andrew Ammerlaan <andrewammerlaan@gentoo.org>

 media-video/v4l2loopback/Manifest                  |  1 +
 .../v4l2loopback/v4l2loopback-0.12.7.ebuild        | 59 ++++++++++++++++++++++
 media-video/v4l2loopback/v4l2loopback-9999.ebuild  | 19 +++----
 3 files changed, 70 insertions(+), 9 deletions(-)
Comment 4 Tim Song 2023-06-21 12:22:31 UTC
Yes, I can confirm the bug has been fixed, I successfully compile it with clang16
Comment 5 Andrew Ammerlaan gentoo-dev 2023-06-21 12:23:25 UTC
Great, Thanks for testing