[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Patch 4/10] argon2: Install pkg-config file.

From: Lukas Gradl
Subject: Re: [Patch 4/10] argon2: Install pkg-config file.
Date: Sun, 25 Sep 2016 17:45:06 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

Hi Danny,

Sorry for the delay!

Danny Milosavljevic <address@hidden> writes:

> Hi Lukas,
> I thought about it some more.
> On Sun, 18 Sep 2016 16:43:03 -0500
> Lukas Gradl <address@hidden> wrote:
>> +               (and
>> +                (install-file "argon2" (string-append out "/bin"))
>> +                (install-file "libargon2.a" (string-append out "/lib"))
>> +                (install-file "" (string-append out "/lib"))
>> +                (install-file "argon2.pc"
>> +                              (string-append out "/lib/pkgconfig"))
> Hmm. I looked at the implementation of "install-file" and its return
> value seems to be the one of "copy-file". And the Guile manual
> specifies that the return value of "copy-file" is
> unspecified. (Instead it does dynamic unwinding on error)
> So I'd do the "install-file" and "copy-recursively" calls outside the "(and 
> ...)".


>> +                (copy-recursively "include"
>> +                                  (string-append out "/include"))
>> +                (zero? (system* "ln" "-s"
>> +                                (string-append out "/lib/")
>> +                                (string-append out "/lib/")))
> I think that there's a "symlink" function in Guile for that (which has 
> unspecified return value). Would probably be marginally faster, too.

>> +                (zero? (system* ; Fix compatability for libtool based 
>> builds.
>> +                        "ln" "-s"
>> +                        (string-append out "/lib/")
>> +                        (string-append out 
>> "/lib/"))))))))))
> Likewise.

I changed the first of these two to use Guile's symlink function and
removed the second one (' because I think it is not
needed after all.  Since the return value of "(symlink ...)" is
unspecified, then we don't need the "(and ...)" at all, right?  I
dropped it for now.

> About the part of the toolchain that sets the soname, either libtool 
> mode=link does it ("-version-info") or it's an option "-soname" to ld (or gcc 
> with "-Wl," prefix). 
> The official soname used is set in argon2 Makefile:
>         SO_LDFLAGS := -Wl,-soname,
>                                   ^^^^^^^^^
> But I'd say it's fine to manually symlink - since it works. Please still 
> check how the client of argon2 in this case (libring ?) loads the shared 
> object.

Thank you for this explanation!

I looked into this some more.  The error that I saw earlier that
prompted me to symlink actually occurred during the phase
'validate-runpath' of the build of libring.  The build itself finished
without any problems, however is not found in the

---8<--- cut here -------------------- start --->8---
starting phase `validate-runpath'
validating RUNPATH of 0 binaries in 
validating RUNPATH of 1 binaries in 
error: depends on '', which cannot be found in RUNPATH 
phase `validate-runpath' failed after 0.0 seconds
builder for 
failed with exit code 1
@ build-failed 
/gnu/store/7hy39m8nlvy2rjd6iljvgrbpqbwq1grz-libring-2.2.0-1.41e032c.drv - 1 
builder for 
failed with exit code 1
guix build: error: build failed: build of 
`/gnu/store/7hy39m8nlvy2rjd6iljvgrbpqbwq1grz-libring-2.2.0-1.41e032c.drv' failed
---8<--- cut here -------------------- end ----->8---

I produced this after commenting all the symlink calls.  I think this
error points out that the following can be found in the offending binary

---8<--- cut here -------------------- start --->8---
address@hidden [env]$ objdump -p 
|grep argon2
---8<--- cut here -------------------- end ----->8---

My understanding is now that if this 'dring' binary were to get
executed, it would look for '' in the Runpath.  However,
there is only '' in
'/gnu/store/8z4lfj32b7q308xigfj8w1nmgbgyvd6g-argon2-20160406/lib', which
it ignores.

My next question was why it was looking for '' at all if
it does not exist.

Actually, '' calls itself '':

---8<--- cut here -------------------- start --->8---
address@hidden [env]$ objdump -p 
Dynamic Section:
---8<--- cut here -------------------- end ----->8---

Libring requires Opendht via pkg-config.  The pkg-config file of Opendht
then tells the libring build process that 'argon2' is required.  Then
'' is found and maybe used during the build of libring, but
somehow (I am not sure how) the soname of '' which does not
match the filename ends up in the 'NEEDED' section of 'dring' as seen

To fix this situation it would probably suffice to make sure that the
soname and the filename of the Argon2 library match.  To that end, one
could either change the soname or the filename to match the other one.
I think that changing either of these is risky because other dependent
libraries might depend on one of those.  So I would keep the symlink
'' -> '' but remove the ''
since it appears unneeded.  Building libring works with these changes.

I hope this makes sense.  My understanding of libtool is still very

Thank you!


From 5fb85fef7b1475baca6c29beb26799ca8f3d814a Mon Sep 17 00:00:00 2001
From: Lukas Gradl <address@hidden>
Date: Tue, 9 Aug 2016 16:49:19 -0500
Subject: [PATCH 04/10] gnu: argon2: Install pkg-config file.

* gnu/packages/password-utils.scm (argon2)[source]: Create pkg-config file.
[arguments]: Install it.
 gnu/packages/password-utils.scm | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/password-utils.scm b/gnu/packages/password-utils.scm
index 7288da6..f62d041 100644
--- a/gnu/packages/password-utils.scm
+++ b/gnu/packages/password-utils.scm
@@ -311,6 +311,21 @@ through the pass command.")
          name "/tar.gz/" version))
        (file-name (string-append name "-" version ".tar.gz"))
+       (snippet
+        '(let ((p (open-file "argon2.pc" "w")))
+           (begin
+             (display
+              (string-append "prefix=/usr/local\n"
+                             "exec_prefix=${prefix}\n"
+                             "includedir=${prefix}/include\n"
+                             "libdir=${prefix}/lib\n\n"
+                             "Name: Argon2\n"
+                             "Description: "
+                             "The Argon2 password hashing algorithm\n"
+                             "Version: 1.0.0\n"
+                             "Cflags: -I${includedir}/\n"
+                             "Libs: -L${libdir} -largon2\n") p)
+             (close-output-port p))))
@@ -321,14 +336,23 @@ through the pass command.")
        (modify-phases %standard-phases
          (delete 'configure)
+         (add-after 'unpack 'fix-pkg-config
+           (lambda _
+             (substitute* "argon2.pc"
+               (("/usr/local")
+                (assoc-ref %outputs "out")))))
          (replace 'install
            (lambda _
              (let ((out (assoc-ref %outputs "out")))
                (install-file "argon2" (string-append out "/bin"))
                (install-file "libargon2.a" (string-append out "/lib"))
                (install-file "" (string-append out "/lib"))
+               (install-file "argon2.pc"
+                             (string-append out "/lib/pkgconfig"))
                (copy-recursively "include"
-                                 (string-append out "/include"))))))))
+                                 (string-append out "/include"))
+               (symlink (string-append out "/lib/")
+                        (string-append out "/lib/"))))))))
     (home-page "";)
     (synopsis "Password hashing library")
     (description "Argon2 provides a key derivation function that was declared

Attachment: signature.asc
Description: PGP signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]