-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gclang fail to identify input files inside linker groups #48
Comments
I would have to read the manual, but what is a linker supposed to do with a .c file? OK so A quick look tells me that the linker expects What does clang do in this case? |
I have to say that I share the feeling that this option should not be used with source files, but this seems actually valid. clang automatically builds a temporary object file from that source (
This behavior is also shared with gcc, even if I did not find it documented anywhere. |
Sigh. Freeping creaturism. So I suppose one would look at the files in the group, if any are source files, add them to the input files All without breaking anything :-) |
Yes exactly, this would work perfectly. I think there is another inconsistency in how gllvm deals with linker groups, still used in Android libhevc fuzzer build script where there can be the occurrence of the Again, I believe this should not be used this way since it seems there is no additional side effect other than it being moved out from the group, but I pointed it out here since it is used in a pretty important project selected as one of the benchmarks in FuzzBench. Thanks for this amazing project btw :) |
OK @pietroborrello I will ping you when I have something to test. Hopefully within a week. |
@pietroborrello Out of curiosity, did you see a real build use linker groups in this way? Or was this something you discovered experimentally? |
At the time of the issue, it was used in the Android libhvec fuzzer build script of the OSSFuzz project by Google The script seems now to be updated to use cmake, so I'm not sure whether they are still using it |
gclang does not seem to identify source input files that are listed inside a linker group.
Environment
To reproduce:
main.c
:lib.c
:Building with
gclang main.c -Wl,--start-group lib.c -Wl,--end-group -o main
produces a valid binary. EnablingWLLVM_OUTPUT_LEVEL="DEBUG"
As you can see
lib.c
is not present in theInputFiles
list.Then executing
WLLVM_OUTPUT_LEVEL="DEBUG" get-bc -b -S -o main.bc main
The call does not fail but produces a bitcode that does not contain any definition for function
foo
or anything present inlib.c
. I suspect this is due togllvm
parser just forwarding the linker group to the linker, skipping the bitcode generation phase for input files present there. The code I suspect being the culprit is here and testing in an older version of gllvm (version 1.2.7) does not show the bug.I understand that does not really make sense to create a group like
-Wl,--start-group lib.c -Wl,--end-group
, but I tried to minimize it since the issue is present any time a source file is present in a group among any other library/archive, like for example in Android libhevc fuzzer build scriptThe text was updated successfully, but these errors were encountered: