Bug 20957 - dlltool: syntax error in def file libstdc++-6.def:0
Summary: dlltool: syntax error in def file libstdc++-6.def:0
Status: WAITING
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-12-11 12:59 UTC by kdmarshall
Modified: 2017-01-04 16:19 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed: 2017-01-04 00:00:00


Attachments
Proposed patch (246 bytes, patch)
2017-01-04 16:19 UTC, Nick Clifton
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description kdmarshall 2016-12-11 12:59:54 UTC
I tripped over this, while trying to regenerate an (apparently) defective libstdc++.dll.a import library, originally created during GCC-5.3.0 cross compiler build; it appears to be another manifestation of a parse error, similar but not identical to bug 13657.  I reduced it to:

 $ cat foo.def
 LIBRARY libstdc++-6.dll
 EXPORTS
 _foo

 $ mingw32-dlltool --as mingw32-as --input-def foo.def --output-lib foo.dll.a
 ++mingw32-dlltool: Syntax error in def file foo.def:0

Notice the '++' prefixed to the diagnostic message; these seem to be residual input, unconsumed by the (lex?) scanner, while processing the LIBRARY spec within the def file.  If I remove those '++' chars from the library name, then the LIBRARY spec is parsed successfully, but the DLL name is recorded (incorrectly) as 'libstdc-6.dll', within the generated import library.  Alternatively, I can work around this bug by deleting the (valid and correct) LIBRARY spec from the def file, and instead adding '--dllname libstdc++-6.dll' as a command line option, but I guess you would want to fix the underlying bug.

FWIW, I see exactly the same manifestation of this bug with every version of dlltool which I have to hand, in various corners of my file system, namely:

 binutils-2.21
 binutils-2.23.1
 binutils-2.24
 binutils-2.26.20160125
Comment 1 kdmarshall 2016-12-11 15:25:42 UTC
Just realized that I can circumvent the failure by quoting the library name, within the def file, but that's not consistent with other usage.  Perhaps it should be made so: either require that the library name always be quoted, or always correctly parse any valid file name, which doesn't require quoting by the shell, regardless of quoting.
Comment 2 Nick Clifton 2017-01-04 16:19:22 UTC
Created attachment 9739 [details]
Proposed patch

Hi Marshall,

  Please could you try out this patch and let me know if it works for you.

Cheers
  Nick