about summary refs log tree commit diff
path: root/pkgs/tools/text/sgml
diff options
context:
space:
mode:
authorRandy Eckenrode <randy@largeandhighquality.com>2023-06-03 11:47:22 -0400
committerRandy Eckenrode <randy@largeandhighquality.com>2023-06-29 23:39:35 -0400
commit4abf3027d8ee8b120d0bfc0f17e00bb28a3150cc (patch)
treeb268799ba126e5dceadf09ce9b5d61d47530f9a1 /pkgs/tools/text/sgml
parent7cb8db1c029996e57b1a9d04b75963d01d0955bc (diff)
opensp: fix build with clang 16
There are two issues preventing a build with clang 16:
* The configure scripts are too old and generate invalid `config.h`.
  This is fixed by using `autoreconfHook` with clang.
* Use of the `register` storage class specifier, which is not allowed in
  C++17 (the default when building with clang 16). This is fixed by
  removing that usage.
Diffstat (limited to 'pkgs/tools/text/sgml')
-rw-r--r--pkgs/tools/text/sgml/opensp/default.nix9
-rw-r--r--pkgs/tools/text/sgml/opensp/fix-register-storage-class.patch11
2 files changed, 19 insertions, 1 deletions
diff --git a/pkgs/tools/text/sgml/opensp/default.nix b/pkgs/tools/text/sgml/opensp/default.nix
index 848bd5ce82eba..836a07b63e739 100644
--- a/pkgs/tools/text/sgml/opensp/default.nix
+++ b/pkgs/tools/text/sgml/opensp/default.nix
@@ -1,5 +1,6 @@
 { lib, stdenv, fetchurl, fetchpatch, xmlto, docbook_xml_dtd_412
 , libxslt, docbook_xsl, autoconf, automake, gettext, libiconv, libtool
+, autoreconfHook
 }:
 
 stdenv.mkDerivation rec {
@@ -21,6 +22,8 @@ stdenv.mkDerivation rec {
       url = "https://gitweb.gentoo.org/repo/gentoo.git/plain/app-text/opensp/files/opensp-1.5.2-c11-using.patch?id=688d9675782dfc162d4e6cff04c668f7516118d0";
       sha256 = "04q14s8qsad0bkjmj067dn831i0r6v7742rafdlnbfm5y249m2q6";
     })
+    # Clang 16 defaults to C++17, which does not allow `register` as a storage class specifier.
+    ./fix-register-storage-class.patch
   ];
 
   setupHook = ./setup-hook.sh;
@@ -41,7 +44,11 @@ stdenv.mkDerivation rec {
     xmlto
     docbook_xml_dtd_412
     docbook_xsl
-  ] ++ lib.optionals stdenv.isCygwin [ autoconf automake libtool ];
+  ]
+  # Clang 16 fails to build due to inappropriate definitions in the `config.h` generated by the
+  # existing configure scripts. Regenerate them to make sure they detect its features correctly.
+  ++ lib.optional stdenv.cc.isClang autoreconfHook
+  ++ lib.optionals stdenv.isCygwin [ autoconf automake libtool ];
 
   doCheck = false; # fails
 
diff --git a/pkgs/tools/text/sgml/opensp/fix-register-storage-class.patch b/pkgs/tools/text/sgml/opensp/fix-register-storage-class.patch
new file mode 100644
index 0000000000000..ce1aba32437bd
--- /dev/null
+++ b/pkgs/tools/text/sgml/opensp/fix-register-storage-class.patch
@@ -0,0 +1,11 @@
+--- a/lib/Recognizer.cxx	2005-11-05 04:05:20.000000000 -0500
++++ b/lib/Recognizer.cxx	2023-06-03 11:45:04.497116217 -0400
+@@ -39,7 +39,7 @@
+   }
+   else
+     in->startTokenNoMulticode();
+-  register const Trie *pos = trie_.pointer();
++  const Trie *pos = trie_.pointer();
+   do {
+     pos = pos->next(map_[in->tokenChar(mgr)]);
+   } while (pos->hasNext());