-
Notifications
You must be signed in to change notification settings - Fork 46
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
Clang relies on __PRETTY_FUNCTION__ and asserts #11
Comments
From a quick grep, I suspect paths are leaking into the binary through this, in case it gives us inspiration for a workaround or fix to clang: |
Another approach would be to do something to ensure the compiler gets fed with relative paths contained within See also, cmake FAQ Why does CMake use full paths, or can I copy my build tree?. So it doesn't look like we can make cmake help us here. It used to have Fortuitously, though, it seems that we can use This seems like a pretty decent workaround, but it does force anyone who wants to reproduce our binaries to use ccache. Looking at the clang logic, I don't think the full path leaking into the binary is a bug, but it looks like possibly a feature request to make it respect |
On second thought it looks like there is an -fmacro-prefix-map, which sounds like it's intended to do this sort of thing, but it fails in this case. So that seems more bug-ish: |
I'm very surprised and troubled by this. I would prefer to think that The GCC doc (https://gcc.gnu.org/onlinedocs/gcc/Preprocessor-Options.html) states:
This seems to have been implemented in clang for compatibility with GCC (https://reviews.llvm.org/D49466) and hence the implementation only takes these two macros in consideration. PRETTY_FUNCTION does not include file names in GCC though. So if this is a bug, I wouldn't know if it is a bug in Is patching Patching the absolute paths before passing to the compiler seems to me to be the cleanest solution. |
Maybe, except that you also have to handle |
FWIW, we don't need to handle the conversion perfectly. In fact, if [[ -f $ARG && ${ARG: -4} == ".cpp" ]]; then But the Ccache solution might be simpler still. |
Bug report for Clang: https://bugs.llvm.org/show_bug.cgi?id=52360 |
Turns out paths continue to leak into binaries so long as the compiler is fed with absolute paths, even if we use CCACHE_BASEDIR. So rewrite them in build.ninja. Also, fix llvm-config, which also captures the build directory.
I've found a ccache issue -- it fails to apply CCACHE_BASEDIR under some circumstances, for example:
So when it 'falls back to running the real compiler', it does not rewrite the paths. So that's a little unfortunate. It may be intentional that the rewrite does not take place in that case. I've taken to fixing the issue by applying a rewrite to build.ninja in 8920f91. |
Turns out paths continue to leak into binaries so long as the compiler is fed with absolute paths, even if we use CCACHE_BASEDIR. So rewrite them in build.ninja. Also, fix llvm-config, which also captures the build directory.
Turns out paths continue to leak into binaries so long as the compiler is fed with absolute paths, even if we use CCACHE_BASEDIR. So rewrite them in build.ninja. Also, fix llvm-config, which also captures the build directory. Signed-off-by: Peter Waller <peter.waller@arm.com>
Turns out paths continue to leak into binaries so long as the compiler is fed with absolute paths, even if we use CCACHE_BASEDIR. So rewrite them in build.ninja. Also, fix llvm-config, which also captures the build directory. Signed-off-by: Peter Waller <peter.waller@arm.com>
Turns out paths continue to leak into binaries so long as the compiler is fed with absolute paths, even if we use CCACHE_BASEDIR. So rewrite them in build.ninja. Also, fix llvm-config, which also captures the build directory. Signed-off-by: Peter Waller <peter.waller@arm.com>
IIRC, we observed that use of
__PRETTY_FUNCTION__
resulted in binaries which depended on the full path of the sources. In order to make the binaries reproducible, we have a workaround:elfshaker/contrib/manyclangs-cmake
Lines 13 to 14 in f69cb7b
Unfortunately the resulting clang binary is completely broken and refuses to compile anything:
https://llvm.org/doxygen/TypeName_8h_source.html
It asserts on
assert(!Name.empty() && "Unable to find the template parameter!");
. I suspect that func doesn't contain the template type parameter information in it.We'll need to find a workaround for this or stop overriding
__PRETTY_FUNCTION__
and therefore have binaries which can only be reproduced if built at a specific absolute path.The text was updated successfully, but these errors were encountered: