Bug 17390 – Pass flags to linker driver without -Xlinker

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
Linux
Creation time
2017-05-10T15:02:48Z
Last change time
2019-09-25T03:50:14Z
Assigned to
No Owner
Creator
Adrian Matoga

Comments

Comment #0 by adrian — 2017-05-10T15:02:48Z
There's an open PR to LDC [1] to allow passing options to the linker driver without -Xlinker on non-Windows platforms. This is required e.g. for flags like --sysroot=path [2] or flags from pkg-config [3] to work as expected. The PR [1] adds option '-Xcc OPT', which passes OPT directly to the linker driver (e.g. gcc or clang) without prepending it with -Xlinker. The global order of flags passed via '-Xcc' and '-L' is preserved, and libraries requested via pragma(lib) are appended after those flags. The choice of '-Xcc' was motivated by clang's convention [4]. A similar feature would probably be useful also for DMD users. Since '-Xcc' doesn't look consistent with current use of '-X' in DMD, DMD probably should use a different switch for it. W.r.t. order of linker (or linker driver) flags, there're a few related DMD issues [5]. [1] https://github.com/ldc-developers/ldc/pull/2104 [2] https://github.com/ldc-developers/ldc/issues/2093 [3] https://github.com/ldc-developers/ldc/issues/1700 [4] https://github.com/ldc-developers/ldc/issues/2093#issuecomment-299707520 [5] https://issues.dlang.org/show_bug.cgi?id=15574 [6] https://issues.dlang.org/show_bug.cgi?id=15531 [7] https://issues.dlang.org/show_bug.cgi?id=7044
Comment #1 by code — 2017-06-09T11:09:18Z
Looks like a duplicate of issue 7678.
Comment #2 by code — 2017-06-09T11:10:51Z
*** Issue 7678 has been marked as a duplicate of this issue. ***
Comment #3 by timothee.cour2 — 2018-03-14T00:39:19Z
ping on this. this would enable: * same motivations as https://github.com/ldc-developers/ldc/issues/2093 (Passing options directly to CC) * makes it easier to switch back and forth between clang build command line and D build command line, by prepending linker arguments with `-Xcc=`, eg: ``` dmd -Xcc=-Wl,-rpath,some_rpath,-lfoo,-Lbar ``
Comment #4 by timothee.cour2 — 2018-03-14T00:39:53Z
also, -Xcc is now part of ldc
Comment #5 by slavo5150 — 2019-09-25T03:50:14Z
This issue has been resolved with the `-preview=noXlinker` switch: https://dlang.org/changelog/pending.html#noxlinker It will allow users to pass options directly to the linker driver without DMD trying to be clever.