[PATCH] [lld] [mach-o] Support -l and -syslibroot options
Tim Northover
t.p.northover at gmail.com
Mon Jul 7 11:18:40 PDT 2014
Hi Shankar,
Thanks for the comments. I'm not sure I have complete responses to any of them, but I'll have a go...
Cheers.
Tim.
================
Comment at: include/lld/ReaderWriter/MachOLinkingContext.h:134
@@ -127,1 +133,3 @@
void setPrintAtoms(bool value=true) { _printAtoms = value; }
+ void setSyslibRoot(StringRef path) { _syslibRoot = path; }
+
----------------
Shankar Kalpathi Easwaran wrote:
> should this be setSysRoot ?
The option is -syslibroot on Darwin. I could see calling the field sysroot anyway, to maintain consistency with ELFLinkingContext. Does lld have any policy on where consistency is preferred?
================
Comment at: lib/Driver/DarwinLdOptions.td:72
@@ -71,1 +71,3 @@
Group<grp_libs>;
+def syslibroot : Separate<["-"], "syslibroot">,
+ HelpText<"Add prefix to all system library search paths">,
----------------
Shankar Kalpathi Easwaran wrote:
> I dont see this an option in the ld64 man page, is this fairly new ?
>
> http://www.manpages.info/macosx/ld.1.html
You'd have to ask someone like Nick for its actual age, but it certainly exists now.
================
Comment at: lib/ReaderWriter/MachO/MachOLinkingContext.cpp:271
@@ +270,3 @@
+ SmallString<128> fullPath;
+ if (libName.endswith(".o")) {
+ // A request ending in .o is special: just search for the file directly.
----------------
Shankar Kalpathi Easwaran wrote:
> - Can the the system paths be prepended to a set of directories that are being looked up, This could help adding for -L.
> - We can possibly search for a library name outside the loop.
>
>
>
>
I started with that system, but specifically moved to this one for two reasons:
+ -syslibroot only applies to the system directories, so I'd need some way of making sure they stay special anyway.
+ Similarly there's a -Z option that removes just these from the search path. This could be handled by dealing with that before any -L or similar, of course.
On the whole, I think the static array is the neatest solution.
================
Comment at: lib/ReaderWriter/MachO/MachOLinkingContext.cpp:300
@@ +299,3 @@
+ path.assign(_syslibRoot);
+ llvm::sys::path::append(path, dir);
+
----------------
Shankar Kalpathi Easwaran wrote:
> - The gnu linker has a way to have the sys root paths be appeneded to the path only if the path starts with an equal to(=) sign, Does MachO also do something like this ? If so this needs to be changed.
> - Does not account for -L
>
>
>
>
>
On the first: I saw that special handling, but I don't believe ld64 has it. The current ld64 man-pages only mention treating "y.o" specially.
On the second: I know. Incremental development and all that. I'd have separated out -syslibroot and -l if I could have reasonably tested one without the other.
http://reviews.llvm.org/D4409
More information about the llvm-commits
mailing list