[linker-script] Find namespec libraries in sysroot standard dirs#1158
[linker-script] Find namespec libraries in sysroot standard dirs#1158deepakshirkem wants to merge 1 commit into
Conversation
|
Hi @parth-07 / @quic-areg / @quic-seaswara, please review this PR. During investigation I found two root causes Please let me know if the approach is correct or if there's a better way to handle this. |
| initializeTarget(IF); | ||
| return; | ||
| } | ||
| } |
There was a problem hiding this comment.
Hi @quic-seaswara, I am also not fully happy about adding this function, and my theory might be wrong. What I observed while reproducing #819 is that when we run the command ld.eld --sysroot=A A/script.t main.o, the code reads A/script.t before the target is initialized. While reading it, the process fails, which is why the code path you mentioned in the discussion is not getting triggered.
That is why I added this function. The function first tries to identify the target using the object file, similar to what I mentioned in the description.
I am not fully aware of the complete codebase yet, but I tried to find a place where we can get the target before reading any object files. It is possible that my intuition is wrong, and if we can determine the target earlier, then this function may not be required.
Your views @quic-areg, @partaror?
There was a problem hiding this comment.
Hi @quic-seaswara, I am also not fully happy about adding this function, and my theory might be wrong. What I observed while reproducing #819 is that when we run the command l
d.eld --sysroot=A A/script.t main.o,the code reads A/script.t before the target is initialized. While reading it, the process fails, which is why the code path you mentioned in the discussion is not getting triggered.That is why I added this function. The function first tries to identify the target using the object file, similar to what I mentioned in the description.
I am not fully aware of the complete codebase yet, but I tried to find a place where we can get the target before reading any object files. It is possible that my intuition is wrong, and if we can determine the target earlier, then this function may not be required.
Your views @quic-areg, @partaror?
Hi @quic-seaswara, I am also not fully happy about adding this function, and my theory might be wrong. What I observed while reproducing #819 is that when we run the command l
d.eld --sysroot=A A/script.t main.o,the code reads A/script.t before the target is initialized. While reading it, the process fails, which is why the code path you mentioned in the discussion is not getting triggered.That is why I added this function. The function first tries to identify the target using the object file, similar to what I mentioned in the description.
I am not fully aware of the complete codebase yet, but I tried to find a place where we can get the target before reading any object files. It is possible that my intuition is wrong, and if we can determine the target earlier, then this function may not be required.
Your views @quic-areg, @partaror?
is the path expansion target specific ?
There was a problem hiding this comment.
Yes. In the ELFEmulation.cpp, the sysroot search paths (/lib, /lib64, /usr/lib, /usr/lib64) are the same for all targets in ELD
| auto EldDir = ELDDirectory(Dir, Sysroot); | ||
| if (llvm::sys::fs::is_directory(EldDir.name())) | ||
| pConfig.directories().insert(Dir); | ||
| } |
There was a problem hiding this comment.
-nostdlib should not add these search directories I think.
There was a problem hiding this comment.
Yes your right its working added test cases for this case also.
| RUN: mkdir -p %t.sysroot/lib64 | ||
| RUN: %clang %clangopts -o %t1.o %p/Inputs/1.c -c | ||
| RUN: %clang %clangopts -o %t.lib1.o %p/Inputs/lib1.c -c | ||
| RUN: %ar cr %aropts %t.sysroot/lib64/lib1.a %t.lib1.o |
There was a problem hiding this comment.
Yes its working also added test case.
c91b968 to
f8afc4d
Compare
ELDEmulateELF only searched =/lib and =/usr/lib under sysroot, missing =/lib64, =/usr/lib64, =/usr/local/lib and =/usr/local/lib64. Also, when no target is known upfront, initEmulator is deferred until the first ELF object is read, causing GROUP(-lfoo) namespec search to fail before any sysroot standard dirs are added. Fixes qualcomm#819. Signed-off-by: deepakshirkem <deepakshirke509@gmail.com>
f8afc4d to
39156e4
Compare
Problem
ELD fails to find namespec libraries (e.g.
GROUP(-lfoo)) in standard directories under the sysroot such as/lib,/lib64,/usr/lib, and so on.Testing
Added
test/Common/standalone/SysrootNamespec— verifies thatGROUP(-lfoo)finds a library placed in the sysrootlib64directory. Test passes on all targets.Output
Fixes #819.