Re: [PATCH] configure: $(CC) -o /dev/null when output not run

2021-05-23 Thread Tomi Ollila
On Sat, May 22 2021, David Bremner wrote:

> Tomi Ollila  writes:
>
>> When C compilation is used just to see whether compilation
>> succeeds, there is no need to write any output file.
>>
>> Some compilations in configure already did this.
>>
>> Now also rm -f lines are used more consistently.
>>
>> While at it reformatted code that prints
>> LIBNOTMUCH_{MAJOR,MINOR,MICRO}_VERSION).
>
> no objection in principle, but has anyone tried a compiler other than
> gcc to make sure it doesn't puke when writing to /dev/null. Not sure
> why it would, but...

I gave it some thought and was sure there would be no such case...

But now that I tested with 'zig cc' -- it apparently tries to remove
the target file before recreating and fails with accessDenied if cannot
(or, hopefully it just checks permissions, as removing /dev/null as
root would be nasty...)

Too bad, I had some plans that this change would have helped but...

Tomi
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH] configure: $(CC) -o /dev/null when output not run

2021-05-22 Thread David Bremner
Tomi Ollila  writes:

> When C compilation is used just to see whether compilation
> succeeds, there is no need to write any output file.
>
> Some compilations in configure already did this.
>
> Now also rm -f lines are used more consistently.
>
> While at it reformatted code that prints
> LIBNOTMUCH_{MAJOR,MINOR,MICRO}_VERSION).

no objection in principle, but has anyone tried a compiler other than
gcc to make sure it doesn't puke when writing to /dev/null. Not sure
why it would, but...
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH] configure: $(CC) -o /dev/null when output not run

2021-05-21 Thread Tomi Ollila
When C compilation is used just to see whether compilation
succeeds, there is no need to write any output file.

Some compilations in configure already did this.

Now also rm -f lines are used more consistently.

While at it reformatted code that prints
LIBNOTMUCH_{MAJOR,MINOR,MICRO}_VERSION).
---

Hmm, these
printf("libnotmuch_version_major=%d\n", LIBNOTMUCH_MAJOR_VERSION)
lines leaked into this commit. I've always wanted to make
this change (as it fits and looks clearer) but haven't found
good commit for that Now edited commit message to mention 
the change.

 configure | 57 ++-
 1 file changed, 23 insertions(+), 34 deletions(-)

diff --git a/configure b/configure
index cfa9c09b..e907c6fc 100755
--- a/configure
+++ b/configure
@@ -362,7 +362,7 @@ errors=0
 printf "int main(void){return 0;}\n" > minimal.c
 
 printf "Sanity checking C compilation environment... "
-test_cmdline="${CC} ${CFLAGS} ${CPPFLAGS} minimal.c ${LDFLAGS} -o minimal"
+test_cmdline="${CC} ${CFLAGS} ${CPPFLAGS} minimal.c ${LDFLAGS} -o /dev/null"
 if  ${test_cmdline} > /dev/null 2>&1
 then
 printf "OK.\n"
@@ -374,7 +374,7 @@ else
 fi
 
 printf "Sanity checking C++ compilation environment... "
-test_cmdline="${CXX} ${CXXFLAGS_for_sh} ${CPPFLAGS} minimal.c ${LDFLAGS} -o 
minimal"
+test_cmdline="${CXX} ${CXXFLAGS_for_sh} ${CPPFLAGS} minimal.c ${LDFLAGS} -o 
/dev/null"
 if ${test_cmdline} > /dev/null 2>&1
 then
 printf "OK.\n"
@@ -392,7 +392,7 @@ if [ $errors -gt 0 ]; then
 running configure in a clean environment, and if the problem persists,
 report a bug.
 EOF
-rm -f minimal minimal.c
+rm -f minimal.c
 exit 1
 fi
 
@@ -401,12 +401,9 @@ cat > _libversion.c <
 #include "lib/notmuch.h"
 int main(void) {
-printf("libnotmuch_version_major=%d\n",
-   LIBNOTMUCH_MAJOR_VERSION);
-printf("libnotmuch_version_minor=%d\n",
-   LIBNOTMUCH_MINOR_VERSION);
-printf("libnotmuch_version_release=%d\n",
-   LIBNOTMUCH_MICRO_VERSION);
+printf("libnotmuch_version_major=%d\n",LIBNOTMUCH_MAJOR_VERSION);
+printf("libnotmuch_version_minor=%d\n",LIBNOTMUCH_MINOR_VERSION);
+printf("libnotmuch_version_release=%d\n",  LIBNOTMUCH_MICRO_VERSION);
 return 0;
 }
 EOF
@@ -432,7 +429,6 @@ else
 fi
 
 
-
 printf "Checking for Xapian development files (>= 1.4.0)... "
 have_xapian=0
 for xapian_config in ${XAPIAN_CONFIG} xapian-config; do
@@ -1045,7 +1041,7 @@ EOF
 fi
 
 printf "Checking for canonicalize_file_name... "
-if ${CC} -o compat/have_canonicalize_file_name 
"$srcdir"/compat/have_canonicalize_file_name.c > /dev/null 2>&1
+if ${CC} -o /dev/null "$srcdir"/compat/have_canonicalize_file_name.c > 
/dev/null 2>&1
 then
 printf "Yes.\n"
 have_canonicalize_file_name=1
@@ -1053,11 +1049,9 @@ else
 printf "No (will use our own instead).\n"
 have_canonicalize_file_name=0
 fi
-rm -f compat/have_canonicalize_file_name
-
 
 printf "Checking for getline... "
-if ${CC} -o compat/have_getline "$srcdir"/compat/have_getline.c > /dev/null 
2>&1
+if ${CC} -o /dev/null "$srcdir"/compat/have_getline.c > /dev/null 2>&1
 then
 printf "Yes.\n"
 have_getline=1
@@ -1065,10 +1059,9 @@ else
 printf "No (will use our own instead).\n"
 have_getline=0
 fi
-rm -f compat/have_getline
 
 printf "Checking for strcasestr... "
-if ${CC} -o compat/have_strcasestr "$srcdir"/compat/have_strcasestr.c > 
/dev/null 2>&1
+if ${CC} -o /dev/null "$srcdir"/compat/have_strcasestr.c > /dev/null 2>&1
 then
 printf "Yes.\n"
 have_strcasestr=1
@@ -1076,10 +1069,9 @@ else
 printf "No (will use our own instead).\n"
 have_strcasestr=0
 fi
-rm -f compat/have_strcasestr
 
 printf "Checking for strsep... "
-if ${CC} -o compat/have_strsep "$srcdir"/compat/have_strsep.c > /dev/null 2>&1
+if ${CC} -o /dev/null "$srcdir"/compat/have_strsep.c > /dev/null 2>&1
 then
 printf "Yes.\n"
 have_strsep="1"
@@ -1087,10 +1079,9 @@ else
 printf "No (will use our own instead).\n"
 have_strsep="0"
 fi
-rm -f compat/have_strsep
 
 printf "Checking for timegm... "
-if ${CC} -o compat/have_timegm "$srcdir"/compat/have_timegm.c > /dev/null 2>&1
+if ${CC} -o /dev/null "$srcdir"/compat/have_timegm.c > /dev/null 2>&1
 then
 printf "Yes.\n"
 have_timegm="1"
@@ -1098,7 +1089,6 @@ else
 printf "No (will use our own instead).\n"
 have_timegm="0"
 fi
-rm -f compat/have_timegm
 
 cat < _time_t.c
 #include 
@@ -1117,7 +1107,7 @@ else
 fi
 
 printf "Checking for dirent.d_type... "
-if ${CC} -o compat/have_d_type "$srcdir"/compat/have_d_type.c > /dev/null 2>&1
+if ${CC} -o /dev/null "$srcdir"/compat/have_d_type.c > /dev/null 2>&1
 then
 printf "Yes.\n"
 have_d_type="1"
@@ -1125,10 +1115,9 @@ else
 printf "No (will use stat instead).\n"
 have_d_type="0"
 fi
-rm -f compat/have_d_type
 
 printf "Checking for standard version of getpwuid_r... "
-if ${CC} -o compat/check_getpwuid "$srcdir"/compat/check_getpwuid.c >