From f9ff2e7eb9019acb3134fcb60535da401b9fcee7 Mon Sep 17 00:00:00 2001 From: Fabian Meumertzheim Date: Mon, 6 Sep 2021 14:27:20 +0200 Subject: [PATCH] Resolve symlinks among output binaries Certain (C)Make projects (such as [AFL++](https://github.com/AFLplusplus/AFLplusplus)) emit binaries that are symlinks to other emitted binaries. When built with `rules_foreign_cc`, this can lead to non-deterministic dangling symlink errors since Bazel visits the outputs in an unspecified order. This is fixed by resolving symlinks among the emitted binaries, just like it is already done for libraries. --- foreign_cc/private/framework.bzl | 1 + 1 file changed, 1 insertion(+) diff --git a/foreign_cc/private/framework.bzl b/foreign_cc/private/framework.bzl index c7215369e..dcb94ee95 100644 --- a/foreign_cc/private/framework.bzl +++ b/foreign_cc/private/framework.bzl @@ -422,6 +422,7 @@ def cc_external_rule_impl(ctx, attrs): ] + [ "##replace_symlink## {}".format(file.path) for file in ( + outputs.out_binary_files + outputs.libraries.static_libraries + outputs.libraries.shared_libraries + outputs.libraries.interface_libraries