bazel-contrib / bazel-contrib/rules_go

setting `extldflags` as flag does not parse properly

Open
#3,921 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
1.5k
Forks
762
Avg merge
1d 11h
Merged PRs (30d)
12

Description

Setting -extldflags via command line flag, (e.g. bazel --@rules_go//go/config:gc_goopts=-extldflags=-Wl,-ld_classic) emits duplicate linker arguments for -extldflags instead of combining with the toolchain arguments (see below for detailed output). There is a test for this at the rule level but this does not appear to cover the case where it is specified via command line.

What version of rules_go are you using?

v0.46.0

What version of gazelle are you using?

v0.35.0

What version of Bazel are you using?
Bazelisk version: development
Build label: 7.1.1
Build target: @@//src/main/java/com/google/devtools/build/lib/bazel:BazelServer
Build time: Thu Mar 21 18:08:59 2024 (1711044539)
Build timestamp: 1711044539
Build timestamp as int: 1711044539
Does this issue reproduce with the latest releases of all the above?

yes

What operating system and processor architecture are you using?

macos 14.4.1, arm64

Any other potentially useful information about your toolchain?
What did you do?

in current rules_go

# cd examples/basic-gazelle 
#  bazel aquery --@io_bazel_rules_go//go/config:gc_linkopts=extldflags=-Wl,-ld_classic 'mnemonic("GoLink", //:basic-gazelle)'
...
  Command Line: (exec bazel-out/darwin_arm64-opt-exec-ST-13d3ddad9198/bin/external/go_sdk/builder_reset/builder \
    link \
    ...
    'extldflags=-Wl' \
    -ld_classic \
    ...
    -extldflags \
    '-mmacosx-version-min=10.11 -no-canonical-prefixes -fobjc-link-runtime -headerpad_max_install_names -lm')
What did you expect to see?
#  bazel aquery --@io_bazel_rules_go//go/config:gc_linkopts=extldflags=-Wl,-ld_classic 'mnemonic("GoLink", //:basic-gazelle)'
...
  Command Line: (exec bazel-out/darwin_arm64-opt-exec-ST-13d3ddad9198/bin/external/go_sdk/builder_reset/builder \
    link \
    ...
    -extldflags \
    '-Wl,-ld_classic -mmacosx-version-min=10.11 -no-canonical-prefixes -fobjc-link-runtime -headerpad_max_install_names -lm')
What did you see instead?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with tests/legacy/extldflags_rpath/README.md and reproduce the command-line case from examples/basic-gazelle using Bazel aquery. Compare the resulting GoLink arguments with the expected output; done means the command-line extldflags are combined into one -extldflags argument with the toolchain arguments, without duplicates.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.