Re: [PATCH 2/2] tests: fix helldl rule generation in _LT_DEMO_SETUP macro

2019-03-15 Thread Nikolai Merinov
Hi,

Eric Blake  writes:

> On 3/14/19 5:46 PM, Nikolai Merinov wrote:
>> * tests/demo.at (_LT_DEMO_SETUP): $@ expanded to empty string during
>>   _LT_DEMO_SETUP expanding. Avoid $@ usage inside m4_define call.
>
> It is not necessary to avoid $@, you just merely have to quote it so
> that m4 doesn't eat it.
>
>> ---
>>  tests/demo.at | 15 ++-
>>  1 file changed, 10 insertions(+), 5 deletions(-)
>> 
>> diff --git a/tests/demo.at b/tests/demo.at
>> index 4eb156cf..a10520b0 100644
>> --- a/tests/demo.at
>> +++ b/tests/demo.at
>> @@ -121,11 +121,16 @@ else
>>  
>>  # Create a script that says that -dlopen is not supported.
>>  bin_SCRIPTS = helldl
>> -helldl helldl$(EXEEXT):
>> -rm -rf $@
>> -echo '#! /bin/sh' > $@
>> -echo 'echo sorry, -dlopen is unsupported' >> $@
>> -chmod +x $@
>
> Writing $[@] is generally sufficient to keep m4 from eating things.  If
> that fails, m4sh supports quadrigraphs, where you can write @S|@@ to get
> $@ in the resulting file.

An additional quotation had had no effect: 

  $@   --> empty string
  $[@] --> $[@]
  [$@] --> []

But your suggestion with quadrigraph works well. Updated patch attached.

Regards,
Nikolai

>From 0a9bd9dab0a2ad7149ab0411a7a93837abdcf5b7 Mon Sep 17 00:00:00 2001
From: Nikolai Merinov 
Date: Fri, 15 Mar 2019 01:39:46 +0500
Subject: [PATCH 2/2] tests: fix helldl rule generation in _LT_DEMO_SETUP macro

* tests/demo.at (_LT_DEMO_SETUP): $@ expanded to empty string during
  _LT_DEMO_SETUP expanding. Use quadrigrapth to emit $@ in resulting
  file.
---
 tests/demo.at | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tests/demo.at b/tests/demo.at
index 4eb156cf..7d66e2aa 100644
--- a/tests/demo.at
+++ b/tests/demo.at
@@ -122,10 +122,10 @@ else
 # Create a script that says that -dlopen is not supported.
 bin_SCRIPTS = helldl
 helldl helldl$(EXEEXT):
-	rm -rf $@
-	echo '#! /bin/sh' > $@
-	echo 'echo sorry, -dlopen is unsupported' >> $@
-	chmod +x $@
+	rm -rf @S|@@
+	echo '#! /bin/sh' > @S|@@
+	echo 'echo sorry, -dlopen is unsupported' >> @S|@@
+	chmod +x @S|@@
 
 endif
 
-- 
2.21.0



[PATCH 0/2] Support quotted arguments in user-supplied flags

2019-03-14 Thread Nikolai Merinov
Currently in the `_LT_COMPILER_OPTION' macro exists same issue as I tried
to fix for autoconf in the following thread: 
https://lists.gnu.org/archive/html/autoconf-patches/2019-03/msg3.html

As result of this issue the following call:

> ./configure CPPFLAGS='-DSTR=\"TESTME\"' CC=clang

always ends with "checking if clang PIC flag -fPIC -DPIC works... no".
As result it is impossible to compile shared libraries with "clang" and flags
with quotes. This bug reproduced only with clang because it produce slightly
different warning with "-fPIC" and without this option:

$ clang '-DTEST=\"str\"' main.c |& head -2
In file included from :349:
:1:15: warning: missing terminating '"' character 
[-Winvalid-pp-token]
$ clang '-DTEST=\"str\"' -fPIC main.c |& head -2
In file included from :351:
:1:15: warning: missing terminating '"' character 
[-Winvalid-pp-token]

Suggested patch changes code to evaluate `ac_compile' twice: in second time
user-supplied arguments itself will be unquotted. This is a same behavior
as with CFLAGS passed to "make" command. 

Please note, suggested new test will work only with autoconf with my patch
from https://lists.gnu.org/archive/html/autoconf-patches/2019-03/msg3.html
With older autoconf versions my test will fail on ./configure call and
test will be skipped.

During work on this issue I observed that _LT_DEMO_SETUP produced broken
code for a Makefile.am file. I failed to find how we can safely use $@
inside of m4_define function call and decided to workaround issue with
removing $@ at all.





[PATCH 1/2] libtool: Support quoted arguments in user-supplied flags

2019-03-14 Thread Nikolai Merinov
* m4/libtool.m4 (_LT_COMPILER_OPTION): Evaluate `lt_compile' variable
  twice in order to unquote user-supplied variables in same manner as
  it made during compilation in Makefiles
  (_LT_COMPILER_C_O): Same
* Makefile.am (TESTSUITE_AT): Add new test
* tests/escaped_cflags.at: New test for quoted CFLAGS. This test would
  work only with autoconf > 2.69; for older autoconf ./configure will
  fail and test will be skipped.
---
 Makefile.am |  1 +
 m4/libtool.m4   |  4 
 tests/escaped_cflags.at | 44 +
 3 files changed, 49 insertions(+)
 create mode 100644 tests/escaped_cflags.at

diff --git a/Makefile.am b/Makefile.am
index 6b546092..e99949b2 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -658,6 +658,7 @@ TESTSUITE_AT= tests/testsuite.at \
  tests/libtoolize.at \
  tests/libtool.at \
  tests/demo.at \
+ tests/escaped_cflags.at \
  tests/pic_flag.at \
  tests/with-pic.at \
  tests/cdemo.at \
diff --git a/m4/libtool.m4 b/m4/libtool.m4
index f2d1f398..fa7887e0 100644
--- a/m4/libtool.m4
+++ b/m4/libtool.m4
@@ -1606,6 +1606,8 @@ AC_CACHE_CHECK([$1], [$2],
-e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:$LINENO: $lt_compile\"" >_MESSAGE_LOG_FD)
+   # Evaluate compilation command twice in order to unqoute *FLAGS
+   eval lt_compile="\"$lt_compile\""
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >_MESSAGE_LOG_FD
@@ -2088,6 +2090,8 @@ AC_CACHE_CHECK([if $compiler supports -c -o 
file.$ac_objext],
-e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:$LINENO: $lt_compile\"" >_MESSAGE_LOG_FD)
+   # Evaluate compilation command twice in order to unqoute *FLAGS
+   eval lt_compile="\"$lt_compile\""
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >_MESSAGE_LOG_FD
diff --git a/tests/escaped_cflags.at b/tests/escaped_cflags.at
new file mode 100644
index ..3dd95ba4
--- /dev/null
+++ b/tests/escaped_cflags.at
@@ -0,0 +1,44 @@
+# escaped_cflags.at -- escaped CFLAGS and tests for PIC flags   -*- Autotest 
-*-
+
+#   Copyright (C) 2019 Free Software Foundation, Inc.
+#
+#   This file is part of GNU Libtool.
+#
+# GNU Libtool is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# GNU Libtool is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Libtool; see the file COPYING.  If not, a copy
+# can be downloaded from  http://www.gnu.org/licenses/gpl.html,
+# or obtained by writing to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+
+AT_SETUP([check pic_flags with escaped CFLAGS])
+
+AT_DATA([foo.c],
+[[int data = 42;
+int func(void) { return data; }
+]])
+
+# Set up a tests/demo.at style project.
+_LT_DEMO_SETUP
+
+# Bootstrap, and configure it so that we can extract libtool --config
+# settings.
+LT_AT_BOOTSTRAP([], [-I m4], [], [--add-missing], [],
+[CFLAGS='"-Wall"'], [ignore])
+
+: ${MAKE=make}
+AT_CHECK([$MAKE], [], [stdout], [ignore])
+AT_CHECK([if ./libtool --features | $GREP 'enable shared libraries'; then ]dnl
+[  $GREP -i ' -fPIC' stdout; else exit 77; fi], [], [ignore], [ignore])
+
+AT_CLEANUP
-- 
2.21.0




[PATCH 2/2] tests: fix helldl rule generation in _LT_DEMO_SETUP macro

2019-03-14 Thread Nikolai Merinov
* tests/demo.at (_LT_DEMO_SETUP): $@ expanded to empty string during
  _LT_DEMO_SETUP expanding. Avoid $@ usage inside m4_define call.
---
 tests/demo.at | 15 ++-
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/tests/demo.at b/tests/demo.at
index 4eb156cf..a10520b0 100644
--- a/tests/demo.at
+++ b/tests/demo.at
@@ -121,11 +121,16 @@ else
 
 # Create a script that says that -dlopen is not supported.
 bin_SCRIPTS = helldl
-helldl helldl$(EXEEXT):
-   rm -rf $@
-   echo '#! /bin/sh' > $@
-   echo 'echo sorry, -dlopen is unsupported' >> $@
-   chmod +x $@
+helldl:
+   rm -rf helldl
+   echo '#! /bin/sh' > helldl
+   echo 'echo sorry, -dlopen is unsupported' >> helldl
+   chmod +x helldl
+helldl$(EXEEXT):
+   rm -rf helldl$(EXEEXT)
+   echo '#! /bin/sh' > helldl$(EXEEXT)
+   echo 'echo sorry, -dlopen is unsupported' >> helldl$(EXEEXT)
+   chmod +x helldl$(EXEEXT)
 
 endif
 
-- 
2.21.0




Re: [PATCH 2/2] tests: fix helldl rule generation in _LT_DEMO_SETUP macro

2019-09-28 Thread Nikolai Merinov
Hi,

Should I make any additional changes to the patch in order to merge it?

Regards,
Nikolai

On Fri, Mar 15, 2019 at 5:25 PM Nikolai Merinov <
nikolai.meri...@member.fsf.org> wrote:

> Hi,
>
> Eric Blake  writes:
>
> > On 3/14/19 5:46 PM, Nikolai Merinov wrote:
> >> * tests/demo.at (_LT_DEMO_SETUP): $@ expanded to empty string during
> >>   _LT_DEMO_SETUP expanding. Avoid $@ usage inside m4_define call.
> >
> > It is not necessary to avoid $@, you just merely have to quote it so
> > that m4 doesn't eat it.
> >
> >> ---
> >>  tests/demo.at | 15 ++-
> >>  1 file changed, 10 insertions(+), 5 deletions(-)
> >>
> >> diff --git a/tests/demo.at b/tests/demo.at
> >> index 4eb156cf..a10520b0 100644
> >> --- a/tests/demo.at
> >> +++ b/tests/demo.at
> >> @@ -121,11 +121,16 @@ else
> >>
> >>  # Create a script that says that -dlopen is not supported.
> >>  bin_SCRIPTS = helldl
> >> -helldl helldl$(EXEEXT):
> >> -rm -rf $@
> >> -echo '#! /bin/sh' > $@
> >> -echo 'echo sorry, -dlopen is unsupported' >> $@
> >> -chmod +x $@
> >
> > Writing $[@] is generally sufficient to keep m4 from eating things.  If
> > that fails, m4sh supports quadrigraphs, where you can write @S|@@ to get
> > $@ in the resulting file.
>
> An additional quotation had had no effect:
>
>   $@   --> empty string
>   $[@] --> $[@]
>   [$@] --> []
>
> But your suggestion with quadrigraph works well. Updated patch attached.
>
> Regards,
> Nikolai
>
>


Re: [PATCH 2/2] tests: fix helldl rule generation in _LT_DEMO_SETUP macro

2020-02-16 Thread Nikolai Merinov
Hi,

This is gentle reminder about the patch

Regards,
Nikolai

Nikolai Merinov  writes:

> Hi,
>
> Should I make any additional changes to the patch in order to merge it? 
>
> Regards,
> Nikolai
>
> On Fri, Mar 15, 2019 at 5:25 PM Nikolai Merinov 
>  wrote:
>
>  Hi,
>
>  Eric Blake  writes:
>
>  > On 3/14/19 5:46 PM, Nikolai Merinov wrote:
>  >> * tests/demo.at (_LT_DEMO_SETUP): $@ expanded to empty string during
>  >>   _LT_DEMO_SETUP expanding. Avoid $@ usage inside m4_define call.
>  >
>  > It is not necessary to avoid $@, you just merely have to quote it so
>  > that m4 doesn't eat it.
>  >
>  >> ---
>  >>  tests/demo.at | 15 ++-
>  >>  1 file changed, 10 insertions(+), 5 deletions(-)
>  >> 
>  >> diff --git a/tests/demo.at b/tests/demo.at
>  >> index 4eb156cf..a10520b0 100644
>  >> --- a/tests/demo.at
>  >> +++ b/tests/demo.at
>  >> @@ -121,11 +121,16 @@ else
>  >>  
>  >>  # Create a script that says that -dlopen is not supported.
>  >>  bin_SCRIPTS = helldl
>  >> -helldl helldl$(EXEEXT):
>  >> -rm -rf $@
>  >> -echo '#! /bin/sh' > $@
>  >> -echo 'echo sorry, -dlopen is unsupported' >> $@
>  >> -chmod +x $@
>  >
>  > Writing $[@] is generally sufficient to keep m4 from eating things.  If
>  > that fails, m4sh supports quadrigraphs, where you can write @S|@@ to get
>  > $@ in the resulting file.
>
>  An additional quotation had had no effect: 
>
>$@   --> empty string
>$[@] --> $[@]
>[$@] --> []
>
>  But your suggestion with quadrigraph works well. Updated patch attached.
>
>  Regards,
>  Nikolai