This change introduces a pair of -fsanitize-link-runtime and
-fno-sanitize-link-runtime flags which can be used to control linking of
sanitizer runtimes. This is useful in certain environments like kernels
where existing runtime libraries cannot be used.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
There is an existing option -fsanitize-minimal-runtime, will -fsanitize-no-runtime be a name providing more consistency?
It wouldn't, -nodefaultlibs (same as -nostdlib) disables linking of runtime dependencies, but not the runtime itself, e.g. -fsanitize=address -nodefaultlibs disables linking of -lpthread -lrt -lm -ldl which are all dependencies of ASan, but doesn't disable linking of libclang_rt.asan.a which is what we care about.
That's fine with me, I used -f[no-]sanitize-link-deps for consistency with XRay, but -fsanitize-no-runtime would work as well.
I've updated the change and renamed the flag to -fsanitize-no-runtime although I'm not sure if it's necessarily better. I was thinking that ideal interface might be -fsanitize-runtime=(none|minimal|shared|static) which could also replace -fshared-libsan and -fstatic-libsan, but it'd be a breaking change so we might have to keep the existing flag and maybe print a deprecation warning. WDYT?
I've decided to go with the original -f[no-]sanitize-link-deps: -fsanitize-minimal-runtime is also a cc1 flag which affects codegen, -fshared-libsan and -fstatic-libsan are orthogonal, e.g. it's possible to have minimal shared or static runtime, so these really need to be different flags.
One more change, I went with -fsanitize-runtime and -fno-sanitize-runtime in the end which seems like the best fit.