This adds support for the -syslibroot option. This is required to
make the library search order actually function. With this, it is now
possible to link a test Darwin x86_64 program with lld on Darwin.
Details
- Reviewers
smeenai Ktwu int3 - Group Reviewers
Restricted Project - Commits
- rG0ccda7c2326e: MachO: support `-syslibroot`
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
lld/MachO/Driver.cpp | ||
---|---|---|
162 | any particular reason why you picked 261? | |
174 | suppresses | |
lld/test/MachO/syslibroot.test | ||
2 | s/non-existant/nonexistent/ | |
4 | s/NONEXISTANT/NONEXISTENT/ | |
15 | nit: could we have a shorter tmp directory name? | |
16 | nit: most other tests use double-dash flags, i.e. --check-prefix | |
19 | nit: would be better to pass the tmp dir to FileCheck via -DTMP=%t and use it here instead of {{.+}}. I believe the current check would pass even if there were only whitespace before /Users/... |
lld/MachO/Driver.cpp | ||
---|---|---|
162 | MAX(256, 261) - 261 is the Windows path limit, 256 is the value used on Unix. |
lld/test/MachO/syslibroot.test | ||
---|---|---|
15 | Sure, we can make it a system library path instead. IMO, the longer path immediately identifies that this is definitely not a default search path (/System/Library/Frameworks vs /Library/Frameworks is slightly easier to miss). |
Oh yeah, don't forget to remove the HelpHidden tag from syslibroot's definition in Options.td
lld/MachO/Driver.cpp | ||
---|---|---|
160 | Will this work on Windows given the use of Style::posix? | |
162 | Ah I see. Can we make it a named constant? | |
lld/test/MachO/syslibroot.test | ||
22–23 | which is the fuzzy match here? not sure I follow... | |
24 | is /var/empty also going to be empty on Windows? might be better to create our own empty tmp directory instead |
lld/MachO/Driver.cpp | ||
---|---|---|
160 | Yes, it should work on windows just as well. I've been running the tests on Windows :) | |
161 | I think its obvious given that roots is just declared above, but Im fine with replacing it with StringRef. | |
162 | Id rather do that in a follow up. There are other places where we have file path sized buffers. | |
164 | Hmm, would you prefer to use llvm::sys::fs::is_directory instead? | |
424 | const auto arg is pretty common, but sure, Arg *arg is shorter. | |
lld/test/MachO/syslibroot.test | ||
22–23 | /var/empty is not being checked. | |
24 | No, /var/empty will not exist on Windows, but the fuzzy match takes care of that. The intent of the /var/empty is ensure that a non-sysroot is not treated as a sysroot. |
lgtm modulo those two questions. Thanks!
lld/MachO/Driver.cpp | ||
---|---|---|
160 | I guess my question then is how does it work? I was under the impression that we would want the style to be native since the path separators are different on Windows. (I'm working on setting up a Windows VM so I can answer these things myself in the future 😅) | |
162 | sgtm | |
164 | seems better, thanks! | |
lld/test/MachO/syslibroot.test | ||
22–23 | ah I see. Maybe make that explicit in the comment? Also, shouldn't we be able to portably check that /var/empty isn't present? My understanding is that the -syslibroot / will make -syslibroot /var/empty a no-op on all platforms... is that right? |
lld/MachO/Driver.cpp | ||
---|---|---|
160 | Windows paths are dark and full of terrors. The Win32 APIs will re-normalize the paths and accept / and \ (though not the NT APIs). I opted for the posix representation to make the printing work out better. We can always change this in the future. | |
lld/test/MachO/syslibroot.test | ||
22–23 | Sure, I can make that more explicit in the comment. The problem is that -syslibroot / will then pick up /usr/lib and /usr/local/lib which makes the test more brittle. This was basically my attempt to force the test to be more uniform across Linux/BSD/Darwin/Windows. |
Will this work on Windows given the use of Style::posix?