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

cgo packages with assembly: Support CGO_ENABLED=0 #3661

Merged
merged 2 commits into from
Aug 20, 2023
Merged

cgo packages with assembly: Support CGO_ENABLED=0 #3661

merged 2 commits into from
Aug 20, 2023

Conversation

evanj
Copy link
Contributor

@evanj evanj commented Aug 15, 2023

What type of PR is this?

Uncomment one line below and remove others.

Bug fix

What does this PR do? Why is it needed?

Go supports building cgo packages both with and without Cgo. It uses build constraints to exclude the appropriate files. When building a Cgo package with assembly files, we must exclude them. Previous to this change, rules_go would run the Go assembler on them. This meant that packages which had "conditional" imports of cgo libraries with assembly would fail when compiled with cgo disabled.

Add tests for these two cases:

  • asm_conditional_cgo: A Go package that compiles both with and without Cgo.
  • asm_dep_conditional_cgo: A Go package that conditionally imports a package with Cgo.

Which issues(s) does this PR fix?

Fixes #3411

Other notes for review

I tested this with the DataDog/zstd package. This now works both with and without cgo/cross compilation: https://github.com/evanj/ddzstdbazel

evanj added 2 commits August 20, 2023 12:40
Go supports building cgo packages both with and without Cgo. It uses
build constraints to exclude the appropriate files. When building a
Cgo package with assembly files, we must exclude them. Previous to
this change, rules_go would run the Go assembler on them. This meant
that packages which had "conditional" imports of cgo libraries with
assembly would fail when compiled with cgo disabled.

Add tests for these two cases:
* asm_conditional_cgo: A Go package that compiles both with and
  without Cgo.
* asm_dep_conditional_cgo: A Go package that conditionally imports
  a package with Cgo.

Fixes:
#3411
@fmeum fmeum enabled auto-merge (squash) August 20, 2023 10:40
@fmeum fmeum merged commit 2e821f6 into bazel-contrib:master Aug 20, 2023
@evanj evanj deleted the evan.jones/cgoasm-cgo-disabled branch August 20, 2023 18:10
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 this pull request may close these issues.

builds with cgo appear to miss .S assembly files
2 participants