Thread overview
[Issue 16677] -L flag ignores quotes in the arguments passed to the linker
Nov 11, 2016
Sprink
Dec 23, 2016
Atila Neves
Jan 03, 2017
Sprink
Apr 24, 2019
GoaLitiuM
Apr 25, 2019
Jacob Carlborg
Oct 07, 2019
kinke
Oct 07, 2019
Dlang Bot
Oct 18, 2019
Dlang Bot
November 11, 2016
https://issues.dlang.org/show_bug.cgi?id=16677

Sprink <sprink.noreply@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |sprink.noreply@gmail.com

--- Comment #1 from Sprink <sprink.noreply@gmail.com> ---
The problem might be Window's shell consuming the quotes, not that DMD ignores them. A potential workaround would be to escape the quotes you want passed to the linker. You'd have to look it up, I think it is different for cmd and powershell.

https://github.com/dlang/dmd/blob/v2.072.0/src/link.d#L267

Adding quotes around passed in linker flags would make it simpler, not having to deal with escaping the quotes in the command.

--
December 23, 2016
https://issues.dlang.org/show_bug.cgi?id=16677

--- Comment #2 from Atila Neves <atila.neves@gmail.com> ---
If the problem was cmd.exe then cl.exe would also suffer from this, which doesn't happen.

--
January 03, 2017
https://issues.dlang.org/show_bug.cgi?id=16677

--- Comment #3 from Sprink <sprink.noreply@gmail.com> ---
(In reply to Atila Neves from comment #2)
> If the problem was cmd.exe then cl.exe would also suffer from this, which doesn't happen.

No it wouldn't, cl.exe doesn't get the quotes either. So there no quotes to ignore or to process. It's a matter of how DMD sends arguments to the process, it does so by building an entire string. So it just concatenates the passed argument into the list, but it's devoid of it's quotes because of cmd.exe. Escaping the quotes so cmd.exe includes the quotes solves the problem.

--
April 24, 2019
https://issues.dlang.org/show_bug.cgi?id=16677

GoaLitiuM <goalitium@dissues.mail.kapsi.fi> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |goalitium@dissues.mail.kaps
                   |                            |i.fi

--- Comment #4 from GoaLitiuM <goalitium@dissues.mail.kapsi.fi> ---
We just hit this bug too with DMD, but passing the same quoted path to LDC does get handled correctly:

> ldc2 -m64 "-L/LIBPATH:C:/Program Files (x86)/foo/bar" hello.d
> dmd -m64 "-L/LIBPATH:C:/Program Files (x86)/foo/bar" hello.d
LINK : fatal error LNK1181: cannot open input file 'Files.obj' Error: linker exited with status 1181

--
April 25, 2019
https://issues.dlang.org/show_bug.cgi?id=16677

Jacob Carlborg <doob@me.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |doob@me.com

--- Comment #5 from Jacob Carlborg <doob@me.com> ---
*** Issue 19821 has been marked as a duplicate of this issue. ***

--
October 07, 2019
https://issues.dlang.org/show_bug.cgi?id=16677

kinke <kinke@gmx.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kinke@gmx.net

--- Comment #6 from kinke <kinke@gmx.net> ---
This seems to be a DMD bug when building the linker cmdline on Windows, at least for link.exe - it simply doesn't do any quoting and writes the linker flag directly into the cmdline string. On POSIX, an arguments array is used.

POSIX:

$ dmd '-Labc def' foo.d
/usr/bin/ld: error: cannot open abc def: No such file or directory

Windows:

dmd "-Labc def" -m64 foo.d
LINK : fatal error LNK1181: cannot open input file 'abc.obj'

[The current way to make it work is an extremely ugly `dmd "-L\"abc def\"" -m64 foo.d`.]

--
October 07, 2019
https://issues.dlang.org/show_bug.cgi?id=16677

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #7 from Dlang Bot <dlang-bot@dlang.rocks> ---
@kinke created dlang/dmd pull request #10459 "Fix linker flags with blanks on Windows" fixing this issue:

- Fix linker flags with blanks on Windows

  Fixes issue 19821 and 16677, for link.exe only though.

https://github.com/dlang/dmd/pull/10459

--
October 18, 2019
https://issues.dlang.org/show_bug.cgi?id=16677

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #8 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/dmd pull request #10459 "[stable] Fix linker flags with blanks on Windows" was merged into stable:

- ec6de46e76efd34d3f8a5d97f89cd1f42beb1cdd by Martin Kinkelin:
  Fix linker flags with spaces on Windows

  Fixes issue 19821 and 16677 for MS link.exe only (I haven't checked
  Optlink).

https://github.com/dlang/dmd/pull/10459

--