unofficial mirror of help-guix@gnu.org 
 help / color / mirror / Atom feed
From: Christina O'Donnell <cdo@mutix.org>
To: help-guix@gnu.org
Subject: trivial-build-system: ld can't find existing store files
Date: Sun, 14 Jan 2024 11:10:03 +0000	[thread overview]
Message-ID: <0ba16b42-6c3b-5b31-3dc7-038bf8282fbe@mutix.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 4037 bytes --]

Hey Guix!

I've been banging my head against this one for a while and I'd appreciate if
someone could take a look at it quickly, and spot where I went wrong.

So I'm trying to write a package with a single C file using
trivial-build-system[1]. I feel like I'm almost there, except when 
building the
linker fails to find the glibc object files that I definitely specified. 
What
makes this seem odd to me is: the same command succeeds if I run in a 
container
shell with only the dependencies and guile used.

I've attached the following files:

  - evhz.scm - containing the package definition that I just have in
    /gnu/packages/ in my checkout. (this is the only change)
  - build-evhz.out - the output of ./pre-inst-env guix build evhz
  - manual-gcc.out - the output of the command running the invoke gcc 
command
    in a guix-shell container

I've tried the following:

  - make clean and tried a few different master branch versions to see 
if that
    might shake it into action, but no avail.
  - Setting LD_LIBRARY_PATH, no effect
  - Specifying the library files explicitly with -l, still can't find them
  - Specifying native-inputs instead of just inputs, no change

If someone could take a look at my package definition, I've included the 
body
snippet below (full code attached):

         (build-system trivial-build-system)
         (arguments
          `(#:modules ((guix build utils))
            #:builder (begin
                          (use-modules (guix build utils))
                          (let ((source (assoc-ref %build-inputs "source"))
                                (glibc (assoc-ref %build-inputs "glibc"))
                                (gcc (assoc-ref %build-inputs "gcc"))
                                (binutils (assoc-ref %build-inputs 
"binutils"))
                                (linux-libre-headers (assoc-ref 
%build-inputs "linux-libre-headers"))
                                (output (assoc-ref %outputs "out")))
                            (setenv "PATH" (string-join
                                            (list (string-append gcc "/bin")
                                                  (string-append 
binutils "/bin")
                                                  (getenv "PATH"))
                                            ":"))
                            (mkdir-p (string-append output "/bin"))
                            (invoke (string-append gcc "/bin/gcc")
                                    "-o" (string-append output "/bin/evhz")
                                    "-I" (string-append 
linux-libre-headers "/include")
                                    "-L" (string-append glibc "/lib")
                                    (string-append source "/evhz.c"))
                            #t))))
         (inputs
          (list binutils
                gcc
                gcc-toolchain
                glibc
                linux-libre-headers))

Thanks for making Guix awesome!

Christina O'Donnell

[1] It's my first attempt packaging and this looked the easiest on to start
with. There's no make file, so trivial-build-system seemed like it'd be the
right fit.[2]

[2] Aside: I saw that none of the trivial-build-system packages in Guix use
Gexp. Is Gexp compatible with trivial-build-system? I couldn't make it work.

[-- Attachment #2: evhz.scm --]
[-- Type: text/x-scheme, Size: 6720 bytes --]

;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2013, 2014 Andreas Enge <andreas@enge.fr>
;;; Copyright © 2014, 2015, 2017, 2018, 2020 Mark H Weaver <mhw@netris.org>
;;; Copyright © 2014, 2015 Eric Bavier <bavier@member.fsf.org>
;;; Copyright © 2015-2022 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2015 Eric Dvorsak <eric@dvorsak.fr>
;;; Copyright © 2016 Mathieu Lirzin <mthl@gnu.org>
;;; Copyright © 2015 Cyrill Schenkel <cyrill.schenkel@gmail.com>
;;; Copyright © 2016, 2017, 2019-2023 Efraim Flashner <efraim@flashner.co.il>
;;; Copyright © 2016 Nikita <nikita@n0.is>
;;; Copyright © 2016 Alex Kost <alezost@gmail.com>
;;; Copyright © 2016 David Craven <david@craven.ch>
;;; Copyright © 2016, 2017 John Darrington <jmd@gnu.org>
;;; Copyright © 2017-2022 Marius Bakke <marius@gnu.org>
;;; Copyright © 2017, 2018, 2019 Rutger Helling <rhelling@mykolab.com>
;;; Copyright © 2017, 2020 Arun Isaac <arunisaac@systemreboot.net>
;;; Copyright © 2018–2022 Tobias Geerinckx-Rice <me@tobias.gr>
;;; Copyright © 2018 Kei Kebreau <kkebreau@posteo.net>
;;; Copyright © 2018, 2020, 2022 Oleg Pykhalov <go.wigust@gmail.com>
;;; Copyright © 2018 Benjamin Slade <slade@jnanam.net>
;;; Copyright © 2019 nee <nee@cock.li>
;;; Copyright © 2019 Yoshinori Arai <kumagusu08@gmail.com>
;;; Copyright © 2019 Mathieu Othacehe <m.othacehe@gmail.com>
;;; Copyright © 2020 Liliana Marie Prikler <liliana.prikler@gmail.com>
;;; Copyright © 2020 Florian Pelz <pelzflorian@pelzflorian.de>
;;; Copyright © 2020, 2021 Michael Rohleder <mike@rohleder.de>
;;; Copyright © 2020, 2021, 2022, 2023 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;; Copyright © 2020 Jean-Baptiste Note <jean-baptiste.note@m4x.org>
;;; Copyright © 2021 Matthew James Kraai <kraai@ftbfs.org>
;;; Copyright © 2021 Nicolò Balzarotti <nicolo@nixo.xyz>
;;; Copyright © 2021 Matthew James Kraai <kraai@ftbfs.org>
;;; Copyright © 2021 Brice Waegeneire <brice@waegenei.re>
;;; Copyright © 2021 Matthew James Kraai <kraai@ftbfs.org>
;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
;;; Copyright © 2021 qblade <qblade@protonmail.com>
;;; Copyright © 2021 Lu Hui <luhux76@gmail.com>
;;; Copyright © 2023 Zheng Junjie <873216071@qq.com>
;;; Copyright © 2023 Janneke Nieuwenhuizen <janneke@gnu.org>
;;; Copyright © 2023 John Kehayias <john.kehayias@protonmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

(define-module (gnu packages evhz)
  #:use-module (guix gexp)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (guix packages)
  #:use-module (guix download)
  #:use-module (guix git-download)
  #:use-module (guix build-system trivial)
  #:use-module (guix utils)
  #:use-module (gnu packages)
  #:use-module (gnu packages base)
  #:use-module (gnu packages commencement)
  #:use-module (gnu packages gcc)
  #:use-module (gnu packages glib)
  #:use-module (gnu packages linux)
  #:use-module (gnu packages xorg))

(define-public evhz
  (let ((commit "35b7526e0655522bbdf92f6384f4e9dff74f38a0")
        (revision "1"))
      (package
        (name "evhz")
        (version (git-version "0.0.0" revision commit))
        (source (origin
                  (method git-fetch)
                  (uri (git-reference
                        (url "https://git.sr.ht/~iank/evhz")
                        (commit commit)))
                  (sha256
                   (base32
                     "1m2m60sh12jzc8f38g7g67b3avx2vg8ff0lai891jmjqvxw04bcl"))))
        (build-system trivial-build-system)
        (arguments
         `(#:modules ((guix build utils))
           #:builder (begin
                         (use-modules (guix build utils))
                         (let ((source (assoc-ref %build-inputs "source"))
                               (glibc (assoc-ref %build-inputs "glibc"))
                               (gcc (assoc-ref %build-inputs "gcc"))
                               (binutils (assoc-ref %build-inputs "binutils"))
                               (linux-libre-headers (assoc-ref %build-inputs "linux-libre-headers"))
                               (output (assoc-ref %outputs "out")))
                           (setenv "PATH" (string-join
                                           (list (string-append gcc "/bin")
                                                 (string-append binutils "/bin")
                                                 (getenv "PATH"))
                                           ":"))
                           ;; (setenv "LD_LIBRARY_PATH"
                           ;;         (string-join
                           ;;          (list (string-append glibc "/lib")
                           ;;                (getenv "LD_LIBRARY_PATH"))
                           ;;          ":"))
                           (mkdir-p (string-append output "/bin"))
                           (invoke (string-append gcc "/bin/gcc")
                                   "-o" (string-append output "/bin/evhz")
                                   "-I" (string-append linux-libre-headers "/include")
                                   "-L" (string-append glibc "/lib")
                                   ;; In an attempt to get it working. I know this shouldn't be necessary!
                                   ;; "-l" (string-append glibc "/lib/crt1.o")
                                   ;; "-l" (string-append glibc "/lib/crti.o")
                                   (string-append source "/evhz.c"))
                           #t))))
        (inputs
         (list binutils
               gcc
               gcc-toolchain
               glibc
               linux-libre-headers))
        ;; (native-inputs
        ;;  (list binutils
        ;;        gcc
        ;;        gcc-toolchain
        ;;        glibc
        ;;        linux-libre-headers))
        (home-page "https://git.sr.ht/~iank/evhz")
        (synopsis "Show mouse refresh rate under linux + evdev.")
        (description
         "A simple diagnostic utility to show mouse refresh rate under linux +
evdev.")
        (license license:apsl2))))

[-- Attachment #3: build-evhz.out --]
[-- Type: text/plain, Size: 2063 bytes --]

cdo@peter ~/src/guix$ guix shell -CW --pure --share=/var/guix/daemon-socket
guix shell: loading environment from '/home/cdo/src/guix/manifest.scm'...
cdo@peter ~/src/guix [env]$ ./pre-inst-env guix build evhz
substitute: updating substitutes from 'https://ci.guix.gnu.org'... 100.0%
substitute: updating substitutes from 'https://bordeaux.guix.gnu.org'... 100.0%
The following derivation will be built:
  /gnu/store/krh1sk0zn9z517971cim6ld1mp9cimi4-evhz-0.0.0-1.35b7526.drv
building /gnu/store/krh1sk0zn9z517971cim6ld1mp9cimi4-evhz-0.0.0-1.35b7526.drv...
/gnu/store/cv571kkg5hyk98yw48857h1d0zi9azni-binutils-2.38/bin/ld: cannot find crt1.o: No such file or directory
/gnu/store/cv571kkg5hyk98yw48857h1d0zi9azni-binutils-2.38/bin/ld: cannot find crti.o: No such file or directory
collect2: error: ld returned 1 exit status
Backtrace:
           2 (primitive-load "/gnu/store/9nnndgaddiy668h5jdr5y1szzb1?")
In ice-9/eval.scm:
    619:8  1 (_ #(#<directory (guile-user) 7ffff77f7c80> "/gnu/st?" ?))
In guix/build/utils.scm:
    812:6  0 (invoke "/gnu/store/4xzyl951wdy25rgk0ppsn4nisglw3207-g?" ?)

guix/build/utils.scm:812:6: In procedure invoke:
ERROR:
  1. &invoke-error:
      program: "/gnu/store/4xzyl951wdy25rgk0ppsn4nisglw3207-gcc-11.3.0/bin/gcc"
      arguments: ("-o" "/gnu/store/cx1jfsphrpak2zvs6c5d3v0zj723jhc0-evhz-0.0.0-1.35b7526/bin/evhz" "-I" "/gnu/store/sjq77rvlryjgksni6ry1648xkj807ynv-linux-libre-headers-5.15.49/include" "-L" "/gnu/store/ip9mj1pwymxi1yq32zbhwp3n3bycy6yi-glibc-2.35/lib" "/gnu/store/2aji8wq4c7ix1b5g2g10b2wj1yghf4kl-git-checkout/evhz.c")
      exit-status: 1
      term-signal: #f
      stop-signal: #f
builder for `/gnu/store/krh1sk0zn9z517971cim6ld1mp9cimi4-evhz-0.0.0-1.35b7526.drv' failed with exit code 1
build of /gnu/store/krh1sk0zn9z517971cim6ld1mp9cimi4-evhz-0.0.0-1.35b7526.drv failed
Could not find build log for '/gnu/store/krh1sk0zn9z517971cim6ld1mp9cimi4-evhz-0.0.0-1.35b7526.drv'.
guix build: error: build of `/gnu/store/krh1sk0zn9z517971cim6ld1mp9cimi4-evhz-0.0.0-1.35b7526.drv' failed
cdo@peter ~/src/guix [env]$ 

[-- Attachment #4: manual-gcc.out --]
[-- Type: text/plain, Size: 1241 bytes --]

cdo@peter ~$ guix shell -CW binutils gcc gcc-toolchain glibc linux-libre-headers guile --pure
cdo@peter ~ [env]$ exit
cdo@peter ~$ rm evhz
cdo@peter ~$ guix shell -CW binutils gcc gcc-toolchain glibc linux-libre-headers guile --pure
cdo@peter ~ [env]$ guile
GNU Guile 3.0.9
Copyright (C) 1995-2023 Free Software Foundation, Inc.

Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
This program is free software, and you are welcome to redistribute it
under certain conditions; type `,show c' for details.

Enter `,help' for help.
scheme@(guile-user)> (use-modules (guix build utils))
scheme@(guile-user)> (invoke "/gnu/store/4xzyl951wdy25rgk0ppsn4nisglw3207-gcc-11.3.0/bin/gcc" "-o" "evhz" "-I" "/gnu/store/sjq77rvlryjgksni6ry1648xkj807ynv-linux-libre-headers-5.15.49/include" "-L" "/gnu/store/ip9mj1pwymxi1yq32zbhwp3n3bycy6yi-glibc-2.35/lib" "/gnu/store/2aji8wq4c7ix1b5g2g10b2wj1yghf4kl-git-checkout/evhz.c")
$1 = #t
scheme@(guile-user)> 
cdo@peter ~ [env]$ exit
cdo@peter ~$ sudo ./evhz
Press CTRL-C to exit.

event0: Power Button
event1: Power Button
event2: SINO WEALTH Gaming KB 
event3: SINO WEALTH Gaming KB  System Control
event4: SINO WEALTH Gaming KB  Consumer Control
event5: SINO WEALTH Gaming KB  Keyboard
...

             reply	other threads:[~2024-01-14 19:40 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-14 11:10 Christina O'Donnell [this message]
2024-01-14 21:28 ` trivial-build-system: ld can't find existing store files Felix Lechner via
2024-01-17 16:40 ` Simon Tournier
2024-01-17 20:49   ` Christina O'Donnell
2024-01-17 23:55   ` Clément Lassieur

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0ba16b42-6c3b-5b31-3dc7-038bf8282fbe@mutix.org \
    --to=cdo@mutix.org \
    --cc=help-guix@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).