Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build failure: pkgsLLVM.kexec-tools #317526

Closed
RossComputerGuy opened this issue Jun 5, 2024 · 13 comments · Fixed by #317942
Closed

Build failure: pkgsLLVM.kexec-tools #317526

RossComputerGuy opened this issue Jun 5, 2024 · 13 comments · Fixed by #317942
Labels
0.kind: build failure 6.topic: llvm/clang Issues related to llvmPackages, clangStdenv and related

Comments

@RossComputerGuy
Copy link
Member

Steps To Reproduce

Steps to reproduce the behavior:

  1. build pkgsLLVM.kexec-tools

Build log

@nix { "action": "setPhase", "phase": "unpackPhase" }
Running phase: unpackPhase
unpacking source archive /nix/store/mf8zpph7ah0jxlcafxrypaypzw4cf4gv-kexec-tools-2.0.28.tar.xz
source root is kexec-tools-2.0.28
setting SOURCE_DATE_EPOCH to timestamp 1704972668 of file kexec-tools-2.0.28/kexec-tools.spec
@nix { "action": "setPhase", "phase": "patchPhase" }
Running phase: patchPhase
applying patch /nix/store/4pfhyc13jhz84b8973gxbydhx4fn9vxp-ppc64-elfv2.patch
patching file purgatory/arch/ppc64/Makefile
@nix { "action": "setPhase", "phase": "updateAutotoolsGnuConfigScriptsPhase" }
Running phase: updateAutotoolsGnuConfigScriptsPhase
Updating Autotools / GNU config script to a newer upstream version: ./config/config.sub
Updating Autotools / GNU config script to a newer upstream version: ./config/config.guess
@nix { "action": "setPhase", "phase": "configurePhase" }
Running phase: configurePhase
patching script interpreter paths in ./configure
./configure: interpreter directive changed from "#! /bin/sh" to "/nix/store/306znyj77fv49kwnkpxmb0j2znqpa8bj-bash-5.2p26/bin/sh"
configure flags: --prefix=/nix/store/xv9rlr1b0kc7qa4bdlr2n72ans49kbnk-kexec-tools-x86_64-unknown-linux-gnu-2.0.28 BUILD_CC=cc --build=x86_64-unknown-linux-gnu --host=x86_64-unknown-linux-gnu
checking for x86_64-unknown-linux-gnu-gcc... x86_64-unknown-linux-gnu-gcc
checking whether the C compiler works... no
configure: error: in `/build/kexec-tools-2.0.28':
configure: error: C compiler cannot create executables
See `config.log' for more details

Additional context

Add any other context about the problem here.

Notify maintainers

No maintainers, pinging @felixsinger from git blame.

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

 - system: `"x86_64-linux"`
 - host os: `Linux 6.1.0-18-amd64, Debian GNU/Linux, 12 (bookworm), nobuild`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.21.1`
 - channels(root): `"nixpkgs"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixpkgs`

Add a 👍 reaction to issues you find important.

@RossComputerGuy RossComputerGuy added 0.kind: build failure 6.topic: llvm/clang Issues related to llvmPackages, clangStdenv and related labels Jun 5, 2024
@RossComputerGuy
Copy link
Member Author

config.log has:

configure:2939: aarch64-unknown-linux-gnu-gcc -V >&5
aarch64-unknown-linux-gnu-gcc: error: unrecognized command-line option '-V'
aarch64-unknown-linux-gnu-gcc: fatal error: no input files
compilation terminated.
configure:2950: $? = 1
configure:2939: aarch64-unknown-linux-gnu-gcc -qversion >&5
aarch64-unknown-linux-gnu-gcc: error: unrecognized command-line option '-qversion'; did you mean '--version'?
aarch64-unknown-linux-gnu-gcc: fatal error: no input files
compilation terminated.
configure:2950: $? = 1
configure:2939: aarch64-unknown-linux-gnu-gcc -version >&5
aarch64-unknown-linux-gnu-gcc: error: unrecognized command-line option '-version'
aarch64-unknown-linux-gnu-gcc: fatal error: no input files
compilation terminated.
configure:2950: $? = 1
configure:2970: checking whether the C compiler works
configure:2992: aarch64-unknown-linux-gnu-gcc    conftest.c  >&5
/nix/store/v71nlgkf8g6d36gac9r44pmlx54mdql3-binutils-2.41/bin/ld: cannot find crt1.o: No such file or directory
/nix/store/v71nlgkf8g6d36gac9r44pmlx54mdql3-binutils-2.41/bin/ld: cannot find crti.o: No such file or directory
/nix/store/v71nlgkf8g6d36gac9r44pmlx54mdql3-binutils-2.41/bin/ld: cannot find -lgcc_s: No such file or directory
collect2: error: ld returned 1 exit status
configure:2996: $? = 1
configure:3036: result: no
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "kexec-tools"
| #define PACKAGE_TARNAME "kexec-tools"
| #define PACKAGE_VERSION "2.0.28"
| #define PACKAGE_STRING "kexec-tools 2.0.28"
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL ""
| /* end confdefs.h.  */
|
| int
| main (void)
| {
|
|   ;
|   return 0;
| }
configure:3041: error: in `/build/kexec-tools-2.0.28':
configure:3043: error: C compiler cannot create executables
See `config.log' for more details

@paparodeo
Copy link
Contributor

need to edit all-packages.nix to unpin gccStdenv

  kexec-tools = callPackage ../os-specific/linux/kexec-tools {
    # clangStdenv fails with
    # purgatory/arch/i386/entry32-16.S:23:2: error: unknown directive
    #  .arch i386
    #  ^
    # purgatory/arch/i386/entry32-16.S:115:11: error: unknown token in expression
    #  ljmp %cs:*(realdest - entry16)
    #           ^
    # make: *** [Makefile:128: purgatory/arch/i386/entry32-16.o] Error 1
    stdenv = gccStdenv;
  };

will get past configure but fails at link step for a different reason

@RossComputerGuy
Copy link
Member Author

RossComputerGuy commented Jun 7, 2024

will get past configure but fails at link step for a different reason

Looks like clang doesn't understand the assembly syntax kexec-tools uses which appears to be the GNU/GCC style. I see pixman has had a similar problem before which the solution for them is to disable assembly. We don't have that luxury here. We have two solutions but both requires patches:

  1. Change the assembly files to use a syntax clang accepts
  2. Use a different assembler

With the first one, it sounds like ARM has something called UAL (Unified Assembly Language) so we might be able to use that. With the second one, it looks like kexec-tools just uses the CC for the assembler so we would have to patch the Makefiles. Personally, I think the 2nd option is the best here but it looks like this is a part of the Linux kernel git server I think inquiring upstream to look into this is not a bad idea.

@paparodeo
Copy link
Contributor

on x64 linux with gccStdenv removed i get a link error:

x86_64-unknown-linux-gnu-clang -fno-zero-initialized-in-bss -mcmodel=large -Os -fno-builtin -ffreestanding -fno-zero-initialized-in-bss -fno-PIC -fno-PIE -fno-stack-protector -fno-tree-vectorize -mcmodel=large -Wl,--no-undefined -nostartfiles -nostdlib -nodefaultlibs -e purgatory_start -r -Wl,-Map=purgatory/purgatory.map -o purgatory/purgatory.ro.sym purgatory/purgatory.o purgatory/printf.o purgatory/string.o purgatory/arch/x86_64/entry64-32.o purgatory/arch/x86_64/entry64.o purgatory/arch/x86_64/setup-x86_64.o purgatory/arch/x86_64/stack.o purgatory/arch/x86_64/purgatory-x86_64.o purgatory/arch/i386/entry32-16.o purgatory/arch/i386/entry32-16-debug.o purgatory/arch/i386/crashdump_backup.o purgatory/arch/i386/console-x86.o purgatory/arch/i386/vga.o purgatory/arch/i386/pic.o purgatory/sha256.o
x86_64-unknown-linux-gnu-ld: error: attempted static link of dynamic object /nix/store/k3l71w9p5wcbzh0fqcjg0svbap8xla4g-libunwind-x86_64-unknown-linux-gnu-17.0.6/lib/libunwind.so

though /nix/store/k3l71w9p5wcbzh0fqcjg0svbap8xla4g-libunwind-x86_64-unknown-linux-gnu-17.0.6/lib/libunwind.a exists not sure why it is trying to use libunwind.so if it is trying to statically link.

@RossComputerGuy
Copy link
Member Author

RossComputerGuy commented Jun 7, 2024

@paparodeo Yeah, I see that error as well but on aarch64-linux. Not sure why it failed to link things right.

@RossComputerGuy
Copy link
Member Author

I was able to use --keep-failed and run the failed command with -v:

clang version 17.0.6
Target: aarch64-unknown-linux-gnu
Thread model: posix
InstalledDir: /nix/store/0krr0hxfrh9fzl5c9w1lvy22p6fa1xw7-clang-17.0.6/bin
 "/nix/store/g7p2kxa3909bzj2vnbpzszyz2qhr1hg0-aarch64-unknown-linux-gnu-clang-wrapper-17.0.6/bin/aarch64-unknown-linux-gnu-ld" -EL --hash-style=gnu --eh-frame-hdr -m aarch64linux -o purgatory/purgatory.ro.sym -L/nix/store/rc85r09xkl92pga3cq5fgm2nr76llfg4-libcxx-aarch64-unknown-linux-gnu-17.0.6/lib -L/nix/store/2aqakjqjfj5kw644kkmyf3l30hk0x0rf-libunwind-aarch64-unknown-linux-gnu-17.0.6/lib -L/nix/store/dxwzgmb67wslibsidbhr77vf60n5mfpf-zlib-aarch64-unknown-linux-gnu-1.3.1/lib -L/nix/store/v0rr57xna17a8vn6fwsfz0c20n62cydy-glibc-aarch64-unknown-linux-gnu-2.39-52/lib -L/nix/store/ry9ak1v7al43mscn3l7p54v8r5yfj9xa-clang-17.0.6-lib/aarch64-unknown-linux-gnu/lib -L/nix/store/2aqakjqjfj5kw644kkmyf3l30hk0x0rf-libunwind-aarch64-unknown-linux-gnu-17.0.6/lib -dynamic-linker=/nix/store/v0rr57xna17a8vn6fwsfz0c20n62cydy-glibc-aarch64-unknown-linux-gnu-2.39-52/lib/ld-linux-aarch64.so.1 --no-undefined -e purgatory_start -r -Map=purgatory/purgatory.map purgatory/purgatory.o purgatory/printf.o purgatory/string.o purgatory/arch/arm64/entry.o purgatory/arch/arm64/purgatory-arm64.o purgatory/sha256.o -lunwind -rpath /nix/store/j4n12jw7dkpmxm0v75pzxi0iiqy9z4di-kexec-tools-aarch64-unknown-linux-gnu-2.0.28/lib

@RossComputerGuy
Copy link
Member Author

I have discovered that adding -static makes the command work.

@paparodeo
Copy link
Contributor

I have discovered that adding -static makes the command work.

i guess the clang linker is not happy. i can build fine using clangStdenv which uses gnu binutils ld i believe.

@RossComputerGuy
Copy link
Member Author

i can build fine using clangStdenv which uses gnu binutils ld i believe.

Doesn't work for me. I still get the same error during the build phase.

@paparodeo
Copy link
Contributor

i can build fine using clangStdenv which uses gnu binutils ld i believe.

Doesn't work for me. I still get the same error during the build phase.

nix-build --expr 'with import ./. {}; kexec-tools.override { stdenv = clangStdenv; }'

?

@RossComputerGuy
Copy link
Member Author

Oh no, I'm doing: nix-build --expr 'with (import ./. {}).pkgsLLVM; kexec-tools.override { stdenv = clangStdenv; }'. Using the non-LLVM package set works but this issue is with pkgsLLVM.kexec-tools.

@RossComputerGuy
Copy link
Member Author

I made a patch for one of the Makefiles and applying the clangStdenv , works with pkgsLLVM. Will PR it now.

RossComputerGuy added a commit to ExpidusOS/nixpkgs that referenced this issue Jun 7, 2024
RossComputerGuy added a commit to ExpidusOS/nixpkgs that referenced this issue Jun 7, 2024
@paparodeo
Copy link
Contributor

paparodeo commented Jun 9, 2024

seems like an lld problem. it is searching for '.so' files when building a relocatable image but should be searching for .a files. this patch fixes it.

error is coming from:

  case file_magic::elf_shared_object: {
    if (config->isStatic || config->relocatable) {
      error("attempted static link of dynamic object " + path);
      return;
    }
diff --git a/lld/ELF/DriverUtils.cpp b/lld/ELF/DriverUtils.cpp
index ac7460440..77214aa36 100644
--- a/lld/ELF/DriverUtils.cpp
+++ b/lld/ELF/DriverUtils.cpp
@@ -234,7 +234,7 @@ std::optional<std::string> elf::findFromSearchPaths(StringRef path) {
 // search paths.
 std::optional<std::string> elf::searchLibraryBaseName(StringRef name) {
   for (StringRef dir : config->searchPaths) {
-    if (!config->isStatic)
+    if (!(config->isStatic || config->relocatable))
       if (std::optional<std::string> s = findFile(dir, "lib" + name + ".so"))
         return s;
     if (std::optional<std::string> s = findFile(dir, "lib" + name + ".a"))

filed llvm/llvm-project#94958

also, i'm not sure that linking with -lunwind unconditionally is correct but i'm a bit foggy on when unwind is required

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: build failure 6.topic: llvm/clang Issues related to llvmPackages, clangStdenv and related
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants