mirror of
https://github.com/hanzoai/visor.git
synced 2026-09-24 17:04:14 +00:00
bazel/rules_go: don't revert commits
tools/rules_go_facts.patch reverted 30099a6add3c ("Revert "Emit nogo facts into
a separate archive (#3789)""). This change does some adjustments to work with
up-to-date rules_go without reverting anything.
PiperOrigin-RevId: 751073734
This commit is contained in:
@@ -29,10 +29,10 @@ bazel_skylib_workspace()
|
||||
# Load license rules.
|
||||
http_archive(
|
||||
name = "rules_license",
|
||||
sha256 = "6157e1e68378532d0241ecd15d3c45f6e5cfd98fc10846045509fb2a7cc9e381",
|
||||
sha256 = "26d4021f6898e23b82ef953078389dd49ac2b5618ac564ade4ef87cced147b38",
|
||||
urls = [
|
||||
"https://github.com/bazelbuild/rules_license/releases/download/0.0.4/rules_license-0.0.4.tar.gz",
|
||||
"https://mirror.bazel.build/github.com/bazelbuild/rules_license/releases/download/0.0.4/rules_license-0.0.4.tar.gz",
|
||||
"https://mirror.bazel.build/github.com/bazelbuild/rules_license/releases/download/1.0.0/rules_license-1.0.0.tar.gz",
|
||||
"https://github.com/bazelbuild/rules_license/releases/download/1.0.0/rules_license-1.0.0.tar.gz",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -51,13 +51,14 @@ http_archive(
|
||||
"//tools:rules_go_symbols.patch",
|
||||
# Allow for patching of the go_sdk.
|
||||
"//tools:rules_go_sdk.patch",
|
||||
"//tools:rules_go_facts.patch",
|
||||
"//tools:rules_cgo.patch",
|
||||
# Export .x files.
|
||||
"//tools:rules_go_export.patch",
|
||||
],
|
||||
sha256 = "80a98277ad1311dacd837f9b16db62887702e9f1d1c4c9f796d0121a46c8e184",
|
||||
sha256 = "af47f30e9cbd70ae34e49866e201b3f77069abb111183f2c0297e7e74ba6bbc0",
|
||||
urls = [
|
||||
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.46.0/rules_go-v0.46.0.zip",
|
||||
"https://github.com/bazelbuild/rules_go/releases/download/v0.46.0/rules_go-v0.46.0.zip",
|
||||
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.47.0/rules_go-v0.47.0.zip",
|
||||
"https://github.com/bazelbuild/rules_go/releases/download/v0.47.0/rules_go-v0.47.0.zip",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -99,179 +100,179 @@ go_download_sdk(
|
||||
# time on our continuous integration.
|
||||
patch = "//tools:go_types_memoize.patch",
|
||||
patch_strip = 1,
|
||||
version = "1.23.2",
|
||||
# To update this dictionary, run (after updating VERSION):
|
||||
# jq --arg VERSION "1.22.0" 'map(select(.version == "go" + $VERSION)).[0].files | map({(.os + "_" + .arch): [.filename, .sha256]}) | add' < <(curl 'https://go.dev/dl/?mode=json&include=all')
|
||||
sdks = {
|
||||
"_": [
|
||||
"go1.23.2.src.tar.gz",
|
||||
"36930162a93df417d90bd22c6e14daff4705baac2b02418edda671cdfa9cd07f"
|
||||
"go1.23.6.src.tar.gz",
|
||||
"039c5b04e65279daceee8a6f71e70bd05cf5b801782b6f77c6e19e2ed0511222",
|
||||
],
|
||||
"aix_ppc64": [
|
||||
"go1.23.2.aix-ppc64.tar.gz",
|
||||
"560aff7fe1eeadc32248db35ed5c0a81e190d171b6ecec404cf46d808c13e92f"
|
||||
"go1.23.6.aix-ppc64.tar.gz",
|
||||
"adec10f4ba56591f523aa04851f7f6900b1c61508dfa6b80e62717a8e6684a5c",
|
||||
],
|
||||
"darwin_amd64": [
|
||||
"go1.23.2.darwin-amd64.pkg",
|
||||
"40c0b61971a1a74fd4566c536f682c9d4976fa71d40d9daabc875c06113d0fee"
|
||||
"go1.23.6.darwin-amd64.pkg",
|
||||
"7fa387c228b4dd69b518a5d9425638fa5c0d86ec8943de373e3802aff2e5b12a",
|
||||
],
|
||||
"darwin_arm64": [
|
||||
"go1.23.2.darwin-arm64.pkg",
|
||||
"5611cd648f5100b73a7d6fd85589a481af18fdbaf9c153a92de9a8e39a6e061f"
|
||||
"go1.23.6.darwin-arm64.pkg",
|
||||
"a167758a44e08af6eddf844ed86a6acdbff1d3957248913bbca7ee4ef6ff07d0",
|
||||
],
|
||||
"dragonfly_amd64": [
|
||||
"go1.23.2.dragonfly-amd64.tar.gz",
|
||||
"f163b99b03e4bbc64cd30363f1694a08fcd44094415db1f092f13f9d1bb7c28e"
|
||||
"go1.23.6.dragonfly-amd64.tar.gz",
|
||||
"d52efb3020d9332477ade98163c03d2f2fe3e051b0e7e01f0e167412c66de0cb",
|
||||
],
|
||||
"freebsd_386": [
|
||||
"go1.23.2.freebsd-386.tar.gz",
|
||||
"e4d9a1319dfdaa827407855e406c43e85c878a1f93f4f3984c85dce969c8bf70"
|
||||
"go1.23.6.freebsd-386.tar.gz",
|
||||
"d3287706b5823712ac6cf7dff684a556cff98163ef60e7b275abe3388c17aac7",
|
||||
],
|
||||
"freebsd_amd64": [
|
||||
"go1.23.2.freebsd-amd64.tar.gz",
|
||||
"025d77f1780906142023a364c31a572afd7d56d3a3be1e4e562e367ca88d3267"
|
||||
"go1.23.6.freebsd-amd64.tar.gz",
|
||||
"ebb4c6a9b0673dbdabc439877779ed6add16575e21bd0a7955c33f692789aef6",
|
||||
],
|
||||
"freebsd_arm": [
|
||||
"go1.23.2.freebsd-arm.tar.gz",
|
||||
"28af3c40687afdda6b33b300833b6d662716cc2d624fb9fd61a49bdad44cd869"
|
||||
"go1.23.6.freebsd-arm.tar.gz",
|
||||
"b7241584afb0b161c09148f8fde16171bb743e47b99d451fbc5f5217ec7a88b6",
|
||||
],
|
||||
"freebsd_arm64": [
|
||||
"go1.23.2.freebsd-arm64.tar.gz",
|
||||
"f45af3e1434175ff85620a74c07fb41d6844655f1f2cd2389c5fca6de000f58c"
|
||||
"go1.23.6.freebsd-arm64.tar.gz",
|
||||
"004718b53cedd7955d1b1dc4053539fcd1053c031f5f3374334a22befd1f8310",
|
||||
],
|
||||
"freebsd_riscv64": [
|
||||
"go1.23.2.freebsd-riscv64.tar.gz",
|
||||
"f11b9b4d4a0679909202fc5e88093d6ff720a8a417bfe6a34d502c3862367039"
|
||||
"go1.23.6.freebsd-riscv64.tar.gz",
|
||||
"ca026ec8a30dd0c18164f40e1ce21bd725e2445f11699177d05815189a38de7a",
|
||||
],
|
||||
"illumos_amd64": [
|
||||
"go1.23.2.illumos-amd64.tar.gz",
|
||||
"d47e40366cd6c6b6ee14b811554cd7dde0351309f4a8a4569ec5ba2bd7689437"
|
||||
"go1.23.6.illumos-amd64.tar.gz",
|
||||
"7db973efa3fb2e48e45059b855721550fce8e90803e7373d3efd37b88dd821e8",
|
||||
],
|
||||
"linux_386": [
|
||||
"go1.23.2.linux-386.tar.gz",
|
||||
"cb1ed4410f68d8be1156cee0a74fcfbdcd9bca377c83db3a9e1b07eebc6d71ef"
|
||||
"go1.23.6.linux-386.tar.gz",
|
||||
"e61f87693169c0bbcc43363128f1e929b9dff0b7f448573f1bdd4e4a0b9687ba",
|
||||
],
|
||||
"linux_amd64": [
|
||||
"go1.23.2.linux-amd64.tar.gz",
|
||||
"542d3c1705f1c6a1c5a80d5dc62e2e45171af291e755d591c5e6531ef63b454e"
|
||||
"go1.23.6.linux-amd64.tar.gz",
|
||||
"9379441ea310de000f33a4dc767bd966e72ab2826270e038e78b2c53c2e7802d",
|
||||
],
|
||||
"linux_arm64": [
|
||||
"go1.23.2.linux-arm64.tar.gz",
|
||||
"f626cdd92fc21a88b31c1251f419c17782933a42903db87a174ce74eeecc66a9"
|
||||
"go1.23.6.linux-arm64.tar.gz",
|
||||
"561c780e8f4a8955d32bf72e46af0b5ee5e0debe1e4633df9a03781878219202",
|
||||
],
|
||||
"linux_armv6l": [
|
||||
"go1.23.2.linux-armv6l.tar.gz",
|
||||
"e3286bdde186077e65e961cbe18874d42a461e5b9c472c26572b8d4a98d15c40"
|
||||
"go1.23.6.linux-armv6l.tar.gz",
|
||||
"27a4611010c16b8c4f37ade3aada55bd5781998f02f348b164302fd5eea4eb74",
|
||||
],
|
||||
"linux_loong64": [
|
||||
"go1.23.2.linux-loong64.tar.gz",
|
||||
"2293c5c3ffc595418308b4059ce214b99f0383cba83232e47a1a8c3b710c24e8"
|
||||
"go1.23.6.linux-loong64.tar.gz",
|
||||
"c459226424372abc2b35957cc8955dad348330714f7605093325dbb73e33c750",
|
||||
],
|
||||
"linux_mips": [
|
||||
"go1.23.2.linux-mips.tar.gz",
|
||||
"3bd1130a08195d23960b154d2e6eaa80ac7325ebd9d01d74c58b6d12580e6b12"
|
||||
"go1.23.6.linux-mips.tar.gz",
|
||||
"e2a0aff70b958a3463a7d47132a2d0238369f64578d4f7f95e679e3a5af05622",
|
||||
],
|
||||
"linux_mips64": [
|
||||
"go1.23.2.linux-mips64.tar.gz",
|
||||
"a0cf25f236a0fa0a465816fe7f5c930f3b0b90c5c247b09c43a6adeff654e6ae"
|
||||
"go1.23.6.linux-mips64.tar.gz",
|
||||
"7d30ec7db056311d420bf930c16abcae13c0f41c26a202868f279721ec3c2f2f",
|
||||
],
|
||||
"linux_mips64le": [
|
||||
"go1.23.2.linux-mips64le.tar.gz",
|
||||
"2283d12dfe7c8c8a46a41bbf7d11fe007434e7590cd1b89e221e478640b7ee3a"
|
||||
"go1.23.6.linux-mips64le.tar.gz",
|
||||
"74ca7bc475bcc084c6718b74df024d7de9612932cea8a6dc75e29d3a5315a23a",
|
||||
],
|
||||
"linux_mipsle": [
|
||||
"go1.23.2.linux-mipsle.tar.gz",
|
||||
"36b7228bae235eee6c8193f5a956e1a9a17874955affb86b3564709b0fab5874"
|
||||
"go1.23.6.linux-mipsle.tar.gz",
|
||||
"09bf935a14e9f59a20499989438b1655453480016bdbcb10406acf4df2678ccb",
|
||||
],
|
||||
"linux_ppc64": [
|
||||
"go1.23.2.linux-ppc64.tar.gz",
|
||||
"791ca685ee5ca0f6fe849dc078145cb1323d0ea9dd308e9cca9ba2e7186dbb3d"
|
||||
"go1.23.6.linux-ppc64.tar.gz",
|
||||
"5cb2f6a5090276c72c5eda8a55896f5a3d6ea0f28d10fa1a50e8318640f02d6c",
|
||||
],
|
||||
"linux_ppc64le": [
|
||||
"go1.23.2.linux-ppc64le.tar.gz",
|
||||
"c164ce7d894b10fd861d7d7b96f1dbea3f993663d9f0c30bc4f8ae3915db8b0c"
|
||||
"go1.23.6.linux-ppc64le.tar.gz",
|
||||
"0f817201e83d78ddbfa27f5f78d9b72450b92cc21d5e045145efacd0d3244a99",
|
||||
],
|
||||
"linux_riscv64": [
|
||||
"go1.23.2.linux-riscv64.tar.gz",
|
||||
"ea8ab49c5c04c9f94a3f4894d1b030fbce8d10413905fa399f6c39c0a44d5556"
|
||||
"go1.23.6.linux-riscv64.tar.gz",
|
||||
"f95f7f817ab22ecab4503d0704d6449ea1aa26a595f57bf9b9f94ddf2aa7c1f3",
|
||||
],
|
||||
"linux_s390x": [
|
||||
"go1.23.2.linux-s390x.tar.gz",
|
||||
"de1f94d7dd3548ba3036de1ea97eb8243881c22a88fcc04cc08c704ded769e02"
|
||||
"go1.23.6.linux-s390x.tar.gz",
|
||||
"321e7ed0d5416f731479c52fa7610b52b8079a8061967bd48cec6d66f671a60e",
|
||||
],
|
||||
"netbsd_386": [
|
||||
"go1.23.2.netbsd-386.tar.gz",
|
||||
"c4ae1087dce4daf45a837f5fca36ac0e29a02ada9addf857f1c426e60bce6f21"
|
||||
"go1.23.6.netbsd-386.tar.gz",
|
||||
"92d678fb8e1eeeb8c6af6f22e4e5494652dcbb4a320113fc08325cb9956a2d4c",
|
||||
],
|
||||
"netbsd_amd64": [
|
||||
"go1.23.2.netbsd-amd64.tar.gz",
|
||||
"2734a5b54905cea45f136c28249e626d0241b865b0637fa1db64bf533d9d843e"
|
||||
"go1.23.6.netbsd-amd64.tar.gz",
|
||||
"86ba51e7bb26b30ea6a8d88ddb79d8e8c83b4116200040ecb7a5a44cf90a8c5c",
|
||||
],
|
||||
"netbsd_arm": [
|
||||
"go1.23.2.netbsd-arm.tar.gz",
|
||||
"69b31edcd3d4f7d8bbf9aee2b25cafba30b444ef19bc7a033e15026f7d0cc5c2"
|
||||
"go1.23.6.netbsd-arm.tar.gz",
|
||||
"4b974c35345100f0be6ea66afab2781de91ee9882117314126eaf0ae90fd3816",
|
||||
],
|
||||
"netbsd_arm64": [
|
||||
"go1.23.2.netbsd-arm64.tar.gz",
|
||||
"3e80b943d70c7e1633822b42c1aa7234e61da14f13ff8efff7ee6e1347f37648"
|
||||
"go1.23.6.netbsd-arm64.tar.gz",
|
||||
"53e3589fc38e787a493ea038961f8e40803714dbb42754c1713b00099c12e9b9",
|
||||
],
|
||||
"openbsd_386": [
|
||||
"go1.23.2.openbsd-386.tar.gz",
|
||||
"d1fde255843fec1f7f0611d468effd98e1f4309f589ac13037db07b032f9da35"
|
||||
"go1.23.6.openbsd-386.tar.gz",
|
||||
"6d2317b3a8505ccebff8f72d943f2ac9b82c115632e54a53a786eff24ced56d9",
|
||||
],
|
||||
"openbsd_amd64": [
|
||||
"go1.23.2.openbsd-amd64.tar.gz",
|
||||
"8734c7cd464a0620f6605bd3f9256bed062f262d0d58e4f45099c329a08ed966"
|
||||
"go1.23.6.openbsd-amd64.tar.gz",
|
||||
"f699e707d95a984fcc00361d91aecdb413d3c75e18235156ffba7a89edf68aae",
|
||||
],
|
||||
"openbsd_arm": [
|
||||
"go1.23.2.openbsd-arm.tar.gz",
|
||||
"980ceb889915695d94b166ca1300250dba76fa37a2d41eca2c5e7727dcb4fb7f"
|
||||
"go1.23.6.openbsd-arm.tar.gz",
|
||||
"3c1cf6ab893657d0bf1942e40ce115acfd27cbce1ccb9bc88fd9cd21ca3d489f",
|
||||
],
|
||||
"openbsd_arm64": [
|
||||
"go1.23.2.openbsd-arm64.tar.gz",
|
||||
"23b93144e754bbcf5eda700e9decbdbd44d29ceedb1bf1de75f95e8a6ea986bb"
|
||||
"go1.23.6.openbsd-arm64.tar.gz",
|
||||
"cc0875535d14001f2da23ae9af89025b28c466e8f4f4c63f991ebb6f4b02f66c",
|
||||
],
|
||||
"openbsd_ppc64": [
|
||||
"go1.23.2.openbsd-ppc64.tar.gz",
|
||||
"a13cc0d621af4f35afd90b886c60b1bf66f771939d226dc36fa61a337d90eb30"
|
||||
"go1.23.6.openbsd-ppc64.tar.gz",
|
||||
"64de80e29ca66cb566cbf8be030bf8599953af4e48402eab724cbe0a08b40602",
|
||||
],
|
||||
"openbsd_riscv64": [
|
||||
"go1.23.2.openbsd-riscv64.tar.gz",
|
||||
"3bf66879b38a233c5cbb5d2eb982004117f05d6bf06279e886e087d7c504427d"
|
||||
"go1.23.6.openbsd-riscv64.tar.gz",
|
||||
"c398a6b43c569f34bb4a2d16b52f8010eaac9a2a82ecac0602b4338e35cef377",
|
||||
],
|
||||
"plan9_386": [
|
||||
"go1.23.2.plan9-386.tar.gz",
|
||||
"695aac64532da8d9a243601ffa0411cd763be891fcf7fd2e857eea4ab10b8bcc"
|
||||
"go1.23.6.plan9-386.tar.gz",
|
||||
"10998b6b130bb7b542b407f0db42b86a913b111f8fa86d44394beaace4d45f01",
|
||||
],
|
||||
"plan9_amd64": [
|
||||
"go1.23.2.plan9-amd64.tar.gz",
|
||||
"86b5de91fdf7bd9b52c77c62f8762518cf3fc256fe912af9bbff1d073054aa5b"
|
||||
"go1.23.6.plan9-amd64.tar.gz",
|
||||
"9fbe8065436d8d12c02f19f64f51c9107da3a7a4ac46ab5777e182e9fe88c32f",
|
||||
],
|
||||
"plan9_arm": [
|
||||
"go1.23.2.plan9-arm.tar.gz",
|
||||
"6ffa4ac1f4368a3121a032917577a4e0a3feaf696c3e98f213b74ac04c318bc4"
|
||||
"go1.23.6.plan9-arm.tar.gz",
|
||||
"8e3c826b884daee2de37e3b070d7eac4cea5d68edab8db09910e22201c75db83",
|
||||
],
|
||||
"solaris_amd64": [
|
||||
"go1.23.2.solaris-amd64.tar.gz",
|
||||
"fa70d39ddeb6b55241a30b48d7af4e681c6a7d7104e8326c3bc1b12a75e091cc"
|
||||
"go1.23.6.solaris-amd64.tar.gz",
|
||||
"b619eff63fec86daaea92ca170559e448a58b8ba0b92eef1971bc14e92ea86a7",
|
||||
],
|
||||
"windows_386": [
|
||||
"go1.23.2.windows-386.msi",
|
||||
"72a6def70300cc804c70073d8b579603d9b39b39b02b3b5d340968d9e7e0e9d4"
|
||||
"go1.23.6.windows-386.msi",
|
||||
"d00024e8bb7c1d5dfc5dff6808968a43ced8a7c9b7aeddf406a26ff8a576f37b",
|
||||
],
|
||||
"windows_amd64": [
|
||||
"go1.23.2.windows-amd64.msi",
|
||||
"c80cbc5e66d6fb8b0c3300b0dda1fe925c429e199954d3327da2933d9870b041"
|
||||
"go1.23.6.windows-amd64.msi",
|
||||
"d2a587cbf856ed3e8583378cb43259d8e5e2aa663a21049ad0254fe19c22569f",
|
||||
],
|
||||
"windows_arm": [
|
||||
"go1.23.2.windows-arm.msi",
|
||||
"367d522b47c7ce7761a671efcb8b12c8af8f509db1cd6160c91f410ef3201987"
|
||||
"go1.23.6.windows-arm.msi",
|
||||
"923b5689271108ae140f2f2f2682e92d468e32f493d077d68d2937e32126b199",
|
||||
],
|
||||
"windows_arm64": [
|
||||
"go1.23.2.windows-arm64.msi",
|
||||
"0edd985dbd6de64d9c88dbc8835bae21203c58444bf26fce0739cbec4eb1b610"
|
||||
]
|
||||
"go1.23.6.windows-arm64.msi",
|
||||
"5dfcf83cadb05b9f747cd7c2702b5f7feac37c51f454ddc78ae52b65061495ea",
|
||||
],
|
||||
},
|
||||
version = "1.23.6",
|
||||
)
|
||||
|
||||
gazelle_dependencies()
|
||||
@@ -382,9 +383,9 @@ go_repository(
|
||||
# Load C++ rules.
|
||||
http_archive(
|
||||
name = "rules_cc",
|
||||
sha256 = "3d9e271e2876ba42e114c9b9bc51454e379cbf0ec9ef9d40e2ae4cec61a31b40",
|
||||
strip_prefix = "rules_cc-0.0.6",
|
||||
urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.6/rules_cc-0.0.6.tar.gz"],
|
||||
sha256 = "abc605dd850f813bb37004b77db20106a19311a96b2da1c92b789da529d28fe1",
|
||||
strip_prefix = "rules_cc-0.0.17",
|
||||
urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.17/rules_cc-0.0.17.tar.gz"],
|
||||
)
|
||||
|
||||
# Load C++ cross-compilation toolchains.
|
||||
@@ -408,6 +409,19 @@ cc_crosstool(
|
||||
|
||||
register_toolchains("//:cc_toolchain_k8", "//:cc_toolchain_aarch64")
|
||||
|
||||
# System Call test dependencies.
|
||||
# grpc also has a dependency on abseil but as this is before grpc dependency
|
||||
# declaration, it will take precedence over grpc's one
|
||||
http_archive(
|
||||
name = "com_google_absl",
|
||||
sha256 = "f50e5ac311a81382da7fa75b97310e4b9006474f9560ac46f54a9967f07d4ae3",
|
||||
strip_prefix = "abseil-cpp-20240722.0",
|
||||
urls = [
|
||||
"https://storage.googleapis.com/grpc-bazel-mirror/github.com/abseil/abseil-cpp/archive/20240722.0.tar.gz",
|
||||
"https://github.com/abseil/abseil-cpp/archive/20240722.0.tar.gz",
|
||||
],
|
||||
)
|
||||
|
||||
# Load LLVM dependencies.
|
||||
LLVM_COMMIT = "926f85db98aae66ab8f57b9981f47ddddb868c51"
|
||||
|
||||
@@ -461,9 +475,9 @@ http_archive(
|
||||
|
||||
http_archive(
|
||||
name = "com_google_protobuf",
|
||||
sha256 = "c968404387c9cccd18676c6e1d83a1dcc39d162a7f468dace4b243c274de1f02",
|
||||
strip_prefix = "protobuf-5.26.1",
|
||||
urls = ["https://github.com/protocolbuffers/protobuf/archive/v5.26.1.zip"],
|
||||
sha256 = "e7a50ac2a8ae3754c6f1ab6123424627920e4abddd894ee4bc47d6506e86aeb9",
|
||||
strip_prefix = "protobuf-5.29.3",
|
||||
urls = ["https://github.com/protocolbuffers/protobuf/archive/v5.29.3.zip"],
|
||||
)
|
||||
|
||||
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
|
||||
@@ -473,14 +487,18 @@ protobuf_deps()
|
||||
# Load protobuf dependencies.
|
||||
http_archive(
|
||||
name = "rules_proto",
|
||||
sha256 = "c4ebe86f6b8d13ca5a10fdff4008d24788b3c6dd17e141a6f8ac381ff40c4585",
|
||||
strip_prefix = "rules_proto-b5e5fc85f70cf6bbef66c69b679c86168ad1bea6",
|
||||
urls = [
|
||||
"https://github.com/bazelbuild/rules_proto/archive/b5e5fc85f70cf6bbef66c69b679c86168ad1bea6.tar.gz",
|
||||
],
|
||||
sha256 = "14a225870ab4e91869652cfd69ef2028277fc1dc4910d65d353b62d6e0ae21f4",
|
||||
strip_prefix = "rules_proto-7.1.0",
|
||||
url = "https://github.com/bazelbuild/rules_proto/releases/download/7.1.0/rules_proto-7.1.0.tar.gz",
|
||||
)
|
||||
|
||||
load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")
|
||||
load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies")
|
||||
|
||||
rules_proto_dependencies()
|
||||
|
||||
load("@rules_proto//proto:toolchains.bzl", "rules_proto_toolchains")
|
||||
|
||||
rules_proto_toolchains()
|
||||
|
||||
go_repository(
|
||||
name = "org_golang_x_term",
|
||||
@@ -1752,29 +1770,15 @@ load("@rules_pkg//:deps.bzl", "rules_pkg_dependencies")
|
||||
|
||||
rules_pkg_dependencies()
|
||||
|
||||
# System Call test dependencies.
|
||||
# grpc also has a dependency on abseil but as this is before grpc dependency
|
||||
# declaration, it will take precedence over grpc's one
|
||||
# Version LTS 20220623.1
|
||||
http_archive(
|
||||
name = "com_google_absl",
|
||||
sha256 = "a6be76f59c474a215f2df5116b312257462e97f2e38b2bfa6df8b6a55710b058",
|
||||
strip_prefix = "abseil-cpp-8c0b94e793a66495e0b1f34a5eb26bd7dc672db0",
|
||||
urls = [
|
||||
"https://mirror.bazel.build/github.com/abseil/abseil-cpp/archive/8c0b94e793a66495e0b1f34a5eb26bd7dc672db0.tar.gz",
|
||||
"https://github.com/abseil/abseil-cpp/archive/8c0b94e793a66495e0b1f34a5eb26bd7dc672db0.tar.gz",
|
||||
],
|
||||
)
|
||||
|
||||
# Load C++ grpc rules.
|
||||
http_archive(
|
||||
name = "com_github_grpc_grpc",
|
||||
patch_args = ["-p1"],
|
||||
patches = ["//tools:grpc_extra_deps.patch"],
|
||||
sha256 = "493d9905aa09124c2f44268b66205dd013f3925a7e82995f36745974e97af609",
|
||||
strip_prefix = "grpc-1.63.0",
|
||||
sha256 = "cfb80ec62db7b40c90154fa72d1d492b431f5b041e315aad533cbb3bc47b1674",
|
||||
strip_prefix = "grpc-1.71.1",
|
||||
urls = [
|
||||
"https://github.com/grpc/grpc/archive/v1.63.0.tar.gz",
|
||||
"https://github.com/grpc/grpc/archive/v1.71.1.tar.gz",
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
@@ -1,13 +1,30 @@
|
||||
diff --git a/bazel/grpc_extra_deps.bzl b/bazel/grpc_extra_deps.bzl
|
||||
index 4d8afa3131..b42224501f 100644
|
||||
index 1acc8b84e8..8240c69618 100644
|
||||
--- a/bazel/grpc_extra_deps.bzl
|
||||
+++ b/bazel/grpc_extra_deps.bzl
|
||||
@@ -52,14 +52,6 @@ def grpc_extra_deps(ignore_version_differences = False):
|
||||
@@ -23,7 +23,6 @@ load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
|
||||
load("@envoy_api//bazel:repositories.bzl", "api_dependencies")
|
||||
load("@google_cloud_cpp//bazel:google_cloud_cpp_deps.bzl", "google_cloud_cpp_deps")
|
||||
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
|
||||
-load("@rules_java//java:rules_java_deps.bzl", "rules_java_dependencies")
|
||||
load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies")
|
||||
load("@rules_python//python:repositories.bzl", "py_repositories")
|
||||
load("@rules_shell//shell:repositories.bzl", "rules_shell_dependencies", "rules_shell_toolchains")
|
||||
@@ -54,8 +53,6 @@ def grpc_extra_deps(ignore_version_differences = False):
|
||||
rules_shell_dependencies()
|
||||
rules_shell_toolchains()
|
||||
|
||||
- rules_java_dependencies()
|
||||
-
|
||||
protobuf_deps()
|
||||
|
||||
rules_proto_dependencies()
|
||||
@@ -63,14 +60,6 @@ def grpc_extra_deps(ignore_version_differences = False):
|
||||
|
||||
api_dependencies()
|
||||
|
||||
- go_rules_dependencies()
|
||||
- go_register_toolchains(version = "1.18")
|
||||
- go_register_toolchains(version = "1.22.5")
|
||||
- gazelle_dependencies()
|
||||
-
|
||||
- # Pull-in the go 3rd party dependencies for protoc_gen_validate, which is
|
||||
|
||||
@@ -208,6 +208,8 @@ def _nogo_package_config(ctx, deps, importpath = None, target = None):
|
||||
binaries = []
|
||||
if target != None:
|
||||
binaries.extend(target.files.to_list())
|
||||
if hasattr(target.output_groups, "compilation_outputs"):
|
||||
binaries.extend(target.output_groups.compilation_outputs.to_list())
|
||||
target_afile, target_xfile = _select_objfile(binaries)
|
||||
if target_xfile != None:
|
||||
args.append("-archive=%s=%s" % (importpath, target_afile.path))
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
commit 6df2a94ece32425f53ea6fecdca3af7148dcc48b
|
||||
Author: Andrei Vagin <[email protected]>
|
||||
Date: Wed Feb 5 20:18:13 2025 +0000
|
||||
|
||||
../gvisor/tools/rules_cgo.patch
|
||||
|
||||
diff --git a/go/private/rules/cgo.bzl b/go/private/rules/cgo.bzl
|
||||
index b8fc93a6..3fec27e4 100644
|
||||
--- a/go/private/rules/cgo.bzl
|
||||
@@ -14,4 +20,4 @@ index b8fc93a6..3fec27e4 100644
|
||||
+ lib_opts.append("-Wl,--no-whole-archive")
|
||||
clinkopts.extend(cc_link_flags)
|
||||
|
||||
elif hasattr(d, "objc"):
|
||||
elif hasattr(d, "objc"):
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
diff --git a/go/private/actions/archive.bzl b/go/private/actions/archive.bzl
|
||||
index 3bf0bffd..7cfe2fcc 100644
|
||||
--- a/go/private/actions/archive.bzl
|
||||
+++ b/go/private/actions/archive.bzl
|
||||
@@ -201,6 +201,7 @@ def emit_archive(go, source = None, _recompile_suffix = "", recompile_internal_d
|
||||
data = data,
|
||||
direct = direct,
|
||||
libs = depset(direct = [out_lib], transitive = [a.libs for a in direct]),
|
||||
+ export_files = depset(direct = [out_export], transitive = [a.export_files for a in direct]),
|
||||
transitive = depset([data], transitive = [a.transitive for a in direct]),
|
||||
x_defs = x_defs,
|
||||
cgo_deps = depset(transitive = [cgo_deps] + [a.cgo_deps for a in direct]),
|
||||
diff --git a/go/private/rules/binary.bzl b/go/private/rules/binary.bzl
|
||||
index 40b4011e..688a90b8 100644
|
||||
--- a/go/private/rules/binary.bzl
|
||||
+++ b/go/private/rules/binary.bzl
|
||||
@@ -124,6 +124,7 @@ def _go_binary_impl(ctx):
|
||||
source,
|
||||
archive,
|
||||
OutputGroupInfo(
|
||||
+ export_files = archive.export_files,
|
||||
cgo_exports = archive.cgo_exports,
|
||||
compilation_outputs = [archive.data.file],
|
||||
),
|
||||
diff --git a/go/private/rules/library.bzl b/go/private/rules/library.bzl
|
||||
index ac563544..e3dbfe81 100644
|
||||
--- a/go/private/rules/library.bzl
|
||||
+++ b/go/private/rules/library.bzl
|
||||
@@ -53,6 +53,8 @@ def _go_library_impl(ctx):
|
||||
extensions = ["go"],
|
||||
),
|
||||
OutputGroupInfo(
|
||||
+ export_files = archive.export_files,
|
||||
+ libs = archive.libs,
|
||||
cgo_exports = archive.cgo_exports,
|
||||
compilation_outputs = [archive.data.file],
|
||||
),
|
||||
@@ -102,8 +104,7 @@ go_library = rule(
|
||||
with the same path (for example, from different vendor directories).
|
||||
""",
|
||||
),
|
||||
- "importpath_aliases": attr.string_list(
|
||||
- ), # experimental, undocumented
|
||||
+ "importpath_aliases": attr.string_list(), # experimental, undocumented
|
||||
"embed": attr.label_list(
|
||||
providers = [GoLibrary],
|
||||
doc = """
|
||||
diff --git a/go/private/rules/test.bzl b/go/private/rules/test.bzl
|
||||
index 554cd30c..4aeab1b4 100644
|
||||
--- a/go/private/rules/test.bzl
|
||||
+++ b/go/private/rules/test.bzl
|
||||
@@ -183,6 +183,8 @@ def _go_test_impl(ctx):
|
||||
),
|
||||
OutputGroupInfo(
|
||||
compilation_outputs = [internal_archive.data.file],
|
||||
+ export_files = internal_archive.export_files,
|
||||
+ libs = internal_archive.libs,
|
||||
),
|
||||
coverage_common.instrumented_files_info(
|
||||
ctx,
|
||||
@@ -697,6 +699,7 @@ def _recompile_external_deps(go, external_source, internal_archive, library_labe
|
||||
data = arc_data,
|
||||
direct = deps,
|
||||
libs = depset(direct = [arc_data.file], transitive = [a.libs for a in deps]),
|
||||
+ export_files = depset(direct = [arc_data.export_file], transitive = [a.export_files for a in deps]),
|
||||
transitive = depset(direct = [arc_data], transitive = [a.transitive for a in deps]),
|
||||
x_defs = source.x_defs,
|
||||
cgo_deps = depset(direct = arc_data._cgo_deps, transitive = [a.cgo_deps for a in deps]),
|
||||
diff --git a/proto/def.bzl b/proto/def.bzl
|
||||
index 6a2a2d72..0fa8f800 100644
|
||||
--- a/proto/def.bzl
|
||||
+++ b/proto/def.bzl
|
||||
@@ -136,10 +136,11 @@ def _go_proto_library_impl(ctx):
|
||||
if valid_archive:
|
||||
archive = go.archive(go, source)
|
||||
output_groups["compilation_outputs"] = [archive.data.file]
|
||||
+ output_groups["export_files"] = archive.export_files
|
||||
providers.extend([
|
||||
archive,
|
||||
DefaultInfo(
|
||||
- files = depset([archive.data.file]),
|
||||
+ files = depset([archive.data.export_file]),
|
||||
runfiles = archive.runfiles,
|
||||
),
|
||||
])
|
||||
@@ -1,873 +0,0 @@
|
||||
commit 0a21a547f4ebf1d26d79854512cc2e0f1e1e4e90
|
||||
Author: Andrei Vagin <[email protected]>
|
||||
Date: Thu Feb 15 22:30:22 2024 -0800
|
||||
|
||||
Revert "Emit nogo facts into a separate archive (#3789)"
|
||||
|
||||
This reverts commit 30099a6add3c43706b4eec82b773b78310874935.
|
||||
|
||||
diff --git a/go/private/actions/archive.bzl b/go/private/actions/archive.bzl
|
||||
index 42bf2039..a4e737ee 100644
|
||||
--- a/go/private/actions/archive.bzl
|
||||
+++ b/go/private/actions/archive.bzl
|
||||
@@ -58,13 +58,9 @@ def emit_archive(go, source = None, _recompile_suffix = "", recompile_internal_d
|
||||
pre_ext += _recompile_suffix
|
||||
out_lib = go.declare_file(go, name = source.library.name, ext = pre_ext + ".a")
|
||||
|
||||
- # store export information for compiling dependent packages separately
|
||||
+ # store __.PKGDEF and nogo facts in .x
|
||||
out_export = go.declare_file(go, name = source.library.name, ext = pre_ext + ".x")
|
||||
out_cgo_export_h = None # set if cgo used in c-shared or c-archive mode
|
||||
- out_facts = None
|
||||
- nogo = go.get_nogo(go)
|
||||
- if nogo:
|
||||
- out_facts = go.declare_file(go, name = source.library.name, ext = pre_ext + ".facts")
|
||||
|
||||
direct = [get_archive(dep) for dep in source.deps]
|
||||
runfiles = source.runfiles
|
||||
@@ -109,8 +105,6 @@ def emit_archive(go, source = None, _recompile_suffix = "", recompile_internal_d
|
||||
archives = direct,
|
||||
out_lib = out_lib,
|
||||
out_export = out_export,
|
||||
- out_facts = out_facts,
|
||||
- nogo = nogo,
|
||||
out_cgo_export_h = out_cgo_export_h,
|
||||
gc_goopts = source.gc_goopts,
|
||||
cgo = True,
|
||||
@@ -135,8 +129,6 @@ def emit_archive(go, source = None, _recompile_suffix = "", recompile_internal_d
|
||||
archives = direct,
|
||||
out_lib = out_lib,
|
||||
out_export = out_export,
|
||||
- out_facts = out_facts,
|
||||
- nogo = nogo,
|
||||
gc_goopts = source.gc_goopts,
|
||||
cgo = False,
|
||||
testfilter = testfilter,
|
||||
@@ -181,7 +173,6 @@ def emit_archive(go, source = None, _recompile_suffix = "", recompile_internal_d
|
||||
# Information needed by dependents
|
||||
file = out_lib,
|
||||
export_file = out_export,
|
||||
- facts_file = out_facts,
|
||||
data_files = as_tuple(data_files),
|
||||
_cgo_deps = as_tuple(cgo_deps),
|
||||
)
|
||||
diff --git a/go/private/actions/compilepkg.bzl b/go/private/actions/compilepkg.bzl
|
||||
index 10fa6970..48adb910 100644
|
||||
--- a/go/private/actions/compilepkg.bzl
|
||||
+++ b/go/private/actions/compilepkg.bzl
|
||||
@@ -28,18 +28,6 @@ def _archive(v):
|
||||
v.data.export_file.path if v.data.export_file else v.data.file.path,
|
||||
)
|
||||
|
||||
-def _facts(v):
|
||||
- facts_file = v.data.facts_file
|
||||
- if not facts_file:
|
||||
- return None
|
||||
- importpaths = [v.data.importpath]
|
||||
- importpaths.extend(v.data.importpath_aliases)
|
||||
- return "{}={}={}".format(
|
||||
- ":".join(importpaths),
|
||||
- v.data.importmap,
|
||||
- facts_file.path,
|
||||
- )
|
||||
-
|
||||
def _embedroot_arg(src):
|
||||
return src.root.path
|
||||
|
||||
@@ -67,8 +55,6 @@ def emit_compilepkg(
|
||||
clinkopts = [],
|
||||
out_lib = None,
|
||||
out_export = None,
|
||||
- out_facts = None,
|
||||
- nogo = None,
|
||||
out_cgo_export_h = None,
|
||||
gc_goopts = [],
|
||||
testfilter = None, # TODO: remove when test action compiles packages
|
||||
@@ -78,8 +64,6 @@ def emit_compilepkg(
|
||||
fail("sources is a required parameter")
|
||||
if out_lib == None:
|
||||
fail("out_lib is a required parameter")
|
||||
- if bool(nogo) != bool(out_facts):
|
||||
- fail("nogo must be specified if and only if out_facts is specified")
|
||||
|
||||
inputs = (sources + embedsrcs + [go.package_list] +
|
||||
[archive.data.export_file for archive in archives] +
|
||||
@@ -124,13 +108,10 @@ def emit_compilepkg(
|
||||
args.add("-p", importmap)
|
||||
args.add("-package_list", go.package_list)
|
||||
|
||||
- args.add("-lo", out_lib)
|
||||
- args.add("-o", out_export)
|
||||
+ args.add("-o", out_lib)
|
||||
+ args.add("-x", out_export)
|
||||
+ nogo = go.get_nogo(go)
|
||||
if nogo:
|
||||
- args.add_all(archives, before_each = "-facts", map_each = _facts)
|
||||
- inputs.extend([archive.data.facts_file for archive in archives if archive.data.facts_file])
|
||||
- args.add("-out_facts", out_facts)
|
||||
- outputs.append(out_facts)
|
||||
args.add("-nogo", nogo)
|
||||
inputs.append(nogo)
|
||||
if out_cgo_export_h:
|
||||
diff --git a/go/providers.rst b/go/providers.rst
|
||||
index a2361ac1..dccc0e1e 100644
|
||||
--- a/go/providers.rst
|
||||
+++ b/go/providers.rst
|
||||
@@ -260,15 +260,7 @@ rule. Instead, it's referenced in the ``data`` field of GoArchive_.
|
||||
+--------------------------------+-----------------------------------------------------------------+
|
||||
| :param:`file` | :type:`File` |
|
||||
+--------------------------------+-----------------------------------------------------------------+
|
||||
-| The archive file for the linker produced when this library is compiled. |
|
||||
-+--------------------------------+-----------------------------------------------------------------+
|
||||
-| :param:`export_file` | :type:`File` |
|
||||
-+--------------------------------+-----------------------------------------------------------------+
|
||||
-| The archive file for compilation of dependent libraries produced when this library is compiled. |
|
||||
-+--------------------------------+-----------------------------------------------------------------+
|
||||
-| :param:`facts_file` | :type:`File` |
|
||||
-+--------------------------------+-----------------------------------------------------------------+
|
||||
-| The serialized facts for this library produced when nogo ran for this library. |
|
||||
+| The archive file produced when this library is compiled. |
|
||||
+--------------------------------+-----------------------------------------------------------------+
|
||||
| :param:`srcs` | :type:`tuple of File` |
|
||||
+--------------------------------+-----------------------------------------------------------------+
|
||||
diff --git a/go/tools/builders/BUILD.bazel b/go/tools/builders/BUILD.bazel
|
||||
index d327a3af..1b44a15c 100644
|
||||
--- a/go/tools/builders/BUILD.bazel
|
||||
+++ b/go/tools/builders/BUILD.bazel
|
||||
@@ -76,6 +76,7 @@ filegroup(
|
||||
"generate_test_main.go",
|
||||
"importcfg.go",
|
||||
"link.go",
|
||||
+ "pack.go",
|
||||
"read.go",
|
||||
"replicate.go",
|
||||
"stdlib.go",
|
||||
@@ -96,6 +97,7 @@ go_source(
|
||||
"nogo_typeparams_go117.go",
|
||||
"nogo_typeparams_go118.go",
|
||||
"nolint.go",
|
||||
+ "pack.go",
|
||||
],
|
||||
# //go/tools/builders:nogo_srcs is considered a different target by
|
||||
# Bazel's visibility check than
|
||||
diff --git a/go/tools/builders/ar.go b/go/tools/builders/ar.go
|
||||
index d2de6b96..2f4b36c8 100644
|
||||
--- a/go/tools/builders/ar.go
|
||||
+++ b/go/tools/builders/ar.go
|
||||
@@ -23,18 +23,6 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
-const (
|
||||
- // arHeader appears at the beginning of archives created by "ar" and
|
||||
- // "go tool pack" on all platforms.
|
||||
- arHeader = "!<arch>\n"
|
||||
-
|
||||
- // entryLength is the size in bytes of the metadata preceding each file
|
||||
- // in an archive.
|
||||
- entryLength = 60
|
||||
-)
|
||||
-
|
||||
-var zeroBytes = []byte("0 ")
|
||||
-
|
||||
type header struct {
|
||||
NameRaw [16]byte
|
||||
ModTimeRaw [12]byte
|
||||
diff --git a/go/tools/builders/cgo2.go b/go/tools/builders/cgo2.go
|
||||
index 80043e46..fc2876a9 100644
|
||||
--- a/go/tools/builders/cgo2.go
|
||||
+++ b/go/tools/builders/cgo2.go
|
||||
@@ -23,11 +23,9 @@ package main
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
- "io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
- "runtime"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@@ -397,34 +395,3 @@ func (e cgoError) Error() string {
|
||||
fmt.Fprintf(b, "Ensure that 'cgo = True' is set and the C/C++ toolchain is configured.")
|
||||
return b.String()
|
||||
}
|
||||
-
|
||||
-func copyFile(inPath, outPath string) error {
|
||||
- inFile, err := os.Open(inPath)
|
||||
- if err != nil {
|
||||
- return err
|
||||
- }
|
||||
- defer inFile.Close()
|
||||
- outFile, err := os.OpenFile(outPath, os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0666)
|
||||
- if err != nil {
|
||||
- return err
|
||||
- }
|
||||
- defer outFile.Close()
|
||||
- _, err = io.Copy(outFile, inFile)
|
||||
- return err
|
||||
-}
|
||||
-
|
||||
-func linkFile(inPath, outPath string) error {
|
||||
- inPath, err := filepath.Abs(inPath)
|
||||
- if err != nil {
|
||||
- return err
|
||||
- }
|
||||
- return os.Symlink(inPath, outPath)
|
||||
-}
|
||||
-
|
||||
-func copyOrLinkFile(inPath, outPath string) error {
|
||||
- if runtime.GOOS == "windows" {
|
||||
- return copyFile(inPath, outPath)
|
||||
- } else {
|
||||
- return linkFile(inPath, outPath)
|
||||
- }
|
||||
-}
|
||||
diff --git a/go/tools/builders/compilepkg.go b/go/tools/builders/compilepkg.go
|
||||
index b909fa86..46cae3c0 100644
|
||||
--- a/go/tools/builders/compilepkg.go
|
||||
+++ b/go/tools/builders/compilepkg.go
|
||||
@@ -50,9 +50,9 @@ func compilePkg(args []string) error {
|
||||
fs := flag.NewFlagSet("GoCompilePkg", flag.ExitOnError)
|
||||
goenv := envFlags(fs)
|
||||
var unfilteredSrcs, coverSrcs, embedSrcs, embedLookupDirs, embedRoots, recompileInternalDeps multiFlag
|
||||
- var deps, facts archiveMultiFlag
|
||||
+ var deps archiveMultiFlag
|
||||
var importPath, packagePath, nogoPath, packageListPath, coverMode string
|
||||
- var outLinkobjPath, outInterfacePath, outFactsPath, cgoExportHPath string
|
||||
+ var outPath, outFactsPath, cgoExportHPath string
|
||||
var testFilter string
|
||||
var gcFlags, asmFlags, cppFlags, cFlags, cxxFlags, objcFlags, objcxxFlags, ldFlags quoteMultiFlag
|
||||
var coverFormat string
|
||||
@@ -63,7 +63,6 @@ func compilePkg(args []string) error {
|
||||
fs.Var(&embedLookupDirs, "embedlookupdir", "Root-relative paths to directories relative to which //go:embed directives are resolved")
|
||||
fs.Var(&embedRoots, "embedroot", "Bazel output root under which a file passed via -embedsrc resides")
|
||||
fs.Var(&deps, "arc", "Import path, package path, and file name of a direct dependency, separated by '='")
|
||||
- fs.Var(&facts, "facts", "Import path, package path, and file name of a direct dependency's nogo facts file, separated by '='")
|
||||
fs.StringVar(&importPath, "importpath", "", "The import path of the package being compiled. Not passed to the compiler, but may be displayed in debug data.")
|
||||
fs.StringVar(&packagePath, "p", "", "The package path (importmap) of the package being compiled")
|
||||
fs.Var(&gcFlags, "gcflags", "Go compiler flags")
|
||||
@@ -77,9 +76,8 @@ func compilePkg(args []string) error {
|
||||
fs.StringVar(&nogoPath, "nogo", "", "The nogo binary. If unset, nogo will not be run.")
|
||||
fs.StringVar(&packageListPath, "package_list", "", "The file containing the list of standard library packages")
|
||||
fs.StringVar(&coverMode, "cover_mode", "", "The coverage mode to use. Empty if coverage instrumentation should not be added.")
|
||||
- fs.StringVar(&outLinkobjPath, "lo", "", "The full output archive file required by the linker")
|
||||
- fs.StringVar(&outInterfacePath, "o", "", "The export-only output archive required to compile dependent packages")
|
||||
- fs.StringVar(&outFactsPath, "out_facts", "", "The file to emit serialized nogo facts to (must be set if -nogo is set")
|
||||
+ fs.StringVar(&outPath, "o", "", "The output archive file to write compiled code")
|
||||
+ fs.StringVar(&outFactsPath, "x", "", "The output archive file to write export data and nogo facts")
|
||||
fs.StringVar(&cgoExportHPath, "cgoexport", "", "The _cgo_exports.h file to write")
|
||||
fs.StringVar(&testFilter, "testfilter", "off", "Controls test package filtering")
|
||||
fs.StringVar(&coverFormat, "cover_format", "", "Emit source file paths in coverage instrumentation suitable for the specified coverage format")
|
||||
@@ -96,7 +94,7 @@ func compilePkg(args []string) error {
|
||||
}
|
||||
cgoEnabled := os.Getenv("CGO_ENABLED") == "1"
|
||||
cc := os.Getenv("CC")
|
||||
- outLinkobjPath = abs(outLinkobjPath)
|
||||
+ outPath = abs(outPath)
|
||||
for i := range unfilteredSrcs {
|
||||
unfilteredSrcs[i] = abs(unfilteredSrcs[i])
|
||||
}
|
||||
@@ -144,7 +142,6 @@ func compilePkg(args []string) error {
|
||||
packagePath,
|
||||
srcs,
|
||||
deps,
|
||||
- facts,
|
||||
coverMode,
|
||||
coverSrcs,
|
||||
embedSrcs,
|
||||
@@ -162,8 +159,7 @@ func compilePkg(args []string) error {
|
||||
ldFlags,
|
||||
nogoPath,
|
||||
packageListPath,
|
||||
- outLinkobjPath,
|
||||
- outInterfacePath,
|
||||
+ outPath,
|
||||
outFactsPath,
|
||||
cgoExportHPath,
|
||||
coverFormat,
|
||||
@@ -177,7 +173,6 @@ func compileArchive(
|
||||
packagePath string,
|
||||
srcs archiveSrcs,
|
||||
deps []archive,
|
||||
- facts []archive,
|
||||
coverMode string,
|
||||
coverSrcs []string,
|
||||
embedSrcs []string,
|
||||
@@ -195,9 +190,8 @@ func compileArchive(
|
||||
ldFlags []string,
|
||||
nogoPath string,
|
||||
packageListPath string,
|
||||
- outLinkObj string,
|
||||
- outInterfacePath string,
|
||||
- outFactsPath string,
|
||||
+ outPath string,
|
||||
+ outXPath string,
|
||||
cgoExportHPath string,
|
||||
coverFormat string,
|
||||
recompileInternalDeps []string,
|
||||
@@ -215,7 +209,7 @@ func compileArchive(
|
||||
// Otherwise, GoPack will complain if we try to add assembly or cgo objects.
|
||||
// A truly empty archive does not include any references to source file paths, which
|
||||
// ensures hermeticity even though the temp file path is random.
|
||||
- emptyGoFile, err := os.CreateTemp(filepath.Dir(outLinkObj), "*.go")
|
||||
+ emptyGoFile, err := os.CreateTemp(filepath.Dir(outPath), "*.go")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -406,7 +400,7 @@ func compileArchive(
|
||||
}
|
||||
|
||||
// Build an importcfg file for the compiler.
|
||||
- importcfgPath, err := buildImportcfgFileForCompile(imports, goenv.installSuffix, filepath.Dir(outLinkObj))
|
||||
+ importcfgPath, err := buildImportcfgFileForCompile(imports, goenv.installSuffix, filepath.Dir(outPath))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -449,11 +443,12 @@ func compileArchive(
|
||||
|
||||
// Run nogo concurrently.
|
||||
var nogoChan chan error
|
||||
- if nogoPath != "" {
|
||||
+ outFactsPath := filepath.Join(workDir, nogoFact)
|
||||
+ if nogoPath != "" && len(goSrcsNogo) > 0 {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
nogoChan = make(chan error)
|
||||
go func() {
|
||||
- nogoChan <- runNogo(ctx, workDir, nogoPath, goSrcsNogo, facts, packagePath, importcfgPath, outFactsPath)
|
||||
+ nogoChan <- runNogo(ctx, workDir, nogoPath, goSrcsNogo, deps, packagePath, importcfgPath, outFactsPath)
|
||||
}()
|
||||
defer func() {
|
||||
if nogoChan != nil {
|
||||
@@ -483,7 +478,7 @@ func compileArchive(
|
||||
}
|
||||
|
||||
// Compile the filtered .go files.
|
||||
- if err := compileGo(goenv, goSrcs, packagePath, importcfgPath, embedcfgPath, asmHdrPath, symabisPath, gcFlags, pgoprofile, outLinkObj, outInterfacePath); err != nil {
|
||||
+ if err := compileGo(goenv, goSrcs, packagePath, importcfgPath, embedcfgPath, asmHdrPath, symabisPath, gcFlags, pgoprofile, outPath); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -517,25 +512,44 @@ func compileArchive(
|
||||
// Pack .o files into the archive. These may come from cgo generated code,
|
||||
// cgo dependencies (cdeps), or assembly.
|
||||
if len(objFiles) > 0 {
|
||||
- if err := appendToArchive(goenv, outLinkObj, objFiles); err != nil {
|
||||
+ if err := appendFiles(goenv, outPath, objFiles); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// Check results from nogo.
|
||||
+ nogoStatus := nogoNotRun
|
||||
if nogoChan != nil {
|
||||
err := <-nogoChan
|
||||
nogoChan = nil // no cancellation needed
|
||||
if err != nil {
|
||||
- // TODO: Move nogo into a separate action so we don't fail the compilation here.
|
||||
+ nogoStatus = nogoFailed
|
||||
+ // TODO: should we still create the .x file without nogo facts in this case?
|
||||
return err
|
||||
}
|
||||
+ nogoStatus = nogoSucceeded
|
||||
+ }
|
||||
+
|
||||
+ // Extract the export data file and pack it in an .x archive together with the
|
||||
+ // nogo facts file (if there is one). This allows compile actions to depend
|
||||
+ // on .x files only, so we don't need to recompile a package when one of its
|
||||
+ // imports changes in a way that doesn't affect export data.
|
||||
+ // TODO(golang/go#33820): After Go 1.16 is the minimum supported version,
|
||||
+ // use -linkobj to tell the compiler to create separate .a and .x files for
|
||||
+ // compiled code and export data. Before that version, the linker needed
|
||||
+ // export data in the .a file when building a plugin. To work around that,
|
||||
+ // we copy the export data into .x ourselves.
|
||||
+ if err = extractFileFromArchive(outPath, workDir, pkgDef); err != nil {
|
||||
+ return err
|
||||
}
|
||||
-
|
||||
- return nil
|
||||
+ pkgDefPath := filepath.Join(workDir, pkgDef)
|
||||
+ if nogoStatus == nogoSucceeded {
|
||||
+ return appendFiles(goenv, outXPath, []string{pkgDefPath, outFactsPath})
|
||||
+ }
|
||||
+ return appendFiles(goenv, outXPath, []string{pkgDefPath})
|
||||
}
|
||||
|
||||
-func compileGo(goenv *env, srcs []string, packagePath, importcfgPath, embedcfgPath, asmHdrPath, symabisPath string, gcFlags []string, pgoprofile, outLinkobjPath, outInterfacePath string) error {
|
||||
+func compileGo(goenv *env, srcs []string, packagePath, importcfgPath, embedcfgPath, asmHdrPath, symabisPath string, gcFlags []string, pgoprofile string, outPath string) error {
|
||||
args := goenv.goTool("compile")
|
||||
args = append(args, "-p", packagePath, "-importcfg", importcfgPath, "-pack")
|
||||
if embedcfgPath != "" {
|
||||
@@ -551,24 +565,19 @@ func compileGo(goenv *env, srcs []string, packagePath, importcfgPath, embedcfgPa
|
||||
args = append(args, "-pgoprofile", pgoprofile)
|
||||
}
|
||||
args = append(args, gcFlags...)
|
||||
- args = append(args, "-o", outInterfacePath)
|
||||
- args = append(args, "-linkobj", outLinkobjPath)
|
||||
+ args = append(args, "-o", outPath)
|
||||
args = append(args, "--")
|
||||
args = append(args, srcs...)
|
||||
absArgs(args, []string{"-I", "-o", "-trimpath", "-importcfg"})
|
||||
return goenv.runCommand(args)
|
||||
}
|
||||
|
||||
-func runNogo(ctx context.Context, workDir string, nogoPath string, srcs []string, facts []archive, packagePath, importcfgPath, outFactsPath string) error {
|
||||
- if len(srcs) == 0 {
|
||||
- // emit_compilepkg expects a nogo facts file, even if it's empty.
|
||||
- return os.WriteFile(outFactsPath, nil, 0o666)
|
||||
- }
|
||||
+func runNogo(ctx context.Context, workDir string, nogoPath string, srcs []string, deps []archive, packagePath, importcfgPath, outFactsPath string) error {
|
||||
args := []string{nogoPath}
|
||||
args = append(args, "-p", packagePath)
|
||||
args = append(args, "-importcfg", importcfgPath)
|
||||
- for _, fact := range facts {
|
||||
- args = append(args, "-fact", fmt.Sprintf("%s=%s", fact.importPath, fact.file))
|
||||
+ for _, dep := range deps {
|
||||
+ args = append(args, "-fact", fmt.Sprintf("%s=%s", dep.importPath, dep.file))
|
||||
}
|
||||
args = append(args, "-x", outFactsPath)
|
||||
args = append(args, srcs...)
|
||||
@@ -598,13 +607,6 @@ func runNogo(ctx context.Context, workDir string, nogoPath string, srcs []string
|
||||
return nil
|
||||
}
|
||||
|
||||
-func appendToArchive(goenv *env, outPath string, objFiles []string) error {
|
||||
- // Use abs to work around long path issues on Windows.
|
||||
- args := goenv.goTool("pack", "r", abs(outPath))
|
||||
- args = append(args, objFiles...)
|
||||
- return goenv.runCommand(args)
|
||||
-}
|
||||
-
|
||||
func createTrimPath(gcFlags []string, path string) string {
|
||||
for _, flag := range gcFlags {
|
||||
if strings.HasPrefix(flag, "-trimpath=") {
|
||||
diff --git a/go/tools/builders/nogo_main.go b/go/tools/builders/nogo_main.go
|
||||
index 23acdef0..17ff5314 100644
|
||||
--- a/go/tools/builders/nogo_main.go
|
||||
+++ b/go/tools/builders/nogo_main.go
|
||||
@@ -610,8 +610,8 @@ func (i *importer) Import(path string) (*types.Package, error) {
|
||||
}
|
||||
|
||||
func (i *importer) readFacts(pkgPath string) ([]byte, error) {
|
||||
- facts := i.factMap[pkgPath]
|
||||
- if facts == "" {
|
||||
+ archive := i.factMap[pkgPath]
|
||||
+ if archive == "" {
|
||||
// Packages that were not built with the nogo toolchain will not be
|
||||
// analyzed, so there's no opportunity to store facts. This includes
|
||||
// packages in the standard library and packages built with go_tool_library,
|
||||
@@ -621,7 +621,18 @@ func (i *importer) readFacts(pkgPath string) ([]byte, error) {
|
||||
// fmt.Printf accepts a format string.
|
||||
return nil, nil
|
||||
}
|
||||
- return os.ReadFile(facts)
|
||||
+ factReader, err := readFileInArchive(nogoFact, archive)
|
||||
+ if os.IsNotExist(err) {
|
||||
+ // Packages that were not built with the nogo toolchain will not be
|
||||
+ // analyzed, so there's no opportunity to store facts. This includes
|
||||
+ // packages in the standard library and packages built with go_tool_library,
|
||||
+ // such as coverdata.
|
||||
+ return nil, nil
|
||||
+ } else if err != nil {
|
||||
+ return nil, err
|
||||
+ }
|
||||
+ defer factReader.Close()
|
||||
+ return ioutil.ReadAll(factReader)
|
||||
}
|
||||
|
||||
type factMultiFlag map[string]string
|
||||
diff --git a/go/tools/builders/pack.go b/go/tools/builders/pack.go
|
||||
new file mode 100644
|
||||
index 00000000..ddbb1930
|
||||
--- /dev/null
|
||||
+++ b/go/tools/builders/pack.go
|
||||
@@ -0,0 +1,388 @@
|
||||
+// Copyright 2017 The Bazel Authors. All rights reserved.
|
||||
+//
|
||||
+// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
+// you may not use this file except in compliance with the License.
|
||||
+// You may obtain a copy of the License at
|
||||
+//
|
||||
+// http://www.apache.org/licenses/LICENSE-2.0
|
||||
+//
|
||||
+// Unless required by applicable law or agreed to in writing, software
|
||||
+// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
+// See the License for the specific language governing permissions and
|
||||
+// limitations under the License.
|
||||
+
|
||||
+package main
|
||||
+
|
||||
+import (
|
||||
+ "bufio"
|
||||
+ "bytes"
|
||||
+ "errors"
|
||||
+ "fmt"
|
||||
+ "io"
|
||||
+ "io/ioutil"
|
||||
+ "os"
|
||||
+ "path/filepath"
|
||||
+ "runtime"
|
||||
+ "strconv"
|
||||
+ "strings"
|
||||
+)
|
||||
+
|
||||
+func copyFile(inPath, outPath string) error {
|
||||
+ inFile, err := os.Open(inPath)
|
||||
+ if err != nil {
|
||||
+ return err
|
||||
+ }
|
||||
+ defer inFile.Close()
|
||||
+ outFile, err := os.OpenFile(outPath, os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0666)
|
||||
+ if err != nil {
|
||||
+ return err
|
||||
+ }
|
||||
+ defer outFile.Close()
|
||||
+ _, err = io.Copy(outFile, inFile)
|
||||
+ return err
|
||||
+}
|
||||
+
|
||||
+func linkFile(inPath, outPath string) error {
|
||||
+ inPath, err := filepath.Abs(inPath)
|
||||
+ if err != nil {
|
||||
+ return err
|
||||
+ }
|
||||
+ return os.Symlink(inPath, outPath)
|
||||
+}
|
||||
+
|
||||
+func copyOrLinkFile(inPath, outPath string) error {
|
||||
+ if runtime.GOOS == "windows" {
|
||||
+ return copyFile(inPath, outPath)
|
||||
+ } else {
|
||||
+ return linkFile(inPath, outPath)
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+const (
|
||||
+ // arHeader appears at the beginning of archives created by "ar" and
|
||||
+ // "go tool pack" on all platforms.
|
||||
+ arHeader = "!<arch>\n"
|
||||
+
|
||||
+ // entryLength is the size in bytes of the metadata preceding each file
|
||||
+ // in an archive.
|
||||
+ entryLength = 60
|
||||
+
|
||||
+ // pkgDef is the name of the export data file within an archive
|
||||
+ pkgDef = "__.PKGDEF"
|
||||
+
|
||||
+ // nogoFact is the name of the nogo fact file
|
||||
+ nogoFact = "nogo.out"
|
||||
+)
|
||||
+
|
||||
+var zeroBytes = []byte("0 ")
|
||||
+
|
||||
+type bufioReaderWithCloser struct {
|
||||
+ // bufio.Reader is needed to skip bytes in archives
|
||||
+ *bufio.Reader
|
||||
+ io.Closer
|
||||
+}
|
||||
+
|
||||
+func extractFiles(archive, dir string, names map[string]struct{}) (files []string, err error) {
|
||||
+ rc, err := openArchive(archive)
|
||||
+ if err != nil {
|
||||
+ return nil, err
|
||||
+ }
|
||||
+ defer rc.Close()
|
||||
+
|
||||
+ var nameData []byte
|
||||
+ bufReader := rc.Reader
|
||||
+ for {
|
||||
+ name, size, err := readMetadata(bufReader, &nameData)
|
||||
+ if err == io.EOF {
|
||||
+ return files, nil
|
||||
+ }
|
||||
+ if err != nil {
|
||||
+ return nil, err
|
||||
+ }
|
||||
+ if !isObjectFile(name) {
|
||||
+ if err := skipFile(bufReader, size); err != nil {
|
||||
+ return nil, err
|
||||
+ }
|
||||
+ continue
|
||||
+ }
|
||||
+ name, err = simpleName(name, names)
|
||||
+ if err != nil {
|
||||
+ return nil, err
|
||||
+ }
|
||||
+ name = filepath.Join(dir, name)
|
||||
+ if err := extractFile(bufReader, name, size); err != nil {
|
||||
+ return nil, err
|
||||
+ }
|
||||
+ files = append(files, name)
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+func openArchive(archive string) (bufioReaderWithCloser, error) {
|
||||
+ f, err := os.Open(archive)
|
||||
+ if err != nil {
|
||||
+ return bufioReaderWithCloser{}, err
|
||||
+ }
|
||||
+ r := bufio.NewReader(f)
|
||||
+ header := make([]byte, len(arHeader))
|
||||
+ if _, err := io.ReadFull(r, header); err != nil || string(header) != arHeader {
|
||||
+ f.Close()
|
||||
+ return bufioReaderWithCloser{}, fmt.Errorf("%s: bad header", archive)
|
||||
+ }
|
||||
+ return bufioReaderWithCloser{r, f}, nil
|
||||
+}
|
||||
+
|
||||
+// readMetadata reads the relevant fields of an entry. Before calling,
|
||||
+// r must be positioned at the beginning of an entry. Afterward, r will
|
||||
+// be positioned at the beginning of the file data. io.EOF is returned if
|
||||
+// there are no more files in the archive.
|
||||
+//
|
||||
+// Both BSD and GNU / SysV naming conventions are supported.
|
||||
+func readMetadata(r *bufio.Reader, nameData *[]byte) (name string, size int64, err error) {
|
||||
+retry:
|
||||
+ // Each file is preceded by a 60-byte header that contains its metadata.
|
||||
+ // We only care about two fields, name and size. Other fields (mtime,
|
||||
+ // owner, group, mode) are ignored because they don't affect compilation.
|
||||
+ var entry [entryLength]byte
|
||||
+ if _, err := io.ReadFull(r, entry[:]); err != nil {
|
||||
+ return "", 0, err
|
||||
+ }
|
||||
+
|
||||
+ sizeField := strings.TrimSpace(string(entry[48:58]))
|
||||
+ size, err = strconv.ParseInt(sizeField, 10, 64)
|
||||
+ if err != nil {
|
||||
+ return "", 0, err
|
||||
+ }
|
||||
+
|
||||
+ nameField := strings.TrimRight(string(entry[:16]), " ")
|
||||
+ switch {
|
||||
+ case strings.HasPrefix(nameField, "#1/"):
|
||||
+ // BSD-style name. The number of bytes in the name is written here in
|
||||
+ // ASCII, right-padded with spaces. The actual name is stored at the
|
||||
+ // beginning of the file data, left-padded with NUL bytes.
|
||||
+ nameField = nameField[len("#1/"):]
|
||||
+ nameLen, err := strconv.ParseInt(nameField, 10, 64)
|
||||
+ if err != nil {
|
||||
+ return "", 0, err
|
||||
+ }
|
||||
+ nameBuf := make([]byte, nameLen)
|
||||
+ if _, err := io.ReadFull(r, nameBuf); err != nil {
|
||||
+ return "", 0, err
|
||||
+ }
|
||||
+ name = strings.TrimRight(string(nameBuf), "\x00")
|
||||
+ size -= nameLen
|
||||
+
|
||||
+ case nameField == "//":
|
||||
+ // GNU / SysV-style name data. This is a fake file that contains names
|
||||
+ // for files with long names. We read this into nameData, then read
|
||||
+ // the next entry.
|
||||
+ *nameData = make([]byte, size)
|
||||
+ if _, err := io.ReadFull(r, *nameData); err != nil {
|
||||
+ return "", 0, err
|
||||
+ }
|
||||
+ if size%2 != 0 {
|
||||
+ // Files are aligned at 2-byte offsets. Discard the padding byte if the
|
||||
+ // size was odd.
|
||||
+ if _, err := r.ReadByte(); err != nil {
|
||||
+ return "", 0, err
|
||||
+ }
|
||||
+ }
|
||||
+ goto retry
|
||||
+
|
||||
+ case nameField == "/":
|
||||
+ // GNU / SysV-style symbol lookup table. Skip.
|
||||
+ if err := skipFile(r, size); err != nil {
|
||||
+ return "", 0, err
|
||||
+ }
|
||||
+ goto retry
|
||||
+
|
||||
+ case strings.HasPrefix(nameField, "/"):
|
||||
+ // GNU / SysV-style long file name. The number that follows the slash is
|
||||
+ // an offset into the name data that should have been read earlier.
|
||||
+ // The file name ends with a slash.
|
||||
+ nameField = nameField[1:]
|
||||
+ nameOffset, err := strconv.Atoi(nameField)
|
||||
+ if err != nil {
|
||||
+ return "", 0, err
|
||||
+ }
|
||||
+ if nameData == nil || nameOffset < 0 || nameOffset >= len(*nameData) {
|
||||
+ return "", 0, fmt.Errorf("invalid name length: %d", nameOffset)
|
||||
+ }
|
||||
+ i := bytes.IndexByte((*nameData)[nameOffset:], '/')
|
||||
+ if i < 0 {
|
||||
+ return "", 0, errors.New("file name does not end with '/'")
|
||||
+ }
|
||||
+ name = string((*nameData)[nameOffset : nameOffset+i])
|
||||
+
|
||||
+ case strings.HasSuffix(nameField, "/"):
|
||||
+ // GNU / SysV-style short file name.
|
||||
+ name = nameField[:len(nameField)-1]
|
||||
+
|
||||
+ default:
|
||||
+ // Common format name.
|
||||
+ name = nameField
|
||||
+ }
|
||||
+
|
||||
+ return name, size, err
|
||||
+}
|
||||
+
|
||||
+// extractFile reads size bytes from r and writes them to a new file, name.
|
||||
+func extractFile(r *bufio.Reader, name string, size int64) error {
|
||||
+ w, err := os.Create(name)
|
||||
+ if err != nil {
|
||||
+ return err
|
||||
+ }
|
||||
+ defer w.Close()
|
||||
+ _, err = io.CopyN(w, r, size)
|
||||
+ if err != nil {
|
||||
+ return err
|
||||
+ }
|
||||
+ if size%2 != 0 {
|
||||
+ // Files are aligned at 2-byte offsets. Discard the padding byte if the
|
||||
+ // size was odd.
|
||||
+ if _, err := r.ReadByte(); err != nil {
|
||||
+ return err
|
||||
+ }
|
||||
+ }
|
||||
+ return nil
|
||||
+}
|
||||
+
|
||||
+func skipFile(r *bufio.Reader, size int64) error {
|
||||
+ if size%2 != 0 {
|
||||
+ // Files are aligned at 2-byte offsets. Discard the padding byte if the
|
||||
+ // size was odd.
|
||||
+ size += 1
|
||||
+ }
|
||||
+ _, err := r.Discard(int(size))
|
||||
+ return err
|
||||
+}
|
||||
+
|
||||
+func isObjectFile(name string) bool {
|
||||
+ return strings.HasSuffix(name, ".o")
|
||||
+}
|
||||
+
|
||||
+// simpleName returns a file name which is at most 15 characters
|
||||
+// and doesn't conflict with other names. If it is not possible to choose
|
||||
+// such a name, simpleName will truncate the given name to 15 characters.
|
||||
+// The original file extension will be preserved.
|
||||
+func simpleName(name string, names map[string]struct{}) (string, error) {
|
||||
+ if _, ok := names[name]; !ok && len(name) < 16 {
|
||||
+ names[name] = struct{}{}
|
||||
+ return name, nil
|
||||
+ }
|
||||
+ var stem, ext string
|
||||
+ if i := strings.LastIndexByte(name, '.'); i < 0 {
|
||||
+ stem = name
|
||||
+ } else {
|
||||
+ stem = strings.Replace(name[:i], ".", "_", -1)
|
||||
+ ext = name[i:]
|
||||
+ }
|
||||
+ for n := 0; n < len(names)+1; n++ {
|
||||
+ ns := strconv.Itoa(n)
|
||||
+ stemLen := 15 - len(ext) - len(ns)
|
||||
+ if stemLen < 0 {
|
||||
+ break
|
||||
+ }
|
||||
+ if stemLen > len(stem) {
|
||||
+ stemLen = len(stem)
|
||||
+ }
|
||||
+ candidate := stem[:stemLen] + ns + ext
|
||||
+ if _, ok := names[candidate]; !ok {
|
||||
+ names[candidate] = struct{}{}
|
||||
+ return candidate, nil
|
||||
+ }
|
||||
+ }
|
||||
+ return "", fmt.Errorf("cannot shorten file name: %q", name)
|
||||
+}
|
||||
+
|
||||
+func appendFiles(goenv *env, archive string, files []string) error {
|
||||
+ archive = abs(archive) // required for long filenames on Windows.
|
||||
+
|
||||
+ // Create an empty archive if one doesn't already exist.
|
||||
+ // In Go 1.16, 'go tool pack r' reports an error if the archive doesn't exist.
|
||||
+ // 'go tool pack c' copies export data in addition to creating the archive,
|
||||
+ // so we don't want to use that directly.
|
||||
+ _, err := os.Stat(archive)
|
||||
+ if err != nil && !os.IsNotExist(err) {
|
||||
+ return err
|
||||
+ }
|
||||
+ if os.IsNotExist(err) {
|
||||
+ if err := ioutil.WriteFile(archive, []byte(arHeader), 0666); err != nil {
|
||||
+ return err
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ // Append files to the archive.
|
||||
+ // TODO(jayconrod): copy cmd/internal/archive and use that instead of
|
||||
+ // shelling out to cmd/pack.
|
||||
+ args := goenv.goTool("pack", "r", archive)
|
||||
+ args = append(args, files...)
|
||||
+ return goenv.runCommand(args)
|
||||
+}
|
||||
+
|
||||
+type readWithCloser struct {
|
||||
+ io.Reader
|
||||
+ io.Closer
|
||||
+}
|
||||
+
|
||||
+func readFileInArchive(fileName, archive string) (io.ReadCloser, error) {
|
||||
+ rc, err := openArchive(archive)
|
||||
+ if err != nil {
|
||||
+ return nil, err
|
||||
+ }
|
||||
+ var nameData []byte
|
||||
+ bufReader := rc.Reader
|
||||
+ for err == nil {
|
||||
+ // avoid shadowing err in the loop it can be returned correctly in the end
|
||||
+ var (
|
||||
+ name string
|
||||
+ size int64
|
||||
+ )
|
||||
+ name, size, err = readMetadata(bufReader, &nameData)
|
||||
+ if err != nil {
|
||||
+ break
|
||||
+ }
|
||||
+ if name == fileName {
|
||||
+ return readWithCloser{
|
||||
+ Reader: io.LimitReader(rc, size),
|
||||
+ Closer: rc,
|
||||
+ }, nil
|
||||
+ }
|
||||
+ err = skipFile(bufReader, size)
|
||||
+ }
|
||||
+ if err == io.EOF {
|
||||
+ err = os.ErrNotExist
|
||||
+ }
|
||||
+ rc.Close()
|
||||
+ return nil, err
|
||||
+}
|
||||
+
|
||||
+func extractFileFromArchive(archive, dir, name string) (err error) {
|
||||
+ archiveReader, err := readFileInArchive(name, archive)
|
||||
+ if err != nil {
|
||||
+ return fmt.Errorf("error reading %s from %s: %v", name, archive, err)
|
||||
+ }
|
||||
+ defer func() {
|
||||
+ e := archiveReader.Close()
|
||||
+ if e != nil && err == nil {
|
||||
+ err = fmt.Errorf("error closing %q: %v", archive, e)
|
||||
+ }
|
||||
+ }()
|
||||
+ outPath := filepath.Join(dir, pkgDef)
|
||||
+ outFile, err := os.Create(outPath)
|
||||
+ if err != nil {
|
||||
+ return fmt.Errorf("error creating %s: %v", outPath, err)
|
||||
+ }
|
||||
+ defer func() {
|
||||
+ e := outFile.Close()
|
||||
+ if e != nil && err == nil {
|
||||
+ err = fmt.Errorf("error closing %q: %v", outPath, e)
|
||||
+ }
|
||||
+ }()
|
||||
+ if size, err := io.Copy(outFile, archiveReader); err != nil {
|
||||
+ return fmt.Errorf("error writing %s: %v", outPath, err)
|
||||
+ } else if size == 0 {
|
||||
+ return fmt.Errorf("%s is empty in %s", name, archive)
|
||||
+ }
|
||||
+ return err
|
||||
+}
|
||||
@@ -1,7 +1,14 @@
|
||||
commit 441d5858370a443b117e1bcc19288b79d092147e
|
||||
Author: Andrei Vagin <[email protected]>
|
||||
Date: Wed Feb 5 20:18:48 2025 +0000
|
||||
|
||||
../gvisor/tools/rules_go_sdk.patch
|
||||
|
||||
diff --git a/go/private/sdk.bzl b/go/private/sdk.bzl
|
||||
index ca70b237..71149eba 100644
|
||||
--- a/go/private/sdk.bzl
|
||||
+++ b/go/private/sdk.bzl
|
||||
@@ -128,6 +128,8 @@ def _go_download_sdk_impl(ctx):
|
||||
@@ -130,6 +130,8 @@ def _go_download_sdk_impl(ctx):
|
||||
"sdks": ctx.attr.sdks,
|
||||
"urls": ctx.attr.urls,
|
||||
"version": version,
|
||||
@@ -10,7 +17,7 @@ diff --git a/go/private/sdk.bzl b/go/private/sdk.bzl
|
||||
"strip_prefix": ctx.attr.strip_prefix,
|
||||
}
|
||||
return None
|
||||
@@ -143,6 +145,7 @@ go_download_sdk_rule = repository_rule(
|
||||
@@ -145,6 +147,7 @@ go_download_sdk_rule = repository_rule(
|
||||
),
|
||||
"urls": attr.string_list(default = ["https://dl.google.com/go/{}"]),
|
||||
"version": attr.string(),
|
||||
@@ -18,7 +25,7 @@ diff --git a/go/private/sdk.bzl b/go/private/sdk.bzl
|
||||
"strip_prefix": attr.string(default = "go"),
|
||||
"patches": attr.label_list(
|
||||
doc = "A list of patches to apply to the SDK after downloading it",
|
||||
@@ -453,6 +456,8 @@ def _remote_sdk(ctx, urls, strip_prefix, sha256):
|
||||
@@ -462,6 +465,8 @@ def _remote_sdk(ctx, urls, strip_prefix, sha256):
|
||||
res = ctx.execute(["tar", "-xf", "go_sdk.tar.gz", "--strip-components=1"])
|
||||
if res.return_code:
|
||||
fail("error extracting Go SDK:\n" + res.stdout + res.stderr)
|
||||
@@ -26,4 +33,4 @@ diff --git a/go/private/sdk.bzl b/go/private/sdk.bzl
|
||||
+ ctx.patch(ctx.attr.patch, strip=ctx.attr.patch_strip)
|
||||
ctx.delete("go_sdk.tar.gz")
|
||||
elif (urls[0].endswith(".zip") and
|
||||
host_goos != "windows" and
|
||||
host_goos == "darwin" and
|
||||
|
||||
Reference in New Issue
Block a user