Skip to content
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

Sandbox makes build non-deterministic when building with debug symbols #1271

Closed
aaron-michaux opened this issue Aug 29, 2024 · 1 comment · Fixed by #1288
Closed

Sandbox makes build non-deterministic when building with debug symbols #1271

aaron-michaux opened this issue Aug 29, 2024 · 1 comment · Fixed by #1288

Comments

@aaron-michaux
Copy link
Contributor

The sandbox has a unique incrementing number in its path, which in turn finds its way into the debug symbols. This means that binary targets are non-deterministic. For example, when I build @zlib//:zlib with debug symbols, the bit-pattern of libz.a depends on sandbox path, which changes from build to build. Thus, anything that links to libz.a is also non-deterministic.

Gcc has an option -fdebug-prefix-map=old=new, which can mitigate against this; however, to set this option, you'd have to a priori know the path to the sandbox. That is, we want to have a flag that looks like: -fdebug-prefix-map=$SANDBOX_PATH=., where the bazel rule fills in $SANDBOX_PATH for you.

In my mind, this is an issue with the bazel sandbox itself; however, the issue can be mitigated in rules_foreign_cc.

Thanks to @fmeum for prompting me to create this ticket.

@fmeum
Copy link
Member

fmeum commented Aug 29, 2024

In my mind, this is an issue with the bazel sandbox itself; however, the issue can be mitigated in rules_foreign_cc.

It's not an issue with the sandbox itself if you follow its golden rule: exclusively use relative paths. If you do that, then compilers would generally emit relative paths into debug output. But rules_foreign_cc may not be able to ensure this as it forks out to external build systems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants