gnu: xorg: Unify --disable-malloc0-returnsnull code.

The idea is to keep the comments in one place, instead of copying
them over and over.  It's also documented more now.

* gnu/packages/xorg.scm
  (malloc0-flags): New procedure.
  (libxext,libxrender,libx11,libxt): Use new procedures.
This commit is contained in:
Maxime Devos 2021-08-25 14:37:39 +02:00 committed by Mathieu Othacehe
parent 4823adb26b
commit 76362337b9
No known key found for this signature in database
GPG key ID: 8354763531769CA6

View file

@ -102,6 +102,16 @@ (define-module (gnu packages xorg)
;; When cross-compiling certain packages, "--disable-malloc0returnsnull"
;; needs to be passed. Otherwise, the configure script will try to run a
;; binary for the host on the build machine.
(define (malloc0-flags)
(if (%current-target-system)
;; At least on glibc-based systems, malloc(0) evaluates to a non-NULL
;; pointer (except in out-of-memory situations). On other systems,
;; --enable-malloc0returnsnull might be required instead.
'("--disable-malloc0returnsnull")
'()))
;; packages without propagated input ;; packages without propagated input
;; (rationale for this separation: The packages in PROPAGATED_INPUTS need to ;; (rationale for this separation: The packages in PROPAGATED_INPUTS need to
@ -4791,10 +4801,7 @@ (define-public libxext
(string-append "--mandir=" (string-append "--mandir="
(assoc-ref %outputs "doc") (assoc-ref %outputs "doc")
"/share/man") "/share/man")
;; Disable zero malloc check that fails when cross-compiling. ,@(malloc0-flags))))
,@(if (%current-target-system)
'("--disable-malloc0returnsnull")
'()))))
(propagated-inputs (propagated-inputs
`(("xorgproto" ,xorgproto))) `(("xorgproto" ,xorgproto)))
(inputs (inputs
@ -4884,11 +4891,7 @@ (define-public libxrender
(build-system gnu-build-system) (build-system gnu-build-system)
(arguments (arguments
`(#:configure-flags `(#:configure-flags
(list "--disable-static" (list "--disable-static" ,@(malloc0-flags))))
;; Disable zero malloc check that fails when cross-compiling.
,@(if (%current-target-system)
'("--disable-malloc0returnsnull")
'()))))
(propagated-inputs (propagated-inputs
`(("xorgproto" ,xorgproto))) `(("xorgproto" ,xorgproto)))
(inputs (inputs
@ -5561,11 +5564,7 @@ (define-public libx11
(assoc-ref %outputs "doc") (assoc-ref %outputs "doc")
"/share/man") "/share/man")
"--disable-static" "--disable-static"
,@(malloc0-flags))))
;; Disable zero malloc check that fails when cross-compiling.
,@(if (%current-target-system)
'("--disable-malloc0returnsnull")
'()))))
(propagated-inputs (propagated-inputs
`(("xorgproto" ,xorgproto) `(("xorgproto" ,xorgproto)
("libxcb" ,libxcb))) ("libxcb" ,libxcb)))
@ -5643,10 +5642,7 @@ (define-public libxt
(assoc-ref %outputs "doc") (assoc-ref %outputs "doc")
"/share/man") "/share/man")
"--disable-static" "--disable-static"
;; Disable zero malloc check that fails when cross-compiling. ,@(malloc0-flags))))
,@(if (%current-target-system)
'("--disable-malloc0returnsnull")
'()))))
(propagated-inputs (propagated-inputs
`(("libx11" ,libx11) `(("libx11" ,libx11)
("libice" ,libice) ("libice" ,libice)