Skip to content

Commit

Permalink
whatever
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 614416114
  • Loading branch information
common-lisp-dev-copybara authored and copybara-github committed Mar 13, 2024
1 parent 5a9d9e7 commit d3c93b7
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 6 deletions.
16 changes: 13 additions & 3 deletions elfconvert.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,28 @@ 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

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 ;;
Expand Down
26 changes: 23 additions & 3 deletions rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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,
Expand All @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit d3c93b7

Please sign in to comment.