Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C++ flags set through command line configuration are ignored by rules_go cgo logic #2923

Closed
chancila opened this issue Jul 16, 2021 · 1 comment · Fixed by #2926
Closed

Comments

@chancila
Copy link
Contributor

chancila commented Jul 16, 2021

master @ 24c3d41

What version of gazelle are you using?

v0.23.0

What version of Bazel are you using?

4.1

Does this issue reproduce with the latest releases of all the above?

Yes

What operating system and processor architecture are you using?

Mac/Linux x86_64

Any other potentially useful information about your toolchain?

Custom clang 12 toolchain, verified normal cc compilation works fine on all relevant platforms.

What did you do?

I have a global --linkopt=/usr/bin/ld set for my build in order to override the toolchain linker and cgo is not picking it up, causing linking issues. This uncovered an issue with the go rules where they seemingly ignore configuration set via --copt/--linkopt in general.

What did you expect to see?

A successful build

What did you see instead?

 (cd /Users/chancila/<REDACTED> && \
  exec env - \
    CGO_ENABLED=1 \
    GOARCH=amd64 \
    GOOS=darwin \
    GOPATH='' \
    GOROOT=external/go_sdk \
    GOROOT_FINAL=GOROOT \
    PATH=external/cc_toolchain/llvm/bin:/bin:/usr/bin \
  bazel-out/host/bin/external/go_sdk/builder '-param=bazel-out/darwin-opt-exec-2B5CBBC6/bin/<REDACTED>-0.params' -- -extld external/cc_toolchain/llvm/bin/clang '-buildid=redacted' -extldflags '--sysroot=external/cc_toolchain/sysroots/macos_12_0_1_x86_64 --target=x86_64-apple-macos10.15 -fuse-ld=lld -mlinker-version=519 -Wl,-sdk_version,10.14')

the above command fails (due to issues with lld) however I have --linkopt set to use the system linker, if it would be properly picked up, the following modification works if I execute it manually, note -fuse-ld=/usr/bin/ld' at the end:

 (cd /Users/chancila/<REDACTED> && \
  exec env - \
    CGO_ENABLED=1 \
    GOARCH=amd64 \
    GOOS=darwin \
    GOPATH='' \
    GOROOT=external/go_sdk \
    GOROOT_FINAL=GOROOT \
    PATH=external/cc_toolchain/llvm/bin:/bin:/usr/bin \
  bazel-out/host/bin/external/go_sdk/builder '-param=bazel-out/darwin-opt-exec-2B5CBBC6/bin/<REDACTED>-0.params' -- -extld external/cc_toolchain/llvm/bin/clang '-buildid=redacted' -extldflags '--sysroot=external/cc_toolchain/sysroots/macos_12_0_1_x86_64 --target=x86_64-apple-macos10.15 -fuse-ld=lld -mlinker-version=519 -Wl,-sdk_version,10.14 -fuse-ld=/usr/bin/ld')

@chancila chancila changed the title C++ flags set through command line configuration are ignored by toolchains C++ flags set through command line configuration are ignored by rules_go cgo logic Jul 16, 2021
@rmohr
Copy link
Contributor

rmohr commented Jul 30, 2021

Seeing the same. With #2926 I can set the linker like expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants