Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 885483 - x11-drivers/nvidia-drivers-525.60.13[kernel-open]: ld.lld: error: target emulation unknown
Summary: x11-drivers/nvidia-drivers-525.60.13[kernel-open]: ld.lld: error: target emul...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Ionen Wolkens
URL: https://github.com/NVIDIA/open-gpu-ke...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-12-11 18:21 UTC by Frederik Pfautsch
Modified: 2022-12-11 19:12 UTC (History)
2 users (show)

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


Attachments
emerge --info (emerge-info.txt,22.45 KB, text/plain)
2022-12-11 18:21 UTC, Frederik Pfautsch
Details
nvidia-drivers build.log (build.log.bz2,34.56 KB, application/octet-stream)
2022-12-11 18:22 UTC, Frederik Pfautsch
Details
ld.lld gentoo patch (link_xz_o.patch,789 bytes, patch)
2022-12-11 18:23 UTC, Frederik Pfautsch
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Frederik Pfautsch 2022-12-11 18:21:51 UTC
Created attachment 841489 [details]
emerge --info

The build of nvidia-drivers[kernel-open] aborts with

mkdir -p _out/Linux_x86_64
cd _out/Linux_x86_64/; ld.lld -r -z noexecstack --format=binary turing_shaders.xz -o /var/tmp/portage/x11-drivers/nvidia-drivers-525.60.13/work/kernel-module-source/src/nvidia-modeset/_out/Linux_x86_64/turing_shaders.xz.o
ld.lld: error: target emulation unknown: -m or at least one .o file required
make[1]: *** [Makefile:192: _out/Linux_x86_64/turing_shaders.xz.o] Error 1

Linux is compiled using clang-15.0.5 with LTO (gentoo-sources-6.0.12). 

A similar issue was discussed on nvidia's github (https://github.com/NVIDIA/open-gpu-kernel-modules/issues/405), however it turned out to be a different problem. The fix proposed during the discussion fixes this issue for me. It does not seem like it was further considered for merging.

I adjusted the proposed to Gentoo's folder structure and attached it below. Not sure if it should be fixed on Nvidia's side or (also) here. It does not seem like the Makefile is considering LDFLAGS in general. In the ebuild I can see that adding the -m flag has been done for compiling the tools.
Comment 1 Frederik Pfautsch 2022-12-11 18:22:47 UTC
Created attachment 841491 [details]
nvidia-drivers build.log
Comment 2 Frederik Pfautsch 2022-12-11 18:23:34 UTC
Created attachment 841493 [details, diff]
ld.lld gentoo patch
Comment 3 Ionen Wolkens gentoo-dev 2022-12-11 19:05:58 UTC
(In reply to Frederik Pfautsch from comment #2)
> Created attachment 841493 [details, diff] [details, diff]
> ld.lld gentoo patch
>-	$$(call quiet_cmd_no_at,LD) -r -z noexecstack --format=binary \
>+	$$(call quiet_cmd_no_at,LD) -r -z noexecstack -m elf_x86_64 --format=binary \
That wouldn't quite work for aarch64 (nvidia-drivers is available there). But not the first of this issue, just have to copy what previously did for nvidia-settings until nvidia comes up with their own solution.
Comment 4 Larry the Git Cow gentoo-dev 2022-12-11 19:12:46 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=1093d6cf18080fded4f22ca5aa04c869fff1c4e7

commit 1093d6cf18080fded4f22ca5aa04c869fff1c4e7
Author:     Ionen Wolkens <ionen@gentoo.org>
AuthorDate: 2022-12-11 18:41:59 +0000
Commit:     Ionen Wolkens <ionen@gentoo.org>
CommitDate: 2022-12-11 19:11:29 +0000

    x11-drivers/nvidia-drivers: pass raw-ldflags for USE=kernel-open too
    
    Same as nvidia-settings-390.144-raw-ldflags.patch, but applied
    to kernel-module-source. Not a perfect fix given profiles don't
    define LDFLAGS_arm64, but that's not a high priority and can
    wait for nvidia's fix.
    
    Note that modules are still generally fragile and untested with
    llvm toolchain.
    
    Closes: https://bugs.gentoo.org/885483
    Signed-off-by: Ionen Wolkens <ionen@gentoo.org>

 .../nvidia-kernel-module-source-515.86.01-raw-ldflags.patch | 13 +++++++++++++
 x11-drivers/nvidia-drivers/nvidia-drivers-515.49.25.ebuild  |  4 ++--
 x11-drivers/nvidia-drivers/nvidia-drivers-515.86.01.ebuild  |  4 ++--
 x11-drivers/nvidia-drivers/nvidia-drivers-525.60.11.ebuild  |  4 ++--
 x11-drivers/nvidia-drivers/nvidia-drivers-525.60.13.ebuild  |  4 ++--
 5 files changed, 21 insertions(+), 8 deletions(-)