-
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
Compilation outputs contain absolute paths that can't be stripped #76
Comments
I tried tracing this down and it seemed like even when passing relative paths to |
I get the same reproduction when invoking via a relative path: $ bazel-rules_cc/external/zig_sdk/tools/x86_64-linux-gnu.2.34/c++ -o out.o -c hello_world.cc -ffile-prefix-map=$(bazel info output_base)=redacted && strings out.o | grep zig_sdk | grep -v redacted
/home/jvolkman/.cache/bazel/_bazel_jvolkman/3aa3feaef46d2c24bea3a7828d24c330/external/zig_sdk/tools/x86_64-linux-gnu.2.34/../../lib/libcxx/include/locale
/home/jvolkman/.cache/bazel/_bazel_jvolkman/3aa3feaef46d2c24bea3a7828d24c330/external/zig_sdk/tools/x86_64-linux-gnu.2.34/../../lib/libcxx/include/string
/home/jvolkman/.cache/bazel/_bazel_jvolkman/3aa3feaef46d2c24bea3a7828d24c330/external/zig_sdk/tools/x86_64-linux-gnu.2.34/../../lib/libcxx/include/__memory/allocator.h
/home/jvolkman/.cache/bazel/_bazel_jvolkman/3aa3feaef46d2c24bea3a7828d24c330/external/zig_sdk/tools/x86_64-linux-gnu.2.34/../../lib/libcxx/include/ostream
/home/jvolkman/.cache/bazel/_bazel_jvolkman/3aa3feaef46d2c24bea3a7828d24c330/external/zig_sdk/tools/x86_64-linux-gnu.2.34/../../lib/libcxx/include/ios
/home/jvolkman/.cache/bazel/_bazel_jvolkman/3aa3feaef46d2c24bea3a7828d24c330/external/zig_sdk/tools/x86_64-linux-gnu.2.34/../../lib/libcxx/include/__locale
/home/jvolkman/.cache/bazel/_bazel_jvolkman/3aa3feaef46d2c24bea3a7828d24c330/external/zig_sdk/tools/x86_64-linux-gnu.2.34/../../lib/libcxx/include/__iterator/ostreambuf_iterator.h
/home/jvolkman/.cache/bazel/_bazel_jvolkman/3aa3feaef46d2c24bea3a7828d24c330/external/zig_sdk/tools/x86_64-linux-gnu.2.34/../../lib/libcxx/include/__memory/compressed_pair.h
/home/jvolkman/.cache/bazel/_bazel_jvolkman/3aa3feaef46d2c24bea3a7828d24c330/external/zig_sdk/tools/x86_64-linux-gnu.2.34/../../lib/libcxx/include/streambuf
'const union (anonymous union at /home/jvolkman/.cache/bazel/_bazel_jvolkman/3aa3feaef46d2c24bea3a7828d24c330/external/zig_sdk/tools/x86_64-linux-gnu.2.34/../../lib/libcxx/include/string:784:9)'
'const struct (anonymous struct at /home/jvolkman/.cache/bazel/_bazel_jvolkman/3aa3feaef46d2c24bea3a7828d24c330/external/zig_sdk/tools/x86_64-linux-gnu.2.34/../../lib/libcxx/include/string:761:9)'
'union (anonymous union at /home/jvolkman/.cache/bazel/_bazel_jvolkman/3aa3feaef46d2c24bea3a7828d24c330/external/zig_sdk/tools/x86_64-linux-gnu.2.34/../../lib/libcxx/include/string:784:9)' |
c++
is invoked via absolute path
Actually @fmeum I take that back. Zig uses its own cache (which defaults to Lots of moving pieces here, unfortunately. |
This has nothing to do with zig's internal cache directory, as the headers are in zig's stdlib. If it were zig's cache, it would start with Optimization flag is a red herring; this is UBSAN:
Optimizations ( |
It does pas the I have been trying to narrow down the difference between clang:
zig cc:
Here are the invocations: And the diff of the commands: Output of
Output of
As we can see from the |
Edit: nope. I turned on this macro in clang and it still does not output the header paths. |
The next step would be to inspect the resulting object file |
I found the |
This is a great find! I am still puzzled on why this does not reproduce on clang though (it does not have that flag). I am open to put it to the default cflags in fastbuild. Thoughts? Edit: how about |
Nice find! Would this also be needed in the |
Is there anything special about -4? Certainly -1 isn't very useful, but depending on the use case (e.g., this rules_go use case where the cwd is changed), -4 could bleed into the random part of the path. |
It's going to be hard to set this properly in a generic way. It would be much better if something like |
Looking at the example paths, the 4 "final" ones have not bled, but that's just anecdotal and not guaranteed to remain such. I take it back,
Feel free, but be prepared to dive deeper once you get some guidance from those folks. :) |
Steps to reproduce:
As you can see in the logs above, some references to headers shipped with the toolchain are not affected by
-ffile-prefix-map
. I haven't found a way to work around this issue yet.This directly affects usage with rules_go as a build of the standard library with CGo enabled changes the working directory from the Bazel execroot to various temporary directories, which results in absolute paths to header files being included in the stdlib archives.
Full list
The text was updated successfully, but these errors were encountered: