discuss@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: Ingo Schwarze <schwarze@usta.de>
To: Stephen Gregoratto <dev@sgregoratto.me>
Cc: discuss@mandoc.bsd.lv, christos@netbsd.org
Subject: Re: man_validate.c compile errors on Linux gcc/clang
Date: Wed, 13 Mar 2019 19:38:14 +0100	[thread overview]
Message-ID: <20190313183814.GC46802@athene.usta.de> (raw)
In-Reply-To: <20190313013235.najhyodv2hpboasu@BlackBox>

Hi Stephen,

Stephen Gregoratto wrote on Wed, Mar 13, 2019 at 12:32:35PM +1100:

> The latest patches to man_validate.c do not compile on my Linux machines 
> using gcc/clang. Only my OpenBSD server can complete fully.

Thank you for reporting this issue.
I (hopefully) fixed it with the commit below.
Can you confirm that the fix works?

Yours,
  Ingo


Log Message:
-----------
Contrary to what the NetBSD attribute(3) manual page suggests, 
using __dead instead of __attribute__((__noreturn__)) actually 
hinders portability rather than helping it.

Given that mandoc already uses __attribute__ in several files 
and that in the portable version, ./configure already contains
rudimentary support for ignoring it on platforms that do not 
support it, use __attribute__ directly.

This is expected to fix build failures that Stephen Gregoratto 
<dev at sgregoratto dot me> reported from Arch and Debian Linux.

Modified Files:
--------------
    mandoc:
        man_validate.c
        mdoc_validate.c

Revision Data
-------------
Index: mdoc_validate.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/mdoc_validate.c,v
retrieving revision 1.372
retrieving revision 1.373
diff -Lmdoc_validate.c -Lmdoc_validate.c -u -p -r1.372 -r1.373
--- mdoc_validate.c
+++ mdoc_validate.c
@@ -64,7 +64,7 @@ static	size_t		macro2len(enum roff_tok);
 static	void	 rewrite_macro2len(struct roff_man *, char **);
 static	int	 similar(const char *, const char *);
 
-static __dead void post_abort(POST_ARGS);
+static	void	 post_abort(POST_ARGS) __attribute__((__noreturn__));
 static	void	 post_an(POST_ARGS);
 static	void	 post_an_norm(POST_ARGS);
 static	void	 post_at(POST_ARGS);
@@ -497,7 +497,7 @@ check_toptext(struct roff_man *mdoc, int
 	}
 }
 
-static __dead void
+static void
 post_abort(POST_ARGS)
 {
 	abort();
Index: man_validate.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/man_validate.c,v
retrieving revision 1.147
retrieving revision 1.148
diff -Lman_validate.c -Lman_validate.c -u -p -r1.147 -r1.148
--- man_validate.c
+++ man_validate.c
@@ -41,7 +41,7 @@
 
 typedef	void	(*v_check)(CHKARGS);
 
-static __dead void check_abort(CHKARGS);
+static	void	  check_abort(CHKARGS) __attribute__((__noreturn__));
 static	void	  check_par(CHKARGS);
 static	void	  check_part(CHKARGS);
 static	void	  check_root(CHKARGS);
@@ -196,7 +196,7 @@ check_root(CHKARGS)
 		    "(OpenBSD)" : "(NetBSD)");
 }
 
-static __dead void
+static void
 check_abort(CHKARGS)
 {
 	abort();


 ----- 8< ----- schnipp ----- >8 ----- 8< ----- schnapp ----- >8 -----


> On my Arch Linux machine:
> 
> Linux 5.0.0-arch1-1-ARCH x86_64 GNU/Linux
> 
> gcc -g -W -Wall -Wmissing-prototypes -Wstrict-prototypes -Wwrite-strings -Wno-unused-parameter   -c -o man_validate.o man_validate.c
> man_validate.c:44:14: error: expected ‘;’ before ‘void’
>  static __dead void check_abort(CHKARGS);
>               ^~~~~
>               ;
> man_validate.c:199:14: error: expected ‘;’ before ‘void’
>  static __dead void
>               ^~~~~
>               ;
> make: *** [<builtin>: man_validate.o] Error 1
> 
> gcc (GCC) 8.2.1 20181127
> Copyright (C) 2018 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions.  There is NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
> 
> 
> clang -g -W -Wall -Wmissing-prototypes -Wstrict-prototypes -Wwrite-strings -Wno-unused-parameter   -c -o man_validate.o man_validate.c
> man_validate.c:44:8: error: unknown type name '__dead'
> static __dead void check_abort(CHKARGS);
>        ^
> man_validate.c:44:15: error: expected identifier or '('
> static __dead void check_abort(CHKARGS);
>               ^
> man_validate.c:67:2: error: use of undeclared identifier 'check_abort'
>         check_abort,/* LP */
>         ^
> man_validate.c:69:2: error: use of undeclared identifier 'check_abort'
>         check_abort,/* P */
>         ^
> man_validate.c:199:8: error: unknown type name '__dead'
> static __dead void
>        ^
> man_validate.c:199:15: error: expected identifier or '('
> static __dead void
>               ^
> 6 errors generated.
> make: *** [<builtin>: man_validate.o] Error 1
> 
> clang version 7.0.1 (tags/RELEASE_701/final)
> Target: x86_64-pc-linux-gnu
> Thread model: posix
> InstalledDir: /usr/bin
> 
> On my Debian 9 Server:
> 
> Linux mail.sgregoratto.me 4.9.0-8-amd64 #1 SMP Debian 4.9.144-3 (2019-02-02) x86_64 GNU/Linux
> 
> gcc -g -W -Wall -Wmissing-prototypes -Wstrict-prototypes -Wwrite-strings -Wno-unused-parameter   -c -o man_validate.o man_validate.c
> man_validate.c:44:15: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’
>  static __dead void check_abort(CHKARGS);
>                ^~~~
> man_validate.c:67:2: error: ‘check_abort’ undeclared here (not in a function)
>   check_abort,/* LP */
>   ^~~~~~~~~~~
> man_validate.c:199:15: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’
>  static __dead void
>                ^~~~
> <builtin>: recipe for target 'man_validate.o' failed
> make: *** [man_validate.o] Error 1
> 
> gcc (Debian 6.3.0-18+deb9u1) 6.3.0 20170516
> Copyright (C) 2016 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions.  There is NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR 
> PURPOSE.
> 
> I'm unsure if __dead is defined in glibc. I couldn't find it under 
> <sys/cdefs/h>.
--
 To unsubscribe send an email to discuss+unsubscribe@mandoc.bsd.lv

  reply	other threads:[~2019-03-13 18:38 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-13  1:32 Stephen Gregoratto
2019-03-13 18:38 ` Ingo Schwarze [this message]
2019-03-14  1:11   ` Stephen Gregoratto
2019-03-14  1:30     ` Stephen Gregoratto
2019-03-14 11:45     ` Ingo Schwarze

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

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

  git send-email \
    --in-reply-to=20190313183814.GC46802@athene.usta.de \
    --to=schwarze@usta.de \
    --cc=christos@netbsd.org \
    --cc=dev@sgregoratto.me \
    --cc=discuss@mandoc.bsd.lv \
    /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 NNTP newsgroup(s).