Configure updates for clang++

--zhXaljGHf11kAtnf
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

I have some Configure updates to satisfy some clang++ issues.  I also have
updates for the metaconfig units, but haven't fully sorted out matching
them to the new metaconfig repository.

How does this work in the brave new github world?  Shall I just push 
my Configure changes as before?  Or would folks prefer that I sort out
the metaconfig changes first?

(I have seen the notes about forks and pull requests in perlgit.pod; my question
is more about whether I should deal with the metaconfig units first.

For reference, I've attached the patches here.

-- 
    Andy Dougherty		doughera@lafayette.edu

--zhXaljGHf11kAtnf
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="configure.patches"

From 80634f2e4ce2f031fc0e80985641ea01f31e0b83 Mon Sep 17 00:00:00 2001
From: Andy Dougherty <doughera@lafayette.edu>
Date: Tue, 27 Aug 2019 12:55:57 -0400
Subject: [PATCH 1/5] Add <stdlib.h> for futimes compilation test.

Since the test uses exit(), the appropriate header should be
included.  clang++ throws an error otherwise.
---
 Configure | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Configure b/Configure
index 9e2051085c4..576f024523b 100755
--- a/Configure
+++ b/Configure
@@ -14115,6 +14115,7 @@ echo " "
 echo "Checking if you have a working futimes()" >&4
 $cat >try.c <<EOCP
 #include <stdio.h>
+#include <stdlib.h>
 #include <sys/time.h>
 #include <errno.h>
 #include <fcntl.h>
-- 
2.20.1


From 866f406ad4a6bc6c61b1c31414e60ad415bef1c4 Mon Sep 17 00:00:00 2001
From: Andy Dougherty <doughera@lafayette.edu>
Date: Tue, 27 Aug 2019 12:58:23 -0400
Subject: [PATCH 2/5] Use a compile and run test for lchown() to satisfy
 clang++.

For glibc, previous reports were that some functions (such as lchown())
are present in libc, but are unimplemented.  That is, they always fail
and set errno=ENOSYS.  Unfortunately, the stub test doesn't work under
clang++.  Thus use a compile and run test.  This should be more reliable.
---
 Configure | 33 +++++++++++++++------------------
 1 file changed, 15 insertions(+), 18 deletions(-)

diff --git a/Configure b/Configure
index 576f024523b..8b74a823225 100755
--- a/Configure
+++ b/Configure
@@ -15905,27 +15905,24 @@ esac
 
 : see if lchown exists
 echo " "
-$cat > try.c <<'EOCP'
-/* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char lchown(); below.  */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error.  */
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char lchown();
-int main() {
-    /*  The GNU C library defines this for functions which it implements
-        to always fail with ENOSYS.  Some functions are actually named
-	something starting with __ and the normal name is an alias.  */
-#if defined (__stub_lchown) || defined (__stub___lchown)
-choke me
-#else
-lchown();
+$cat > try.c <<EOCP
+#include <pwd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#$i_unistd	I_UNISTD
+#ifdef I_UNISTD
+#  include <unistd.h>
 #endif
-; return 0; }
+int main(int argc, char *argv[])
+{
+   if (lchown("./try.c", -1, getgid()) == -1) {
+       exit(EXIT_FAILURE);
+   }
+   exit(EXIT_SUCCESS);
+}
 EOCP
 set try
-if eval $compile; then
+if eval $compile && ./try; then
     $echo "lchown() found." >&4
     val="$define"
 else
-- 
2.20.1


From 89e284daf00ee73facc0baef4f75967ade2ea776 Mon Sep 17 00:00:00 2001
From: Andy Dougherty <doughera@lafayette.edu>
Date: Tue, 27 Aug 2019 15:00:26 -0400
Subject: [PATCH 3/5] Fix strtoull() probe to run under clang++.

Include the appropriate header and get rid of slightly
incorrect prototype.  Change function return type to void
since we don't explicitly return a useful value.
---
 Configure | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Configure b/Configure
index 8b74a823225..b3498b3eed8 100755
--- a/Configure
+++ b/Configure
@@ -19240,14 +19240,14 @@ case "$d_longlong-$d_strtoull" in
 Checking whether your strtoull() works okay...
 EOM
 	$cat >try.c <<'EOCP'
+#include <stdlib.h>
 #include <errno.h>
 #ifdef __hpux
 #define strtoull __strtoull
 #endif
 #include <stdio.h>
-extern unsigned long long int strtoull(char *s, char **, int);
 static int bad = 0;
-int check(char *s, long long eull, int een) {
+void check(const char *s, long long eull, int een) {
 	long long gull;
 	errno = 0;
 	gull = strtoull(s, 0, 10);
-- 
2.20.1


From f914b385efae2ba2f7811d27f08766da2a79a228 Mon Sep 17 00:00:00 2001
From: Andy Dougherty <doughera@lafayette.edu>
Date: Tue, 27 Aug 2019 15:22:05 -0400
Subject: [PATCH 4/5] Fix strtoll, strtoul, and strtouq probes to compile under
 clang++.

The test programs were missing the stdlib.h header, and needed
tweaks to the check() prototype to compile under clang++.  These
changes should be fine for C compilers as well, but they have typically
been more forgiving, so shouldn't be affected.
---
 Configure | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/Configure b/Configure
index b3498b3eed8..0419850ee4c 100755
--- a/Configure
+++ b/Configure
@@ -19105,9 +19105,9 @@ EOM
 #define strtoll _strtoll
 #endif
 #include <stdio.h>
-extern long long int strtoll(char *s, char **, int);
+#include <stdlib.h>
 static int bad = 0;
-int check(char *s, long long ell, int een) {
+void check(const char *s, long long ell, int een) {
 	long long gll;
 	errno = 0;
 	gll = strtoll(s, 0, 10);
@@ -19160,11 +19160,11 @@ case "$d_strtoul" in
 Checking whether your strtoul() works okay...
 EOM
 	$cat >try.c <<'EOCP'
+#include <stdlib.h>
 #include <errno.h>
 #include <stdio.h>
-extern unsigned long int strtoul(char *s, char **, int);
 static int bad = 0;
-void check(char *s, unsigned long eul, int een) {
+void check(const char *s, unsigned long eul, int een) {
 	unsigned long gul;
 	errno = 0;
 	gul = strtoul(s, 0, 10);
@@ -19297,11 +19297,11 @@ case "$d_strtouq" in
 Checking whether your strtouq() works okay...
 EOM
 	$cat >try.c <<'EOCP'
+#include <stdlib.h>
 #include <errno.h>
 #include <stdio.h>
-extern unsigned long long int strtouq(char *s, char **, int);
 static int bad = 0;
-void check(char *s, unsigned long long eull, int een) {
+void check(const char *s, unsigned long long eull, int een) {
 	unsigned long long gull;
 	errno = 0;
 	gull = strtouq(s, 0, 10);
-- 
2.20.1


From eaba48217052ec408bdb03588371c02f0201c623 Mon Sep 17 00:00:00 2001
From: Andy Dougherty <doughera@lafayette.edu>
Date: Wed, 28 Aug 2019 10:30:23 -0400
Subject: [PATCH 5/5] Include <stdio.h> in getpgrp/setpgrp probes for printf
 prototype.

C compilers typically issue a warning, but c++ compilers may abort with
an error.
---
 Configure | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Configure b/Configure
index 0419850ee4c..9b54c7bc226 100755
--- a/Configure
+++ b/Configure
@@ -11289,6 +11289,7 @@ case "$d_getpgrp" in
 	echo " "
 	echo "Checking to see which flavor of getpgrp is in use..."
 	$cat >try.c <<EOP
+#include <stdio.h>
 #$i_unistd I_UNISTD
 #include <sys/types.h>
 #ifdef I_UNISTD
@@ -11355,6 +11356,7 @@ case "$d_setpgrp" in
 	echo " "
 	echo "Checking to see which flavor of setpgrp is in use..."
 	$cat >try.c <<EOP
+#include <stdio.h>
 #$i_unistd I_UNISTD
 #include <sys/types.h>
 #ifdef I_UNISTD
-- 
2.20.1


--zhXaljGHf11kAtnf--
0
doughera
12/14/2019 3:04:23 AM
perl.perl5.porters 48067 articles. 1 followers. Follow

3 Replies
56 Views

Similar Articles

[PageSpeed] 47

On 12/13/19 10:04 PM, Andy Dougherty wrote:
> I have some Configure updates to satisfy some clang++ issues.  I also have
> updates for the metaconfig units, but haven't fully sorted out matching
> them to the new metaconfig repository.
> 
> How does this work in the brave new github world?  Shall I just push
> my Configure changes as before?  Or would folks prefer that I sort out
> the metaconfig changes first?
> 
> (I have seen the notes about forks and pull requests in perlgit.pod; my question
> is more about whether I should deal with the metaconfig units first.
> 
> For reference, I've attached the patches here.
> 

I'll leave it to tux to make a ruling on this, but tomorrow I will 
locally apply those patches to ./Configure and try them out in the 
situations where clang++ has been problematic.

Thank you very much.
Jim Keenan
0
jkeenan
12/14/2019 4:55:35 AM
--Sig_/4FSisDUSG6f59YkjjrJn=H7
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: quoted-printable

On Fri, 13 Dec 2019 22:04:23 -0500, Andy Dougherty
<doughera@lafayette.edu> wrote:

> I have some Configure updates to satisfy some clang++ issues.  I also
> have updates for the metaconfig units, but haven't fully sorted out
> matching them to the new metaconfig repository.
>=20
> How does this work in the brave new github world?  Shall I just push=20
> my Configure changes as before?  Or would folks prefer that I sort out
> the metaconfig changes first?

Both?

I don't care about the order, but note that I am a bit behind on
keeping sync. Real life, you know.

So probably just pushing to blead is easiest.

> (I have seen the notes about forks and pull requests in perlgit.pod;
> my question is more about whether I should deal with the metaconfig
> units first.
>=20
> For reference, I've attached the patches here.

--=20
H.Merijn Brand  http://tux.nl   Perl Monger  http://amsterdam.pm.org/
using perl5.00307 .. 5.31      porting perl5 on HP-UX, AIX, and Linux
https://useplaintext.email  https://tux.nl  http://www.test-smoke.org
http://qa.perl.org   http://www.goldmark.org/jeff/stupid-disclaimers/

--Sig_/4FSisDUSG6f59YkjjrJn=H7
Content-Type: application/pgp-signature
Content-Description: OpenPGP digital signature

-----BEGIN PGP SIGNATURE-----

iQEzBAEBCAAdFiEEGolmczWuFi3lJEbAA6FHoT5dwJgFAl30sYwACgkQA6FHoT5d
wJiRIQgAg+T3NMPwhpjDsuLv3qoDjq0P44ySeeMfHST9zld4Ufuc8udQDOGXLLCG
aqQK3UpU57VLyipO5zRnybrETfe0sgdzzcIVrA52eNLYod+vVR01q4AiYQnuTpZm
H15vo4GHSXle/SyY2S/8pK5PZGbmWFXXEnC1g1ex/+NrTFbypWjpBePu6gjNOeiV
ipsZOVScLFNH3j+KlmYlI40jkuj3ISdMWibNwU9jTHXzGufavK4qMOq0o52AX637
fkzi5zNj/8glsuVY8wkDD7mDmHMU0fhZmM9FRfrv/YNN8OkR5kQjSCTImGKBWz/1
l1AJvahm3j3Jy+K5ViyNOQfA2DlzyA==
=eIDk
-----END PGP SIGNATURE-----

--Sig_/4FSisDUSG6f59YkjjrJn=H7--
0
h
12/14/2019 9:55:24 AM
On 12/13/19 11:55 PM, James E Keenan wrote:
> On 12/13/19 10:04 PM, Andy Dougherty wrote:
>> I have some Configure updates to satisfy some clang++ issues.� I also 
>> have
>> updates for the metaconfig units, but haven't fully sorted out matching
>> them to the new metaconfig repository.
>>
>> How does this work in the brave new github world?� Shall I just push
>> my Configure changes as before?� Or would folks prefer that I sort out
>> the metaconfig changes first?
>>
>> (I have seen the notes about forks and pull requests in perlgit.pod; 
>> my question
>> is more about whether I should deal with the metaconfig units first.
>>
>> For reference, I've attached the patches here.
>>
> 
> I'll leave it to tux to make a ruling on this, but tomorrow I will 
> locally apply those patches to ./Configure and try them out in the 
> situations where clang++ has been problematic.
> 
> Thank you very much.
> Jim Keenan

I created this branch:
smoke-me/jkeenan/andyd/configure-20191214
.... and applied each of the 5 patches in turn, configuring with clang++ 
after each one and recording config.sh and config.h.  I then did before- 
and after-5-patches diffs, as well as diffs for clang vs clang++.

I've posted the results in https://github.com/Perl/perl5/issues/17133, 
which is the successor to 
https://rt-archive.perl.org/perl5/Ticket/Display.html?id=134375 in which 
these issues were originally discussed.

Thank you very much.
Jim Keenan
0
jkeenan
12/15/2019 5:07:33 AM
Reply: