From d3c93b7f835e6c26e5363d5012f1cf86a96ac5fa Mon Sep 17 00:00:00 2001 From: Common Lisp at Google Date: Sun, 10 Mar 2024 07:51:25 -0700 Subject: [PATCH] whatever PiperOrigin-RevId: 614416114 --- elfconvert.sh | 16 +++++++++++++--- rules.bzl | 26 +++++++++++++++++++++++--- 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/elfconvert.sh b/elfconvert.sh index 206835c..410f38b 100755 --- a/elfconvert.sh +++ b/elfconvert.sh @@ -11,7 +11,7 @@ case $SAR_ARGV0 in *) sbcl_subdir=k8 esac sbcl=$RUNFILES/google3/third_party/lisp/sbcl/binary-distribution/$sbcl_subdir/bin/sbcl -args=(--noinform --dynamic-space-size 512MB) +args=(--noinform --dynamic-space-size 1GB) mode='(setq *evaluator-mode* :compile)' script=$RUNFILES/google3/third_party/lisp/sbcl/src/tools-for-build/elftool @@ -19,10 +19,20 @@ action=$1 input=$2 output=$3 +compactcore=/tmp/compact-$$.core +tmpcore=/tmp/patched-$$.core +DSS=16384 + case $action in split) - exec $sbcl ${args[@]} --eval "$mode" --load $script --eval \ - '(sb-editcore:split-core "'$input'" "'$output'")' --quit ;; + exec $sbcl ${args[@]} --eval "$mode" --load $script \ + --eval '(sb-editcore:reorganize-core "'$input'" "'$compactcore'")' \ + --eval '(sb-editcore:move-dynamic-code-to-text-space "'$compactcore'" "'$tmpcore'")' \ + --eval '(delete-file "'$compactcore'")' \ + --eval '(sb-editcore:redirect-text-space-calls "'$tmpcore'")' \ + --eval '(sb-editcore:split-core "'$tmpcore'" "'$output'" :dynamic-space-size '$DSS')' \ + --eval '(delete-file "'$tmpcore'")' --quit ;; + copy) exec $sbcl ${args[@]} --eval "$mode" --load $script --eval \ '(sb-editcore::copy-to-elf-obj "'$input'" "'$output'")' --quit ;; diff --git a/rules.bzl b/rules.bzl index 1e41048..2426c2b 100644 --- a/rules.bzl +++ b/rules.bzl @@ -785,6 +785,16 @@ def _lisp_binary_impl(ctx): toolchain = None, ) + # libc++ dependencies from cc_runtimes_toolchain. + cc_runtimes_toolchain = ctx.toolchains["@bazel_tools//tools/cpp:cc_runtimes_toolchain_type"] + runtimes_ccinfos = [] + if cc_runtimes_toolchain: + runtimes_ccinfos += [ + target[CcInfo] + for target in cc_runtimes_toolchain.cc_runtimes_info.runtimes + if CcInfo in target + ] + # The rule's malloc attribute can be overridden by the --custom_malloc flag. malloc = ctx.attr._custom_malloc or ctx.attr.malloc linking_outputs = cc_common.link( @@ -811,7 +821,7 @@ def _lisp_binary_impl(ctx): # implementation, so this does not get propagated to any of the # binary's consumers. malloc[CcInfo].linking_context, - ], + ] + [info.linking_context for info in runtimes_ccinfos], stamp = ctx.attr.stamp, output_type = "executable", additional_inputs = link_additional_inputs, @@ -830,7 +840,12 @@ lisp_binary = rule( exec_groups = {"cpp_link": exec_group()}, attrs = _LISP_BINARY_ATTRS, fragments = ["cpp"], - toolchains = use_cc_toolchain(), + toolchains = use_cc_toolchain() + [ + config_common.toolchain_type( + "@bazel_tools//tools/cpp:cc_runtimes_toolchain_type", + mandatory = False, + ), + ], doc = """ Supports all of the same attributes as [`lisp_library`](#lisp_library), plus additional attributes governing the behavior of the completed binary. The @@ -854,7 +869,12 @@ lisp_test = rule( test = True, attrs = _LISP_TEST_ATTRS, fragments = ["cpp"], - toolchains = use_cc_toolchain(), + toolchains = use_cc_toolchain() + [ + config_common.toolchain_type( + "@bazel_tools//tools/cpp:cc_runtimes_toolchain_type", + mandatory = False, + ), + ], doc = """ Like [`lisp_binary`](#lisp_binary), for defining tests to be run with the [`test`](https://docs.bazel.build/versions/master/user-manual.html#test)