Diff Detail
Event Timeline
lib/Driver/SanitizerArgs.cpp | ||
---|---|---|
176 | Why not hasArg()? | |
lib/Driver/Tools.cpp | ||
1849 | The logic is too obscure here. --whole-archive makes no sense for dynamic library. If we're linking executable, add "--whole-archive X --no-whole-archive", where X is either full asan, or preinit-asan. Maybe it would be even simpler to pull this logic to addAsanRT (we handle dynamic runtime for Android there, for instance), |
We have tests for Clang driver behavior. It makes sense to verify that driver is doing the right thing w/o actually checking out / building compiler-rt. You should probably extend test/Driver/sanitizer-ld.c
Please rebase the patch before uploading the next diff.
lib/Driver/Tools.cpp | ||
---|---|---|
1882–1898 | The logic is still non-understandable. Please find a better way to express it. As a suggestion: if (NeedsSharedRT) { // add asan-dynamic.so to the link line. } if (Args.hasArg(options::OPT_shared)) { return; // don't link static parts into shared objects. } StringRef AsanStaticPart = NeedsSharedRT ? "asan-preinit" : "asan"; bool BeforeLibStdCXX = true; bool ExportSymbols = !NeedsSharedRT; addSanitizerRTLinkFlags(TC, Args, CmdArgs, AsanStaticPart, BeforeLibStdCXX, ExportSymbols); now, if you don't want do add "-ldl lpthread -lrt -lm" to the link line for executable and -shared-libasan mode, you may add one more |
General comments:
- please don't modify the behavior of Clang driver for static runtime. I think that some users may depend on the fact that there's a single ASan .a runtime, and wouldn't like to break them without strong reasons.
- nit: please decrease the amount of added vertical whitespaces.
lib/Driver/Tools.cpp | ||
---|---|---|
1817–1823 | Update the comment. | |
1818 | just "bool Shared". Also, I think you can avoid using the default value this argument. | |
1865 | Add the comment specifying that we need to explicitly link with system libraries static ASan runtime depends on. | |
1881–1882 | use an early return here to decrease identation: if (Android) { // code return; } // more code |
I think this change will be fine to go in after the following fixes. I'll take a look at compiler-rt part tomorrow.
lib/Driver/SanitizerArgs.cpp | ||
---|---|---|
174 | AsanSharedRuntime should be true on Android. | |
lib/Driver/Tools.cpp | ||
1870–1871 | Delete this. You already have LibSanitizer defined above. | |
1881–1882 | Please put this Android-specific logic to getSanitizerRTLibName. Then you'll be able to merge this block with the following one (and quit early on Android - there's no asan-preinit there. | |
1895 | Oh, let's switch back to a single addSanitizerRTLinkFlags(TC, Args, CmdArgs, LibAsanStaticPart, /* BeforeLibStdCXX */ true, /* Export Symbols */ !Shared, /* Link Deps */ !Shared); Sorry for changing my mind. |
lib/Driver/SanitizerArgs.cpp | ||
---|---|---|
174 | Well, I thought about this. But my understanding was that SanitizerArgs is really about cmdline args, not about making control decisions. |
lib/Driver/SanitizerArgs.cpp | ||
---|---|---|
174 | Kind of... But we may think of it this way: "-shared-libasan argument is implied for Android". Otherwise, logic for dynamic runtime on Android shoudln't be different from dynamic runtime on Linux, there's no need to special-case it in control decisions. |
AsanSharedRuntime should be true on Android.