aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpg <pg@yandex-team.com>2025-02-26 19:22:42 +0300
committerpg <pg@yandex-team.com>2025-02-26 19:48:05 +0300
commit5a3aa70af58a490cada682b229eef368bd42340c (patch)
tree1b31107d99ee400f1ee96f3cd53a8bc88b5a7709
parent95821e1fe9a744181bc40019b20bfba422c8bb5c (diff)
downloadydb-5a3aa70af58a490cada682b229eef368bd42340c.tar.gz
implement golang ld plugins
commit_hash:fb3ab9a0d420c781eb07bf3f791ba1f3fc1f2353
-rw-r--r--build/conf/go.conf11
-rw-r--r--build/scripts/go_tool.py13
2 files changed, 9 insertions, 15 deletions
diff --git a/build/conf/go.conf b/build/conf/go.conf
index 9d767c449c..4862f881c1 100644
--- a/build/conf/go.conf
+++ b/build/conf/go.conf
@@ -95,7 +95,6 @@ _GO_CGO1_WRAPPER_FLAGS=--build-prefix=/-B --source-prefix=/-S
_GO_LINK_EXE_EXT_CMD=
# tag:go-specific
-GO_WITH_MUSL=
# tag:go-specific
GO_TOOLS_ROOT=${GO_TOOLS_RESOURCE_GLOBAL}
@@ -233,12 +232,12 @@ macro _GO_LINK_LIB_IMPL(CGO_FILES[], EXTRA_INPUTS[], EXTRA_TEXT_INPUTS[], GO_FIL
# tag:go-specific
macro _GO_LINK_EXE_IMPL(CGO_FILES[], EXTRA_INPUTS[], EXTRA_TEXT_INPUTS[], GO_FILES...) {
- .CMD=${hide:_GO_FAKEID} $GO_TOOL ${hide;input:EXTRA_INPUTS} ${hide;context=TEXT;input:EXTRA_TEXT_INPUTS} --ya-start-command-file $_GO_TOOL_COMMON_FLAGS ++vcs $VCS_GO $GO_WITH_MUSL $GO_EXTLD ++peers ${rootrel;tags_in=local,GO|local,GO_PROTO|local,GO_PROTO_FROM_SCHEMA|local,GO_FBS:PEERS} ++non-local-peers ${rootrel;tags_in=GO|GO_PROTO|GO_PROTO_FROM_SCHEMA|GO_FBS|;tags_out=local:PEERS} ++cgo-peers ${VCS_C_OBJ_RR} ${_EXTRA_OBJS} ${rootrel;tags_out=GO|GO_PROTO|GO_PROTO_FROM_SCHEMA|GO_FBS|RESOURCE_LIB:PEERS} --ya-end-command-file ${hide;kv:"p LD"} ${hide;kv:"pc light-red"} ${hide;kv:"show_out"} && $_GO_LINK_EXE_EXT_CMD
+ .CMD=${hide:_GO_FAKEID} $GO_TOOL ${hide;input:EXTRA_INPUTS} ${hide;context=TEXT;input:EXTRA_TEXT_INPUTS} --ya-start-command-file $_GO_TOOL_COMMON_FLAGS ++ld_plugins ${ext=.pyplugin:SRCS_GLOBAL} ++vcs $VCS_GO $GO_EXTLD ++peers ${rootrel;tags_in=local,GO|local,GO_PROTO|local,GO_PROTO_FROM_SCHEMA|local,GO_FBS:PEERS} ++non-local-peers ${rootrel;tags_in=GO|GO_PROTO|GO_PROTO_FROM_SCHEMA|GO_FBS|;tags_out=local:PEERS} ++cgo-peers ${VCS_C_OBJ_RR} ${_EXTRA_OBJS} ${rootrel;tags_out=GO|GO_PROTO|GO_PROTO_FROM_SCHEMA|GO_FBS|RESOURCE_LIB:PEERS} --ya-end-command-file ${hide;kv:"p LD"} ${hide;kv:"pc light-red"} ${hide;kv:"show_out"} && $_GO_LINK_EXE_EXT_CMD
}
# tag:go-specific
macro _GO_LINK_TEST_IMPL(CGO_FILES[], EXTRA_INPUTS[], EXTRA_TEXT_INPUTS[], GO_TEST_FILES[], GO_XTEST_FILES[], GO_FILES...) {
- .CMD=${hide:_GO_FAKEID} $GO_TOOL ${hide;input:EXTRA_INPUTS} ${hide;context=TEXT;input:EXTRA_TEXT_INPUTS} --ya-start-command-file $_GO_TOOL_COMMON_FLAGS ++vcs $VCS_GO $GO_WITH_MUSL $GO_EXTLD ++test-miner $GO_TEST_MINER ++test-import-path $GO_TEST_IMPORT_PATH ++peers ${rootrel;tags_in=local,GO|local,GO_PROGRAM|local,GO_PROTO|local,GO_PROTO_FROM_SCHEMA|local,GO_FBS:PEERS} ++non-local-peers ${rootrel;tags_in=GO|GO_PROTO|GO_PROTO_FROM_SCHEMA|GO_FBS;tags_out=local:PEERS} ++cgo-peers ${VCS_C_OBJ_RR} ${rootrel;tags_out=GO|GO_PROGRAM|GO_PROTO|GO_PROTO_FROM_SCHEMA|GO_FBS|RESOURCE_LIB:PEERS} ++test_srcs ${input:GO_TEST_FILES} ++xtest_srcs ${input:GO_XTEST_FILES} ++cover_info $GO_COVER_INFO_VALUE ++skip-tests $_GO_SKIP_TEST_VALUE --ya-end-command-file ${hide;kv:"p GO"} ${hide;kv:"pc light-red"} ${hide;kv:"show_out"}
+ .CMD=${hide:_GO_FAKEID} $GO_TOOL ${hide;input:EXTRA_INPUTS} ${hide;context=TEXT;input:EXTRA_TEXT_INPUTS} --ya-start-command-file $_GO_TOOL_COMMON_FLAGS ++ld_plugins ${ext=.pyplugin:SRCS_GLOBAL} ++vcs $VCS_GO $GO_EXTLD ++test-miner $GO_TEST_MINER ++test-import-path $GO_TEST_IMPORT_PATH ++peers ${rootrel;tags_in=local,GO|local,GO_PROGRAM|local,GO_PROTO|local,GO_PROTO_FROM_SCHEMA|local,GO_FBS:PEERS} ++non-local-peers ${rootrel;tags_in=GO|GO_PROTO|GO_PROTO_FROM_SCHEMA|GO_FBS;tags_out=local:PEERS} ++cgo-peers ${VCS_C_OBJ_RR} ${rootrel;tags_out=GO|GO_PROGRAM|GO_PROTO|GO_PROTO_FROM_SCHEMA|GO_FBS|RESOURCE_LIB:PEERS} ++test_srcs ${input:GO_TEST_FILES} ++xtest_srcs ${input:GO_XTEST_FILES} ++cover_info $GO_COVER_INFO_VALUE ++skip-tests $_GO_SKIP_TEST_VALUE --ya-end-command-file ${hide;kv:"p GO"} ${hide;kv:"pc light-red"} ${hide;kv:"show_out"}
}
# tag:go-specific
@@ -638,7 +637,7 @@ otherwise {
###
### The base module of all golang modules. Defines common properties, dependencies and rules for go build.
module _GO_BASE_UNIT: _BASE_UNIT {
- .EXTS=.go .gosrc .o .obj .sbom .a .symabis .mf
+ .EXTS=.go .gosrc .o .obj .sbom .a .symabis .mf .pyplugin
.CMD=$TOUCH_UNIT
.STRUCT_CMD=yes
.NODE_TYPE=Bundle
@@ -870,10 +869,6 @@ module GO_PROGRAM: _GO_BASE_UNIT {
PEERDIR += ${GOSTD}/runtime/race
}
- when ($MUSL == "yes") {
- GO_WITH_MUSL = ++musl
- }
-
when ($HARDENING == "yes") {
_GO_BUILDMODE=++buildmode=pie
}
diff --git a/build/scripts/go_tool.py b/build/scripts/go_tool.py
index e866468d1c..f7c4a19f9e 100644
--- a/build/scripts/go_tool.py
+++ b/build/scripts/go_tool.py
@@ -525,12 +525,7 @@ def do_link_exe(args):
cmd.append('-extld={}'.format(args.extld))
if args.extldflags is not None:
- filter_musl = bool
- if args.musl:
- cmd.append('-linkmode=external')
- extldflags.append('-static')
- filter_musl = lambda x: x not in ('-lc', '-ldl', '-lm', '-lpthread', '-lrt')
- extldflags += [x for x in args.extldflags if filter_musl(x)]
+ extldflags.extend(args.extldflags)
cgo_peers = []
if args.cgo_peers is not None and len(args.cgo_peers) > 0:
is_group = args.targ_os == 'linux'
@@ -545,6 +540,10 @@ def do_link_exe(args):
except ValueError:
extldflags.extend(cgo_peers)
if len(extldflags) > 0:
+ for p in args.ld_plugins:
+ res = subprocess.check_output([sys.executable, p, sys.argv[0]] + extldflags, cwd=args.build_root).decode().strip()
+ if res:
+ extldflags = json.loads(res)[1:]
cmd.append('-extldflags={}'.format(' '.join(extldflags)))
cmd.append(compile_args.output)
call(cmd, args.build_root)
@@ -850,6 +849,7 @@ if __name__ == '__main__':
parser.add_argument('++test_srcs', nargs='*')
parser.add_argument('++xtest_srcs', nargs='*')
parser.add_argument('++cover_info', nargs='*')
+ parser.add_argument('++ld_plugins', nargs='*')
parser.add_argument('++output', nargs='?', default=None)
parser.add_argument('++source-root', default=None)
parser.add_argument('++build-root', required=True)
@@ -881,7 +881,6 @@ if __name__ == '__main__':
parser.add_argument('++vet-flags', nargs='*', default=None)
parser.add_argument('++vet-info-ext', default=vet_info_ext)
parser.add_argument('++vet-report-ext', default=vet_report_ext)
- parser.add_argument('++musl', action='store_true')
parser.add_argument('++skip-tests', nargs='*', default=None)
parser.add_argument('++ydx-file', default='')
parser.add_argument('++debug-root-map', default=None)