diff mbox series

[bug#40767] gnu: Add maradns.

Message ID 20200422132922.9539-1-arunisaac@systemreboot.net
State Accepted
Headers show
Series [bug#40767] gnu: Add maradns. | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch success View Laminar job

Commit Message

Arun Isaac April 22, 2020, 1:29 p.m. UTC
* gnu/packages/dns.scm (maradns): New variable.
---
 gnu/packages/dns.scm | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

Comments

Mathieu Othacehe April 22, 2020, 1:49 p.m. UTC | #1
Hello,

> +       #:make-flags (list "CC=gcc"
> +                          (string-append "PREFIX=" %output)
> +                          (string-append "RPM_BUILD_ROOT=" %output))

Hard-coding CC variable this way prevents cross-compilation. If you run:

--8<---------------cut here---------------start------------->8---
./pre-inst-env guix build maradns --target=aarch64-linux-gnu --target=aarch64-linux-gnu
--8<---------------cut here---------------end--------------->8---

you will obtain a native version of the binaries. Something like that
would work better:

--8<---------------cut here---------------start------------->8---
(string-append "CC=" (if target
                          (string-append (assoc-ref %build-inputs "cross-gcc")
                                         "/bin/" target "-gcc")
                          "gcc"))
--8<---------------cut here---------------end--------------->8---

As this is a recurrent problem we may need to put this snippet into a
gnu-build-system function?

Thanks,

Mathieu
Efraim Flashner April 22, 2020, 3:09 p.m. UTC | #2
On Wed, Apr 22, 2020 at 03:49:32PM +0200, Mathieu Othacehe wrote:
> 
> Hello,
> 
> > +       #:make-flags (list "CC=gcc"
> > +                          (string-append "PREFIX=" %output)
> > +                          (string-append "RPM_BUILD_ROOT=" %output))
> 
> Hard-coding CC variable this way prevents cross-compilation. If you run:
> 
> --8<---------------cut here---------------start------------->8---
> ./pre-inst-env guix build maradns --target=aarch64-linux-gnu --target=aarch64-linux-gnu
> --8<---------------cut here---------------end--------------->8---
> 
> you will obtain a native version of the binaries. Something like that
> would work better:
> 
> --8<---------------cut here---------------start------------->8---
> (string-append "CC=" (if target
>                           (string-append (assoc-ref %build-inputs "cross-gcc")
>                                          "/bin/" target "-gcc")
>                           "gcc"))
> --8<---------------cut here---------------end--------------->8---
> 
> As this is a recurrent problem we may need to put this snippet into a
> gnu-build-system function?
> 
> Thanks,
> 
> Mathieu

would (which "gcc") work when cross compiling?
Mathieu Othacehe April 22, 2020, 5:26 p.m. UTC | #3
> would (which "gcc") work when cross compiling?

When cross-compiling the cross gcc is named target-gcc
(aarch64-linux-gnu-gcc for instance), so (which "gcc") would return the
native compiler, not the cross one.

Note that when using autoconf/autotools, cross-compilation is working
fine because we pass "--host=target" and it manages to find the native
and cross-compiler from that.

This issue only arises when raw Makefile are using hard-coded CC=gcc to
build stuff.

Thanks,

Mathieu
Arun Isaac April 22, 2020, 7:01 p.m. UTC | #4
> Hello,

Thanks for the patch review!

>> +       #:make-flags (list "CC=gcc"
>> +                          (string-append "PREFIX=" %output)
>> +                          (string-append "RPM_BUILD_ROOT=" %output))
>
> Hard-coding CC variable this way prevents cross-compilation.

Oops, I overlooked that.

> If you run:
>
> --8<---------------cut here---------------start------------->8---
> ./pre-inst-env guix build maradns --target=aarch64-linux-gnu --target=aarch64-linux-gnu
> --8<---------------cut here---------------end--------------->8---
>
> you will obtain a native version of the binaries. Something like that
> would work better:
>
> --8<---------------cut here---------------start------------->8---
> (string-append "CC=" (if target
>                           (string-append (assoc-ref %build-inputs "cross-gcc")
>                                          "/bin/" target "-gcc")
>                           "gcc"))
> --8<---------------cut here---------------end--------------->8---

Sure, I'll fix this. Any other changes?

> As this is a recurrent problem we may need to put this snippet into a
> gnu-build-system function?

I think that's a good idea. The build phase of the gnu-build-system
should include this snippet.
Mathieu Othacehe April 23, 2020, 8:37 a.m. UTC | #5
Hello,

> Sure, I'll fix this. Any other changes?

No other than that, this LGTM :).

Mathieu
Arun Isaac April 24, 2020, 10:13 p.m. UTC | #6
Pushed with discussed change. Thank you for the review!
Arun Isaac April 24, 2020, 10:15 p.m. UTC | #7
Closing this issue.
Mathieu Othacehe April 25, 2020, 8:13 a.m. UTC | #8
Hello,

> Pushed with discussed change. Thank you for the review!

I still have the following error when cross-building for
aarch64-linux-gnu or arm-linux-gnueabihf:

--8<---------------cut here---------------start------------->8---
../rng/rng-alg-fst.c: In function ‘rngKeySetupEnc’:
../rng/rng-alg-fst.c:104:34: error: ‘Te4’ undeclared (first use in this function); did you mean ‘STe4’?
                                 (Te4[(temp >> 16) & 0xff] & 0xff000000) ^
                                  ^~~
                                  STe4
../rng/rng-alg-fst.c:104:34: note: each undeclared identifier is reported only once for each function it appears in
../rng/rng-alg-fst.c:125:27: error: ‘Te0’ undeclared (first use in this function); did you mean ‘Te4’?
                 STe0[i] = Te0[i];
                           ^~~
                           Te4
--8<---------------cut here---------------end--------------->8---

Also, please be careful to stay under the 78 column limit.

Could you have a look?

Thanks,

Mathieu
diff mbox series

Patch

diff --git a/gnu/packages/dns.scm b/gnu/packages/dns.scm
index 0f7227ad03..75be82b3b4 100644
--- a/gnu/packages/dns.scm
+++ b/gnu/packages/dns.scm
@@ -14,6 +14,7 @@ 
 ;;; Copyright © 2019 Chris Marusich <cmmarusich@gmail.com>
 ;;; Copyright © 2019 Rutger Helling <rhelling@mykolab.com>
 ;;; Copyright © 2020 Pierre Langlois <pierre.langlois@gmx.com>
+;;; Copyright © 2020 Arun Isaac <arunisaac@systemreboot.net>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -949,3 +950,44 @@  could) directly register names in the Domain Name System (DNS).  Some examples
 of public suffixes are .com, .co.uk and pvt.k12.ma.us.  This is a list of all
 known public suffixes.")
       (license license:mpl2.0))))
+
+(define-public maradns
+  (package
+    (name "maradns")
+    (version "3.5.0004")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append "https://maradns.samiam.org/download/"
+                           (version-major+minor version) "/"
+                           version "/maradns-" version ".tar.xz"))
+       (sha256
+        (base32
+         "1zv0i6m4m05ay5zlhwq1h88hgjq2d81cjanpnb3gyhr0xhmjwk6a"))))
+    (build-system gnu-build-system)
+    (arguments
+     `(#:tests? #f ; need to be root to run tests
+       #:make-flags (list "CC=gcc"
+                          (string-append "PREFIX=" %output)
+                          (string-append "RPM_BUILD_ROOT=" %output))
+       #:phases
+       (modify-phases %standard-phases
+         (replace 'configure
+           (lambda _
+             (invoke "./configure")))
+         (add-before 'install 'create-install-directories
+           (lambda* (#:key outputs #:allow-other-keys)
+             (let ((out (assoc-ref outputs "out")))
+               (for-each (lambda (dir)
+                           (mkdir-p (string-append out dir)))
+                         (list "/bin" "/sbin" "/etc"
+                               "/share/man/man1"
+                               "/share/man/man5"
+                               "/share/man/man8"))
+               #t))))))
+    (home-page "https://maradns.samiam.org")
+    (synopsis "Small lightweight DNS server")
+    (description "MaraDNS is a small and lightweight DNS server.  MaraDNS
+consists of a UDP-only authoritative DNS server for hosting domains, and a UDP
+and TCP-capable recursive DNS server for finding domains on the internet.")
+    (license license:bsd-2)))