This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [committed, PATCH] Update PR ld/21903 tests for dejagnu 1.4.4
On Thu, Aug 24, 2017 at 5:15 PM, Maciej W. Rozycki <macro@imgtec.com> wrote:
> On Thu, 24 Aug 2017, H.J. Lu wrote:
>
>> > Add '\' before -- to workaround dejagnu 1.4.4 which complains:
>> >
>> > ERROR: bad switch "--no-define-common may not be used without -shared":...
>> >
>> > * testsuite/ld-elf/pr21903c.d: Add '\' before --.
>> > * testsuite/ld-elf/pr21903d.d: Likewise.
>> > * testsuite/ld-elf/pr21903e.d: Likewise.
>>
>> I checked in this patch to workaround another dejagnu 1.4.4 issue.
>>
>>
>> H.J.
>> ---
>> Subject: [PATCH] ld: Replace regexp with string match
>>
>> Replace regexp with string match to workaround dejagnu 1.4.4 which
>> complains:
>>
>> ERROR: bad switch "-fPIE": must be -all, -about, -indices, -inline, -expanded, -line, -linestop, -lineanchor, -nocase, -start, or --
>
> Hmm, isn't `--' the usual way to signify any further strings are not
> options even if they start with `-'? It's even quoted in the error
> message. Have you tried it instead?
>
> If that indeed works as documented[1], then similarly I think the earlier
> problem ought to be addressed by fixing the invocation of `regexp' used to
> handle `#error' (and any similar tags) in the test framework rather than
> applying hacks like yours to individual test cases.
>
>> diff --git a/ld/testsuite/ld-i386/i386.exp b/ld/testsuite/ld-i386/i386.exp
>> index c91a8611f3..c813a80551 100644
>> --- a/ld/testsuite/ld-i386/i386.exp
>> +++ b/ld/testsuite/ld-i386/i386.exp
>> @@ -468,8 +468,8 @@ proc undefined_weak {cflags ldflags} {
>> set testname "$testname ($cflags $ldflags)"
>> }
>>
>> - if { [ regexp "\-fPIE" $cflags]
>> - && ![ regexp "\-z nodynamic-undefined-weak" $ldflags] } {
>> + if { [string match "*-fPIE*" $cflags]
>> + && ![string match "*-z nodynamic-undefined-weak*" $ldflags] } {
>
> So this would then become:
>
> if { [ regexp -- "\-fPIE" $cflags]
> && ![ regexp -- "\-z nodynamic-undefined-weak" $ldflags] } {
>
> (the backslashes can also be removed as there is no special meaning
> assigned to a `\-' sequence in the regular expression syntax defined by
> TCL AFAIK, so this is equivalent to plain `-' I believe).
>
> References:
>
> [1] <http://tmml.sourceforge.net/doc/tcl/regexp.html>
>
This works. I will check it in.
Thanks.
--
H.J.
---
diff --git a/ld/testsuite/ld-elf/pr21903c.d b/ld/testsuite/ld-elf/pr21903c.d
index 1668c084cb..d3910ec79b 100644
--- a/ld/testsuite/ld-elf/pr21903c.d
+++ b/ld/testsuite/ld-elf/pr21903c.d
@@ -1,3 +1,3 @@
#source: pr21903.s
#ld: --no-define-common
-#error: \--no-define-common may not be used without -shared
+#error: --no-define-common may not be used without -shared
diff --git a/ld/testsuite/ld-elf/pr21903d.d b/ld/testsuite/ld-elf/pr21903d.d
index 84d0e76e83..ec729007d1 100644
--- a/ld/testsuite/ld-elf/pr21903d.d
+++ b/ld/testsuite/ld-elf/pr21903d.d
@@ -1,4 +1,4 @@
#source: pr21903.s
#ld: --no-define-common -pie
#target: *-*-linux* *-*-gnu*
-#error: \--no-define-common may not be used without -shared
+#error: --no-define-common may not be used without -shared
diff --git a/ld/testsuite/ld-elf/pr21903e.d b/ld/testsuite/ld-elf/pr21903e.d
index e673e4a7a9..894c595c43 100644
--- a/ld/testsuite/ld-elf/pr21903e.d
+++ b/ld/testsuite/ld-elf/pr21903e.d
@@ -1,3 +1,3 @@
#source: pr21903.s
#ld: -r --no-define-common
-#error: \--no-define-common may not be used without -shared
+#error: --no-define-common may not be used without -shared
diff --git a/ld/testsuite/lib/ld-lib.exp b/ld/testsuite/lib/ld-lib.exp
index cddcaf834b..c240410270 100644
--- a/ld/testsuite/lib/ld-lib.exp
+++ b/ld/testsuite/lib/ld-lib.exp
@@ -976,7 +976,7 @@ proc run_dump_test { name {extra_options {}} } {
&& (($cmdret == 0) == ($check_ld(terminal) == 0)) \
&& ((($check_ld(source) == "regex") \
&& ($check_ld(regex) == "") == ($comp_output == "") \
- && [regexp $check_ld(regex) $comp_output]) \
+ && [regexp -- $check_ld(regex) $comp_output]) \
|| (($check_ld(source) == "file") \
&& (![regexp_diff "tmpdir/ld.messages"
"$srcdir/$subdir/$check_ld(file)"]))) } {
# We have the expected output from ld.